/*
			punto = 46
			coma = 45
			guion = 44
			parentesis ( = 40
			parentesis ) = 41
			espacio = 32
			porcentaje = 37
*/
	function calendario(file,window) 
	{   
		msgWindow=open('',window,'resizable=yes,width=280,height=230,screenX=400,screenY=300,top=300,left=400');  
		msgWindow.location.href = file;  
		if (msgWindow.opener == null) 
			msgWindow.opener = self;
	}
	function calendario2(file,window) 
	{   
		var d=document.form1;
		msgWindow=open('',window,'resizable=yes,width=280,height=230,screenX=400,screenY=300,top=300,left=400');  
		msgWindow.location.href = file+"&amp;anio="+d.anio.value+"&amp;mes="+d.mes.value;  
		if (msgWindow.opener == null) 
			msgWindow.opener = self;
	}	
	function mayuscula(caracter)
	{
			var caracter_m=caracter.toUpperCase();
			return caracter_m;
	}
	function letra(caracter)
	{
	
		if (caracter>=97&&caracter<=122) //minusculas
			return true;
		if (caracter>=65&&caracter<=90)//mayusculas
			return true;
		if (caracter==32)//espacio en blanco
			return true;
   	    if (caracter==241||caracter==209)//Ñ
			return true;
		return false;	
	}	
	function numero(caracter)
	{
		if (caracter>=48&&caracter<=57) //numeros
			return true;
		return false;	
	}	
	function letraynum(caracter)
	{
		if (letra(caracter)==true || numero(caracter)==true) //letras y numeros
			return true;
		return false;	
	}	
	function texto(caracter)
	{
		if (letra(caracter)==true) //letras
			return true;
		if (caracter==32||caracter==209||caracter==241||caracter==225||caracter==233||caracter==237||caracter==243||caracter==250||caracter==46)
			return true
		return false;	
	}	
	function textoynum(caracter)
	{
		if (letra(caracter)==true || numero(caracter)==true) //letras y numeros
			return true;
		if (caracter==32||caracter==209||caracter==241||caracter==225||caracter==233||caracter==237||caracter==243||caracter==250||caracter==46)
			return true
		return false;	
	}	
	function textoynumyenter(caracter)
	{
		if (letra(caracter)==true || numero(caracter)==true) //letras y numeros
			return true;
		if (caracter==32||caracter==209||caracter==241||caracter==225||caracter==233||caracter==237||caracter==243||caracter==250||caracter==46)
			return true
		if (caracter==13) //letras y numeros
			return true;
		return false;	
	}	
	function todosCaracteresValidacion(caracter)
	{		
		if (caracter!=34 && caracter!=39 && caracter!=37) //todo excepto comilla sencilla y doble y porcentaje
			return true;
		return false	
	}
	function caracterTelefono(caracter)
	{ 
		if (numero(caracter)==true)
			return true;
		if (caracter==40||caracter==41||caracter==45||caracter==32)
			return true
		return false	
	}
	function flotante(caracter)
	{ 
		if (numero(caracter)==true)
			return true;
		if (caracter==46)
			return true
		return false	
	}
	function transformaCadena(cadena){
		return escape(cadena);		
	}
   function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Correo Electronico invalido!!!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Correo Electronico invalido!!!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Correo Electronico invalido!!!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Correo Electronico invalido!!!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Correo Electronico invalido!!!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Correo Electronico invalido!!!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Correo Electronico invalido!!!")
		    return false
		 }

 		 return true				
	}
	
	function echeck2(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Correo Electronico invalido!!!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Correo Electronico invalido!!!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Correo Electronico invalido!!!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Correo Electronico invalido!!!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Correo Electronico invalido!!!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Correo Electronico invalido!!!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Correo Electronico invalido!!!")
		    return false
		 }

 		 return true				
	}
 //}
 
 	function encriptacion(cadena)	
	{ 
		var cadena_ret="";
		var buscar="ABCDEFGHIJKLMNÑOPQRSTUVWXYZ ";
		var reemplazar="ZFMATXGKBW*EQVHMDÑUCYLORISJP";
		var caracter;
		for(i=0; i<cadena.length; i++)
			{
					caracter=cadena.charAt(i);
					index = buscar.indexOf(caracter);
					if(index != -1)
							cadena_ret = cadena_ret.concat(reemplazar.charAt(index));
					else
						cadena_ret = cadena_ret.concat(caracter);
			}
		return cadena_ret;	
	}
 		function getRandomNum(lbound, ubound)
		{
			return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
		}
		
		function getRandomChar() {
			var charSet = "23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			return charSet.charAt(getRandomNum(0, charSet.length));
		}
		
		function generarContrasena() {
			var rc = "";
			for (var idx = 1; idx < 7; idx++) 
			{
				rc = rc + getRandomChar();
			}
			return rc;
		}

		function hash(pass)
		{
			var code= 0;
			var acum = 0;
			var aux = 0;
		
			for(var i = 0; i < pass.length; i++)
			  {
				code = pass.charCodeAt(i);
			   if(i%2 == 0)
		
				{
				   aux = acum + code;
				   acum = Math.sin(aux);	  
				 }
			 else
				 { 
				 aux = acum + code;
				 acum = Math.cos(aux);
				 }   
			  }
			  acum = acum *  Math.round(Math.pow(10, 9));
			  acum = Math.round(acum);
			 return acum;
		}
 	function asignaRadiobutton(button, value) {
			for (i=button.length-1; i > -1; i--) 
				if (button[i].value == value)
					button[i].checked = true;
	}

	function asignaSelect(button, value) {
			for (i=button.length-1; i > -1; i--) 
				if (button.options[i].value == value)
					button.options[i].selected = true;
	}

 
	function ajustaFechaHoraMinutoFinal()
	{
		tiempoAjuste = 1; //(en horas)
		var d = document.form1;
		var fecha01 = d.fechaEvento.value;
			dia = fecha01.substring(0,2);
			mes = fecha01.substring(3,5);
			anio = fecha01.substring(6,10);
			hora = d.horaInicio.value;
			minuto = d.minutoInicio.value;
		var fechaAjustar = new Date(anio,mes-1,dia,Number(hora),Number(minuto));
		var milisegundos = fechaAjustar.valueOf();
		milisegundos = milisegundos + tiempoAjuste*3600000; // cantidad de horas * milisegundos por hora
		var fechaAjustada = new Date();
			fechaAjustada.setTime(milisegundos)
			dia = fechaAjustada.getDate();
			mes = fechaAjustada.getMonth()+1;
			anio = fechaAjustada.getFullYear();
			hora = fechaAjustada.getHours();
			minuto = fechaAjustada.getMinutes();
			if(dia<10) dia = "0"+dia;
			if(mes<10) mes = "0"+mes;
			if(hora<10) hora = "0"+hora;
			if(minuto<10) minuto = "0"+minuto;
		asignaSelect(d.horaFin,hora);
		asignaSelect(d.minutoFin,minuto);
	}
	
	function Trim(s)
     {
        // Remove leading spaces and carriage returns
        while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
        { s = s.substring(1,s.length); }

        // Remove trailing spaces and carriage returns
        while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
        { s = s.substring(0,s.length-1); }
        return s;
     }
	 
	 function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '$' + num + '.' + cents);
	}

	function abreVentana(file,window) 
	{   
		msgWindow=open('',window,'resizable=yes,width=600,height=400,screenX=600,screenY=400,top=400,left=600');  
		msgWindow.location.href = file;  
		if (msgWindow.opener == null) 
			msgWindow.opener = self;
	}
	function abreVentanaContactos(file,window) 
	{   
		msgWindow=open('',window,'resizable=yes,scrollbars=yes, width=800,height=600,screenX=800,screenY=600,top=600,left=800');  
		msgWindow.location.href = file;  
		if (msgWindow.opener == null) 
			msgWindow.opener = self;
	}
	function cierraVentanaFoto(opcion){
		if(opcion!="1") {
			window.opener.document.form1.actualizaFoto.onchange(); 
			window.close();
		}	
	}

	/*INICIA AJAX*/
	function iniciaAjax()
	{
		 document.body.style.cursor = 'wait';
		 document.getElementById("mensaje_ajax").innerHTML = "<br><center><img src='../imagenes/espere.gif'  width='16' height='16' >  <font class='alerta'>ESPERE UN MOMENTO POR FAVOR</font></center>";
	}
	function iniciaAjaxRaiz()
	{
		 document.body.style.cursor = 'wait';
		 document.getElementById("mensaje_ajax").innerHTML = "<br><center><img src='imagenes/espere.gif'  width='16' height='16' >  <font class='alerta'>ESPERE UN MOMENTO POR FAVOR</font></center>";
	}
	function terminaAjax()
	{
		 document.body.style.cursor = 'default';
		 document.getElementById("mensaje_ajax").innerHTML = "<br><center><font class='alerta'></font></center>"
	}
	/*TERMINA AJAX*/

	
	function asignaSelect(button, value) {
			for (i=button.length-1; i > -1; i--) 
				if (button.options[i].value == value)
					button.options[i].selected = true;
	}
	function irA(url) {
		var d = document.form1;
		d.action=url;
		d.submit();		
	}
	function irAConfiguracionMenu(url, target){
		var d = document.form1;
		d.target=target;
		d.action=url;
		d.submit();		
	}
	function textCounter(field, countfield, maxlimit) {
	
		if (field.value.length > maxlimit)
				field.value = field.value.substring(0, maxlimit);
		else 
				countfield.value = maxlimit - field.value.length;
	}
	function verificaFechaAlerta(fecha)
	{ 
		var dia="";
		var mes="";
		var anio="";
		if(fecha != "")
		{
				dia = fecha.substring(0,2);
				mes = fecha.substring(3,5);
				anio = fecha.substring(6,10);

			var  fechaElegida= new Date(anio,mes-1,dia,23,59);
			var hoy=new Date();

			if(fechaElegida >= hoy)
			{
					alert("La fecha seleccionada no es válida. Debe ser anterior al dia actual.")
					fecha = "";
			}			
		}
		
		return(fecha);
	}
	function validaRadiobutton(button) {
			var opcionSeleccionada = "-1";
			for (i=button.length-1; i > -1; i--) 
				if (button[i].checked) 
						opcionSeleccionada = button[i].value;
			return opcionSeleccionada;
	}

	function validaCheckboxbutton(button, valor) {
			opcion = false;
			for (i=button.length-1; i > -1; i--) 
				if (button[i].checked) 
					if(button[i].value == valor)
						opcion = true;
			return opcion;
	}
	function verificaCheckbox(button) {
		if(button.checked)
			button.value = "S";
		else	
			button.value = "N";
	}
	function valoresSeleccionadosCheckboxbutton(button) {
		var valoresSeleccionados="";
			opcion = false;
			if(button.length != undefined) {
				for (i=0; i < button.length; i++) 
					if (button[i].checked) 
						valoresSeleccionados = valoresSeleccionados + button[i].value+"|";
			} else			
				if (button.checked) 
					valoresSeleccionados = valoresSeleccionados + button.value+"|";
		return valoresSeleccionados;			
	}
	
	/*VARIABLES DEL REGISTRO*/

	function asignaMetodoOrdenacion(opcion) {
		var d = document.form1;
			d.pagina.value='1';
			d.ordenacion.value=opcion;
			ajax('1');
	}
	function asignaMetodoOrdenacionPagina(opcionAjax, opcion) {
		var d = document.form1;
			d.pagina.value='1';
			d.ordenacion.value=opcion;
			ajax(Number(opcionAjax));
	}
	function asignaMetodoOrdenacionOpcion(opcion, opcionAjax) {
		var d = document.form1;
			d.pagina.value='1';
			d.ordenacion.value=opcion;
			ajax(Number(opcionAjax));
	}
	
	function asignaPagina(pagina) {
		var d = document.form1;
			d.pagina.value=pagina;
			ajax('1');
	}
	function asignaPaginaOpcion(pagina, opcionAjax) {
		var d = document.form1;
			d.pagina.value=pagina;
			ajax(Number(opcionAjax));
	}
	function asignaPaginaClasificacionMasiva(pagina) {
		var d = document.form1;
			d.pagina.value=pagina;
			ajax('19');
	}
	function buscaMunicipioClasificacionMasiva(){
		ajax('27');
	}
	function buscaDistritoClasificacionMasiva(){
	    ajax('30');
	}
	function buscaMunicipioAlbum(){
		ajax('3');
	}
	function buscaDistritoAlbum(){
	    ajax('4');
	}
	function buscaDistritoBusqueda(){
	    ajax('31');
	}
	function buscaMunicipioBusqueda(){
	    ajax('28');
	}
	function buscaMunicipioRutas(){
	    ajax('17');
	}
	function buscaDistritoRutas(){
	    ajax('18');
	}
	function buscaEventosPorHorario(){
		ajax('22');
	}
	function buscaMunicipio(opcion){
	    ajax(opcion);
	}
	
	var color="";
	function colorFondoNormal(src,color_entrada) 
	{ 
	   color = src.bgColor;
	   src.bgColor = color_entrada;
    } 
	function colorFondoContraste(src,color_entrada) 
	{ 
	   src.bgColor = color;
    }

	function usuariosNuevoUsuario() {
	/*
		var d = document.form1;
		var varHtml="";
		varHtml="<font class='cuerponegrobold'><center>NUEVO USUARIO</center></font><br /> "+
			 "<input type='hidden' name='contrasena' /> "+
			 "<input type='hidden' name='contrasenaEnc' /> "+
			 "<table border='0' align='center' class='style1' width='800'> "+
			 "	<tr> "+
			 "		<td class='cuerpogrisbold' align='right'><span class='alerta'>*</span> CLAVE DE USUARIO</td> "+
			 "		<td> "+
			 "			<input name='cveUsuario' type='text' class='campo01' maxlength='20'  "+
			 "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "+
			 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td class='cuerpogrisbold' align='right'><span class='alerta'>*</span> NOMBRE</td> "+
			 "		<td> "+
			 "			<input name='nombre' type='text' class='campo01' maxlength='50'  "+
			 "			onkeypress='if(!texto(event.keyCode)) event.returnValue=false;' "+
			 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td class='cuerpogrisbold' align='right'><span class='alerta'>*</span> PATERNO</td> "+
			 "		<td> "+
			 "			<input name='paterno' type='text' class='campo01' maxlength='50'  "+
			 "			onkeypress='if(!texto(event.keyCode)) event.returnValue=false;' "+
			 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td class='cuerpogrisbold' align='right'>MATERNO</td> "+
			 "		<td> "+
			 "			<input name='materno' type='text' class='campo01' maxlength='50'  "+
			 "			onkeypress='if(!texto(event.keyCode)) event.returnValue=false;' "+
			 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td class='cuerpogrisbold' align='right'><span class='alerta'>*</span> CORREO ELECTRÓNICO</td> "+
			 "		<td> "+
			 "			<input name='correo' type='text' class='campo01' maxlength='100'  "+
			 "			onkeypress='if(!todosCaracteresValidacion(event.keyCode)) event.returnValue=false;' "+
			 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value); if(!echeck(this.value)) this.value=\"\";' /> "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td class='cuerpogrisbold' align='right'><span class='alerta'>*</span> DIAS DE ANTICIPACIÓN PARA LA NOTIFICACIÓN DE EVENTOS</td> "+
			 "		<td> "+
			 "			<input name='diasAviso' type='text' class='campo02' maxlength='5'  "+
			 "			onkeypress='if(!numero(event.keyCode)) event.returnValue=false;' /> "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td></td> "+
			 "		<td align='left'> "+
			 "			<input name='diasHabiles' type='checkbox' class='campo02' value='0' onclick='if(this.checked == true) this.value=\"1\"; else this.value=\"0\";'  /> DIAS HÁBILES "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td align='center' colspan='2'> "+
			 "			<br /> "+
			 "			<input name='cancelar' type='button' class='boton01' value='CANCELAR'  "+
			 "			onclick='reiniciaUsuariosNuevoUsuario();'/> "+
			 "			&nbsp; "+
			 "			<input name='registrar' type='button' class='boton02' value='ALMACENAR' "+
			 "			onclick='almacenaNuevoUsuario();'/> "+
			 "			<br /> "+
			 "		</td> "+
			 "	</tr> "+
			 "</table>"; 
		document.getElementById("idNuevoUsuario").innerHTML=varHtml;
		document.getElementById("idNuevoUsuario").style.display="inline";
//		document.getElementById("idActualizaUsuario").style.display="none";	
		document.getElementById("idBotonNuevoUsuario").style.display="none";	
		
		*/
		ajax('12');
	}
	function usuariosActualizaUsuario(cveUsuario) {
		var d = document.form1;
		d.cveUsuario.value=cveUsuario;
		ajax(3);
	}
	
	function reiniciaUsuariosNuevoUsuario() {
		document.getElementById("idNuevoUsuario").style.display="none";
//		document.getElementById("idActualizaUsuario").style.display="none";	
		document.getElementById("idBotonNuevoUsuario").style.display="inline";	
	}
	function almacenaNuevoUsuario() {
		var d = document.form1;
		if(d.cveUsuario.value==""){
			alert("Debe introducir Clave de Usuario");
			return("");
		}
		if(d.nombre.value==""){
			alert("Debe introducir Nombre del Usuario");
			return("");
		}
		if(d.paterno.value==""){
			alert("Debe introducir Apellido Paterno del Usuario");
			return("");
		}
		if(d.correo.value==""){
			alert("Debe introducir Correo Electrónico del Usuario");
			return("");
		}
		if(!echeck(d.correo.value)) return("");
		if(d.cveTipoUsuario.value=="0"){
			alert("Debe seleccionar Tipo de usuario");
			return("");
		}
		if(d.diasAviso.value==""){
			alert("Debe introducir Número de Dias de Anticipación para la Notificación de Eventos");
			return("");
		}

		ajax(2);		

	}
	
	function almacenaActualizaUsuario() {
		var d = document.form1;

		if(d.nombre.value==""){
			alert("Debe introducir Nombre del Usuario");
			return("");
		}
		if(d.paterno.value==""){
			alert("Debe introducir Apellido Paterno del Usuario");
			return("");
		}
		if(d.correo.value==""){
			alert("Debe introducir Correo Electrónico del Usuario");
			return("");
		}
		if(!echeck(d.correo.value)) return("");
		if(d.cveTipoUsuario.value=="0"){
			alert("Debe seleccionar Tipo de usuario");
			return("");
		}
		if(d.diasAviso.value==""){
			alert("Debe introducir Número de Dias de Anticipación para la Notificación de Eventos");
			return("");
		}

		ajax(3);		
	}
	function almacenaActualizaUsuarioDatosPersonales() {
		var d = document.form1;

		if(d.nombre.value==""){
			alert("Debe introducir Nombre del Usuario");
			return("");
		}
		if(d.paterno.value==""){
			alert("Debe introducir Apellido Paterno del Usuario");
			return("");
		}
		if(d.correo.value==""){
			alert("Debe introducir Correo Electrónico del Usuario");
			return("");
		}
		if(!echeck(d.correo.value)) return("");
		if(d.diasAviso.value==""){
			alert("Debe introducir Número de Dias de Anticipación para la Notificación de Eventos");
			return("");
		}

		ajax(8);		
	}
	
	function cambiaEstatusUsuario(usuario, estatus) {
		var d = document.form1;
		d.cveUsuarioEspecial.value=usuario;
		d.estatusEspecial.value=estatus;
		ajax(4);
	}
	function consultaUsuario(usuario) {
		var d = document.form1;
		d.cveUsuarioEspecial.value=usuario;
		ajax(5);
	}
	function consultaUsuarioDatosPersonales() {
		var d = document.form1;
		ajax(7);
	}
	
	function muestraUsuariosEstatus(estatus) {
		var d = document.form1;
		d.pagina.value="1";
		d.ordenacion.value="1";
		d.estatus.value=estatus;
		ajax(1);
	}
	
	function capturaUsuarioSolicitud() {
		var d = document.form1;
		var varHtml="";
		varHtml="<font class='cuerpogris'><center>SOLICITUD DE CONTRASEÑA DE USUARIO</center></font><br /> "+
			 "<table border='0' align='center' class='style1' width='800'> "+
			 "	<tr> "+
			 "		<td class='cuerpogrisbold' align='right'><span class='alerta'>*</span> CLAVE DE USUARIO</td> "+
			 "		<td> "+
			 "			<input name='cveUsuario' type='text' class='campo02' maxlength='20'  "+
			 "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "+
			 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
			 "		</td> "+
			 "	</tr> "+
			 "	<tr> "+
			 "		<td align='center' colspan='2'> "+
			 "			<br /> "+
			 "			<input name='cancelar' type='button' class='boton01' value='CANCELAR'  "+
			 "			onclick='irA(\"../blanco.jsp\");'/> "+
			 "			&nbsp; "+
			 "			<input name='registrar' type='button' class='boton02' value='BUSCAR' "+
			 "			onclick='buscaDatosUsuario();'/> "+
			 "			<br /> "+
			 "		</td> "+
			 "	</tr> "+
			 "</table>"; 
		document.getElementById("idParametroUsuario").innerHTML=varHtml;
		document.getElementById("idParametroUsuario").style.display="inline";
	}
	function buscaDatosUsuario(){
		ajax('9');
	}	
	function reiniciaRegistroNuevoRegistro() {
		document.getElementById("idNuevoRegistro").style.display="none";
		document.getElementById("idBotonNuevoRegistro").style.display="inline";	
	}
	function registroNuevoRegistro() {
		var d = document.form1;
		d.almacenado.value = "";
		ajax(2);
	}
	function traeMunicipios() {
		var d = document.form1;
		if(d.cveEstado.value=="2") //baja california
			document.getElementById("idColonia").innerHTML = "<select class='campo02' name='cveColonia'> "+
													 	 	 "</select> "+
															 "<input type='hidden' name='colonia' /> ";
		else	
			document.getElementById("idColonia").innerHTML = "<input name='colonia' type='text' class='campo01' maxlength='50' "+
															 "onkeypress='if(!textoynum(event.keyCode)) event.returnValue=false;' "+
															 "style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
															 "<input type='hidden' name='cveColonia' /> ";
		ajax(3);
	}
	function traeMunicipiosDesdeEvento() {
		var d = document.form1;
		ajax(13);
	}
	function traeColonias() {
		var d = document.form1;
		if(d.cveEstado.value=="2" && d.cveMunicipio!="0" && d.cveMunicipio!="") //baja california y ya seleccionaron colonia
			ajax(4);
		else
			traeDistritos();	
	}
	function traeDistritos(){
		ajax(29);
	}
	function almacenaNuevoRegistro(){
		var d = document.form1;

		if(d.cveTipoRegistro.value=="0"){
			alert("Debe seleccionar Tipo de Registro");
			return("");
		}
		if(d.cveNivelRelacion.value=="0"){
			alert("Debe seleccionar Nivel de Relación");
			return("");
		}
		if(d.paterno.value==""){
			alert("Debe introducir Apellido Paterno");
			return("");
		}
		if(d.nombre.value==""){
			alert("Debe introducir Nombre");
			return("");
		}
		if(d.cveEstado.value=="0"){
			alert("Debe seleccionar Estado");
			return("");
		}
		if(d.cveMunicipio.value=="0"){
			alert("Debe seleccionar Municipio");
			return("");
		}
		if(d.calle.value==""){
			alert("Debe introducir Dirección (calle)");
			return("");
		}
		
		/*INICIO MIEMBROS*/
		/* NINGUN DATO ES OBLIGATORIO */
		/*FIN MIEMBROS*/
		/*INICIO PRENSA*/
		if(d.cveTipoRegistro.value=="4"){//prensa
			if(d.cveTipoMedio.value=="0"){
				alert("Debe seleccionar Tipo de Prensa");
				return("");
			}
			if(d.cveCobertura.value=="0"){
				alert("Debe seleccionar Cobertura del medio");
				return("");
			}
		}
		/*FIN PRENSA*/

		ajax(5);
	}
	function consultaFuncionario(registro) {
		var d = document.form1;
		d.cveRegistroEspecial.value=registro;
		ajax(6);
	}
	function almacenaActualizaRegistro(){
		var d = document.form1;
		if(d.cveTipoRegistro.value=="0"){
			alert("Debe seleccionar Tipo de Registro");
			return("");
		}
		if(d.cveNivelRelacion.value=="0"){
			alert("Debe seleccionar Nivel de Relación");
			return("");
		}
		if(d.paterno.value==""){
			alert("Debe introducir Apellido Paterno");
			return("");
		}
		if(d.nombre.value==""){
			alert("Debe introducir Nombre");
			return("");
		}
		if(d.cveEstado.value=="0"){
			alert("Debe seleccionar Estado");
			return("");
		}
		if(d.cveMunicipio.value=="0"){
			alert("Debe seleccionar Municipio");
			return("");
		}
		if(d.calle.value==""){
			alert("Debe introducir Dirección (calle)");
			return("");
		}
		if(d.cveTipoRegistro.value=="4"){//prensa
			if(d.cveTipoMedio.value=="0"){
				alert("Debe seleccionar Tipo de Prensa");
				return("");
			}
			if(d.cveCobertura.value=="0"){
				alert("Debe seleccionar Cobertura del medio");
				return("");
			}
		}
		ajax(7);
	}
	
	function muestraDatosComplementarios(tipoRegistro) {
		var innerHtml="";
		if(tipoRegistro=="1") { //basico
			innerHtml="";
			document.getElementById("datosComplementarios").innerHTML = innerHtml;
		}
		if(tipoRegistro=="2") { //funcionario publico
			ajax(8);
		}
		if(tipoRegistro=="3") { //miembro
			innerHtml="<br /><br /><font class='cuerponegrobold'><center>INFORMACIÓN ADICIONAL</center></font><br /> "+
				 "<table border='0' align='center' class='style1' width='800'> "+
				 "<input type='hidden' name='aspirante' /> "+
//				 "	<tr> "+
//				 "		<td class='cuerpogrisbold' align='right' width='300'> ASPIRANTE</td> "+
//				 "		<td> "+
//				 "			<input name='aspirante' type='text' class='campo02' maxlength='10'  "+
//				 "			onkeypress='if(!numero(event.keyCode)) event.returnValue=false;' "+
//				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
//				 "		</td> "+
//				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> RFC</td> "+
				 "		<td> "+
				 "			<input name='rfc' type='text' class='campo02' maxlength='10'  "+
				 "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "+
				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> HOMOCLAVE</td> "+
				 "		<td> "+
				 "			<input name='homoclave' type='text' class='campo02' maxlength='3'  "+
				 "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "+
				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> REGISTRO NACIONAL</td> "+
				 "		<td> "+
				 "			<input name='registroNacional' type='text' class='campo01' maxlength='25'  "+
				 "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "+
				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> CLAVE DE ELECTOR</td> "+
				 "		<td> "+
				 "			<input name='registroIFE' type='text' class='campo01' maxlength='25'  "+
				 "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "+
				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> SEXO</td> "+
				 "		<td> "+
				 "			<input name='sexo' type='radio' class='campo02' value='F' checked='checked' /> FEMENINO <br />"+
				 "			<input name='sexo' type='radio' class='campo02' value='M' /> MASCULINO "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> FECHA DE NACIMIENTO</td> "+
				 "		<td> "+
				 " 			<input type='text' name='fechaNacimiento' class='campo02' readonly /> "+
				 "			<a onclick='calendario(\"../librerias/calendario.jsp?fecha=1\",\"winPopup\"); ' style='cursor:hand'><img src='../imagenes/seleccioneFecha.jpg'  style='cursor:hand; text-decoration:none'/></a> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> FECHA DE REGISTRO</td> "+
				 "		<td> "+
				 " 			<input type='text' name='fechaRegistro' class='campo02' readonly /> "+
				 "			<a onclick='calendario(\"../librerias/calendario.jsp?fecha=2\",\"winPopup\"); ' style='cursor:hand'><img src='../imagenes/seleccioneFecha.jpg'  style='cursor:hand; text-decoration:none'/></a> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> SECCIÓN</td> "+
				 "		<td> "+
				 "			<input name='seccion' type='text' class='campo02' maxlength='5'  "+
				 "			onkeypress='if(!numero(event.keyCode)) event.returnValue=false;' "+
				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> DISTRITO</td> "+
				 "		<td> "+
				 "			<input name='distrito' type='text' class='campo02' maxlength='5'  "+
				 "			onkeypress='if(!numero(event.keyCode)) event.returnValue=false;' "+
				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> DOMICILIO COMPLEMENTARIO</td> "+
				 "		<td> "+
				 "			<input name='domicilioComplementario' type='text' class='campo01' maxlength='100'  "+
				 "			onkeypress='if(!textoynum(event.keyCode)) event.returnValue=false;' "+
				 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td class='cuerpogrisbold' align='right'> OBSERVACIONES</td> "+
				 "		<td> "+
				 "			<input name='observacionesMlen' type='hidden' value='200' /> "+
				 "			<textarea name='observacionesM'   style='text-transform:uppercase'  "+
				 "			class='campo02'  cols='46' rows='7' "+
				 "			onkeypress='if(!todosCaracteresValidacion(event.keyCode)) event.returnValue=false;'" +
				 "			onchange='this.value=mayuscula(this.value)'"+
				 "			onkeydown='textCounter(document.form1.observacionesM,document.form1.observacionesMlen,200);'" +
				 "			onkeyup='textCounter(document.form1.observacionesM,document.form1.observacionesMlen,200);'></textarea> "+
				 "		</td> "+
				 "	</tr> "+
				 "	</table> ";
			document.getElementById("datosComplementarios").innerHTML = innerHtml;
		}
		if(tipoRegistro=="4") { //prensa
			ajax(24);
		}
	}
	function traeDependencias(){
		ajax(9);
	}
	function muestraRamoDependencia() {
		var d = document.form1;
		if(d.clasificacion.value=="1") { //estatal
			document.getElementById("idRamoDependencia").innerHTML = "<table width='100%' border='0'>"+
															 "<tr><td class='cuerpogrisbold' align='right' width='300'> RAMO</td><td>"+
															 "<select class='campo01' name='ramo' onchange='traeDependencias()'> "+
													 	 	 "</select> "+
															 "<input type='hidden' name='sector' /> "+
															 "</td></tr> "+
															 "<tr><td class='cuerpogrisbold' align='right'> DEPENDENCIA</td><td>"+
															 "<select class='campo02' name='dependencia'> "+
															 "</select> "+
															 "<input type='hidden' name='nombreAsociacion' /> "+
															 "</td></tr></table> ";
			ajax(10);
		}													 
		else	
			document.getElementById("idRamoDependencia").innerHTML = "<table width='100%' border='0'>"+
															 "<tr><td class='cuerpogrisbold' align='right' width='300'> SECTOR</td><td>"+
															 "<input name='sector' type='text' class='campo01' maxlength='100' "+
															 "onkeypress='if(!textoynum(event.keyCode)) event.returnValue=false;' "+
															 "style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
															 "<input type='hidden' name='ramo' /> "+
															 "</td></tr> "+
															 "<tr><td class='cuerpogrisbold' align='right'> NOMBRE</td><td>"+
															 "<input name='nombreAsociacion' type='text' class='campo01' maxlength='100' "+
															 "onkeypress='if(!textoynum(event.keyCode)) event.returnValue=false;' "+
															 "style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
															 "<input type='hidden' name='dependencia' /> "+
															 "</td></tr></table> ";
	}
	function parametrosBusqueda() {
		ajax(26);
	}

	function parametrosBusquedaClasificacionMasiva() {
		ajax(25);
	}
	function parametrosBusquedaAlbum() {
		ajax(1);
	}	
	function parametrosRutas() {
		ajax(16);
	}
		function parametrosBusquedaSeleccion() {
		var innerHTML="";
					innerHTML="<br /><br /><font class='cuerponegrobold'><center>PARÁMETROS DE BÚSQUEDA</center></font><br /> "+
						 "<table border='0' align='center' class='style1' width='800'> "+
						 "	<tr> "+
						 "		<td class='cuerpogrisbold' align='center'> PATERNO</td> "+
						 "		<td class='cuerpogrisbold' align='center'> MATERNO</td> "+
						 "		<td class='cuerpogrisbold' align='center'> NOMBRE</td> "+
						 "		<td align='center' rowspan='2'> "+
						 "			<br /> "+
						 "			<input name='buscar' type='button' class='boton02' value='BUSCAR' "+
						 "			onclick='buscarRegistrosSeleccion();'/> "+
						 "			<br /> "+
						 "		</td> "+
						 "		<td align='center' rowspan='2'> "+
						 "			<br /> "+
						 "			<input name='buscar' type='button' class='boton03' value='SELECCIONAR' "+
						 "			onclick='asignarSeleccion();'/> "+
						 "			<br /> "+
						 "		</td> "+
						 "	</tr> "+
						 "	<tr> "+
						 "		<td align='center'> "+
						 "			<input name='paternoBusqueda' type='text' class='campo02' maxlength='50'  "+
						 "			onkeypress='if(!texto(event.keyCode)) event.returnValue=false;' onchange='buscarRegistrosSeleccion()' "+
						 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
						 "		</td> "+
						 "		<td align='center'> "+
						 "			<input name='maternoBusqueda' type='text' class='campo02' maxlength='50'  "+
						 "			onkeypress='if(!texto(event.keyCode)) event.returnValue=false;'  onchange='buscarRegistrosSeleccion()'"+
						 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
						 "		</td> "+
						 "		<td align='center'> "+
						 "			<input name='nombreBusqueda' type='text' class='campo02' maxlength='50'  "+
						 "			onkeypress='if(!texto(event.keyCode)) event.returnValue=false;'  onchange='buscarRegistrosSeleccion()'"+
						 "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "+
						 "		</td> "+
						 "	</tr> "+
						 "	</table> ";
		document.getElementById("idParametroBusqueda").innerHTML=innerHTML;
		document.getElementById("idParametroBusqueda").style.display="inline";		
		inicializaContactosForma();
	}
	function buscarRegistros() {
		ajax(11);
	}
	function buscarRegistrosSeleccion() {
		ajax(18);
	}
	function buscarRegistrosClasificacionMasiva()	{
		var d = document.form1;
		d.pagina.value="1";		
		ajax(19);
	}
	function buscarRegistrosAlbum()	{
		var d = document.form1;
		if(Number(d.edadFinal.value)>0 && d.edadInicial.value == ""){
			alert("Debe introducir rango de edad (Edad inicial).");
			return("");
		}
		if(d.edadFinal.value != "" && Number(d.edadInicial.value) == 0){
			alert("La edad inicial no puede ser cero.");
			return("");
		}
		if(d.edadFinal.value != "" && Number(d.edadFinal.value) <  Number(d.edadInicial.value) ){
			alert("La edad final no puede ser menor que la edad inicial.");
			return("");
		}
		d.pagina.value="1";		
		ajax(2);
	}
	
	function reiniciaConsulta(){
		var d = document.form1;
		d.pagina.value="1";		
		d.ordenacion.value="1";		
	}
	function buscarRegistrosRutas() {
		var d = document.form1;
		if(d.fecha01.value!="" && d.fecha02.value!="")
			ajax(19);
	}
	function buscarRegistrosRutasVersionImprimir() {
			ajax(20);
	}
	function imprimirRutas(){
		document.getElementById("idBotonNuevoEventoSuperior").style.display="none";
		document.getElementById("idBotonNuevoEventoInferior").style.display="none";
		document.getElementById("idParametroBusqueda").style.display="none";
		document.getElementById("idBotonRegresar").style.display="none";
		document.getElementById("idTituloConsultas").style.display="none";
		document.getElementById("btnImprimir").style.display="none";		
		window.print();
		document.getElementById("idBotonNuevoEventoSuperior").style.display="inline";
		document.getElementById("idBotonNuevoEventoInferior").style.display="inline";
		document.getElementById("idParametroBusqueda").style.display="inline";
		document.getElementById("idBotonRegresar").style.display="inline";
		document.getElementById("idTituloConsultas").style.display="inline";
		document.getElementById("btnImprimir").style.display="inline";
	}
	function inicioRegistro() {
		parametrosBusqueda(); 
	
	}
	function ocultaDiv(div){
		document.getElementById(div).style.display="none";	
	}
	function muestraDiv(div){
		document.getElementById(div).style.display="inline";	
	}
	/*INICIA EVENTOS*/
	function registroNuevoEvento() {
		ocultaDiv("idBotonActualizaContacto");
		ajax(12);
	}
	
	function reiniciaRegistroNuevoEvento() {
		document.getElementById("idNuevoEvento").style.display="none";
		document.getElementById("idBotonNuevoEvento").style.display="inline";	
		muestraDiv("idBotonActualizaContacto");
	}	
	function reiniciaRegistroNuevoEventoDesdeEvento() {
		document.getElementById("idNuevoEvento").style.display="none";
		document.getElementById("idBotonNuevoEvento").style.display="inline";	
	}	
		
	function almacenaNuevoEvento() {
		var d = document.form1;
		if(d.cveTipoEvento.value=="0") {
			alert("Debe seleccionar tipo de evento");
			return("");
		}
		if(d.descripcion.value=="") {
			alert("Debe introducir descripcion del evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="-1") {
			alert("Debe seleccionar tipo de Registro de Evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="1" && d.dia.value=="0") {
			alert("Debe seleccionar dia del evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="1" && d.mes.value=="0") {
			alert("Debe seleccionar mes del evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="2" && d.fechaEvento.value=="") {
			alert("Debe seleccionar fecha del evento");
			return("");
		}
		ajax(13);
	}
		
	function almacenaNuevoEventoDesdeEvento() {
		var d = document.form1;
		if(d.cveTipoEvento.value=="0") {
			alert("Debe seleccionar tipo de evento");
			return("");
		}
		if(d.descripcion.value=="") {
			alert("Debe introducir descripcion del evento");
			return("");
		}
		if(d.fechaEvento.value=="") {
			alert("Debe seleccionar fecha del evento");
			return("");
		}
		if(d.repetible.value=="1" && d.repite.checked) {/*se debe validar los datos de la repeticion*/
			if(d.cveTipoRepeticion.value=="0") {
				alert("Debe seleccionar Tipo de Repeticion");
				return("");
			}
			if(d.fechaEventoRepeticionInicial.value=="") {
				alert("Debe seleccionar Fecha Inicial de Repeticion");
				return("");
			}
			if(validaRadiobutton(d.tipoRegistroEvento)=="1" && d.cantidadVeces.value=="") {
				alert("Debe indicar la cantidad de veces que se llevara a cabo la Repeticion");
				return("");
			}
			if(validaRadiobutton(d.tipoRegistroEvento)=="2" && d.fechaEventoRepeticion.value=="") {
				alert("Debe seleccionar Fecha Final de Repeticion");
				return("");
			}
		}

		ajax(9);
	}
	function muestraDatosEspecialesAgenda(){
	 	ajax(12);
	}
	function validaDatosAgenda(){
		var d = document.form1;
        if(d.cveTipoEvento.value == "3") //tipo agenda
        	muestraDatosEspecialesAgenda();
        else {
            document.getElementById("divDatosAgenda").innerHTML="";
            document.getElementById("divDatosAgenda").style.display="none";
        }
	}
	function asignaSeleccionFechaEvento() {
      var meses=new Array(12);
	      meses[0]= "ENE"; meses[1]= "FEB"; meses[2]= "MAR"; meses[3]= "ABR"; meses[4]= "MAY"; meses[5]= "JUN"; meses[6]= "JUL";
	      meses[7]= "AGO"; meses[8]= "SEP"; meses[9]= "OCT"; meses[10]= "NOV"; meses[11]= "DIC";
		var mesValor=document.getElementById("mes").value;
		var diaValor=document.getElementById("dia").value;
		if(mesValor=="") mesValor="0";
		if(diaValor=="") diaValor="0";
		
		if(mesValor == "0") {
	      	document.getElementById("dia").options.length = 0;
	        document.getElementById("dia").options[0] = new Option('--',0);		
			for(i=1; i<32;i++)
	          document.getElementById("dia").options[i] = new Option(i,i);		
	        document.getElementById("dia").options[diaValor].selected = true;

	      	document.getElementById("mes").options.length = 0;
	        document.getElementById("mes").options[0] = new Option('--',0);		
			for(i=0; i<12;i++)
	          document.getElementById("mes").options[i+1] = new Option(meses[i],i+1);		
	        document.getElementById("mes").options[mesValor].selected = true;
	    }    
		/*enero, marzo, mayo, julio, agosto, octubre, diciembre = 31 dias*/
		if(mesValor == "1" || mesValor == "3" || mesValor == "5" || mesValor == "7" || mesValor == "8" || mesValor == "10" || mesValor == "12") {
	      	document.getElementById("dia").options.length = 0;
	        document.getElementById("dia").options[0] = new Option('--',0);		
			for(i=1; i<32;i++)
	          document.getElementById("dia").options[i] = new Option(i,i);		
	        document.getElementById("dia").options[diaValor].selected = true;

	      	document.getElementById("mes").options.length = 0;
	        document.getElementById("mes").options[0] = new Option('--',0);		
			for(i=0; i<12;i++)
	          document.getElementById("mes").options[i+1] = new Option(meses[i],i+1);		
	        document.getElementById("mes").options[mesValor].selected = true;
	    }    
		if(mesValor == "4" || mesValor == "6" || mesValor == "9" || mesValor == "11") {
			if(diaValor > 30) diaValor="0";
	      	document.getElementById("dia").options.length = 0;
	        document.getElementById("dia").options[0] = new Option('--',0);		
			for(i=1; i<31;i++)
	          document.getElementById("dia").options[i] = new Option(i,i);		
	        document.getElementById("dia").options[diaValor].selected = true;

	      	document.getElementById("mes").options.length = 0;
	        document.getElementById("mes").options[0] = new Option('--',0);		
			for(i=0; i<12;i++)
	          document.getElementById("mes").options[i+1] = new Option(meses[i],i+1);		
	        document.getElementById("mes").options[mesValor].selected = true;
	    }    
		if(mesValor == "2") {
			if(diaValor > 29) diaValor="0";
	      	document.getElementById("dia").options.length = 0;
	        document.getElementById("dia").options[0] = new Option('--',0);		
			for(i=1; i<30;i++)
	          document.getElementById("dia").options[i] = new Option(i,i);		
	        document.getElementById("dia").options[diaValor].selected = true;

	      	document.getElementById("mes").options.length = 0;
	        document.getElementById("mes").options[0] = new Option('--',0);		
			for(i=0; i<12;i++)
	          document.getElementById("mes").options[i+1] = new Option(meses[i],i+1);		
	        document.getElementById("mes").options[mesValor].selected = true;
	    }    
		
	}
	function tipoRegistroEventoRegula() {
		var d = document.form1;
		var tipoRegistroEvento=validaRadiobutton(d.tipoRegistroEvento);
		if(tipoRegistroEvento=="1") { //registro de dia/mes
			ocultaDiv("idSeleccioneFecha");
			document.getElementById("dia").disabled="";
			document.getElementById("mes").disabled="";
			asignaSeleccionFechaEvento();
		}
		if(tipoRegistroEvento=="2") { //registro de dia/mes
			muestraDiv("idSeleccioneFecha");
			document.getElementById("dia").disabled="disabled";
			document.getElementById("mes").disabled="disabled";
			document.getElementById("fechaEvento").value="";
		}
	}
	function tipoRegistroEventoRegulaRepeticion() {
		var d = document.form1;
		var tipoRegistroEvento=validaRadiobutton(d.tipoRegistroEvento);
		if(tipoRegistroEvento=="1") { 
			document.getElementById("fechaEventoRepeticion").value="";
			ocultaDiv("idSeleccioneFechaRepeticion");
			document.getElementById("cantidadVeces").disabled="";
		}
		if(tipoRegistroEvento=="2") {
			muestraDiv("idSeleccioneFechaRepeticion");
			document.getElementById("cantidadVeces").disabled="disabled";
			document.getElementById("cantidadVeces").value="";
		}
	}
	function consultaEvento(evento) {
		var d = document.form1;
		d.cveEventoEspecial.value=evento;
		ocultaDiv("idBotonActualizaContacto");
		ajax(15);
	}
	function almacenaActualizaEvento() {
		var d = document.form1;
		if(d.cveTipoEvento.value=="0") {
			alert("Debe seleccionar tipo de evento");
			return("");
		}
		if(d.descripcion.value=="") {
			alert("Debe seleccionar tipo de evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="-1") {
			alert("Debe seleccionar tipo de Registro de Evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="1" && d.dia.value=="0") {
			alert("Debe seleccionar dia del evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="1" && d.mes.value=="0") {
			alert("Debe seleccionar mes del evento");
			return("");
		}
		if(validaRadiobutton(d.tipoRegistroEvento)=="2" && d.fechaEvento.value=="") {
			alert("Debe seleccionar fecha del evento");
			return("");
		}
		ajax(16);
	}
	function muestraObservaciones(cveEvento) {
		abreVentana("../observaciones/observaciones.jsp?cveEvento="+cveEvento, "winPopup");
	}
	function verAgendaActual(){
		var d = document.form1;
		var horarioInicio = d.horaInicio.value+":"+d.minutoInicio.value;
		var horarioFin = d.horaFin.value+":"+d.minutoFin.value;
		if(d.fechaEvento.value==""){
			alert("Debe seleccionar Fecha de Evento");
			return("");
		}
		abreVentana("../evento/eventoProgramadoHorario.jsp?fechaEvento="+d.fechaEvento.value+"&horaInicio="+horarioInicio+"&horaFin="+horarioFin, "winPopupHorario");
	}
	function eliminaEvento(cveEvento, cveFuncionario) {
		var d = document.form1;
		if(confirm("¿Esta usted seguro de eliminar este evento (S/N)?")) {
			d.cveEventoEspecial.value=cveEvento;
			d.cveRegistroEspecial.value=cveFuncionario;
			ajax(17);
		} else {
			d.cveEventoEspecial.value="";
			d.cveRegistroEspecial.value="";
		}	
	}
	function eliminaEventoRegistrado(cveEvento) {
		var d = document.form1;
		if(confirm("¿Esta usted seguro de eliminar este evento (S/N)?")) {
			d.cveEventoEspecial.value=cveEvento;
			ajax(15);
		} else
			d.cveEventoEspecial.value="";
	}
	/*TERMINA EVENTOS*/
	
	/*INICIA CATALOGO*/
	function eventosNuevoCatalogo(opcionCatalogo) {
		var d = document.form1;
		var varHtml = "";
		switch(opcionCatalogo) {
			case 1:
				varHtml = "<font class='cuerponegrobold'><center>NUEVO NIVEL DE RELACION</center></font><br /> "
                        + "<table border='0' align='center' class='style1' width='800'> "
                        + "	<tr> "
                        + "		<td width='285' class='cuerpogrisbold' align='right'><span class='alerta'>*</span> DESCRIPCION</td> "
                        + "		<td width='505'> "
                        + "			<input name='descripcion' type='text' class='campo01' maxlength='30'  "
                        + "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
                        + "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
                        + "		</td> "
                        + "	</tr> "
                        + "	<tr> "
                        + "		<td align='center' colspan='2'> "
                        + "			<br /> "
                        + "			<input name='cancelar' type='button' class='boton01' value='CANCELAR'  "
                        + "			onclick='reiniciaCatalogo();'/> "
                        + "			&nbsp; "
                        + "			<input name='registrar' type='button' class='boton02' value='ALMACENAR' "
                        + "			onclick='almacenaNuevoNivelRelacion();'/> "
                        + "			<br /> "
                        + "		</td> "
                        + "	</tr> "
                        + "</table>"; 
        	break;                
			case 2:
				varHtml = "<font class='cuerponegrobold'><center>NUEVO TIPO DE REGISTRO</center></font><br /> "
                        + "<table border='0' align='center' class='style1' width='800'> "
                        + "	<tr> "
                        + "		<td width='285' class='cuerpogrisbold' align='right'><span class='alerta'>*</span> DESCRIPCION</td> "
                        + "		<td width='505'> "
                        + "			<input name='descripcion' type='text' class='campo01' maxlength='30'  "
                        + "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
                        + "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
                        + "		</td> "
                        + "	</tr> "
                        + "	<tr> "
                        + "		<td align='center' colspan='2'> "
                        + "			<br /> "
                        + "			<input name='cancelar' type='button' class='boton01' value='CANCELAR'  "
                        + "			onclick='reiniciaCatalogo();'/> "
                        + "			&nbsp; "
                        + "			<input name='registrar' type='button' class='boton02' value='ALMACENAR' "
                        + "			onclick='almacenaNuevoTipoRegistro();'/> "
                        + "			<br /> "
                        + "		</td> "
                        + "	</tr> "
                        + "</table>"; 
			break;
			case 3:
				varHtml = "<font class='cuerponegrobold'><center>NUEVA CLASIFICACIÓN DE AGENDA</center></font><br /> "
                        + "<table border='0' align='center' class='style1' width='800'> "
                        + "	<tr> "
                        + "		<td width='285' class='cuerpogrisbold' align='right'><span class='alerta'>*</span> DESCRIPCION</td> "
                        + "		<td width='505'> "
                        + "			<input name='descripcion' type='text' class='campo01' maxlength='30'  "
                        + "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
                        + "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
                        + "		</td> "
                        + "	</tr> "
                        + "	<tr> "
                        + "		<td align='center' colspan='2'> "
                        + "			<br /> "
                        + "			<input name='cancelar' type='button' class='boton01' value='CANCELAR'  "
                        + "			onclick='reiniciaCatalogo();'/> "
                        + "			&nbsp; "
                        + "			<input name='registrar' type='button' class='boton02' value='ALMACENAR' "
                        + "			onclick='almacenaNuevaClasificacionAgenda();'/> "
                        + "			<br /> "
                        + "		</td> "
                        + "	</tr> "
                        + "</table>"; 
			break;
		}
		document.getElementById("idNuevoCatalogo").innerHTML = varHtml;
		document.getElementById("idNuevoCatalogo").style.display = "inline";
		document.getElementById("idBotonNuevoCatalogo").style.display = "none";	
	}
	function almacenaNuevoNivelRelacion() {
		var d = document.form1;
		if(d.descripcion.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}
		ajax(2);
	}

	function almacenaActualizaNivelRelacion() {
		var d = document.form1;
		if(d.descripcion.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}
		ajax(3);		
	}

    function consultaNivelRelacion(clave) {
            var d = document.form1;
            d.cveCatalogo.value = clave;
            ajax(4);
	}
	function almacenaNuevoTipoRegistro() {
		var d = document.form1;
		if(d.descripcion.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}
		ajax(6);
	}

	function almacenaActualizaTipoRegistro() {
		var d = document.form1;
		if(d.descripcion.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}
		ajax(7);		
	}

    function consultaTipoRegistro(clave) {
            var d = document.form1;
            d.cveCatalogo.value = clave;
            ajax(8);
	}
	function almacenaNuevaClasificacionAgenda() {
		var d = document.form1;
		if(d.descripcion.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}
		ajax(11);
	}

	function almacenaActualizaClasificacionAgenda() {
		var d = document.form1;
		if(d.descripcion.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}
		ajax(12);		
	}

    function consultaClasificacionAgenda(clave) {
            var d = document.form1;
            d.cveCatalogo.value = clave;
            ajax(13);
	}
	function reiniciaCatalogo() {
		document.getElementById("idNuevoCatalogo").style.display="none";
		document.getElementById("idBotonNuevoCatalogo").style.display="inline";	
	}
	function asignaEstatusCatalogo(cveEstatus, opcionAjax){
            var d = document.form1;
            d.cveEstatus.value = cveEstatus;
            ajax(opcionAjax);
	}
	function cambiaEstatusTipoRegistro(cveTipoRegistro, cveEstatus){
            var d = document.form1;
            d.cveCatalogo.value = cveTipoRegistro;
            d.cveCatalogoEstatus.value = cveEstatus;
            ajax(9);			
	}
	/*TERMINA CATALOGO*/
	/*INICIA TIPO EVENTO*/
	function eventosNuevoTipo() {
		var d = document.form1;
		var varHtml = "";
		varHtml = "<font class='cuerponegrobold'><center>NUEVO TIPO DE EVENTO</center></font><br /> "
                        + "<table border='0' align='center' class='style1' width='800'> "
                        + "	<tr> "
                        + "		<td width='285' class='cuerpogrisbold' align='right'><span class='alerta'>*</span> DESCRIPCION</td> "
                        + "		<td width='505'> "
                        + "			<input name='descEvento' type='text' class='campo01' maxlength='30'  "
                        + "			onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
                        + "			style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
                        + "		</td> "
                        + "	</tr> "
                        + "	<tr> "
                        + "		<td></td> "
                        + "		<td align='left'> "
                        + "			<input name='repetible' type='checkbox' class='campo02' value='0' onclick='if(this.checked == true) this.value=\"1\"; else this.value=\"0\";'  /> REPETIBLE "
                        + "		</td> "
                        + "	</tr> "
                        + "	<tr> "
                        + "		<td align='center' colspan='2'> "
                        + "			<br /> "
                        + "			<input name='cancelar' type='button' class='boton01' value='CANCELAR'  "
                        + "			onclick='reiniciaEventosNuevoTipo();'/> "
                        + "			&nbsp; "
                        + "			<input name='registrar' type='button' class='boton02' value='ALMACENAR' "
                        + "			onclick='almacenaNuevoEventosTipo();'/> "
                        + "			<br /> "
                        + "		</td> "
                        + "	</tr> "
                        + "</table>"; 
		document.getElementById("idNuevoTipoEvento").innerHTML = varHtml;
		document.getElementById("idNuevoTipoEvento").style.display = "inline";
//		document.getElementById("idActualizaUsuario").style.display = "none";	
		document.getElementById("idBotonNuevoTipoEvento").style.display = "none";	
	}

      	function reiniciaEventosNuevoTipo() {
		document.getElementById("idNuevoTipoEvento").style.display="none";
//		document.getElementById("idActualizaUsuario").style.display="none";	
		document.getElementById("idBotonNuevoTipoEvento").style.display="inline";	
	}

	function almacenaNuevoEventosTipo() {
		var d = document.form1;

		if(d.descEvento.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}

		ajax(2);
	}

	function almacenaActualizaEventosTipo() {
		var d = document.form1;

		if(d.descEvento.value==""){
			alert("Debe introducir Descripcion");
			return("");
		}

		ajax(3);		
	}

        function consultaEventosTipo(evento) {
            var d = document.form1;
            d.cveEventoEspecial.value = evento;
            ajax(5);
	}

	/*TERMINA TIPO EVENTO*/
	/*INICIO OBSERVACIONES*/
		function inicioObservaciones(){
			ajax(1);
		}	
		function reiniciaRegistroNuevaObservacion() {
			document.getElementById("idNuevaObservacion").style.display="none";
			document.getElementById("idBotonNuevaObservacion").style.display="inline";	
		}
		function registroNuevaObservacion() {
			var innerHtml = "";
			innerHtml="<br /><br /><font class='cuerponegrobold'><center>NUEVA OBSERVACION</center></font><br /> "+
				 "<table border='0' align='center' class='style1' width='800'> "+
				 "	<tr> "+
				 "		<td align='center'> "+
				 "			<input name='observacioneslen' type='hidden' value='500' /> "+
				 "			<textarea name='observaciones'   style='text-transform:uppercase'  "+
				 "			class='campo02'  cols='100' rows='5' "+
				 "			onkeypress='if(!todosCaracteresValidacion(event.keyCode)) event.returnValue=false;'" +
				 "			onchange='this.value=mayuscula(this.value)'"+
				 "			onkeydown='textCounter(document.form1.observaciones,document.form1.observacioneslen,500);'" +
				 "			onkeyup='textCounter(document.form1.observaciones,document.form1.observacioneslen,500);'></textarea> "+
				 "		</td> "+
				 "	</tr> "+
				 "	<tr> "+
				 "		<td align='center'> "+
				 "			<br /> "+
				 "			<input name='cancelar' type='button' class='boton01' value='CANCELAR'  "+
				 "			onclick='reiniciaRegistroNuevaObservacion();'/> "+
				 "			&nbsp; "+
				 "			<input name='registrar' type='button' class='boton02' value='ALMACENAR' "+
				 "			onclick='almacenaNuevaObservacion();'/> "+
				 "			<br /> "+
				 "		</td> "+
				 "	</tr> "+
				 "	</table> ";
			document.getElementById("idNuevaObservacion").innerHTML = innerHtml;
			document.getElementById("idNuevaObservacion").style.display="inline";
		}
		function almacenaNuevaObservacion() {
            var d = document.form1;
			if(d.observaciones.value=="") {
				alert("Debe introducir observacion");
				return("");
			}
			ajax(2);
		}
		function asignarSeleccion() {
            var d = document.form1;
            var i=0;
            var valoresSeleccionados = "";
            var valoresSplit;
            var valoresSplitEspecial;
			valoresSeleccionados = valoresSeleccionadosCheckboxbutton(d.seleccionFuncionario);			
			valoresSplit = valoresSeleccionados.split("|");
			for(i=0;i<valoresSplit.length-1;i++) {
				valoresSplitEspecial = valoresSplit[i].split("*");
				if(!validaExisteValorEnSelect("contactosSeleccionados", Trim(valoresSplitEspecial[0])))
					document.getElementById("contactosSeleccionados").options[document.getElementById("contactosSeleccionados").options.length] = new Option(Trim(valoresSplitEspecial[1]),Trim(valoresSplitEspecial[0]));
			}
		}
		function validaExisteValorEnSelect(select, valor) {
			var i=0;
			for(i=0;i<document.getElementById(select).options.length; i++)
				if(document.getElementById(select).options[i].value == valor)
					return true;
			return false;		
		}
		function validaDeseleccionaContacto() {
			var i=0;
			for(i=0;i<document.getElementById("contactosSeleccionados").options.length; i++)
				if(!document.getElementById("contactosSeleccionados").options[i].selected) 
					document.getElementById("contactosSeleccionadosTemporal").options[document.getElementById("contactosSeleccionadosTemporal").options.length] = new Option(document.getElementById("contactosSeleccionados").options[i].text,document.getElementById("contactosSeleccionados").options[i].value);

			document.getElementById("contactosSeleccionados").options.length = 0;
			for(i=0;i<document.getElementById("contactosSeleccionadosTemporal").options.length; i++)
					document.getElementById("contactosSeleccionados").options[document.getElementById("contactosSeleccionados").options.length] = new Option(document.getElementById("contactosSeleccionadosTemporal").options[i].text,document.getElementById("contactosSeleccionadosTemporal").options[i].value);

			document.getElementById("contactosSeleccionadosTemporal").options.length = 0;
		}
		function asignaContactosForma() {
			if(window.opener != null) {
				window.opener.document.getElementById("contactos").options.length=0;
				for(i=0;i<document.getElementById("contactosSeleccionados").options.length; i++) {
				    window.opener.addOption(document.getElementById("contactosSeleccionados").options[i].text, document.getElementById("contactosSeleccionados").options[i].value);
				}
				window.close();
			}		
		}
		function inicializaContactosForma() {
			if(window.opener != null) {
				document.getElementById("contactosSeleccionados").options.length=0;
				for(i=0;i<window.opener.document.getElementById("contactos").options.length; i++)
					document.getElementById("contactosSeleccionados").options[document.getElementById("contactosSeleccionados").options.length] = new Option(window.opener.document.getElementById("contactos").options[i].text,window.opener.document.getElementById("contactos").options[i].value);
			}		
		}
		function seleccionaContactos() {
			abreVentanaContactos("../busqueda/busquedaPorNombreSeleccion.jsp", "winPopup");
		}
		function addOption(texto, valor)
		{
		  var theSel = document.getElementById('contactos');
		  var newOpt = new Option(texto, valor);
		  var selLength = theSel.length;
		  theSel.options[selLength] = newOpt;
		}
		
	/*TERMINA OBSERVACIONES*/
	/*INICIA BUSQUEDA*/

	function busquedaEventosRegistrados() {
		var innerHTML="";
                innerHTML = "<br /><br /><font class='cuerponegrobold'><center>EVENTOS REGISTRADOS</center></font><br />"
                          + "<table border='0' align='center' class='style1' width='800'>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>FECHA INICIAL&nbsp;</div></td>"
                          + "			<td width='412' align='center'>"
                          + "				<div align='left'>"
                          + "					<input name='fecha01' type='text' class='campo02' maxlength='12' size='12' onchange=\"buscarEventosRegistrados();\" readonly='true' />"
                          + "                                   <a onclick='calendario(\"../librerias/calendario.jsp?fecha=4\",\"winPopup\"); ' style='cursor:hand'><img src='../imagenes/seleccioneFecha.jpg' border='0' title='Abrir Calendario'></a>"
                          + "				</div>"
                          + "			</td>"
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td class='cuerpogrisbold' align='center'> <div align='right'>FECHA FINAL&nbsp;</div></td>"
                          + "			<td align='center'>"
                          + "				<div align='left'>"
                          + "					<input name='fecha02' type='text' class='campo02' maxlength='12' size='12' onchange=\"buscarEventosRegistrados();\" readonly='true' />" 
                          + "					<a onclick='calendario(\"../librerias/calendario.jsp?fecha=5\",\"winPopup\"); ' style='cursor:hand'><img src='../imagenes/seleccioneFecha.jpg' border='0' title='Abrir Calendario'></a>"
                          + "				</div>"
                          + "			</td>"									  
                          + "		</tr>" 
                          + "</table>"
		document.getElementById("idParametroBusqueda").innerHTML = innerHTML;
		document.getElementById("idParametroBusqueda").style.display = "inline";
	}

        function comparaFechasInicialFinal(fecha, fechaInicial, fechaFinal) { 
            var diaInicial = "", diaFinal = "";
            var mesInicial ="", mesFinal = "";
            var anioInicial = "", anioFinal = "";

            if(fechaInicial!="" && fechaFinal!="") {
                //Solo si estan las dos fechas se hara la validacion
                diaInicial = fechaInicial.substring(0,2);
                mesInicial = fechaInicial.substring(3,5);
                anioInicial = fechaInicial.substring(6,10);

                diaFinal = fechaFinal.substring(0,2);
                mesFinal = fechaFinal.substring(3,5);
                anioFinal = fechaFinal.substring(6,10);

                var fechaIni = new Date(anioInicial,mesInicial-1,diaInicial,23,59);
                var fechaFin = new Date(anioFinal,mesFinal-1,diaFinal,23,59);

                if(fechaIni > fechaFin) {
                	if(fecha!=3 && fecha!=4)
	                    alert("La Fecha Inicial no puede ser mayor a la Fecha Final");
	                else    
	                    alert("Fecha Invalida. Por favor verifique el traslape de fechas.");
                    fechaRegresa = "";
                }
                else {
                    if(fecha==1) fechaRegresa = fechaInicial;
                    else fechaRegresa = fechaFinal;
                }
            }
            else {
                if(fecha==1) fechaRegresa = fechaInicial;
                    else fechaRegresa = fechaFinal;
            }

            return(fechaRegresa);
	}

        function buscarEventosRegistrados() {
            var d = document.form1;
			d.pagina.value="1";
			d.ordenacion.value="1";
            if(d.fecha01.value!=""||d.fecha02.value!="") {
                ajax(Number(d.opcionAjaxDefault.value));
            }            
        }

        /*function reiniciaEventosRegistrados() {
		document.getElementById("idNuevoTipoEvento").style.display="none";
		document.getElementById("idBotonNuevoTipoEvento").style.display="inline";	
	}*/

        function asignaMetodoOrdenacionEventosRegistrados(opcion) {
			var d = document.form1;
				d.pagina.value='1';
				d.ordenacion.value=opcion;
				ajax(Number(d.opcionAjaxDefault.value));
		}

	    function asignaPaginaEventosRegistrados(pagina) {
			var d = document.form1;
				d.pagina.value=pagina;
				ajax(Number(d.opcionAjaxDefault.value));
		}
        function asignaMetodoOrdenacionRutas(opcion) {
			var d = document.form1;
			d.pagina.value='1';
			d.ordenacion.value=opcion;
			buscarRegistrosRutas();
		}
		function asignaPaginaRutas(pagina){
			var d = document.form1;
			d.pagina.value=pagina;
			buscarRegistrosRutas();
		}
		/*TERMINA BUSQUEDA*/
		/*INICIO EVENTO*/
		function registroNuevoEventoDesdeEvento() {
			ajax(6);
		}	
		function verificaRepetible() {
	    	document.getElementById("repetible").value="";
	    	document.getElementById("repite").checked=false;
	        document.getElementById("divRepetible").style.display = "none";
			document.getElementById("divRepetibleComplementario").style.display="none";			
			ajax(7);
		}
		function validaRepetible() {
		var d = document.form1;
			if(d.repite.checked)
				document.getElementById("divRepetibleComplementario").style.display="inline";			
			else	
				document.getElementById("divRepetibleComplementario").style.display="none";			
		}			
		
		function formaVistaPreeliminar(valor) {
      	var meses=new Array(12);
	      meses[0]= "ENE"; meses[1]= "FEB"; meses[2]= "MAR"; meses[3]= "ABR"; meses[4]= "MAY"; meses[5]= "JUN"; meses[6]= "JUL";
	      meses[7]= "AGO"; meses[8]= "SEP"; meses[9]= "OCT"; meses[10]= "NOV"; meses[11]= "DIC";
		var innerHTML="";
		var i=0;
		var d;
		var cantidadDias = 1;
		var almacenaCantidadDias="";

		if(valor == "1")	d = window.opener.document.form1;
		else				d = document.form1;

		if(d.cantidadDias.value != "") cantidadDias = Number(d.cantidadDias.value);
		
			if(d.cveTipoRepeticion.value != "0" && d.fechaEventoRepeticionInicial.value!="" && ((validaRadiobutton(d.tipoRegistroEvento)=="1" && d.cantidadVeces.value!="")  || (validaRadiobutton(d.tipoRegistroEvento)=="2" && d.fechaEventoRepeticion.value!="")	) && cantidadDias>0 ) {
			
			    var diaInicial = "", diaFinal = "";
            	var mesInicial ="", mesFinal = "";
            	var anioInicial = "", anioFinal = "";
                diaInicial = (d.fechaEventoRepeticionInicial.value).substring(0,2);
                mesInicial = (d.fechaEventoRepeticionInicial.value).substring(3,5);
                anioInicial = (d.fechaEventoRepeticionInicial.value).substring(6,10);

                var fechaIni = new Date(anioInicial,mesInicial-1,diaInicial);
			
                innerHTML = "<br /><br /><font class='cuerponegrobold'><center>DIAS A REGISTRAR</center></font><br />"
                          + "<table border='0' align='center' class='style1' width='400'>";

				var fechaValidacion;
				var validacion;
				var otroFactor=0;
				if(validaRadiobutton(d.tipoRegistroEvento)=="1") { //por cantidad de dias
					for(i=0; i<(Number(d.cantidadVeces.value)+otroFactor);i++) {			
						
						var fechaAumenta = new Date(fechaIni.getTime() + i*cantidadDias*24*60*60*1000);	
						
						validacion = new Date(fechaAumenta.getFullYear(), fechaAumenta.getMonth()-1, fechaAumenta.getDate(),0,0);
		
						if(i>0 && validacion.getTime() == fechaValidacion.getTime()) {
							otroFactor++;
						} else {
							fechaValidacion =  new Date(fechaAumenta.getFullYear(), fechaAumenta.getMonth(), fechaAumenta.getDate(),0,0);
		                	innerHTML = innerHTML + "<tr><td class='cuerpogrisbold' align='center'>"+(fechaAumenta.getDate()+"/"+meses[fechaAumenta.getMonth()]+"/"+fechaAumenta.getFullYear())+"</td></tr>";
		                	if(fechaAumenta.getDate()<10)
			                	almacenaCantidadDias = almacenaCantidadDias + "0"+fechaAumenta.getDate()+"/";
			                else	
			                	almacenaCantidadDias = almacenaCantidadDias + fechaAumenta.getDate()+"/";
		                	if((fechaAumenta.getMonth()+1)<10)
			                	almacenaCantidadDias = almacenaCantidadDias + "0"+(fechaAumenta.getMonth()+1)+"/";
			                else	
			                	almacenaCantidadDias = almacenaCantidadDias + (fechaAumenta.getMonth()+1)+"/";
		                	almacenaCantidadDias = almacenaCantidadDias + fechaAumenta.getFullYear()+"|";
		                }	
	                }	
				}
				if(validaRadiobutton(d.tipoRegistroEvento)=="2") { //por fecha final
			            diaFinal = (d.fechaEventoRepeticion.value).substring(0,2);
			            mesFinal = (d.fechaEventoRepeticion.value).substring(3,5);
			            anioFinal = (d.fechaEventoRepeticion.value).substring(6,10);
			            var fechaFin = new Date(anioFinal,mesFinal-1,diaFinal,0,0);
		                var fechaAumenta = new Date(anioInicial,mesInicial-1,diaInicial);
						var i=0;
					while(fechaAumenta<=fechaFin) {			

						validacion = new Date(fechaAumenta.getFullYear(), fechaAumenta.getMonth(), fechaAumenta.getDate(),0,0);
						if(i == 0 || validacion.getTime() != fechaValidacion.getTime()) {
							fechaValidacion =  new Date(fechaAumenta.getFullYear(), fechaAumenta.getMonth(), fechaAumenta.getDate(),0,0);

		                	innerHTML = innerHTML + "<tr><td class='cuerpogrisbold' align='center'>"+(fechaAumenta.getDate()+"/"+meses[fechaAumenta.getMonth()]+"/"+fechaAumenta.getFullYear())+"</td></tr>";
		                	if(fechaAumenta.getDate()<10)
			                	almacenaCantidadDias = almacenaCantidadDias + "0"+fechaAumenta.getDate()+"/";
			                else	
			                	almacenaCantidadDias = almacenaCantidadDias + fechaAumenta.getDate()+"/";
		                	if((fechaAumenta.getMonth()+1)<10)
			                	almacenaCantidadDias = almacenaCantidadDias + "0"+(fechaAumenta.getMonth()+1)+"/";
			                else	
			                	almacenaCantidadDias = almacenaCantidadDias + (fechaAumenta.getMonth()+1)+"/";
		                	almacenaCantidadDias = almacenaCantidadDias + fechaAumenta.getFullYear()+"|";
						}		
						fechaAumenta = new Date(fechaAumenta.getTime() + cantidadDias*24*60*60*1000);						
						i++;                	
	                }	
				}
				
                innerHTML = innerHTML + "</table>";
                d.almacenaCantidadDias.value=almacenaCantidadDias;
//                alert(d.almacenaCantidadDias.value);
            }              
            
		if(valor == "1") {
			window.opener.document.getElementById("divVistaPreeliminar").innerHTML = innerHTML;
			window.opener.document.getElementById("divVistaPreeliminar").style.display = "inline";
		} else {
			document.getElementById("divVistaPreeliminar").innerHTML = innerHTML;
			document.getElementById("divVistaPreeliminar").style.display = "inline";
		}			
	}
	function verificaCambioTipoRepeticion() {
		ajax(8);
	}
	function asignaContactosPipas() {
		var enviaValores="";
		for(i=0;i<document.getElementById("contactos").options.length; i++)
			enviaValores = enviaValores + document.getElementById("contactos").options[i].value+"*"+document.getElementById("contactos").options[i].text+"|";
		return enviaValores;	
	}
	function consultaEventoRegistrado(evento) {
		var d = document.form1;
		d.cveEventoEspecial.value=evento;
		ajax(10);
	}
	function almacenaActualizaEventoDesdeEvento() {
		var d = document.form1;
		if(d.cveTipoEvento.value=="0") {
			alert("Debe seleccionar tipo de evento");
			return("");
		}
		if(d.descripcion.value=="") {
			alert("Debe introducir descripcion del evento");
			return("");
		}
		if(d.fechaEvento.value=="") {
			alert("Debe seleccionar fecha del evento");
			return("");
		}
		ajax(11);
	}
		/*TERMINA EVENTO*/
		/*INICIA INDEX*/
	function cargaImagenes(){
		MM_preloadImages('imagenes/menu/encabezadoContactosBold.jpg','imagenes/menu/encabezadoEventosBold.jpg','imagenes/menu/encabezadoClasificacionBold.jpg','imagenes/menu/encabezadousuariosBold.jpg','imagenes/menu/encabezadoBuscarBold.jpg','imagenes/menu/encabezadoSalirBold.jpg','imagenes/menu/encabezadoUsuariosBold.jpg','imagenes/menu/encabezadoAgendaBold.jpg', 'imagenes/menu/encabezadoCatalogoBold.jpg', 'imagenes/menu/encabezadoHerramientasBold.jpg', 'imagenes/menu/encabezadoAgendaCelebracionesBold.jpg', 'imagenes/menu/opcionClasificacionAgendaBold.jpg','imagenes/menu/encabezadoAlbumBold.jpg');
	}
	function parametroIndex(usuario, tipoContrasena){
		var innerHTML="";
		if(usuario=="") { //debe solicitar usuario y contrasena
                innerHTML = "<table border='0' align='center' class='style1' width='800' bgcolor='#FFFFFF'cellpadding='0' cellspacing='0'> "
                	      + "  <tr> "
                    	  + "   <td align='center'> "
                    	  + "   	<img name='encabezado_r1_c1' src='imagenes/menu/encabezado_r1_c1.jpg' height='134' border='0' id='encabezado_r1_c1' alt='' />"
                    	  + " 		<font class='cuerpogris'>POR FAVOR INTRODUZCA SU USUARIO Y CONTRASENA</font> "
                    	  + " 	</td> "
	                      + "  </tr> "
                	  	  + "  <tr><td align='center'><br />	"
                	  	  + "	<table border='0' align='center' class='style1'> "
                          + "		<tr>"
                          + "			<td align='center' class='cuerpogrisbold'> <div align='right'>USUARIO</div></td>"
						  + "			<td> "
						  + "				<input name='cveUsuario' type='text' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' tabindex='1' /> "
						  + "			</td> "
			 			  + "			<td align='center' rowspan='2'> "
			 			  + "				<input name='registrar' type='button' class='boton02' value='BUSCAR' "
			 			  + "				onclick='verificaUsuarioContrasena();' tabindex='3'/> "
			 			  + "			</td> "
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td align='center' class='cuerpogrisbold'> <div align='right'>CONTRASENA</div></td>"
						  + "			<td> "
						  + "				<input name='contrasena' type='password' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' tabindex='2'/> "
						  + "			</td> "
                          + "		</tr>"
						  + "		<tr> "
                          + "			<td align='center' class='cuerpogrisbold' colspan='3'><a href='javascript:irA(\"usuario/solicitaContrasena.jsp\")' class='enlaces' tabindex='4'>SI OLVIDÓ SU CONTRASEÑA SOLICITELA AQUÍ</a></td>"
			 			  + "		</tr> "
                          + " 	</table>"
                          + "</td></tr></table>";
		} else {//debe traer menu
			if(tipoContrasena!=3)
				cambioContrasenaRequerido();
			else	
				muestraMenu();
		}
		document.getElementById("idParametroIndex").innerHTML = innerHTML;
		document.getElementById("idParametroIndex").style.display = "inline";
		if(usuario=="")document.form1.cveUsuario.focus();		
	}
	function solicitaContrasena(){
		ajax('10');
	}
	function cambioContrasenaRequerido() {
		irAConfiguracionMenu('usuario/cambioContrasena.jsp','principal');
		irAConfiguracionMenu('blanco.jsp','inicio');
	}
	function cambioContrasenaRequeridoFormato(){
		var d = document.form1;
		var innerHTML="";
                innerHTML = "<br /><br /><font class='cuerpogris'><center>EL SISTEMA HA DETECTADO QUE SU CONTRASENA HA SIDO ASIGNADA AUTOMATICAMENTE. <br /> POR FAVOR INTRODUZCA LA NUEVA CONTRASENA.</center></font><br /><br />"
                          + "<table border='0' align='center' class='style1' width='800'>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>USUARIO</div></td>"
						  + "			<td> "
						  + "				<input name='cveUsuario' type='text' class='campo02' maxlength='20' readonly='readonly'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' value='"+d.cveUsuarioAux.value+"' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>CONTRASENA ANTERIOR</div></td>"
						  + "			<td> "
						  + "				<input name='contrasena' type='password' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' value='"+d.contrasenaAux.value+"' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>CONTRASENA NUEVA</div></td>"
						  + "			<td> "
						  + "				<input name='contrasenaNueva' type='password' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>CONFIRMACION DE CONTRASENA NUEVA</div></td>"
						  + "			<td> "
						  + "				<input name='contrasenaNuevaConfirmacion' type='password' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
						  + "	<tr> "
			 			  + "		<td align='center' colspan='2'> "
			 			  + "			<br /> "
			 			  + "			<input name='cancelar' type='button' class='boton02' value='CANCELAR' "
			 			  + "			onclick='salirSistemaUsuarios();'/> "
						  + "			&nbsp; "
			 			  + "			<input name='registrar' type='button' class='boton02' value='GUARDAR DATOS' "
			 			  + "			onclick='verificaCambioContrasenaUsuarioContrasena();'/> "
			 			  + "		</td> "
			 			  + "	</tr> "
                          + "</table>"
			
		document.getElementById("idParametroIndex").innerHTML = innerHTML;
		document.getElementById("idParametroIndex").style.display = "inline";
	}
	function cambioContrasenaFormato(){
		var d = document.form1;
		var innerHTML="";
                innerHTML = "<br /><br /><font class='cuerpogris'><center>CAMBIO DE CONTRASEÑA</center></font><br /><br />"
                          + "<table border='0' align='center' class='style1' width='800'>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>USUARIO</div></td>"
						  + "			<td> "
						  + "				<input name='cveUsuario' type='text' class='campo02' maxlength='20' readonly='readonly'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' value='"+d.cveUsuarioAux.value+"' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>CONTRASENA ANTERIOR</div></td>"
						  + "			<td> "
						  + "				<input name='contrasena' type='password' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' value='"+d.contrasenaAux.value+"' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>CONTRASENA NUEVA</div></td>"
						  + "			<td> "
						  + "				<input name='contrasenaNueva' type='password' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
                          + "		<tr>"
                          + "			<td width='378' align='center' class='cuerpogrisbold'> <div align='right'>CONFIRMACION DE CONTRASENA NUEVA</div></td>"
						  + "			<td> "
						  + "				<input name='contrasenaNuevaConfirmacion' type='password' class='campo02' maxlength='20'  "
						  + "				onkeypress='if(!letraynum(event.keyCode)) event.returnValue=false;' "
						  + "				style='text-transform:uppercase' onchange='this.value=mayuscula(this.value);' /> "
						  + "			</td> "
                          + "		</tr>"
						  + "	<tr> "
			 			  + "		<td align='center' colspan='2'> "
			 			  + "			<br /> "
			 			  + "			<input name='cancelar' type='button' class='boton02' value='CANCELAR' "
			 			  + "			onclick='irA(\"../blanco.jsp\");'/> "
						  + "			&nbsp; "
			 			  + "			<input name='registrar' type='button' class='boton02' value='GUARDAR DATOS' "
			 			  + "			onclick='verificaCambioContrasenaUsuarioContrasena();'/> "
			 			  + "		</td> "
			 			  + "	</tr> "
                          + "</table>"
			
		document.getElementById("idParametroIndex").innerHTML = innerHTML;
		document.getElementById("idParametroIndex").style.display = "inline";
	}
	function verificaUsuarioContrasena() {
		var d = document.form1;
		if(d.cveUsuario.value=="") {
			alert("Debe introducir Usuario");
			return("");
		}
		if(d.contrasena.value=="") {
			alert("Debe introducir Contrasena");
			return("");
		}
		ajax(1);
	}
	function salirSistema() {
		ajax(4);
	}
	function salirSistemaUsuarios() {
		ajax(11);
	}
	function verificaCambioContrasenaUsuarioContrasena() {
		var d = document.form1;
		if(d.cveUsuario.value=="") {
			alert("Debe introducir Usuario");
			return("");
		}
		if(d.contrasena.value=="") {
			alert("Debe introducir Contrasena");
			return("");
		}
		if(d.contrasenaNueva.value=="") {
			alert("Debe introducir Contrasena Nueva");
			return("");
		}
		if(d.contrasenaNuevaConfirmacion.value=="") {
			alert("Debe introducir Confirmacion de Contrasena Nueva");
			return("");
		}
		if(d.contrasenaNueva.value=="") {
			alert("Debe introducir Contrasena Nueva");
			return("");
		}
		if(d.contrasenaNueva.value!=d.contrasenaNuevaConfirmacion.value) {
			alert("Contrasena Nueva y Confirmacion de Contrasena Nueva No Coinciden");
			return("");
		}
		ajax(6);
	}
	function muestraMenu(){
		ajax(3);
	}
	function muestraMenuConfiguracion(){
		irAConfiguracionMenu('inicio.jsp','inicio');
		irAConfiguracionMenu('blanco.jsp','principal');
	}
	function muestraMenuConfiguracionUsuarios(){
		irAConfiguracionMenu('../inicio.jsp','inicio');
		irAConfiguracionMenu('../blanco.jsp','principal');
	}
	
		/*TERMINA INDEX*/
		/*INICIA CLASIFICACION MASIVA*/
	function verFoto(cveFuncionario) {
		abreVentanaContactos("../registro/verFoto.jsp?cveFuncionario="+cveFuncionario, "winPopup");
	}
	function agregarFoto(cveFuncionario) {
		abreVentanaContactos("../registro/verFoto.jsp?cveFuncionario="+cveFuncionario+"&opcion=1", "winPopup");
	}
	function eliminarFoto(cveFuncionario) {
		if(confirm("¿Esta usted seguro de eliminar la Foto (S/N)?")) {
			var d = document.form1;
			d.cveFuncionario.valule = cveFuncionario;
			ajax(22);
		}	
	}
	function traeFotoFuncionario(opcion){
		if(opcion=="1") //agregarFoto
		{
			var innerHTML="";
                innerHTML = "<br /><br /><font class='cuerpogris'><center>AGREGAR FOTO</center></font><br /><br />"
                          + "<table border='0' align='center' class='style1' width='100%'>"
                          + "		<tr>"
                          + "			<td width='100%' align='center' class='cuerpogrisbold'> UBICACION DEL ARCHIVO "
						  + "					<input type='file' name='archivo' class='campo01' /> "
						  + "			</td> "
                          + "		</tr>"
						  + "	<tr> "
			 			  + "		<td align='center' colspan='2'> "
			 			  + "			<br /> "
			 			  + "			<input name='cancelar' type='button' class='boton02' value='CERRAR' "
			 			  + "			onclick='window.close();'/> "
						  + "			&nbsp; "
			 			  + "			<input name='registrar' type='button' class='boton02' value='GUARDAR INFORMACION' "
			 			  + "			onclick='verificaNombreArchivo();'/> "
			 			  + "		</td> "
			 			  + "	</tr> "
                          + "</table>";
//			alert(innerHTML);
			document.getElementById("idNuevaFoto").innerHTML = innerHTML;
			document.getElementById("idNuevaFoto").style.display = "inline";
		}else {
			document.getElementById("idNuevaFoto").innerHTML = "";
			document.getElementById("idNuevaFoto").style.display = "none";
			ajax(20);
		}	
	}
	function actualizaNivelRelacion(cveFuncionario, cveNivelRelacion) {
		var d = document.form1;
		var nivelRelacion = document.getElementById(cveNivelRelacion).options[document.getElementById(cveNivelRelacion).options.selectedIndex].value;
		d.cveRegistroEspecial.value = cveFuncionario;
		d.txtClave.value = nivelRelacion;
		ajax(21);
	}
	
	function verificaNombreArchivo(){
		var d = document.form2;
		var d1 = document.form1;
		var nombre = d.archivo.value;
	      var extensionesPermitidas=new Array();
	      extensionesPermitidas[0]= "bmp"; extensionesPermitidas[1]= "jpg"; extensionesPermitidas[2]= "gif"; 
		if(nombre == "") {
			alert("Debe indicar el archivo a cargar");
			return("");
		}
		if(nombre.lastIndexOf(".") == -1) {
			alert("Archivo a Cargar Invalido.");
			return("");
		}
		var extension=nombre.substring(nombre.lastIndexOf(".")+1);
		extension = extension.toLowerCase();
		
		if(extension == "") {
			alert("Archivo a Cargar Invalido.");
			return("");
		}
		var extensionValida="0";
		var i=0;
		var extensionesPermitidasCadena="";
		for(i=0;i<extensionesPermitidas.length;i++){
			extensionesPermitidasCadena = extensionesPermitidasCadena + " " + extensionesPermitidas[i];
			if(extension == extensionesPermitidas[i])
				extensionValida="1";
		}		
				
		if(extensionValida == "0") {
			alert("Extension Invalida ("+extension+"). Las Extensiones Permitidas son: "+extensionesPermitidasCadena);
			return("");
		}
		d.action = d.action + "?cveFuncionario="+d1.cveFuncionario.value;
		d.submit();
		
	}
		/*TERMINA CLASIFICACION MASIVA*/
		
			/*INICIA FORMATO MENU*/
		function MM_findObj(n, d) { //v4.01
		  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		  if(!x && d.getElementById) x=d.getElementById(n); return x;
		}
		function MM_swapImage() { //v3.0
		  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}
		function MM_swapImgRestore() { //v3.0
		  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}
		
		function MM_preloadImages() { //v3.0
		  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}
		function muestraDiv(div) {
			document.getElementById(div).style.display = 'inline';
		}
		function ocultaTodosDiv() {
			document.getElementById("divCatalogo").style.display='none';			
			document.getElementById("divHerramientas").style.display='none';			
			document.getElementById("divAgenda").style.display='none';			
			document.getElementById("divAgendaCelebraciones").style.display='none';						
		}

	/*TERMINA FORMATO MENU*/
	/*INICIA CALENDARIO*/	
	function inicioBusquedaEventosPorMes(){
		busquedaEventosPorMes(1);
	}
	function inicioBusquedaEventosPorMesPrivado(){
		busquedaEventosPorMes(4);
	}
	function inicioBusquedaEventosPorMesPublicoPrivado(){
		busquedaEventosPorMes(6);
	}
	function busquedaEventosPorMes(opcion){
		ajax(opcion);
	}
	function inicioBusquedaEventosPorDia(){
		busquedaEventosPorDia(3);
	}
	function inicioBusquedaEventosPorDiaPrivado(){
		busquedaEventosPorDia(5);
	}
	function inicioBusquedaEventosPorDiaPublicoPrivado(){
		busquedaEventosPorDia(7);
	}
	function busquedaEventosPorDia(opcion){
		ajax(opcion);
	}
	/*AGENDA*/
	function inicioBusquedaEventosAgendaPorMes(){
		busquedaEventosPorMes(8);
	}
	function inicioBusquedaEventosAgendaPorMesPrivado(){
		busquedaEventosPorMes(10);
	}
	function inicioBusquedaEventosAgendaPorMesPublicoPrivado(){
		busquedaEventosPorMes(12);
	}
	function inicioBusquedaEventosAgendaPorDia(){
		busquedaEventosPorDia(9);
	}
	function inicioBusquedaEventosAgendaPorDiaPrivado(){
		busquedaEventosPorDia(11);
	}
	function inicioBusquedaEventosAgendaPorDiaPublicoPrivado(){
		busquedaEventosPorDia(13);
	}
	function inicioBusquedaEventosAgendaPorDiaPublico(){	
		busquedaEventosPorDia(14);
	}	
	
	function verDia(dia, mes, anio, opcion){
		var d = document.form1;
		if(opcion==1)//publicos
			d.action="eventoCalendarioDia.jsp?dia="+dia+"&mes="+mes+"&anio="+anio;
		if(opcion==4)//privados
			d.action="eventoCalendarioDiaPrivado.jsp?dia="+dia+"&mes="+mes+"&anio="+anio;
		if(opcion==6)//privados / publicos
			d.action="eventoCalendarioDiaPublicoPrivado.jsp?dia="+dia+"&mes="+mes+"&anio="+anio;			
		if(opcion==8)//agenda publicos
			d.action="eventoCalendarioDiaAgenda.jsp?dia="+dia+"&mes="+mes+"&anio="+anio;
		if(opcion==10)//agenda privados
			d.action="eventoCalendarioDiaAgendaPrivado.jsp?dia="+dia+"&mes="+mes+"&anio="+anio;
		if(opcion==12)//agenda privados / publicos
			d.action="eventoCalendarioDiaAgendaPublicoPrivado.jsp?dia="+dia+"&mes="+mes+"&anio="+anio;			
			
		d.submit();
	}
	function asignaNuevaFechaDia(dia, mes, anio, opcion){
		var d = document.form1;
		d.dia.value=dia;
		d.mes.value=mes;
		d.anio.value=anio;
		busquedaEventosPorDia(opcion);
	}
	function asignaNuevaFecha(mes, anio, opcion){
		var d = document.form1;
		d.mes.value=mes;
		d.anio.value=anio;
		busquedaEventosPorMes(opcion);
	}
	function nuevoEventoDia(dia, mes, anio){
		var d = document.form1;		
		var fecha="";
		if(dia != "" && mes != "" && anio != "") {
			if(dia<10)	fecha=fecha+"0"+dia;
			else		fecha=fecha+""+dia;
			if(mes<10)	fecha=fecha+"/0"+mes;
			else		fecha=fecha+"/"+mes;
			fecha=fecha+"/"+anio;		
			d.action="../evento/evento.jsp?opcion=1&fechaTentativa="+fecha;
		} else
			d.action="../evento/evento.jsp?opcion=1";
		
		d.submit();
	}
	function consultaEventoDesdeCalendario(evento){ 
		var d = document.form1;		
		d.action="evento.jsp?opcion=2&evento="+evento;
		d.submit();
	}
	function inicioPaletaColores(opcionPaleta){
		var d=document.form1;
		d.opcionPaleta.value = opcionPaleta;
		ajax(2);
	}
	function validaValorAnio(){
		var d = document.form1;	
		if(isNaN(Number(d.anio.value))) {
			alert("Anio Invalido. El valor debe ser numérico.");
			d.anio.value="";
			d.anio.focus();
			return("");
		}
		if(Number(d.anio.value)<1900) {
			alert("Anio Invalido. Debe ser mayor de 1900.");
			d.anio.value="";
			d.anio.focus();
			return("");
		}
	}
	function buscarFechaCalendario(){
		var d = document.form1;	
		d.submit();
	}	
	/*TERMINA CALENDARIO*/
	/*PRUEBAS*/
	function validaCamposFormaEnvioCorreosPrueba(){
		var d = document.form1;	
		if(d.destinatarios.value=="") {
			alert("Debe introducir Destinatarios");
			return("");
		}
		if(d.asunto.value=="") {
			alert("Debe introducir Asunto");
			return("");
		}
		if(d.mensaje.value=="") {
			alert("Debe introducir mensaje");
			return("");
		}
		d.submit();		
	}
	/*PRUEBAS*/
	/*INICIA OPINION*/
	function inicioOpinion(){
		ajax(1);
	}
	function almacenaNuevoOpinion(){
		var d = document.form1;	
		if(d.nombre.value=="") {
			alert("Por favor, Introduzca su Nombre.");
			return("");
		}
		if(d.correo.value=="") {
			alert("Por favor, Introduzca su Direcion de Correo.");
			return("");
		}
		if(d.calle.value=="") {
			alert("Por favor, Introduzca su Domicilio (Calle y Numero).");
			return("");
		}
		if(d.cveEstado.value=="0") {
			alert("Por favor, Seleccione Estado.");
			return("");
		}
		if(d.cveMunicipio.value=="0") {
			alert("Por favor, Seleccione Municipio.");
			return("");
		}
		if(d.asunto.value=="") {
			alert("Por favor, Introduzca Asunto del Mensaje.");
			return("");
		}
		if(d.mensaje.value=="") {
			alert("Por favor, Introduzca su Mensaje.");
			return("");
		}
		ajax(3);	
	}
	function mensajeAgradecimiento(){
		var cadena="";
		cadena = "<center>"+
				 "<br/>Su información ha sido enviada satisfactoriamente."+
				 "<br/>Gracias."+
				 "<br/>"+
				 "</center>"; 
		return cadena;
	}
	function limpiarValoresContactoCiudadano(){
		var d = document.form1;	
		d.nombre.value="";
		d.correo.value="";
		d.calle.value="";
		d.colonia.value="";
		d.delegacion.value="";
		d.codigoPostal.value="";
		d.asunto.value="";
		d.mensaje.value="";
		asignaSelect(d.cveEstado,"2");
		buscaMunicipio('2');
	}
	/*TERMINA OPINION*/