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==""){
		alert('Seleccione una de las Opciones en la Lista.');
	}
	else{
		var encuesta = "encuesta=" + dato;
		redireccionar("?op=graficos/encuesta&encuesta="+dato);
		}
}
function cambiartema(style){	
 	BorrarCookie('_theme');
	IntroducirCookie(style);
	//if(CojerCookie('_theme') != null)
		//var coki = CojerCookie('_theme')
	//alert(coki);
	location.reload();
}
function CojerValorCookie(indice) {
	//indice indica el comienzo del valor
	var galleta = document.cookie
	//busca el final del valor, dado por ;, a partir de indice
	var finDeCadena = galleta.indexOf(";", indice)
	//si no existe el ;, el final del valor lo marca la longitud total de la cookie
	if (finDeCadena == -1)
		finDeCadena = galleta.length

	return unescape(galleta.substring(indice, finDeCadena))
	}

function CojerCookie(nombre) {
	var galleta = document.cookie
	//construye la cadena con el nombre del valor
	var arg = nombre + "="
	var alen = arg.length			//longitud del nombre del valor
	var glen = galleta.length		//longitud de la cookie

	var i = 0
	while (i < glen) {
		var j = i + alen			//posiciona j al final del nombre del valor
		if (galleta.substring(i, j) == arg)	//si en la cookie estamo ya en nombre del valor		
			return CojerValorCookie(j)	//devuleve el valor, que esta a partir de j

		i = galleta.indexOf(" ", i) + 1		//pasa al siguiente
		if (i == 0)
			break				//fin de la cookie
	}
	return null					//no se encuentra el nombre del valor
}

function GuardarCookie (nombre, valor, caducidad) {
	if(!caducidad)
		caducidad = Caduca(0)

	//crea la cookie: incluye el nombre, la caducidad y la ruta donde esta guardada
	//cada valor esta separado por ; y un espacio
	document.cookie = nombre + "=" + escape(valor) + "; expires=" + caducidad + "; path=/"
}

function Caduca(dias) {
	var hoy = new Date()										//coge la fecha actual
	var msEnXDias = eval(dias) * 24 * 60 * 60 * 1000	//pasa los dias a mseg.

	hoy.setTime(hoy.getTime() + msEnXDias)			//fecha de caducidad: actual + caducidad
	return (hoy.toGMTString())
}

function BorrarCookie(nombre) {
	//para borrar la cookie, se le pone una fecha del pasado mediante Caduca(-1)
	document.cookie = nombre + "=; expires=" + Caduca(-1) + "; path=/"
}

function IntroducirCookie(nombre) {
	//establece la cookie: la caducidad es de 31 dias
	var _31dias = Caduca(31)				//crea la fecha de caducidad si 31 dias
	if (nombre != "") 
		GuardarCookie("_theme", nombre, _31dias)
}

function MostrarCookie(nombre, formulario) {
	if(CojerCookie(nombre) != null)
		var coki = CojerCookie(nombre)
		alert(coki);
}

function MostrarMiCookie() {
	MostrarCookie('_theme', document.cookies)
}

	
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 craninos(url){ 
   window.open(url,"","width=600,height=550, left=50,top=0, scrollbars=NO") 
}
function redireccionar(pagina){
	location.href=pagina;
}

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_usuario01(){
	
	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 interes=document.getElementById('interes').value;
	var tel=document.getElementById('telefono').value;
	var correo=document.getElementById('correo').value;
	var nulo=document.getElementById('nulo').value;
	if (document.getElementById('ced_usu').value.length < 1) {
		alert('El campo Cedulas no puede ser vacio.');
		document.getElementById('ced_usu').focus();
		return (false);
	}
	if (document.getElementById('ced_usu').value.length < 6) {
		alert('Escriba por lo menos 6 dígitos  en campo CEDULA.');
		document.getElementById('ced_usu').focus();
		return (false);
	}
	if (document.getElementById('nombre_usu').value.length < 1) {
		alert('El campo NOMBRES no puede ser vacio.');
		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) {
		alert('Escriba sólo letras en el campo NOMBRES.');
		document.getElementById('nombre_usu').focus();
		return (false);
	}
	if (document.getElementById('ape_usu').value.length < 1) {
		alert('El campo APELLIDOS no puede ser vacio.');
	    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) {
		alert('Escriba sólo letras en el campo APELLIDOS.');
		document.getElementById('ape_usu').focus();
		return (false);
	}
	
	if (document.getElementById('municipio').value.length < 1) {
		alert('El campo MUNICIPIO no puede ser vacio.');
	    document.getElementById('municipio').focus();
		return (false);
	}
	/*if (document.getElementById('entidad').value.length < 1) {
		alert('El campo ENTIDAD no puede ser vacio.');
	    document.getElementById('entidad').focus();
		return (false);
	}*/
	if (document.getElementById('telefono').value.length < 1) {
		alert('El campo TELEFONO no puede ser vacio.');
	    document.getElementById('telefono').focus();
		return (false);
	}
	if (correo.length > 0) 
	if ((document.getElementById('correo').value.indexOf ('@', 0) == -1)||(document.getElementById('correo').value.length < 5)) {
		alert('Escriba una dirección de correo válida en el campo CORREO ELECTRONICO.');
		document.getElementById('correo').focus();
    	return (false);
  	}
	
	if(correo.length < 1)correo=nulo;
	var datos="ced_usu="+ced+"&nombre_usu="+nom+"&ape_usu="+ape+"&municipio="+munic+"&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) {
		alert('Escriba una dirección de correo válida en el campo CORREO ELECTRONICO.');
		document.getElementById('con_correo').focus();
    	return (false);
  	}
	if (document.getElementById('comment').value.length < 1) {
		alert('Por favor escriba su mensaje.');
		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); 
	} 
	
	
