var buscador;

function global(){
	
buscador="entra";	
}
function busca(){
	document.getElementById('buscador').style.display="block";	
}
function log(id){
	if(id=='usuario' && document.getElementById(id).value=='Usuario'){
	
		document.getElementById(id).value="";
	
	}
	
	else{
		if(id=='passw' && document.getElementById(id).value=='1111111'){
	
			document.getElementById(id).value="";	
		}		
	}	
}

function fueraBusc(){
	if(buscador!='entra'){

		document.getElementById('buscador').style.display="none";
		document.getElementById('registro').style.display="none";
		document.getElementById("flash").style.display="block";
		document.getElementById("wrapper").style.opacity=1;
		document.getElementById("wrapper").style.filter = "alpha (opacity=" +100 + ")";
		if(document.getElementById('alf')!=null){
			document.getElementById('alf').style.display="none";
			document.getElementById('alfa').style.background="#EEEEEE none repeat scroll 0% 50%";	
			document.getElementById('city').style.display="none";
			document.getElementById('ciudad2').style.background="#EEEEEE none repeat scroll 0% 50%";
			document.getElementById('valoradas').style.display="none";
			document.getElementById('val').style.background="#EEEEEE none repeat scroll 0% 50%";
		}
	}

	buscador='';
	
}
function mostra(id,id2){
	if(id!='alf'){
		document.getElementById('alf').style.display="none";
		document.getElementById('alfa').style.background="#EEEEEE none repeat scroll 0% 50%";
	}
	if(id!='city'){
		document.getElementById('city').style.display="none";
		document.getElementById('ciudad2').style.background="#EEEEEE none repeat scroll 0% 50%";
	}
	if(id!='valoradas'){
		document.getElementById('valoradas').style.display="none";
		document.getElementById('val').style.background="#EEEEEE none repeat scroll 0% 50%";
	}
	if(document.getElementById(id).style.display=="none"){
		document.getElementById(id).style.display="block";	
		document.getElementById(id2).style.background="#CCCCCC none repeat scroll 0%";
	}
	else{
		document.getElementById(id).style.display="none";
		document.getElementById(id2).style.background="#EEEEEE none repeat scroll 0% 50%";

	}
	
	
}



function registro(tipo){
	cargaProvincias();
	
	document.getElementById("registro").style.display="block";
	document.getElementById("flash").style.display="none";
	document.getElementById("wrapper").style.opacity=.5;
	//document.getElementById("wrapper").style.filters.alpha.opacity=950
	document.getElementById("wrapper").style.filter = "alpha (opacity=" +50 + ")";
	
	if(tipo==1){
		document.getElementById("tuEmpresa").style.display="block";
		document.getElementById("tuEmpresa2").style.display="block";
		document.getElementById("tuEmpresa3").style.display="block";
	}
	else{
		if(tipo==0){
			document.getElementById("tuEmpresa").style.display="none";
			document.getElementById("tuEmpresa2").style.display="none";
			document.getElementById("tuEmpresa3").style.display="none";
		}
	}
	//document.getElementById("wrapper").style.filter = 'alpha(opacity=' + 50*10 + ')';
	document.location="#arriba";
}

function AjustarAltosDiv(Izquierda,Derecha,offset){
  var colIzq = document.getElementById(Izquierda); // Ambos bloques los tengo identificados como colIzq y colDer respect.
  var colDer = document.getElementById(Derecha);
 
  hColDer = colDer.offsetHeight;
  hColIzq = colIzq.offsetHeight;

  //alert("izq: " + hColIzq + "; der: " + hColDer + ";");
  /* //Esto funciona
  if (hColIzq > hColDer) {
    colDer.style.height = hColIzq;
 }  else {
    colIzq.style.height = hColDer;
  } */
  //Aunque creo que sería más legible esta línea sólo

  if(navigator.appName=="Netscape"){
  	colDer.style.minHeight  = colIzq.style.minHeight = Math.max( hColIzq, hColDer )+offset +"px";
  
  }
  else{
	   colDer.style.height  = colIzq.style.height = Math.max( hColIzq, hColDer )+offset +"px";
  }
  if(document.getElementById('tripleboxbottom')!=null){
	document.getElementById('tripleboxbottom').style.marginBottom="0px";
  }
}

function nuevoAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function cargarContenido(){
	
	if((document.getElementById('pass').value==document.getElementById('repass').value)&&(document.getElementById('pass').value!='')&&document.getElementById('comprueb').style.display=="none"){
		document.getElementById('passInc').style.display='none';
		var t1, t2, contenedor,t3,t4;
		contenedor = contenedor = document.getElementById('barraRegistro');
		contenedor.style.display="block";
		document.getElementById('registro').style.display="none";
		t1 = document.getElementById('user').value;
		t2 = document.getElementById('pass').value;
		t3 = document.getElementById('ciudad').value;
		t4 = document.getElementById('mail').value;
		if(document.getElementById('tuEmpresa').style.display=='none'){
		
			t5='fuera';	
		}
		else{
		t5 = document.getElementById('empresa').value;
	
		}
		ajax=nuevoAjax();
		ajax.open("GET", "http://empresaperfecta.com/ajaxRegistro.php?user="+t1+"&pass="+t2+"&sector="+t3+"&mail="+t4+"&empresa="+t5,true);
		
		ajax.onreadystatechange=function() {
			if ( ajax.readyState != 4){
			
			contenedor.innerHTML ='<div style="margin-left:350px" id="barra"><img src="/images/visorAjax.gif"></div>'; 	
			
			}
			else{
						
				window.setTimeout('espera();',2000);
				
	
		 	}
		}
		ajax.send(null);
		}
		else{
			document.getElementById('passInc').style.display='block';
		}
}
function espera()
	{
		if(ajax.responseText!=0){
			/* Esta función solo nos sirve para retardar la carga de los datos */
			contenedor = document.getElementById('logado');

			document.getElementById('barraRegistro').style.display="none";
			//ajax.responseText
			contenedor.innerHTML="";

			document.getElementById('logado').style.display="block";
			document.getElementById('registro').style.display="none";
			document.getElementById('reg').style.display="none";
			document.getElementById("wrapper").style.opacity=1;
				document.getElementById("wrapper").style.filter = "alpha (opacity=" +100 + ")";
			document.getElementById('usuarioHidden').value=ajax.responseText;

			var div1=contenedor;
			var p1=document.createElement('p');
			div1.appendChild(p1);
			var txt1=document.createTextNode('Bienvenido '+ajax.responseText);
			p1.appendChild(txt1);
			var ul1=document.createElement('ul');
			div1.appendChild(ul1);
			var li1=document.createElement('li');
			ul1.appendChild(li1);
			var a1=document.createElement('a');
			a1.setAttribute('href','http://empresaperfecta.com/configuracion.php');
			li1.appendChild(a1);
			var txt2=document.createTextNode('Configuracion Cuenta');
			a1.appendChild(txt2);
			var li2=document.createElement('li');
			ul1.appendChild(li2);
			var a2=document.createElement('a');
			a2.setAttribute('href','http://empresaperfecta.com/EstadisticasIndividuales.php');
			li2.appendChild(a2);
			var txt3=document.createTextNode('Est.Individuales');
			a2.appendChild(txt3);
			var a3=document.createElement('a');
			a3.setAttribute('href','javascript:deslogar()');
			div1.appendChild(a3);
			var txt4=document.createTextNode('Log out');
			a3.appendChild(txt4);
			contenedor.style.margin="0px";
			document.location="http://empresaperfecta.com/index.php";
		}
		else{
	
			document.getElementById('barraRegistro').style.display="none";
			document.getElementById('registro').style.display="none";
			document.getElementById("wrapper").style.opacity=1;
			document.getElementById('logado').style.display="block";
			document.getElementById('logado').innerHTML="Usuario ya existente";
			
		}


	} 

	function deslogar(){
		document.getElementById('usuario').value="";
		document.getElementById('passw').value="";
		//contenedor.style.marginLeft="45px";
		contenedor.innerHTML ='<div style="margin-left:70px;margin-top:35px"><img src="/images/ajax-loader.gif"></div>'; 				
		window.setTimeout('fuera();',2000);

}
function fuera(){
	
	document.getElementById('reg').style.display="block";
	document.getElementById('logado').style.display="none";
	document.getElementById('logadoEmpresa').style.display="none";
	document.getElementById('usuarioHidden').value="";	
	ajax=nuevoAjax();
	ajax.open("GET", "http://empresaperfecta.com/logout.php",true);
		
	ajax.onreadystatechange=function() {
		
		if ( ajax.readyState == 4){
			document.location="http://empresaperfecta.com/index.php";
				
		}
	}
	ajax.send(null)
}


