// 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 verificaCorreo(correo){
        divContainer = document.getElementById('validacion_correo_electronico');
		divContainer.innerHTML = "";
		ajax=objetoAjax();
        ajax.open( "POST" , "includes/ajax.php" , true );
        ajax.onreadystatechange=function() {               			
                if (ajax.readyState==4) {
                            divContainer.innerHTML = ajax.responseText
                    }
        }
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        ajax.send("correo="+correo+"&mov=1")
}

function verificaTelefono(telefono){
        divContainer = document.getElementById('validacion_telefono');
		divContainer.innerHTML = "";
        ajax=objetoAjax();
        ajax.open( "POST" , "includes/ajax.php" , true );
        ajax.onreadystatechange=function() {               
				if (ajax.readyState==4) {
                            divContainer.innerHTML = ajax.responseText
                    }
        }
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        ajax.send("telefono="+telefono+"&mov=2")
}

function AceptaSolicitud(usuario,programa){	
		if(confirm("Esta acci\u00f3n no se podr\u00e1 deshacer.\n\nDesea continuar ?")){			
			divContainer = document.getElementById('procesando');
			ajax=objetoAjax();
			ajax.open( "POST" , "../includes/ajax.php" , true );
			ajax.onreadystatechange=function() {               
					if (ajax.readyState==1) {
								divContainer.innerHTML = "Procesando ..."
					}
					if (ajax.readyState==4) {
								divContainer.innerHTML = ""
								if(ajax.responseText == "1"){
										window.location.reload();
									}else{
										divContainer.innerHTML = "Error al realizar la accion. Intentelo de nuevo mas tarde "+ ajax.responseText
							}
					}
			}
			ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			ajax.send("usuario="+usuario+"&programa="+programa+"&mov=3")		
		}		
}

function RechazarSolicitud(usuario,programa){	
		if(confirm("Esta acci\u00f3n no se podr\u00e1 deshacer.\n\nDesea continuar ?")){			
			divContainer = document.getElementById('procesando');
			ajax=objetoAjax();
			ajax.open( "POST" , "../includes/ajax.php" , true );
			ajax.onreadystatechange=function() {               
					if (ajax.readyState==1) {
								divContainer.innerHTML = "Procesando ..."
					}
					if (ajax.readyState==4) {
								divContainer.innerHTML = ""
								if(ajax.responseText == "1"){
										window.location.reload();
									}else{
										divContainer.innerHTML = "Error al realizar la accion. Intentelo de nuevo mas tarde "+ ajax.responseText
							}
					}
			}
			ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			ajax.send("usuario="+usuario+"&programa="+programa+"&mov=4")		
		}		
}


function listadoMejoresProgramas(pagina){
		divContainer = document.getElementById('listadoMejoresProgramas');		
		divContainer.innerHTML = "";
        ajax=objetoAjax();
        ajax.open( "POST" , "includes/ajax.php" , true );
        ajax.onreadystatechange=function() {               
				if (ajax.readyState==1) {
                            divContainer.innerHTML = "loading ..."
                    }
				if (ajax.readyState==4) {
                            divContainer.innerHTML = ajax.responseText
                    }
        }
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        ajax.send("pagina="+pagina+"&paginador=1")
}