function comentarionotica(id_noti){
	var capacarga = document.getElementById('enviaandocomentario');
	var nom_ape=document.getElementById('nom_ape').value;
	var con_correo=document.getElementById('con_correo').value;
	var comment=document.getElementById('comment').value;
	var notificar = document.getElementById('notificar').value;
	//var reenviar_mail;
	if (nom_ape.length < 1){
		alert('Por favor escriba su nombre');
		document.getElementById('nom_ape').focus();
    	return (false);
	}
	
	var email_con = isEmail(con_correo);
	
	if (email_con== false) {
		alert('Escriba una dirección de correo válida en el campo CORREO ELECTRONICO.');
		document.getElementById('con_correo').focus();
    	return (false);
  	}
	
	if (document.getElementById('comment').value.length < 1) {
		alert('Por favor escriba su mensaje.');
		document.getElementById('comment').focus();
		return (false);
	}
	
	var datos="nom_ape="+nom_ape+"&con_correo="+con_correo+"&comment="+comment+"&notificar="+notificar+"&id_noti="+id_noti;
	ajax= nuevoAjax();
	ajax.open("GET", "guardarcomentario.php?"+datos,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			capacarga.style.display ='block';
		}
		if (ajax.readyState==4) {
			capacarga.style.display ='none';
			alert(ajax.responseText);	
			location.reload();
		}
		if(ajax.readyState==404){
			alert('No se encontro la pagina');
		}
	}
	ajax.send(null);
}
	
	
//------------------------login---------------------------------