function compruebaUser(){
	var t1, t2, contenedor,t3,t4;

	t1 = document.getElementById('user').value;
	
	contenedor=document.getElementById('comprueb');
	contenedor.style.display="block";

	ajax=nuevoAjax();
	ajax.open("GET", "http://empresaperfecta.com/CompruebaUser.php?user="+t1,true);
		
	ajax.onreadystatechange=function() {
		if ( ajax.readyState == 4){
			if(ajax.responseText==0){
		contenedor.innerHTML ='Usuario ocupado'; 	
			
			}
			else{
				contenedor.style.display="none";
				
				
			}
								
		}		 
	}
	ajax.send(null)
}


function Login(){
	var t1, t2, contenedor,t3,t4;

	t1 = document.getElementById('usuario').value;
	t2 = document.getElementById('passw').value;
	contenedor = document.getElementById('logado');
	contenedor.style.display="block";
	document.getElementById('registro').style.display="none";
	document.getElementById('reg').style.display="none";
	ajax=nuevoAjax();
	ajax.open("GET", "http://empresaperfecta.com/Login.php?user="+t1+"&pass="+t2,true);		
	ajax.onreadystatechange=function() {
		if ( ajax.readyState != 4){

			contenedor.innerHTML ='<div style="margin-left:70px;margin-top:35px"><img src="/images/ajax-loader.gif"></div>'; 					
									
		}
			else{
					
				window.setTimeout('esperaLogin();',2000);
								
			}
		
	 
	}
	ajax.send(null)
}


	
	function esperaLogin()
	{	contenedor = document.getElementById('logado');
			
		contenedor.style.margin="0px";
		if(ajax.responseText!=0){
			
	
			/* Esta función solo nos sirve para retardar la carga de los datos */

			

			//ajax.responseText
			contenedor.innerHTML="";
			contenedor.innerHTML ="";
			document.getElementById('logado').style.display="block";




			document.getElementById('usuarioHidden').value=ajax.responseText;

			var div1=contenedor;

			var p1=document.createElement('p');
			div1.appendChild(p1);
			var txt1=document.createTextNode('Bienvenido  '+ajax.responseText);
			p1.appendChild(txt1);
			var ul1=document.createElement('ul');
			div1.appendChild(ul1);
			var li1=document.createElement('li');
			ul1.appendChild(li1);
			var a1=document.createElement('a');
			a1.setAttribute('href','http://empresaperfecta.com/configuracion.php');
			li1.appendChild(a1);
			var txt2=document.createTextNode('Configuracion Cuenta');
			a1.appendChild(txt2);
			var li2=document.createElement('li');
			ul1.appendChild(li2);
			var a2=document.createElement('a');
			a2.setAttribute('href','http://empresaperfecta.com/EstadisticasIndividuales.php');
			li2.appendChild(a2);
			var txt3=document.createTextNode('Est.Individuales');
			a2.appendChild(txt3);
			var a3=document.createElement('a');
			a3.setAttribute('href','javascript:deslogar()');
			div1.appendChild(a3);
			var txt4=document.createTextNode('Log out');
			a3.appendChild(txt4);
			document.location="http://empresaperfecta.com/index.php";
		}
		else{

			document.getElementById('reg').style.display="block";	
			document.getElementById('usuario').value="";
			document.getElementById('passw').value="";
			document.getElementById('logado').style.display="block";
			document.getElementById('logado').innerHTML="Usuario o Contraseña incorrecta<br> <p>Ha olvidado la contraseña?? presione<a href=\"/http://empresaperfecta.com/lostPasw.php\"> aqui</a></p>";
			
		}

		AjustarAltosDiv('leftcolumn','rightcolumn',00);
} 



