function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}
var http = createRequestObject();

/*function show() {
	window.print();
	//window.location = pag;
	window.history.back();
}*/

function show(obj) {
	if(document.getElementById){
		var el = document.getElementById(obj);
		//alert("img_" + obj);
		var img_trax = "img_" + obj;
		//alert(img_trax);
		if(el.style.display != "block"){ //DynamicDrive.com change
			el.style.display = "block";
			//document.img_tra1.src='Images/menos.gif';
			eval("document." + img_trax + ".src='images/menos.gif'");
		}else{
			el.style.display = "none";
			//document.img_trax.src='Images/mas.gif';
			eval("document." + img_trax + ".src='images/mas.gif'");
		}
	}
}

function Imprimir() {
	setTimeout("show()",100);
}

function regresar() {
	window.history.back();
}

function cerrarPopup() {
	window.close();	
}

function muestra_opc(i) {
	//alert("hola");
	eval("document.getElementById('opciones_" + i + "').style.display = 'block'");	
}

function oculta_opc(i) {
	//alert("hola");
	eval("document.getElementById('opciones_" + i + "').style.display = 'none'");	
}

function datosGeo() {
	document.getElementById('dat_geo').style.display = 'block';
	document.getElementById('ban_nac').style.display = 'none';
	
	document.img_geo.src='Images/dat_geo_on.PNG';
	document.img_ban.src='Images/ban_nac.PNG';
}

function agenciasBan() {
	document.getElementById('dat_geo').style.display = 'none';
	document.getElementById('ban_nac').style.display = 'block';
	
	document.img_geo.src='Images/dat_geo.PNG';
	document.img_ban.src='Images/ban_nac_on.PNG';
}

//funcion para mandar el mail de contactenos////////////////////
function ajax_contactenos_mail() {
	if (http.readyState == 1) { //1: cargando
		document.getElementById('contenido').innerHTML = "<font style='background-color: #BF2323; color: #ffffff' >&nbsp;Cargando...&nbsp;</font>";
	}
	if (http.readyState == 4) { //4: completado
		if (http.status == 200) { //200: OK
			res = http.responseText;
   			document.getElementById('contenido').innerHTML = res;
   			//Procesarespuesta();
  		}
  		else { //Se produjo un error
	   		alert("Error: " + http.statusText);
  		}
 	}
}

function contactenos_mail(pag) {
	if(valida_contactenos() == false){
		return false;	
	}
		
	var nombres = document.getElementById('nombres').value;
	var codigo = document.getElementById('codigo').value;
	var facultad = document.getElementById('facultad').value;
	var ciudad = document.getElementById('ciudad').value;
	var email = document.getElementById('email').value;
	var comentario = document.getElementById('comentario').value;
	
	//alert("nom: " + nombres + ", codigo: " + codigo + ", fac: " + facultad + ", ciudad: " + ciudad + ", email: " + email + ", comentario: " + comentario);
	
	http.open('get', pag + '?enviar=ok&nombres=' + nombres + '&codigo=' + codigo + '&facultad=' + facultad + '&ciudad=' + ciudad + '&email=' + email + '&comentario=' + comentario);
	http.onreadystatechange = ajax_contactenos_mail;
	http.send(null);
	
}
////////////////////////////////////////////////////////////////

//funcion para mandar el mail de sucribir////////////////////
function ajax_suscribirse_mail() {
	if (http.readyState == 1) { //1: cargando
		document.getElementById('contenido').innerHTML = "<font style='background-color: #BF2323; color: #ffffff' >&nbsp;Cargando...&nbsp;</font>";
	}
	if (http.readyState == 4) { //4: completado
		if (http.status == 200) { //200: OK
			res = http.responseText;
   			document.getElementById('contenido').innerHTML = res;
   			//Procesarespuesta();
  		}
  		else { //Se produjo un error
	   		alert("Error: " + http.statusText);
  		}
 	}
}

function suscribirse_mail(pag) {
	if(valida_suscribirse() == false){
		return false;	
	}
		
	var nombres = document.getElementById('nombres').value;
	var apellidos = document.getElementById('apellidos').value;
	var email = document.getElementById('email').value;
	
	//alert("nom: " + nombres + ", codigo: " + codigo + ", fac: " + facultad + ", ciudad: " + ciudad + ", email: " + email + ", comentario: " + comentario);
	
	http.open('get', pag + '?suscribirse=ok&nombres=' + nombres + '&apellidos=' + apellidos + '&email=' + email);
	http.onreadystatechange = ajax_suscribirse_mail;
	http.send(null);
	
}
////////////////////////////////////////////////////////////////