function CheckLogin(){
	var divlogin = document.getElementById('login');
	var cargandolog = document.getElementById('cargandologin');
	var username = document.getElementById("username").value;
    var password = document.getElementById("password1").value;
	var inpitpassword = document.getElementById("password1");
	var inputusernombre = document.getElementById("username");
	if (username.length < 1) {
		alert('Digite nombre de Usuario');
	    document.getElementById('username').focus();
	}
	else{
		if (password.length < 1) {
			alert('Digite su password');
	   	 	document.getElementById('password1').focus();
		}
		else{
	ajax=nuevoAjax();
	ajax.open("POST", "login.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			cargandolog.style.display ='block';
			document.getElementById('buttonlogin').disabled="disabled"
		}
		if (ajax.readyState==4) {
			document.getElementById('buttonlogin').disabled=false;
			cargandolog.style.display ='none';
			if((ajax.responseText==0)||(ajax.responseText==1)){
				if(ajax.responseText==0){
					inpitpassword.style.background='#FFB3B3'; 
					alert("Error! La contraseña es incorrecta.");
				}
				if(ajax.responseText==1){
					inputusernombre.style.background='#FFB3B3';
					alert("Error! Nombre de usuario no existe o su cuenta no ha sido activada");	
				}
			}
			else{
				var resp = ajax.responseText;
				divlogin.innerHTML = resp;
				location.reload();
			}
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("username="+username+"&password="+password);
		}
	}
	
}
function inputnombrestyle(){
	var inputusernombre = document.getElementById("username");
	inputusernombre.style.background='#F4F4F4';
}
function inputclavestyle(){
	var inpitpassword = document.getElementById("password1");
	inpitpassword.style.background='#F4F4F4'; 
}


function terminarsesion(){
	//var cargandolog = document.getElementById('cargandologin');
	//var divlogin = document.getElementById('login');
	ajax_v= nuevoAjax();
	ajax_v.open("GET", "cerrarsesion.php",true);
	ajax_v.onreadystatechange=function(){
		if (ajax_v.readyState==1) {
			cargandolog.style.display ='block';
		}
		if (ajax_v.readyState==4){
			//cargandolog.style.display ='none';
			//divlogin.innerHTML = ajax_v.responseText;
			location.reload();
		}
	}	
	ajax_v.send(null);
}
//------------------------login---------------------------------
function imprimir_nota(url){ 
   window.open(url,'Ing_Jader','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,tittlebar=si, left=170,top=100 ,width=600,height=700' ); 
}

function enviarporcorreo(url){ 
   window.open(url,'Ing_Jader','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,tittlebar=si, left=170,top=100 ,width=600,height=400' ); 
}
function regirtarusu(url){ 
   window.open(url,'Ing_Jader','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=NO,resizable=NO,tittlebar=NO, left=170,top=100 ,width=580,height=271' ); 
}
function organigrama(url){ 
   window.open(url,'Ing_Jader','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=NO,tittlebar=NO, left=170,top=100 ,width=870,height=768' ); 
}
//------------------registrar usuario-----------------------------------
function inputnombrestyle2(){
	var inputusernombre = document.getElementById("nom_usuario");
	inputusernombre.style.background='#F4F4F4';
}
function inputcorreo(){
	var correo = document.getElementById("correo");
	correo.style.background='#F4F4F4'; 
}
function registrar_usuario(){
	var nom=document.getElementById('nombre_usu').value;
	var nominput=document.getElementById('nombre_usu');
	var correo=document.getElementById('correo').value;
	var correoinput=document.getElementById('correo');
	var user=document.getElementById('nom_usuario').value;
	var userinput=document.getElementById('nom_usuario');
	var pass=document.getElementById('password').value;
	var passinput=document.getElementById('password');
	var confir_password=document.getElementById('confir_password').value;
	var confir_passwordinput=document.getElementById('confir_password');
	var divcarga=document.getElementById('resultado_mensaje');
	var check = document.getElementById('notificarme');
	if (check.checked == true){
    	var notificar = "1";
	}
	else{
    	var notificar = "0";
	}
	if (nom.length < 1) {
		nominput.style.background='#FFB3B3'; 
		alert('El campo Nombra no puede ser vacio.');
		document.getElementById('nombre_usu').focus();
		return (false);
	}
	if (nom.length < 3) {
		nominput.style.background='#FFB3B3'; 
		alert('Nombre de usuario incoreecto.');
		document.getElementById('nombre_usu').focus();
		return (false);
	}
	
	if (user.length < 1) {
		userinput.style.background='#FFB3B3';
		alert('El campo Usuario no puede ser vacio.');
		document.getElementById('nom_usuario').focus();
		return (false);
	}
	if (user.length < 3) {
		userinput.style.background='#FFB3B3'
		alert('Usuario incoreecto.');
		document.getElementById('nom_usuario').focus();
		return (false);
	}
	var email_con = isEmail(correo);
	if (email_con== false) {
		correoinput.style.background='#FFB3B3'
		alert('Escriba una dirección de correo válida en el campo CORREO ELECTRONICO.');
		document.getElementById('correo').focus();
    	return (false);
  	}
	if (pass.length < 1) {
		passinput.style.background='#FFB3B3'
		alert('El campo PASSWORD no puede ser vacio.');
		document.getElementById('password').focus();
		return (false);
	}
		
	if (pass != confir_password) {
		confir_passwordinput.style.background='#FFB3B3'
		alert('Las Contrasenas no conciden verifique e intentelo de nuevo');
    	document.getElementById('confir_password').focus();
    	return (false);
  	}
	
	
	var datos="nom="+nom+"&correo="+correo+"&user="+user+"&pass="+pass+"&notificar="+notificar;
	ajax= nuevoAjax();
	ajax.open("GET", "registrarusuario.php?"+datos,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divcarga.style.display ='block';
		}
		if (ajax.readyState==4) {
			divcarga.style.display ='none';
			result = ajax.responseText;	
			
			if(result=="0"){
				alert('Usuario ingresado con exito');
			}
			if(result=="1"){
				document.getElementById('nom_usuario').style.background='#FFB3B3';
				alert('El nombre de usuario: '+user+' no esta dosponible');
				
			}
			if(result=="2"){
				document.getElementById('correo').style.background='#FFB3B3';
				alert('la direccion de email: '+correo+' ya esta registrada en nuestra base de datos ');
				
			}	
			if(result=="3"){
				alert('Usuario ingresado con exito');
			}
				
		}
		if(ajax.readyState==404){
			alert('No se encontro la pagina');
		}
	}
	ajax.send(null);
}
function cambiar_estilo(caja){
	var inpitcaja = document.getElementById(caja);
	inpitcaja.style.background='#FFFFFF'; 
}


