			
			var valor1=0;
			var valor2=0;
			var valor3=0;
			
			function chequea(){
				if (document.getElementById("empresab").value == ''){
					document.getElementById("empresab").value = "todas-las-empresas";
				}
				document.busqueda.submit();
			}
			
			function registrar(){
				
				var resultado;
				var email;
				var usuario;
				var password;
				var password2
				var jefecheck;
				var nombre;
				var apellidos;
				var telefono;
				var empresa;
				var departamento;
				var cargo;
								
				resultado = '';
				
				email = document.getElementById("email").value;
				usuario = document.getElementById("usuario").value;
				password = document.getElementById("password").value;
				password2 = document.getElementById("password2").value;
				jefecheck = 0;
				nombre = document.getElementById("nombre").value;
				apellidos = document.getElementById("apellidos").value;
				telefono = document.getElementById("telefono").value;
				empresa = document.getElementById("empresa").value;
				departamento = document.getElementById("departamento").value;
				cargo = document.getElementById("cargo").value;
				
				if (email == ""){resultado += 'Debe rellenar el campo EMAIL <br>'};
				if (usuario == ""){resultado += 'Debe rellenar el campo USUARIO <br>'};
				if (password == ""){resultado += 'Debe rellenar el campo PASSWORD <br>'};
				if (password2 == ""){resultado += 'Debe rellenar el campo REPETIR PASSWORD <br>'};
				if (password != password2){resultado += 'Deben coincidir los campos PASSWORD y REPETIR PASSWORD <br>'};
				
				if (document.getElementById("jefecheck").checked){
					jefecheck = 1;
					if (nombre == ""){resultado += 'Debe rellenar el campo NOMBRE <br>'};
					if (apellidos == ""){resultado += 'Debe rellenar el campo APELLIDOS <br>'};
					if (telefono == ""){resultado += 'Debe rellenar el campo TELEFONO <br>'};
					if (empresa == ""){resultado += 'Debe rellenar el campo EMPRESA <br>'};
					if (departamento == 0){resultado += 'Debe rellenar el campo DEPARTAMENTO <br>'};
					if (cargo == 0){resultado += 'Debe rellenar el campo CARGO <br>'};
				}
								
				if (resultado != ""){
					//GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado+'<br><br> Atentamente. El equipo de comoestujefe.com',150,300);
					alert (resultado);
					return false;
				}else{
					oConn = new XHConn();								
					strPost = "accion=registro&email="+email+"&usuario="+usuario+"&password="+password+"&jefecheck="+jefecheck+"&nombre="+nombre+"&apellidos="+apellidos+"&telefono="+telefono+"&empresa="+empresa+"&departamento="+departamento+"&cargo="+cargo;
					if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
					var fnWhenDone = function (oXML)
					{					
						resultado = oXML.responseText;																
						//GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,150,300);
						alert(resultado);
					};
					oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
				}				
			}			
			
			function del_alerta (alerta){
				document.getElementById("alerta"+alerta).style.display = "none";
				document.getElementById("alerta"+alerta).style.visibility = "hidden";
				
				oConn = new XHConn();								
				strPost = "accion=borrar_alerta&alerta="+alerta;
				if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
				var fnWhenDone = function (oXML)
				{					
					resultado = oXML.responseText;																
					GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,150,300);
				};
				oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
				
			}
			
			function crear_alerta(){
				empresa = document.getElementById("empresac").value;				
				nombre = document.getElementById("nombre").value;
				
				oConn = new XHConn();								
				strPost = "accion=crear_alerta&empresa="+empresa+"&nombre="+nombre;
				if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
				var fnWhenDone = function (oXML)
				{					
					resultado = oXML.responseText;																
					GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,150,300);
				};
				oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
			}
			
			function peticion(){
			
				resultado = "";
								
				email = document.getElementById("email").value;				
				nombre = document.getElementById("nombre").value;
				apellidos = document.getElementById("apellidos").value;
				movil = document.getElementById("movil").value;
				localidad = document.getElementById("localidad").value;
				provincia = document.getElementById("provincia").value;				
				cp = document.getElementById("cp").value;
				direccion = document.getElementById("direccion").value;

				oConn = new XHConn();								
				strPost = "accion=registro_libro&email="+email+"&movil="+movil+"&nombre="+nombre+"&apellidos="+apellidos+"&localidad="+localidad+"&provincia="+provincia+"&cp="+cp+"&direccion="+direccion;
				if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
				var fnWhenDone = function (oXML)
				{					
					resultado = oXML.responseText;																
					GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,150,300);
				};
				oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
			}				
			
			function registrar_cambios(){
			
				resultado = "";
								
				password = document.getElementById("password").value;
				password2 = document.getElementById("password2").value;
				jefecheck = 0;
				nombre = document.getElementById("nombre").value;
				apellidos = document.getElementById("apellidos").value;
				telefono = document.getElementById("telefono").value;
				empresa = document.getElementById("empresa").value;
				departamento = document.getElementById("departamento").value;
				cargo = document.getElementById("cargo").value;
								
				if (password != password2){resultado += 'Deben coincidir los campos PASSWORD y REPETIR PASSWORD <br>'};
				
				if (document.getElementById("jefecheck").checked){
					jefecheck = 1;
					if (nombre == ""){resultado += 'Debe rellenar el campo NOMBRE <br>'};
					if (apellidos == ""){resultado += 'Debe rellenar el campo APELLIDOS <br>'};
					if (telefono == ""){resultado += 'Debe rellenar el campo TELEFONO <br>'};
					if (empresa == ""){resultado += 'Debe rellenar el campo EMPRESA <br>'};
					if (departamento == 0){resultado += 'Debe rellenar el campo DEPARTAMENTO <br>'};
					if (cargo == 0){resultado += 'Debe rellenar el campo CARGO <br>'};
				}
				
				if (resultado != ""){
					GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado+'<br><br> Atentamente. El equipo de comoestujefe.com',150,300);
					return false;
				}else{
					oConn = new XHConn();								
					strPost = "accion=registro_cambios&password="+password+"&jefecheck="+jefecheck+"&nombre="+nombre+"&apellidos="+apellidos+"&telefono="+telefono+"&empresa="+empresa+"&departamento="+departamento+"&cargo="+cargo;
					if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
					var fnWhenDone = function (oXML)
					{					
						resultado = oXML.responseText;																
						GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,150,300);
					};
					oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
				}				
			}	
			
			function selecciona (sel, val){
				document.getElementById(sel).selected = val;
			}
			
			function login(){				
				oConn = new XHConn();			
				var usuario;
				var password;
				usuario = document.getElementById('usuario').value;					
				password = document.getElementById("password").value;
				strPost = "accion=login&usuario="+usuario+"&password="+password;
				if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
				var fnWhenDone = function (oXML)
				{					
					resultado = oXML.responseText;
					if (resultado == 0){																
						GB_show('Mensaje de comoestujefe','mensaje.php?m=Usuario o password erroneo',150,300);
					}else{
						document.location.href="index.php";
					}
				};
				oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
			}
			
			function marcajefe(){				
				if (!document.getElementById("jefecheck").checked){
					document.getElementById("ob1").style.visibility = "hidden";
					document.getElementById("ob2").style.visibility = "hidden";
					document.getElementById("ob3").style.visibility = "hidden";
					document.getElementById("ob4").style.visibility = "hidden";
					document.getElementById("ob5").style.visibility = "hidden";
					document.getElementById("ob6").style.visibility = "hidden";
				}else{
					document.getElementById("ob1").style.visibility = "visible";
					document.getElementById("ob2").style.visibility = "visible";
					document.getElementById("ob3").style.visibility = "visible";
					document.getElementById("ob4").style.visibility = "visible";
					document.getElementById("ob5").style.visibility = "visible";
					document.getElementById("ob6").style.visibility = "visible";
				}
			}
			function compruebacampos (){
				resultado = "";
				
				if (document.getElementById("empresa").value == ""){resultado += 'Debe rellenar el campo EMPRESA <br>'};
				if (document.getElementById("departamento").value == 0){resultado += 'Debe rellenar el campo DEPARTAMENTO <br>'};
				//if (document.getElementById("cargo").value == 0){resultado += 'Debe rellenar el campo CARGO <br>'};
				if (document.getElementById("comentarios").value == ""){resultado += 'Debe rellenar el campo COMENTARIOS <br>'};
				if (valor1 == 0){resultado += 'Debe valorar el LIDERAZGO <br>'};
				if (valor2 == 0){resultado += 'Debe valorar la MOTIVACI&Oacute;N <br>'};
				if (valor3 == 0){resultado += 'Debe valorar la JUSTICIA <br>'};
				if (!document.getElementById("normas").checked){resultado += 'Debe rellenar aceptar las normas para los COMENTARIOS <br>'};
				if (resultado == ""){
					return 1;
				}else{
					return resultado;
				}
			}
			
			
			
			function anadecomentario(jef_id,i){
				document.getElementById("anadecomentario"+i).innerHTML = '<textarea name="comentario" id="comentario"><\/textarea><div class="boton"><a href="#" class="boton" onclick="anadircomentario('+jef_id+')">A&ntilde;adir<\/a><div class="normas"><input type="checkbox" name="normas" id="normas">Acepto las normas | <a href="#" onclick="GB_show(\'Mensaje de comoestujefe\',\'mensaje.php?m=Normas para los comentarios\',150,300);">Normas para los comentarios<\/a><\/div>';
				document.getElementById("l-valoracion-"+i).innerHTML = '<div id="ratel" class="rating"><\/div>';
				document.getElementById("m-valoracion-"+i).innerHTML = '<div id="ratem" class="rating"><\/div>';
				document.getElementById("j-valoracion-"+i).innerHTML = '<div id="ratej" class="rating"><\/div>';
				$('#ratel').rating('novoto1', {maxvalue:10, curvalue:0});
      	$('#ratem').rating('novoto2', {maxvalue:10, curvalue:0});
      	$('#ratej').rating('novoto3', {maxvalue:10, curvalue:0});      
			}
			
			function anadircomentario(jef_id){
				
				oConn = new XHConn();			
				resultado = "";
				if (document.getElementById("comentario").value == ""){resultado += 'Debe rellenar el campo COMENTARIOS <br>'};
				if (valor1 == 0){resultado += 'Debe valorar el LIDERAZGO <br>'};
				if (valor2 == 0){resultado += 'Debe valorar la MOTIVACI&Oacute;N <br>'};
				if (valor3 == 0){resultado += 'Debe valorar la JUSTICIA <br>'};
				if (!document.getElementById("normas").checked){resultado += 'Debe rellenar aceptar las normas para los COMENTARIOS <br>'};
				if (resultado != ""){
					GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado+'<br><br> Atentamente. El equipo de comoestujefe.com',150,300);
					return false;
				}
				strPost = "accion=anadecomentario&comentario="+document.getElementById("comentario").value+"&jef_id="+jef_id+"&val1="+valor1+"&val2="+valor2+"&val3="+valor3;
				if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
				var fnWhenDone = function (oXML)
				{					
					resultado = oXML.responseText;																
					GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,150,300);
				};
				oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
			}
			
			function vercomentarios(jef_id,id){
				
				oConn = new XHConn();			
				resultado = "";
				
				strPost = "accion=vercomentarios&jef_id="+jef_id;
				if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
				var fnWhenDone = function (oXML)
				{					
					resultado = oXML.responseText;																
					document.getElementById("vercomentarios"+id).innerHTML = resultado;
				};
				oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
			}
			
			function anade_jefe(){
				var resultado;
				resultado = compruebacampos();
				
				if (resultado == 1){
					oConn = new XHConn();			
					var empresa;
					var departamento;
					var comentarios;
					
					empresa = 			document.getElementById("empresa").value;
					departamento = 	document.getElementById("departamento").value;
					//cargo = 				document.getElementById("cargo").value;				
					comentarios  = 	document.getElementById("comentarios").value;
					strPost = "accion=anadejefe&empresa="+empresa+"&departamento="+departamento+"&val1="+valor1+"&val2="+valor2+"&val3="+valor3+"&comentarios="+comentarios;
					if (!oConn) alert("XMLHTTP no disponible. Intentelo con otro navegador.");
					var fnWhenDone = function (oXML)
					{					
						resultado = oXML.responseText;																
						GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,150,300);
					};
					oConn.connect("servlet.php", "POST", strPost , fnWhenDone);
				}else{
					GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,200,300);
				}
				<!-- -->
			}
			
			function saca_normas(){
				resultado = 'La norma básica para insertar un comentario en comoestujefe.com es el respeto. Cualquier comentario que pudiera considerarse como insidioso, que utilice un lenguaje escatológico no será publicado o será eliminado. Tampoco serán publicados aquellos comentarios que se considere que atentan contra la intimidad de las personas. Procura no hacer valoraciones personales gratuitas sobre terceras personas. Tus valoraciones deben ser profesionales, no de índole personal. Hemos creado esta web con el ánimo de mejorar la calidad de los jefes, tan importantes en la productividad y en la felicidad de las personas. Comoestujefe.com no ha sido creado para la burla y crítica de determinadas personas. Si alguna persona cree que un comentario acerca de su persona o empresa es injustificado puede dirigirse a protesta@comoestujefe.com y será contestado en el plazo más breve posible. Si uno de tus comentarios no ha sido publicado, puedes dirigirte a nopublicados@comotestujefe.com ';
				GB_show('Mensaje de comoestujefe','mensaje.php?m='+resultado,200,300);
			}
			var GB_ANIMATION = true;
		window.onload = function()
  {     	
			settings = {
          tl: { radius: 5 },
          tr: { radius: 5 },
          bl: { radius: 0 },
          br: { radius: 0 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }      
      
      var myBoxObject = new curvyCorners(settings, "dcabecera2");
      myBoxObject.applyCornersToAll();     
      
      $('#rate1').rating('novoto1', {maxvalue:10, curvalue:0});
      $('#rate2').rating('novoto2', {maxvalue:10, curvalue:0});
      $('#rate3').rating('novoto3', {maxvalue:10, curvalue:0});      
      $("#empresab").autocomplete("search.php", { minChars:3, matchSubset:1, matchContains:1, cacheLength:10, onItemSelect:selectItem, formatItem:formatItem, selectOnly:1 });	          
      $("#empresac").autocomplete("search.php", { minChars:3, matchSubset:1, matchContains:1, cacheLength:10, onItemSelect:selectItem, formatItem:formatItem, selectOnly:1 });	          
      $("#empresa").autocomplete("search.php", { minChars:3, matchSubset:1, matchContains:1, cacheLength:10, onItemSelect:selectItem, formatItem:formatItem, selectOnly:1 });	                
  }
  function selectItem(li) {
  	
		if (li.extra) {
			alert("That's '" + li.extra[0] + "' you picked.")
		}
	}
	function formatItem(row) {
		return row[0];
	}
	var muestra = 1;
	function bavanzada(){		
		if (muestra){
			document.getElementById("bavanzada").style.display = "block";
			document.getElementById("bavanzada").style.visibility = "visible";
			muestra = 0;
		}else{
			document.getElementById("bavanzada").style.display = "none";
			document.getElementById("bavanzada").style.visibility = "hidden";
			muestra = 1;
		}
	}