function verComentarios(t1,pagina){
	var t2, contenedor,t3,t4;
	contenedor=document.getElementById('comentarios');
	ajax=nuevoAjax();	
	ajax.open("GET", "http://empresaperfecta.com/ajaxComentarios.php?idEmpresa="+t1+"&pag="+pagina,true);		
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
		document.getElementById('empre').innerHTML=document.getElementById("emp" +t1).innerHTML;
		
		document.getElementById('empre').style.display="block";
			contenedor.innerHTML = ajax.responseText;
			
			document.getElementById('comentarios').style.display="block";
			document.getElementById('empresas').style.display="none";
			if(document.getElementById('usuarioHidden').value==''){
				document.getElementById('formulario').style.display="none";
				document.getElementById('registroAlt').style.display="block";
			}
	

			AjustarAltosDiv('leftcolumn','rightcolumn',00);
			document.location="#arriba";
		}
	else{

		document.getElementById('carga').innerHTML ='<img src="/images/ajax-loader.gif">'; 	
	}
								
			}
			 

	ajax.send(null)
}
function logado(usuario){
	contenedor = document.getElementById('logado');			
	contenedor.style.margin="0px";		
	document.getElementById('reg').style.display="none";			
	//ajax.responseText
	contenedor.innerHTML="";
	contenedor.innerHTML ="";
	document.getElementById('logado').style.display="block";
	document.getElementById('usuarioHidden').value=usuario;
	idLogado=document.getElementById('idLogado').value;
	var div1=contenedor;
	var p1=document.createElement('p');
	div1.appendChild(p1);
	var txt1=document.createTextNode('Bienvenido  '+usuario);
	p1.appendChild(txt1);
	var ul1=document.createElement('ul');
	div1.appendChild(ul1);
	var li1=document.createElement('li');
	ul1.appendChild(li1);
	var a1=document.createElement('a');
	a1.setAttribute('href','http://empresaperfecta.com/configuracion.php');
	li1.appendChild(a1);
	var txt2=document.createTextNode('Configuracion Cuenta');
	a1.appendChild(txt2);
	var li2=document.createElement('li');
	ul1.appendChild(li2);
	var a2=document.createElement('a');
	a2.setAttribute('href','http://empresaperfecta.com/EstadisticasIndividuales.php');
	li2.appendChild(a2);
	var txt3=document.createTextNode('Est.Individuales');
	a2.appendChild(txt3);

	var li3=document.createElement('li');
	ul1.appendChild(li3);
	var a4=document.createElement('a');
	a4.setAttribute('href','http://empresaperfecta.com/comentarios.php?idUsuario='+idLogado+'&usuario='+usuario);
	li3.appendChild(a4);
	var txt5=document.createTextNode('Mis Comentarios');
	a4.appendChild(txt5);

	var a3=document.createElement('a');
	a3.setAttribute('href','javascript:deslogar()');
	div1.appendChild(a3);
	var txt4=document.createTextNode('Log out');
	a3.appendChild(txt4);

	
	
}



