
/*
<head></head>
*/

/*function lnkgt(objeto){
	hobj=objeto.parentNode.getElementsByTagName('a')[0];
	enlace=hobj.href;
	window.location=enlace;
}*/	

function detectarAccion(keyCode, next) {
	if (keyCode==13 && next ==1) {registrarUsuario(document.frmAltaPush.mail.value,document.frmAltaPush.idCurso.value,document.frmAltaPush.idCentro.value);}
	if (keyCode==13 && next ==2) {document.frmAltaPush.submit();}
}

function eliminarMail() {
	if (document.frmatriculaB.mail.value == 'Inserta tu e-mail')
		document.frmatriculaB.mail.value='';
        
	if (document.frmatriculaB3.mail.value == 'Inserta tu e-mail')
		document.frmatriculaB3.mail.value='';        
}

function eliminarMailPush() {
	if (document.frmAltaPush.mail.value == 'Inserta tu e-mail') {
		document.frmAltaPush.mail.value='';
	}
}

function eliminarPasswordPush() {
	if (document.frmAltaPush.password.value == 'Inserta tu contraseña') {
		document.frmAltaPush.password.value='';
        
        padre = document.frmAltaPush.password.parentNode;
       	nuevo = document.frmAltaPush.password.cloneNode(true);
        nuevo.setAttribute('type','password');
        padre.replaceChild(nuevo, document.frmAltaPush.password);
        nuevo.focus();
        document.frmAltaPush.password.focus();
	}        
}

function apuntarse() {
	if(GetCookie('EM_SESSIONINFO')) {
		ventana=window.open('','ventana','scrollbars=yes,resizable=yes');
		document.frmatriculaB.submit();
	}
	else{
		window.location.hash='formularioinf';
  }
}

function acceso_curso()  {
	ventana=window.open('','ventana','scrollbars=yes,resizable=yes');
	document.frmAccesoCurso.submit();
}

function cargaThun(imagen) {
	$("input.baced").css( "display", "none" );
	ppth=document.getElementById('amplia_thumb');
	thn=document.createElement('div');
	thn.className="thgrande";
	thn.style.backgroundImage='url('+imagen+')';
	thn.style.top=ppth.offsetTop+'px';
	//thn.style.left=ppth.offsetLeft+'px';
	thn.style.left=0+'px';
	enth=document.createElement('a');
	enth.setAttribute('href','javascript:void(0)');
	enth.onclick=function(){qtthun()}
	txtenth=document.createTextNode('Cerrar [X]');
	enth.appendChild(txtenth);
	thn.appendChild(enth);
	ppth.appendChild(thn);
}

function qtthun() {
	$("input.baced").css( "display", "inline" );
	ppth.removeChild(thn);
}

function mailAcceso() {
	mail = document.getElementById('mail');

	INV=new Array();
	INV[3]='mail';
	recuperarMailAcceso();
}

function recuperarMailAcceso() {
	var datos;
	if (GetCookie("EM_SESSIONINFO")!=null  &&  GetCookie('INV')) {
		datos=GetCookie('INV');
	}
	else {
		datos=GetCookie('SINV');
	}
	if(datos!=null) {
		datos = unescape(datos);
		var aCampInv=eval(datos.split('#'));
		var camp_inv;
		var nombreCampo;
		for(tt=0;tt<aCampInv.length;tt++) {
			var camp_inv=aCampInv[tt].split("=");
			var nombreCampoInv=camp_inv[0].split("_");
			var nombreCampo=INV[nombreCampoInv[1]];
			if (nombreCampo && document.frmAccesoCurso[nombreCampo]){
				var frmCampo=document.frmAccesoCurso[nombreCampo];
				SetValueField(frmCampo,camp_inv[1]);
			}
		}
	}	
}

function mailPush() {
	mail = document.getElementById('mail');

	INV=new Array();
	INV[3]='mail';
	recuperarMailPush();
}

function recuperarMailPush() {
	var datos;
	if (GetCookie("EM_SESSIONINFO")!=null  &&  GetCookie('INV')) {
		datos=GetCookie('INV');
	}
	else {
		datos=GetCookie('SINV');
	}
	if(datos!=null) {
		datos = unescape(datos);
		var aCampInv=eval(datos.split('#'));
		var camp_inv;
		var nombreCampo;
		for(tt=0;tt<aCampInv.length;tt++) {
			var camp_inv=aCampInv[tt].split("=");
			var nombreCampoInv=camp_inv[0].split("_");
			var nombreCampo=INV[nombreCampoInv[1]];
			if (nombreCampo && document.frmAltaPush[nombreCampo]){
				var frmCampo=document.frmAltaPush[nombreCampo];
				SetValueField(frmCampo,camp_inv[1]);
				if (typeof frmCampo.style!="undefined") {
					if(frmCampo.value!='') {
						frmCampo.style.color  = '#999999';
					}
				}
			}
		}
	}	
}

function dincr() {
	mail = document.getElementById('mail');

	INV=new Array();
	INV[3]='mail';
	Usuario_recuperar_informacion();
}

function Usuario_recuperar_informacion() {
	var datos;
	if (GetCookie("EM_SESSIONINFO")!=null  &&  GetCookie('INV')) {
		datos=GetCookie('INV');
	}
	else {
		datos=GetCookie('SINV');
	}
	if(datos!=null) {
		datos = unescape(datos);
		var aCampInv=eval(datos.split('#'));
		var camp_inv;
		var nombreCampo;
		for(tt=0;tt<aCampInv.length;tt++) {
			var camp_inv=aCampInv[tt].split("=");
			var nombreCampoInv=camp_inv[0].split("_");
			var nombreCampo=INV[nombreCampoInv[1]];
			if (nombreCampo && document.frmatriculaB[nombreCampo]){
				var frmCampo=document.frmatriculaB[nombreCampo];
				SetValueField(frmCampo,camp_inv[1]);
				if (typeof frmCampo.style!="undefined") {
					if(frmCampo.value!='') {
						frmCampo.style.color  = '#999999';
					}
				}
			}
		}
	}
}

function SetValueField(field_name, field_value) {
	field_name.value=field_value;
}

function registrarUsuario(mail,id_centro,id_curso) {
	xmlhttpb = creaXML();
	var urlaux = "/cursos_gratis/solicitudes/index.cfm?accion=registrar_usuario&mail="+mail+"&id_centro="+id_centro+"&id_curso="+id_curso;
	xmlhttpb.open("GET",urlaux,false);
	xmlhttpb.setRequestHeader('Accept','message/x-jl-formresult');
	xmlhttpb.send(null);
		if (xmlhttpb.readyState == 4) {
			var xml = xmlhttpb.responseXML;
			var item = xml.getElementsByTagName('resultado')[0];
						
			var resultado = parseInt(item.childNodes[0].nodeValue);

			if (resultado == 0) {
				document.frmAltaPush.password.style.display='none';
				alert('Por favor, introduce tu e-mail correctamente.');
			}
			if (resultado == 1) {
				document.getElementById("capaPassword").style.display='inline';
				document.getElementById("linkRecordatorioPassword").style.display='inline';				
				
				document.getElementById('button').onclick = function () {document.frmAltaPush.submit();};
				
				alert("Hemos detectado que ya estás registrado en Emagister. Por favor introduce tu contraseña");
			}
			if (resultado == 2) {
				document.frmAltaPush.password.style.display='none';

				var url = document.frmAltaPush.refererCorregistros.value;
				ventana=window.open(url,'ventana2','scrollbars=yes,resizable=yes');
				
				this.location=document.frmAltaPush.referer.value;
			}

	}
}