function actualizar_usuario(){
var nom=document.getElementById('nombre_usu').value;
	var nominput=document.getElementById('nombre_usu');
	var correo=document.getElementById('correo').value;
	var correoinput=document.getElementById('correo');
	var user=document.getElementById('nom_usuario').value;
	var userinput=document.getElementById('nom_usuario');
	var pass=document.getElementById('password').value;
	var passinput=document.getElementById('password');
	var confir_password=document.getElementById('confir_password').value;
	var confir_passwordinput=document.getElementById('confir_password');
	var divcarga=document.getElementById('resultado_mensaje');
	var check = document.getElementById('notificarme');
	
	if (check.checked == true){
    	var notificar = "1";
	}
	else{
    	var notificar = "0";
	}
	if (nom.length < 1) {
		nominput.style.background='#FFB3B3'; 
		alert('El campo Nombra no puede ser vacio.');
		document.getElementById('nombre_usu').focus();
		return (false);
	}
	if (nom.length < 3) {
		nominput.style.background='#FFB3B3'; 
		alert('Nombre de usuario incoreecto.');
		document.getElementById('nombre_usu').focus();
		return (false);
	}
	
	if (user.length < 1) {
		userinput.style.background='#FFB3B3';
		alert('El campo Usuario no puede ser vacio.');
		document.getElementById('nom_usuario').focus();
		return (false);
	}
	if (user.length < 3) {
		userinput.style.background='#FFB3B3'
		alert('Usuario incoreecto.');
		document.getElementById('nom_usuario').focus();
		return (false);
	}
	var email_con = isEmail(correo);
	if (email_con== false) {
		correoinput.style.background='#FFB3B3'
		alert('Escriba una dirección de correo válida en el campo CORREO ELECTRONICO.');
		document.getElementById('correo').focus();
    	return (false);
  	}
	if (pass.length < 1) {
		passinput.style.background='#FFB3B3'
		alert('El campo PASSWORD no puede ser vacio.');
		document.getElementById('password').focus();
		return (false);
	}
		
	if (pass != confir_password) {
		confir_passwordinput.style.background='#FFB3B3'
		alert('Las Contrasenas no conciden verifique e intentelo de nuevo');
    	document.getElementById('confir_password').focus();
    	return (false);
  	}
	
	
	
	var datos="nom="+nom+"&correo="+correo+"&user="+user+"&pass="+pass;
	
	ajax= nuevoAjax();
	ajax.open("GET", "actualizarusuario.php?"+datos,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divcarga.style.display ='block';
		}
		if (ajax.readyState==4) {
			divcarga.style.display ='none';
			result = ajax.responseText;	
			if(result=="0"){
				alert('Datos actualizados correctamente');
			}
			if(result=="1"){
				document.getElementById('nom_usuario').style.background='#FFB3B3';
				alert('El nombre de usuario: '+user+' no esta dosponible');
				
			}
	
		}
		if(ajax.readyState==404){
			alert('No se encontro la pagina');
		}
	}
	ajax.send(null);
}