function logadoEmpresa(usuario){
	contenedor = document.getElementById('logadoEmpresa');
			
	contenedor.style.margin="0px";
		
	document.getElementById('reg').style.display="none";
			

	//ajax.responseText
	contenedor.innerHTML="";
	contenedor.innerHTML ="";
	document.getElementById('logadoEmpresa').style.display="block";

	document.getElementById('usuarioHidden').value=usuario;




	var div1=contenedor;
	var p1=document.createElement('p');
	div1.appendChild(p1);
	var txt1=document.createTextNode('Bienvenido  '+usuario);
	p1.appendChild(txt1);
	var ul1=document.createElement('ul');
	div1.appendChild(ul1);
	var li1=document.createElement('li');
	ul1.appendChild(li1);
	var a1=document.createElement('a');
	a1.setAttribute('href','http://empresaperfecta.com/configuracion.php');
	li1.appendChild(a1);
	var txt2=document.createTextNode('Configuracion Cuenta');
	a1.appendChild(txt2);


	var li1=document.createElement('li');
	ul1.appendChild(li1);
	var a1=document.createElement('a');
	a1.setAttribute('href','http://www.careerbuilder.es/INTL/JobPoster/ECommerce/JobProducts.aspx?siteid=INT_ESAEDIPE');
	li1.appendChild(a1);
	var txt2=document.createTextNode('Añade Ofertas de Empleo');
	a1.appendChild(txt2);


	var li2=document.createElement('li');
	ul1.appendChild(li2);
	var a2=document.createElement('a');
	a2.setAttribute('href','http://empresaperfecta.com/DescripcionEmpresa.php');
	li2.appendChild(a2);
	var txt3=document.createTextNode('Desc.Empresa');
	a2.appendChild(txt3);
	var a3=document.createElement('a');
	a3.setAttribute('href','javascript:deslogar()');
	div1.appendChild(a3);
	var txt4=document.createTextNode('Log out');
	a3.appendChild(txt4);

	
	
}




function nuevoComentario(){
	var provincia,nota,comentario,empresa;
	provincia=document.getElementById('provincia').value;

	nota=document.getElementById('nota').value;

	comentario=document.getElementById('comentario').value;

	empresa=document.getElementById('empresaId').value;

	if(comentario!=''){
	

		ajax=nuevoAjax();
		ajax.open("POST", "http://empresaperfecta.com/NuevoComentario.php",true);
		
		ajax.onreadystatechange=function() {
			if ( ajax.readyState != 4){
				document.getElementById('esperando').style.display="block";
			document.getElementById('esperando').innerHTML='<img src=\"/images/ajax-loader.gif\">';
			
			}
			else{
					
				window.setTimeout('esperaComentario('+empresa+');',2000);
				
	
	 		}
	}
	
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("provincia="+provincia+"&nota="+nota+"&comentario="+comentario+"&idEmpresa="+empresa)
	}
	else{
		document.getElementById('passInc').style.display='block';
	}
}
function esperaComentario(id)
{
		
	verComentarios(id,1);	
	document.getElementById('esperando').style.display="block";
	document.getElementById('esperando').innerHTML='Comentario insertado correctamente <img src="images/is_friend_16.png"/>';

} 

function empresaNueva(){
	document.getElementById('nuevaEmpresa').style.display="block";
	AjustarAltosDiv('leftcolumn','rightcolumn',00);
}