function isEmailAddress(theElement) {
	var s = theElement.value;
	var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
		return true;
	else
		alert("Ingrese una dirección de correo válida");
	theElement.focus();
	return false;
}

function valida_contactenos() {
	if(document.getElementById('nombres').value == "") {
		alert("Debe ingresar su nombre");	
		document.getElementById('nombres').focus();
		return false;
	}
	if(document.getElementById('ciudad').value == "") {
		alert("Debe ingresar su ciudad");	
		document.getElementById('ciudad').focus();
		return false;
	}
	if(document.getElementById('email').value == "") {
		alert("Debe ingresar su email");	
		document.getElementById('email').focus();
		return false;
	}else {
		//var s = theElement.value;
		var valor = document.getElementById('email').value;
		var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
		//if (valor.length == 0 ) 
		//	return true;
		if (filter.test(valor)) {
			//return true;
			//alert("dirección de correo válida");
		}else {
			alert("Ingrese una dirección de correo válida");
			document.getElementById('email').focus();
			return false;
		}
 	}	
	if(document.getElementById('comentario').value == "") {
		alert("Debe ingresar su comentario");	
		document.getElementById('comentario').focus();
		return false;
	}
	
	return true;
}

function valida_suscribirse() {
	if(document.getElementById('nombres').value == "") {
		alert("Debe ingresar su nombre");	
		document.getElementById('nombres').focus();
		return false;
	}
	if(document.getElementById('apellidos').value == "") {
		alert("Debe ingresar sus apellidos");	
		document.getElementById('apellidos').focus();
		return false;
	}
	if(document.getElementById('email').value == "") {
		alert("Debe ingresar su email");	
		document.getElementById('email').focus();
		return false;
	}else {
		//var s = theElement.value;
		var valor = document.getElementById('email').value;
		var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
		//if (valor.length == 0 ) 
		//	return true;
		if (filter.test(valor)) {
			//return true;
			//alert("dirección de correo válida");
		}else {
			alert("Ingrese una dirección de correo válida");
			document.getElementById('email').focus();
			return false;
		}
 	}	
	return true;
}

function valida_recomienda() {
	if(document.getElementById('tu_nombre').value == "") {
		alert("Debes ingresar tu nombre");	
		document.getElementById('tu_nombre').focus();
		return false;
	}
	if(document.getElementById('su_nombre').value == "") {
		alert("Debes ingresar su nombre");	
		document.getElementById('su_nombre').focus();
		return false;
	}
	if(document.getElementById('su_email').value == "") {
		alert("Debes ingresar su email");	
		document.getElementById('su_email').focus();
		return false;
	}else {
		//var s = theElement.value;
		var valor = document.getElementById('su_email').value;
		var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
		//if (valor.length == 0 ) 
		//	return true;
		if (filter.test(valor)) {
			//return true;
			//alert("dirección de correo válida");
		}else {
			alert("Ingrese una dirección de correo válida");
			document.getElementById('su_email').focus();
			return false;
		}
 	}	
 	if(document.getElementById('mensaje').value == "") {
		alert("Debe ingresar su mensaje");	
		document.getElementById('mensaje').focus();
		return false;
	}
	return true;
}