function recuperarclave(){
	
	var correo=document.getElementById('con_correo').value;
	var divcarga=document.getElementById('resultado_mensaje');
	var email_con = isEmail(correo);
	
	if (email_con== false) {
		alert('Escriba una dirección de correo válida.');
		document.getElementById('con_correo').focus();
    	return (false);
  	}
	ajax=nuevoAjax();
	ajax.open("POST", "senclave.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divcarga.style.display ='block';
			document.getElementById('submitclave').disabled="disabled"
		}
		if (ajax.readyState==4) {
			document.getElementById('submitclave').disabled=false;
			divcarga.style.display ='none';
			alert(ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("correo="+correo);
	
	
}


//------------------fin registrar usuario-----------------------------------

function votar_comentario(voto,id_com){
	ajax=nuevoAjax();
	ajax.open("POST", "votar_favor_contra.php",true);
	ajax.onreadystatechange=function() {
		/*if (ajax.readyState==1) {
			divcarga.style.display ='block';
			document.getElementById('submitclave').disabled="disabled"
		}*/
		if (ajax.readyState==4) {
			document.getElementById(id_com).innerHTML=ajax.responseText;
			//divcarga.style.display ='none';
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("voto="+voto+"&id_com="+id_com);
	
	
}
function votar_comentario_res(voto,id_com){
	ajax=nuevoAjax();
	ajax.open("POST", "votar_favor_contra_resp.php",true);
	ajax.onreadystatechange=function() {
		/*if (ajax.readyState==1) {
			divcarga.style.display ='block';
			document.getElementById('submitclave').disabled="disabled"
		}*/
		if (ajax.readyState==4) {
			document.getElementById("respuesta"+id_com).innerHTML=ajax.responseText;
			//divcarga.style.display ='none';
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("voto="+voto+"&id_com="+id_com);
	
	
}

function responder_comentario(id_com){
			document.getElementById("responder"+id_com).style.display ='block';	
}
function oculta_responder_comentario(id_com){
			document.getElementById("responder"+id_com).style.display ='none';	
}

function guardar_res_comentario(id_com){
	var rep_com = document.getElementById("res_comment"+id_com).value;
	if (rep_com.length < 1){
		alert('Por favor escriba su comentario');
		document.getElementById("responder"+id_com).focus();
    	return (false);
	}
	ajax=nuevoAjax();
	ajax.open("POST", "responder_comentario.php",true);
	ajax.onreadystatechange=function() {
		/*if (ajax.readyState==1) {
			divcarga.style.display ='block';
			document.getElementById('submitclave').disabled="disabled"
		}*/
		if (ajax.readyState==4) {
			//document.getElementById(id_com).innerHTML=ajax.responseText;
			//divcarga.style.display ='none';
			
			alert(ajax.responseText);
			location.reload();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("id_com="+id_com+"&rep_com="+rep_com);
	
	
}
function enviar_reporte(){
	Modalbox.hide();
	alert('Reporte enviado correctamente');
}

function cargar_resol_dos(){
	var selec1=document.getElementById('selecuno').value;
	var selec2=document.getElementById('selecdos').value;
	var capa=document.getElementById('inforesol');
	var datos = "selec1="+selec1+"&selec2="+selec2;
	ajax= nuevoAjax();
	ajax.open("GET", "cargar_resol_dos.php?"+datos, true);
	
	ajax.onreadystatechange=function(){
		if (ajax.readyState==1) {
			  capa.innerHTML = "<table align='center'><tr><td class='cargando'>Cargando.....<img src='img/loader_pulse.gif' align='middle'/></td></tr></table>"; 
		}
		if (ajax.readyState==4){
			capa.innerHTML = ajax.responseText;
		}
	}	
	ajax.send(null);
}

function cargar_datos_dos(url){
	var selec1=document.getElementById('selecuno').value;
	var selec2=document.getElementById('selecdos').value;
	var capa=document.getElementById('infodatos');
	var datos = "selec1="+selec1+"&selec2="+selec2;
	if(selec2=="selecione"){
		alert('Seleccione la forma en que desea organizar los datos para continuar');
		document.getElementById('selecdos').focus();
    	return (false);
	}
	ajax= nuevoAjax();
	ajax.open("GET", url+"?"+datos, true);
	
	ajax.onreadystatechange=function(){
		if (ajax.readyState==1) {
			  capa.innerHTML = "<table align='center'><tr><td class='cargando'>Cargando.....<img src='img/loader_pulse.gif' align='middle'/></td></tr></table>"; 
		}
		if (ajax.readyState==4){
			capa.innerHTML = ajax.responseText;
		}
	}	
	ajax.send(null);

}

function cargarsalvoconductos(){	 
		var tipo = document.getElementById('tipodocumento').value;
		var valor = document.getElementById('Cedula_ciud').value;
		var dato = "valor=" + valor + "&tipo=" + tipo;
		if (valor.length < 6){ 
			alert('Número incorrecto.');
			document.getElementById('Cedula_ciud').focus();
		}
		else{
			var infosalvoconducto = document.getElementById('infosalvoconducto');
			ajax_s=nuevoAjax();
			ajax_s.open("GET", "salvoconductocon.php?" + dato,true);	
			ajax_s.onreadystatechange=function() {
				if (ajax_s.readyState==1) {
					infosalvoconducto.innerHTML ="<table align='center'><tr><td class='cargando'>Cargando.....<img src='loader_pulse.gif' /></td></tr></table>";
				}
				if (ajax_s.readyState==4) {
					infosalvoconducto.innerHTML = ajax_s.responseText;
				}
			}
			ajax_s.send(null)
		}
	}