function insertEmpresa(){
	provincia=document.getElementById('provincia2').value;
	nota=document.getElementById('nota2').value;
	comentario=document.getElementById('comentario2').value;
	empresa=document.getElementById('empresa2').value;
	if(comentario!='' &&empresa!=''){
		

		ajax=nuevoAjax();
		ajax.open("GET", "http://empresaperfecta.com/NuevaEmpresa.php?provincia="+provincia+"&nota="+nota+"&comentario="+comentario+"&empresa="+empresa,true);
		
	ajax.onreadystatechange=function() {
		if ( ajax.readyState != 4){
			document.getElementById('esperando2').style.display="block";
			document.getElementById('esperando2').innerHTML='<img src=\"/images/ajax-loader.gif\">';
			
		}
		else{

			window.setTimeout('esperaEmpresa();',2000);
				
	
	 	}
	}
	ajax.send(null);
	}
	else{
		document.getElementById('passInc').style.display='block';AjustarAltosDiv('leftcolumn','rightcolumn',00);
	}
}
function esperaEmpresa()
{			
			
	document.getElementById('esperando2').innerHTML='Empresa insertada correctamente, en un plazo de 24 horas sera validada por el equipo de administradores';
	AjustarAltosDiv('leftcolumn','rightcolumn',00);

} 

function contacto(){
	
	document.getElementById("visor").style.display="block";
	document.getElementById("wrapper").style.opacity=.5;
	//document.getElementById("wrapper").style.filters.alpha.opacity=950
	document.getElementById("wrapper").style.filter = "alpha (opacity=" +50 + ")";
}

function ordena(dev){
	var orden;

	if(dev==1){
	
		document.getElementById('valProv').style.display="block";
		document.getElementById('valEmp').style.display="none";
	}
	else{
		document.getElementById('valEmp').style.display="block";
		document.getElementById('valProv').style.display="none";
	}
	
	
}



function actualizaPass(){
	var t1, t2, contenedor,t3,t4;

	t1 = document.getElementById('passOld').value;
	
	contenedor=document.getElementById('passNew');
	contenedor2=document.getElementById('RePassNew');

	ajax=nuevoAjax();
	ajax.open("GET", "http://empresaperfecta.com/ajaxActualizaPass.php?pass="+t1,true);
		
	ajax.onreadystatechange=function() {
		if ( ajax.readyState == 4){
		
			if(ajax.responseText==0){
				contenedor.disabled=true;
				document.getElementById('submit').disabled=true;
				contenedor2.disabled=true;
			
			}
			else{
				
				contenedor.disabled=false;
				document.getElementById('submit').disabled=false;
				contenedor2.disabled=false;
			}
		
				

		
		}
	
	 
	}
	ajax.send(null)
}

function actualizaDatos(){
	

	var t1, t2, contenedor,t3,t4;
	contenedor=document.getElementById('espera');
	t1 = document.getElementById('pro').value;
	t2 = document.getElementById('email').value;
	t3 = document.getElementById('passNew').value;
	

	ajax=nuevoAjax();
	ajax.open("GET", "http://empresaperfecta.com/ajaxActualiza.php?prov="+t1+"&mail="+t2+"&pass="+t3,true);
		
	ajax.onreadystatechange=function() {
		if ( ajax.readyState != 4){
			contenedor.style.display="block";
		contenedor.innerHTML ='<div style="" id="barra"><img src="/images/visorAjax.gif"></div>'; 	
			
		}
		else{		
				
			window.setTimeout('esperaActualiza();',2000);
				
	
	 	}
	}
	ajax.send(null);

}
function esperaActualiza(){
	document.getElementById('espera').innerHTML="";	
	document.getElementById('espera').innerHTML='Datos actualizados correctamente <img src="images/is_friend_16.png"/>';
	
}

function controlaPass(){
	var t1, t2, contenedor,t3,t4;

	t1 = document.getElementById('passOld').value;
	
	contenedor=document.getElementById('passNew');
	contenedor2=document.getElementById('RePassNew');
	contenedor3=document.getElementById('submit');

	
		if(contenedor.value!=contenedor2.value){
			document.getElementById('espera').innerHTML="<p style=\"color:red\">Contraseña no coincide con la repetición</p>";
				contenedor3.disabled=true;
			
		}
		else{
			document.getElementById('espera').innerHTML="";	
			contenedor3.disabled=false;
		}
		
					 
	
}
function desactivaEnvia(){
	contenedor3=document.getElementById('submit');
	contenedor3.disabled=true;
	
}
function limita()
{
	var max=830;
	if(document.getElementById('comentario').value.length>=max){document.getElementById('comentario').value=document.getElementById('comentario').value.substring(0,max);}
}