function abrePopup(pagina, width, height, top, left) {
	window.open(pagina, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,top=' + top + ',left=' + left + ',resizable=no,width=' + width + ',height=' + height)
}

function abreManual() {
	window.open('manuales/ManualCord/INDEX.HTM', '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,top=50,left=200,resizable=no,width=800,height=600')
}

function popupImprimeNoticia(IDn) {
		window.open('popup_imprimeNoticia.php?IDn=' + IDn, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,top=50,left=200,resizable=yes,width=600,height=500')
	}

function abreEncuesta(voto) {
	var IDe = document.frmEncuesta.IDe.value;
   	for (i = 0; i < document.frmEncuesta.alt.length; i++) {
    	if (document.frmEncuesta.alt[i].checked) {
  			//alert("ddd= " + document.frmEncuesta.alt[i].value);
   			var IDdet = document.frmEncuesta.alt[i].value;
   			
   			if(voto == 'si_voto') {
				window.open('popup_encuesta.php?IDe=' + IDe + '&IDdet=' + IDdet, 'popup_encuesta', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,top=50,left=200,resizable=no,width=400,height=300')   				
   			}
   			
   		}
   	}
   		
   	if(voto == 'no_voto') {
		window.open('popup_encuesta.php?action=ver&IDe=' + IDe, 'popup_encuesta', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,top=50,left=200,resizable=no,width=400,height=300')   				
   	}
   
}

function download_file() {
	alert("hola");
	eval("window.location='mision.php'");
}


function ajax_content() {
	if (http.readyState == 1) { //1: cargando
		document.getElementById('contenido').innerHTML = "<font style='background-color: #BF2323; color: #ffffff' >&nbsp;Cargando...&nbsp;</font>";
	}
	if (http.readyState == 4) { //4: completado
		if (http.status == 200) { //200: OK
			res = http.responseText;
   			document.getElementById('contenido').innerHTML = res;
   			//Procesarespuesta();
  		}
  		else { //Se produjo un error
	   		alert("Error: " + http.statusText);
  		}
 	}
}

function view_content(pag) {
	//alert("fac=" + IDfac + ", esc= " + IDesc);
	http.open('get', pag);
	http.onreadystatechange = ajax_content;
	http.send(null);
}

function ajax_content_admision() {
	if (http.readyState == 1) { //1: cargando
		document.getElementById('contenido_admision').innerHTML = "<font style='background-color: #BF2323; color: #ffffff' >&nbsp;Cargando...&nbsp;</font>";
	}
	if (http.readyState == 4) { //4: completado
		if (http.status == 200) { //200: OK
			res = http.responseText;
   			document.getElementById('contenido_admision').innerHTML = res;
   			//Procesarespuesta();
  		}
  		else { //Se produjo un error
	   		alert("Error: " + http.statusText);
  		}
 	}
}

function view_content_admision(pag) {
	//alert("fac=" + IDfac + ", esc= " + IDesc);
	http.open('get', pag);
	http.onreadystatechange = ajax_content_admision;
	http.send(null);
}

//funcion para listar las ediciones anteriores//////////
function ajax_contenido_ediciones() {
	if (http.readyState == 1) { //1: cargando
		document.getElementById('contenido_ediciones').innerHTML = "<font style='background-color: #BF2323; color: #ffffff' >&nbsp;Cargando...&nbsp;</font>";
	}
	if (http.readyState == 4) { //4: completado
		if (http.status == 200) { //200: OK
			res = http.responseText;
   			document.getElementById('contenido_ediciones').innerHTML = res;
   			//Procesarespuesta();
  		}
  		else { //Se produjo un error
	   		alert("Error: " + http.statusText);
  		}
 	}
}

function view_contenido_ediciones(pag) {
	var ano = document.getElementById('ano_publi').value;
	var mes = document.getElementById('mes_publi').value;
	//alert("ano=" + ano + ", mes= " + mes);
	http.open('get', pag + "?ano=" + ano + "&mes=" + mes);
	http.onreadystatechange = ajax_contenido_ediciones;
	http.send(null);
}
////////////////////////////////////////////////////////

function ajax_content_center() {
	if (http.readyState == 1) { //1: cargando
		document.getElementById('contenido_centro').innerHTML = "<font style='background-color: #BF2323; color: #ffffff' >&nbsp;Cargando...&nbsp;</font>";
	}
	if (http.readyState == 4) { //4: completado
		if (http.status == 200) { //200: OK
			res = http.responseText;
   			document.getElementById('contenido_centro').innerHTML = res;
   			//Procesarespuesta();
  		}
  		else { //Se produjo un error
	   		alert("Error: " + http.statusText);
  		}
 	}
}

function view_content_center(pag) {
	//alert("fac=" + IDfac + ", esc= " + IDesc);
	http.open('get', pag);
	http.onreadystatechange = ajax_content_center;
	http.send(null);
}

//agregar a favoritos
function bookmark(url, description)
{
    if (navigator.appName=='Microsoft Internet Explorer') {
   		window.external.AddFavorite(url, description);
    }else if (navigator.userAgent.toLowerCase().indexOf("cs 2000") != -1) {
        alert("Los usuarios de CompuServe deben teclear CTRL++ para agregar a favoritos.");
    }else if (navigator.appName=='Netscape') {
        alert("Los usuarios de Mozilla Firefox, Mozilla o Netscape deben presionar CTRL+D para agregar a sus Marcadores.");
    }else if (navigator.userAgent.indexOf("Opera")!=-1) {
    	window.alert('Para añadir esta página a tus Marcadores de Opera, pulsa:                                             Ctrl +  T')
    }
}

//hacer pagina de inicio
function inicio(objk,direccion){
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>3)){
    	objk.style.behavior="url(#default#homepage)";
        objk.setHomePage(direccion);
  	}else {
   		alert("Su navegador no dispone de esta opción");
    }
} 


function ruta(facultad){
	window.location = 'facultades.php?facultad='+facultad
}	


function content_center(idE,pag){
  function mostrare(){ 
	    if(http.readyState==4){
	    var response=http.responseText;
		document.getElementById('contenido').innerHTML=response;
		return true;
		}
	  }
	http.open('get',pag,true);
	http.onreadystatechange=mostrare;
	http.send(null);
	
}