var patron1 = new Array(2,2,4)
var patron2 = new Array(2,2)
var patron3 = new Array(3,7)
var patron4 = new Array(4,2,2)
var aFinMes = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); 
var strCaller="";

function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}

function Validar_solicitud(){
	error = false;
	cimail = document.form1.email.value;
	cipasa1 = cimail.indexOf('@');
	cipasa2 = cimail.indexOf('.');
	if(cipasa1<1 || cipasa2<1 || cimail.length < 10) error=true;	
	if(document.form1.nombre.value=='' || document.form1.paterno.value==''|| document.form1.materno.value=='')error=true;	
	if(document.form1.calle.value=='' || document.form1.numero.value==''|| document.form1.localidad.value==''|| document.form1.telefono.value=='')error=true;	
	if(document.form1.motivo.value=='' || document.form1.planteamiento.value=='')error=true;	
	if(error){ document.getElementById('textoError').innerHTML="Su Solicitud no ha sido enviada <br/>debido a que tiene que llenar los campos marcados con *"}
	else {
		document.form1.action="send.php";
		document.form1.submit();
	}
}

function imprimir(){
	window.print();
}

function verificar_busqueda(){
	if(document.getElementById('m_buscar').checked==true){
		document.getElementById('folio').disabled=false;
		document.getElementById('folio').focus();
		document.getElementById('nombre').disabled=true;
		document.getElementById('paterno').disabled=true;
		document.getElementById('materno').disabled=true;
		document.getElementById('nombre').value="";
		document.getElementById('paterno').value="";
		document.getElementById('materno').value="";
	}
	else{
		document.getElementById('folio').disabled=true;
		document.getElementById('folio').value="";		
		document.getElementById('nombre').disabled=false;
		document.getElementById('paterno').disabled=false;
		document.getElementById('materno').disabled=false;
		document.getElementById('nombre').focus();
	}
}

function Validar_rss(){
	error = false;
	cimail = document.form1.email.value;
	cipasa1 = cimail.indexOf('@');
	cipasa2 = cimail.indexOf('.');
	if(cipasa1<1 || cipasa2<1 || cimail.length < 10) error=true;		
	if(error){ document.getElementById('textoError').innerHTML="Su e-Mail no es valido"}
	else {
		document.form1.action="rss.php?type=registrar";
		document.form1.submit();
	}
}

function validar_busqueda(){
	error=false;
	texto='Error';
	
	if(document.getElementById('m_buscar').checked==true){
		if(document.getElementById('folio').value==''){
			error=true;
			texto="Inserte el numero de folio"
			document.getElementById('folio').focus();
			document.getElementById('m_buscar').checked=true;
		}
	}
	else{
		if(document.getElementById('nombre').value==''||document.getElementById('materno').value==''||document.getElementById('paterno').value==''){
			error=true;
			texto="Inserte su nombre y sus apellidos"
			document.getElementById('nombre').focus();
		}		
	}
	if(error){ document.getElementById('textoError').innerHTML=texto;}
	else {
		document.form1.action="resultadossolicitud.php";
		document.form1.submit();
	}
}

function Validar_opina(){
	error = false;
	cimail = document.form1.email.value;
	cipasa1 = cimail.indexOf('@');
	cipasa2 = cimail.indexOf('.');
	if(cipasa1<1 || cipasa2<1 || cimail.length < 10) error=true;	
	if(document.form1.nombre.value=='' || document.form1.localidad.value==''|| document.form1.opina.value=='')error=true;	
	
	
	if(error){ document.getElementById('textoError').innerHTML="Su opini&oacute;n no ha sido enviada <br/>debido a que tiene que llenar los campos marcados con *"}
	else {
		document.form1.action="send2.php";
		document.form1.submit();
	}
}

function cursor_mano(){
	document.body.style.cursor = "pointer";
}

function cursor_flecha(){
	document.body.style.cursor = "default";
}

function slide1(){
	document.getElementById('history').style.display='block';
	document.getElementById('presidenta').style.display='none';
	document.getElementById('bienestar').style.display='none';
}

function slide2(){
	document.getElementById('history').style.display='none';
	document.getElementById('presidenta').style.display='block';
	document.getElementById('bienestar').style.display='none';
}

function slide3(){
	document.getElementById('history').style.display='none';
	document.getElementById('presidenta').style.display='none';
	document.getElementById('bienestar').style.display='block';
}

function ir_a(num){
	pagina="#";
	switch (num){
		case 1:
			pagina="bienvenida.html"
			break;
		case 2:
			pagina="historia.html"
			break;
		case 5:
			pagina="plan.html"
			break;
		case 4:
			pagina="localizar.html"
			break;
		case 6:
			pagina="directorio.html"
			break;
		case 7:
			pagina="organigrama.html"
			break;
		case 8:
			pagina="noticias.php"
			break;
		case 9:
			pagina="rss.php"
			break;
		case 10:
			pagina="ley.html"
			break;
		case 11:
			pagina="constitucion.html"
			break;
		case 12:
			pagina="constitucion2.html"
			break;
		case 15:
			pagina="transparencia.html"
			break;
		case 16:
			pagina="estadosolicitud.html"
			break;
		case 25:
			pagina="opinion.html"
			break;
		case 26:
			pagina="ciudadano.php"
			break;
		case 27:
			pagina="bolsatrabajo.php"
			break;
		case 28:
			pagina="empresas.php"
			break;
		case 29:
			pagina="registrousuario.php"
			break;
		case 30:
			pagina="index.php?video=no"
			break;
		case 31:
			pagina="bando.html"
			break;
		case 32:
			pagina="establecimiento.html"
			break;
	}
	window.location=pagina	
}