function cierraDescr(){
	
	document.getElementById('descripEmpresa').style.display="none";
	document.getElementById('NodescripEmpresa').style.display="block";
}
function muestraDescr(){
	
	document.getElementById('descripEmpresa').style.display="block";
	document.getElementById('NodescripEmpresa').style.display="none";
}

function insertHistorial(id){
	var t1, t2, contenedor,t3,t4;
	
	contenedor=document.getElementById('noticia').innerHTML;
	noti=contenedor;

	resultado = noti.split('&');
	noti=resultado.join("");

	
	ajax2=nuevoAjax();
					
	ajax2.open("POST", "http://empresaperfecta.com/insert.php",true);
	ajax2.onreadystatechange=function() {
		if(ajax2.responseText==0){
			if(ajax2.responseText!=0){
				contenedor.innerHTML ='OK!!'; 	
			
			}
						
		}
					
					
	}
	ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax2.send("id="+id+"&noti="+noti);								
				
	document.getElementById('noticiaMala.'+id).innerHTML='';
				
}
		
				

function abrir (link){

	window.open(link);
}


function verArticulos(){
	
	document.getElementById('comentarios').style.display="block";
	
	AjustarAltosDiv('leftcolumn','rightcolumn',00);
}

function nuevoComentarioArticulo(){
	var provincia,nota,comentario,empresa;

	comentario=document.getElementById('comentario').value;

	articulo=document.getElementById('articuloId').value;

	if(comentario!=''){
	

		ajax=nuevoAjax();
		ajax.open("POST", "http://empresaperfecta.com/NuevoComentarioArticulo.php",true);
		
	ajax.onreadystatechange=function() {
		if ( ajax.readyState != 4){
			document.getElementById('esperando').style.display="block";
			document.getElementById('esperando').innerHTML='<img src=\"/images/ajax-loader.gif\">';
			
		}
		else{
					
			window.setTimeout('esperaComentarioArticulo('+articulo+');',2000);
				
	
	 	}
	}
	
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("comentario="+comentario+"&idArticulo="+articulo)
	}
	else{
		document.getElementById('passInc').style.display='block';
	}
}
function esperaComentarioArticulo(id)
{			
		document.getElementById('esperando').style.display="block";
		document.getElementById('esperando').innerHTML='Comentario insertado correctamente <img src="images/is_friend_16.png"/>';


} 

function panelInfo(){
	
	document.getElementById('panelInformacion').style.display="block";
	
}
function fueraPanelInfo(){
	
	document.getElementById('panelInformacion').style.display="none";
	
}

function verEmpresas(){
	var t2, contenedor,t3,t4;


	contenedor=document.getElementById('emprisas');
	contenedor.innerHTML='';

	ajax=nuevoAjax();
	
	ajax.open("GET", "http://empresaperfecta.com/ajaxEmpresas.php",true);
		
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		
			contenedor.innerHTML = ajax.responseText;
			
			

			
		}
		else{
			contenedor=document.getElementById('emprisas');

			contenedor.innerHTML='<img src=\"/images/ajax-loader.gif\">';
			
		}
								
	}
			 

	ajax.send(null)
}
function cargaProvincias(){
	var t2, contenedor,t3,t4;
	
	contenedor=document.getElementById('ciudad');


	ajax=nuevoAjax();
	
	ajax.open("GET", "http://empresaperfecta.com/ajaxProvincias.php",true);
		
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		
			document.getElementById('ciudad').innerHTML = ajax.responseText;
			//console.log(contenedor.innerHTML);
			

			
		}
		else{

			
		}
								
	}
			 

	ajax.send(null)
}
