// JavaScript Document for CICE
// Víctor J. Chamorro - Ipdea.com

document.write('<script type="text/javascript" src="../js/XHConn.js"></script>');	//Ajax
var strbussy = '<p style="text-align:rigth"><img style="text-align:rigth" alt="cargando" src="../../img/calendar/loading2.gif" /> Espere...</p>';
//___________________________________________________________________________________________________

function Entrar(){
	if (document.frmLoggin.usuario.value.length>0 && document.frmLoggin.clave.value.length>0){
		document.getElementById('acceso_mensaje').innerHTML = strbussy;
		document.getElementById('acceso_formulario').style.display = 'none';
		document.getElementById('acceso_mensaje').style.display = '';
		var str_centro = document.getElementById('str_centro').value;
		var location =document.getElementById('location').value;
		data('../../area_privada/area_privada.cod.php', 'accion=loggin&usuario='+document.frmLoggin.usuario.value+'&clave='+document.frmLoggin.clave.value+'&str_centro='+str_centro+'&location='+location, CompruebaLoggin);
	}else{
		alert('Indique un nombre de usuario y contraseña');
	}
}
//_____________________________________________________________________________________________________

function intro(ev){
	if (ev.keyCode){
		if (ev.keyCode == 13) Entrar();
	}
}
//_____________________________________________________________________________________________________

function CompruebaLoggin(xml){
	try{
		var resultado = xml.getElementsByTagName('resultado')[0].firstChild.data;
		var str_centro = xml.getElementsByTagName('str_centro')[0].firstChild.data;
		var location = xml.getElementsByTagName('location')[0].firstChild.data;
		if (resultado != 1){
			document.getElementById('acceso_mensaje').innerHTML = '<div style="line-height:1em;">El nombre de usuario o la clave no es correcta <a href="javascript:reintentar();"><strong class="pink">Reintentar</strong></a></div>';
		}else{
			//var str_centro= window.url_get('0');
			if (location=="form_datos"){
				
				window.location.href="../../area_privada/datos/"+str_centro+"/index.html";
			}else{
				
				
				window.location.href="../../area_privada/"+str_centro+"/index.html";
			}
		}
	}catch(ex){
		document.getElementById('acceso_mensaje').innerHTML = 'Se ha producido un error en el loggin <a href="javascript:reintentar();">Reintentar</a>';
	}
}
//_____________________________________________________________________________________________________

function reintentar(){
	document.getElementById('acceso_mensaje').style.display = 'none';
	document.getElementById('acceso_formulario').style.display = '';
}
//_____________________________________________________________________________________________________

