function nuevoAjax(){
		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 encuasta(){
    var i;
	var elementos = document.getElementsByName("datoencues");
	var dato="";
    for(var i=0; i<elementos.length; i++) {
   		 if (elementos[i].checked){
				dato=elementos[i].value;
		 }
    }
	if(dato==""){
		jAlert('Seleccione una le las Opciones en la Lista.','Alerta');
	}
	else{
		var encuesta = "encuesta=" + dato;
		redireccionar("?op=graficos/encuesta&encuesta="+dato);
		}
}

	
  
	function cargarnoticia(dato){	
		var valor = "valor=" + dato;
		var infonoticia, todasnoticias;
		todasnoticias = document.getElementById('contenido');	
		infonoticia = document.getElementById('contenido_remoto');
		ajax1=nuevoAjax();
		ajax1.open("GET", "./info.php?" + valor,true);
		ajax1.onreadystatechange=function() {
			if (ajax1.readyState==1) {
				todasnoticias.style.display ='none';
				infonoticia.innerHTML ="<table align='center'><tr><td class='cargando'>Cargando.....<img src='img/loader_pulse.gif' /></td></tr></table>";
			}
			if (ajax1.readyState==4) {
				
				infonoticia.innerHTML = ajax1.responseText;	
				todasnoticias.style.display ='none';
				infonoticia.style.display ='block';
			}
		}
		ajax1.send(null)
	}
	
function cargar_pagina_remota(ruta){
	var todasnoticias, pagina_remota;
	todasnoticias = document.getElementById('contenido');		
	pagina_remota= document.getElementById('contenido_remoto');
	ajax_v= nuevoAjax();
	ajax_v.open("GET", ruta,true);
	ajax_v.onreadystatechange=function(){
		if (ajax_v.readyState==1) {
			todasnoticias.style.display ='none';
			pagina_remota.innerHTML ="<table align='center'><tr><td class='cargando'>Cargando.....<img src='img/loader_pulse.gif'/></td></tr></table>";
		}
		if (ajax_v.readyState==4){
			pagina_remota.innerHTML = ajax_v.responseText;	
			todasnoticias.style.display ='none';
			pagina_remota.style.display ='block';
		}
	}	
	ajax_v.send(null);
}

function campodelacruz(){ 
   window.open("municipios/campodelacruz.htm","","width=450,height=370,scrollbars=NO") 
}
function candelaria(){ 
   window.open("municipios/candelaria.htm","","width=410,height=310,scrollbars=NO") 
}
function galapa(){ 
   window.open("municipios/galapa.htm","","width=460,height=370,scrollbars=NO") 
}
function juandeacosta(){ 
   window.open("municipios/juandeacosta.htm","","width=450,height=550,scrollbars=NO") 
}
function luruaco(){ 
   window.open("municipios/luruaco.htm","","width=450,height=370,scrollbars=NO") 
}
function malambo(){ 
   window.open("municipios/malambo.htm","","width=450,height=370,scrollbars=NO") 
}
function manati(){ 
   window.open("municipios/manati.htm","","width=350,height=390,scrollbars=NO") 
}
function palmar(){ 
   window.open("municipios/palmar.htm","","width=400,height=320,scrollbars=NO") 
}
function piojo(){ 
   window.open("municipios/piojo.htm","","width=450,height=370,scrollbars=NO") 
}
function polonuevo(){ 
   window.open("municipios/polonuevo.htm","","width=330,height=370,scrollbars=NO") 
}
function ponedera(){ 
   window.open("municipios/ponedera.htm","","width=380,height=350,scrollbars=NO") 
}
function puerto(){ 
   window.open("municipios/puerto.htm","","width=450,height=370,scrollbars=NO") 
}
function repelon(){ 
   window.open("municipios/repelon.htm","","width=450,height=350,scrollbars=NO") 
}
function sabanagrande(){ 
   window.open("municipios/sabanagrande.htm","","width=450,height=350,scrollbars=NO") 
}
function sabanalarga(){ 
   window.open("municipios/sabanalarga.htm","","width=450,height=370,scrollbars=NO") 
}
function santalucia(){ 
   window.open("municipios/santalucia.htm","","width=310,height=430,scrollbars=NO") 
}
function santotomas(){ 
   window.open("municipios/santotomas.htm","","width=340,height=420,scrollbars=NO") 
}
function soledad(){ 
   window.open("municipios/soledad.htm","","width=450,height=370,scrollbars=NO") 
}
function suan(){ 
   window.open("municipios/suan.htm","","width=300,height=400,scrollbars=NO") 
}
function tubara(){ 
   window.open("municipios/tubara.htm","","width=450,height=510,scrollbars=NO") 
}
function usiacuri(){ 
   window.open("municipios/usiacuri.htm","","width=410,height=340,scrollbars=NO") 
}
function barranquilla(){ 
   window.open("municipios/barranquilla.htm","","width=350,height=280,scrollbars=NO") 
}
function baranoa(){ 
   window.open("municipios/baranoa.htm","","width=350,height=280,scrollbars=NO") 
}
function pradomar(){ 
   window.open("municipios/pradomar.htm","","width=350,height=280,scrollbars=NO") 
}

function enlaces_corp(){ 
   window.open("enlaces.php","","width=720,height=630, left=10,top=10, scrollbars=NO") 
}

function resoliciones(url){ 
   window.open(url,"","width=720,height=630, left=10,top=10, scrollbars=NO") 
}


function abrir_pdf(ruta){ 
   window.open(ruta) 
}
function enableButtom(){
	var check = document.getElementById('checkboxtra');
    var boton = document.getElementById('sendformtrami');
	if (check.checked == true){
    	boton.disabled = false;
	}
	if (check.checked == false){
    	boton.disabled = true;
	}
}

function buscar(){
	var dato = document.getElementById('busqueda').value;
	if (dato.length < 3) {
		alert('Digite por lo menos tres caracteres');
		document.getElementById('busqueda').focus();
		return (false);
	}
	else
		location.href="?op=buscar&dato="+dato;
}


function registrar_usuario(){
	
	var ced=document.getElementById('ced_usu').value;
	var nom=document.getElementById('nombre_usu').value;
	var ape=document.getElementById('ape_usu').value;
	var munic=document.getElementById('municipio').value;
	var tel=document.getElementById('telefono').value;
	var correo=document.getElementById('correo').value;
	var interes=document.getElementById('interes').value;
	var nulo=document.getElementById('nulo').value;
	if (document.getElementById('ced_usu').value.length < 1) {
		jAlert('El campo Cedulas no puede ser vacio.','Alerta');
		document.getElementById('ced_usu').focus();
		return (false);
	}
	if (document.getElementById('ced_usu').value.length < 6) {
		jAlert('Escriba por lo menos 6 dígitos  en campo CEDULA.','Alerta');
		document.getElementById('ced_usu').focus();
		return (false);
	}
	if (document.getElementById('nombre_usu').value.length < 1) {
		jAlert('El campo NOMBRES no puede ser vacio.','Alerta');
		document.getElementById('nombre_usu').focus();
		return (false);
	}
	var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
	var checkStr = document.getElementById('nombre_usu').value;
	var allValid = true;
	for (i = 0; i < checkStr.length; i++) {
		ch = checkStr.charAt(i);
		for (j = 0; j < checkOK.length; j++)
		    if (ch == checkOK.charAt(j))
		    break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
	}
	if (!allValid) {
		jAlert('Escriba sólo letras en el campo NOMBRES.','Alerta');
		document.getElementById('nombre_usu').focus();
		return (false);
	}
	if (document.getElementById('ape_usu').value.length < 1) {
		jAlert('El campo APELLIDOS no puede ser vacio.','Alerta');
	    document.getElementById('ape_usu').focus();
		return (false);
	}
	var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
	var checkStr = document.getElementById('ape_usu').value;
	var allValid = true;
	for (i = 0; i < checkStr.length; i++) {
		ch = checkStr.charAt(i);
		for (j = 0; j < checkOK.length; j++)
		    if (ch == checkOK.charAt(j))
		    break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
	}
	if (!allValid) {
		jAlert('Escriba sólo letras en el campo APELLIDOS.','Alerta');
		document.getElementById('ape_usu').focus();
		return (false);
	}
	
	if (document.getElementById('municipio').value.length < 1) {
		jAlert('El campo MUNICIPIO no puede ser vacio.','Alerta');
	    document.getElementById('municipio').focus();
		return (false);
	}
	/*if (document.getElementById('entidad').value.length < 1) {
		jAlert('El campo ENTIDAD no puede ser vacio.','Alerta');
	    document.getElementById('entidad').focus();
		return (false);
	}*/
	if (document.getElementById('telefono').value.length < 1) {
		jAlert('El campo TELEFONO no puede ser vacio.','Alerta');
	    document.getElementById('telefono').focus();
		return (false);
	}
	if (correo.length > 0) 
	if ((document.getElementById('correo').value.indexOf ('@', 0) == -1)||(document.getElementById('correo').value.length < 5)) {
		jAlert('Escriba una dirección de correo válida en el campo CORREO ELECTRONICO.','Alerta');
		document.getElementById('correo').focus();
    	return (false);
  	}
	
	if(correo.length < 1)correo=nulo;
	if(interes.length < 1)interes=nulo;
	var datos="ced_usu="+ced+"&nombre_usu="+nom+"&ape_usu="+ape+"&municipio="+munic+"&interes="+interes+"&telefono="+tel+"&correo="+correo+"&interes="+interes;
  	window.open("cargar_usuarios.php?"+datos) 
	//ajax.open("GET", "usu_convocatoria/registrar_usuario.php?"+datos,true);
	
}
function isEmail(email) {
	var result = false; var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) result= true;
	return result;
}
function contactenos(){


	var nom_ape=document.getElementById('nom_ape').value;
	var con_correo=document.getElementById('con_correo').value;
	var asunto=document.getElementById('asunto').value;
	var comment=document.getElementById('comment').value;
	var en_mail=document.getElementById('en_mail')
	//var reenviar_mail;
	if (nom_ape.length < 1)nom_ape="";
	if (asunto.length < 1)asunto="";
	//if (en_mail.checked == true)reenviar_mail=1;	else reenviar_mail=0;
	var email_con = isEmail(con_correo);
	
	if (email_con== false) {
		jAlert('Escriba una dirección de correo válida en el campo CORREO ELECTRONICO.','Alerta');
		document.getElementById('con_correo').focus();
    	return (false);
  	}
	if (document.getElementById('comment').value.length < 1) {
		jAlert('Por favor escriba su mensaje.','Alerta');
		document.getElementById('comment').focus();
		return (false);
	}
	
	var datos="nom_ape="+nom_ape+"&con_correo="+con_correo+"&asunto="+asunto+"&comment="+comment;
 	window.open("mail.php?"+datos) 
	//ajax.open("GET", "usu_convocatoria/registrar_usuario.php?"+datos,true);
	
}


	function validar(e) {
    	tecla = (document.all) ? e.keyCode : e.which;
    	if (tecla==8) return true; //Tecla de retroceso (para poder borrar)
    	patron = /\d/; //Solo acepta números
    	te = String.fromCharCode(tecla);
    	return patron.test(te); 
	} 
	