function objetoAjax(){
	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 validarAccesoExtranet(){ 
	
	if ($("input[@name=usuario]").val().length==0 || $("input[@name=usuario]").val()=="Usuario:"){  
	   alert("Rellene el campo Usuario") 
	   $("input[@name=usuario]").focus() 
	   return 0; 
	}

	if ($("input[@name=pass]").val().length==0 || $("input[@name=pass]").val()=="Contraseña:"){  
	   alert("Rellene el campo Contraseña") 
	   $("input[@name=pass]").focus() 
	   return 0; 
	}
					
	//el formulario se envia 
	document.formAccesoExtranet.submit(); 
} 



function validarRecordarPass(){ 
	
	if ($("input[@name=nombre]").val().length==0 || $("input[@name=nombre]").val()=="¿Nombre?"){  
	   alert("Rellene el campo Nombre") 
	   $("input[@name=nombre]").focus() 
	   return 0; 
	}
	
	if ($("textarea[@name=apellidos]").val().length==0 || $("textarea[@name=apellidos]").val()=="¿Apellidos?"){  
	   alert("Rellene el campo Apellidos") 
	   $("textarea[@name=apellidos]").focus() 
	   return 0; 
	}
	
	ajax=objetoAjax();

	variables="&nombre="+$("input[@name=nombre]").val();
	variables+="&apellidos="+$("input[@name=apellidos]").val();
	variables+="&email="+$("input[@name=email]").val();
	variables+="&relacion="+$("textarea[@name=relacion]").val();

	ajax.open("POST", "../../funciones/enviarEmailRecordarPass.php?", true);

	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(variables);

	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) { //cuando ya este cargado			
			$("#contCargando").css("display","none");
			var linea=new String(ajax.responseText);
			
			$("input[@name=nombre]").val("")
			$("input[@name=apellidos]").val("")
			$("input[@name=email]").val("")
			$("textarea[@name=relacion]").val("")			
		}
		else{
			$("#contCargando").css("display","block");			
		}
	}					
	
} 

