// JavaScript Document
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 validaUsr(){	
	divContainer = document.getElementById('resultado');	
	divContainer.innerHTML = '<img src="assets/ajax-loader.gif" alt="Validando ..." title="Validando ...">';
	folio = document.getElementById('folio').value;
	passwd = document.getElementById('psswd').value;
	
	ajax=objetoAjax();
	ajax.open( "POST" , "fb_user/login.php" , true );
	ajax.onreadystatechange=function() {
			if (ajax.readyState==1) {
						divContainer.innerHTML = '<img src="assets/ajax-loader.gif" alt="Validando ..." title="Validando ...">'
				}
			if (ajax.readyState==4) {
						if(ajax.responseText == 'incorrecto'){
							divContainer.innerHTML = '<b style="color:#fff"><strong>Datos Incorrectos.</strong></b>'
						}else{
							if(ajax.responseText == 'correcto'){
								divContainer.innerHTML = '';
								//window.location = 'fb_user/index.php';		
								//window.location = 'becas_statussolicitud.php';		
								top.location.href = 'becas_statussolicitud.php';		
							}							
						}
				}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("f="+folio+"&p="+passwd);
}



function ValidaRSLogin(){
	divContainer = document.getElementById('resultadoRS');	
	divContainer.innerHTML = '<img src="assets/ajax-loader.gif" alt="Validando ..." title="Validando ...">';
	folio = document.getElementById('usr_rs').value;
	passwd = document.getElementById('pass_rs').value;
	
	ajax=objetoAjax();
	ajax.open( "POST" , "fb_empresa/login.php" , true );
	ajax.onreadystatechange=function() {
			if (ajax.readyState==1) {
						divContainer.innerHTML = '<img src="assets/ajax-loader.gif" alt="Validando ..." title="Validando ...">'
				}
			if (ajax.readyState==4) {
						if(ajax.responseText == 'incorrecto'){
							divContainer.innerHTML = '<b style="color:#000"><strong>Datos Incorrectos.</strong></b>'
						}else{
							if(ajax.responseText == 'correcto'){
								divContainer.innerHTML = '';
								window.location = 'fb_empresa/index.php';		
							}							
						}
				}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("f="+folio+"&p="+passwd);	
}

function validaUsrFavoritos(){
		pe = /^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/ 		
		
		if(document.frm_usr.correo.value == "" || document.frm_usr.psswd.value == ""){
			alert("Debe ingresar sus datos para accesar.");
			return false;
		}else{		
				if(!pe.exec(document.frm_usr.correo.value)){
					alert("Ingrese un correo valido");
					return false;
				}else{
						document.frm_usr.submit();
					}				
			}			
	}



/**
 * FunciÃ³n para validar el enter en un input text
 */
function isEnter(e){
	var keynum;
	var keychar;
	var numcheck;

	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}

	if(keynum == 13){
		return true;
	}
	return false;
}



