// JavaScript Document
var ventanaEncuesta = null;
function abrirEncuesta(){
if(ventanaEncuesta == null || ventanaEncuesta.closed){
ventanaEncuesta=window.open("http://www.sip.gob.mx/encuesta/index.php?id=154","Encuesta","width=510,height=695,menubar=no,toolbar=no,resizable=no,scrollbars=yes,status=yes");
}else{
 ventanaEncuesta.focus();
}
}

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 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_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 ValidarBusqueda(){
  if(document.getElementById("palabra").value!="")
  return true;
  else{
	  alert("Debes de especificar la palabra de busqueda");
	  return false;
	  }
}

function quitar(){
pal=document.getElementById("palabra").value;
 if(pal=='palabra')
  document.getElementById("palabra").value="";
 else
 document.getElementById("palabra").value="palabra";
 
}


function boletin()
{
  var valor=document.formboletin.email.value;
  var name=document.formboletin.name.value;
  
  if(name==""){
    alert("Ingrese su nombre");
	document.formboletin.name.focus();
    return false;
  }else{
	    	 var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ. " + "abcdefghijklmnñopqrstuvwxyz. " + "áéíóú";
  var checkStr = name;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Por favor escribe solo letras en el campo Nombre"); 
    //name.focus(); 
	document.formboletin.name.focus();
    document.formboletin.name.value=""; 
    return false; 
  } 
	  
	  }
  
 var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
 if (filter.test(valor)){
    return true;
 }else{
    alert("Ingrese una dirección de correo válida");
	
    document.formboletin.email.value="";
    document.formboletin.email.focus();
    return false;
  
  }
  
}



function $(id){
   return document.getElementById(id);
}

function validar(){
	
  
  //var er_tlfono = /[0123456789-()\s]/;
  //var er_email = /^(.+\@.+\..+)$/;
  //var er_empresa = /[A-Za-zñÑ\s.]/;
  
  var sel = false;
	for(var i=0; i<3; i++) {
		if (form1.queja[i].checked) {
			sel = true;
  		    break;
		}
	}
	
	if (sel == false) {
	   $('errorradios').style.display='block';
	   return false;
		
	}
	
  if($('name').value.length==0){
     $('errorname').style.display='block';
     return false;
  }else{
	     
		
		 var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ. " + "abcdefghijklmnñopqrstuvwxyz. " + "áéíóú";
  var checkStr = $('name').value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Por favor escribe solo letras en el campo Nombre"); 
    $('name').focus(); 
    $('name').value=""; 
    return false; 
  } 
	  
	  }
	
  
   if($('email').value.length==0){
     $('erroremail').style.display='block';
     return false;
  }else{
	    var valor=$('email').value;
	    var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
        if(filter.test(valor)){
          // alert("Your e-mail is correct");
	       //return (true);
	    }else{
               alert("Por favor escribe un email valido");
	           $('email').focus(); 
               $('email').value=""; 
               return false;
             }
			// return false;
       }
	
  
  if($('empresa').value.length==0){
     $('errorempresa').style.display='block';
     return false;
  }else{
	   var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ. " + "abcdefghijklmnñopqrstuvwxyz. " + "áéíóú";
  var checkStr = $('empresa').value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Por favor escribe solo letras en el campo Empresa"); 
    $('empresa').focus(); 
    $('empresa').value=""; 
    return false; 
  } 
	    }
  
  if($('telefono').value.length==0){
     $('errorphone').style.display='block';
     return false;
  }else{
	  
	   var checkOK = "0123456789-()"; 
   var checkStr =$('telefono').value; 
  var allValid = true; 
  var decPoints = 0; 
  var allNum = ""; 
  for (i = 0; i < checkStr.length; i++) { 
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++) 
      if (ch == checkOK.charAt(j))
        break; 
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    } 
    allNum += ch; 
  } 
  if (!allValid) { 
    alert("Por favor escribe solo digitos y -  en el campo Teléfono ");
    $('telefono').value="";
	$('telefono').focus();
    return (false); 
  } 
	  }
  
  if($('fecha').value.length==0){
     $('errorfecha').style.display='block';
     return false;
  }
  
  if((form1.queja[1].checked) && (form1.queja[1].value=='Quejas')){
  
    if($('desqueja').value.length==0){
     $('errordesqueja').style.display='block';
     return false;
    }else{
	   var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ., " + "abcdefghijklmnñopqrstuvwxyz. " + "áéíóú";
  var checkStr = $('desqueja').value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Por favor escribe solo letras en el campo Queja"); 
    $('desqueja').focus(); 
    $('desqueja').value=""; 
    return false; 
  } 
	    }
	
	
	if($('desocurrio').value.length==0){
     $('errordesocurrio').style.display='block';
     return false;
    }else{
	   var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ., " + "abcdefghijklmnñopqrstuvwxyz. " + "áéíóú";
  var checkStr = $('desocurrio').value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Por favor escribe solo letras en el campo Donde Ocurrio"); 
    $('desocurrio').focus(); 
    $('desocurrio').value=""; 
    return false; 
  } 
	    }
    
	if($('desmotivo').value.length==0){
     $('errordesmotivo').style.display='block';
     return false;
    }else{
	   var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ., " + "abcdefghijklmnñopqrstuvwxyz. " + "áéíóú";
  var checkStr = $('desmotivo').value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Por favor escribe solo letras en el campo Que motivo la queja"); 
    $('desmotivo').focus(); 
    $('desmotivo').value=""; 
    return false; 
  } 
	    }
 
 }  
  
  if((form1.queja[0].checked) && (form1.queja[0].value=='Comentarios')){
  
    if($('descomentarios').value.length==0){
     $('errordescomentarios').style.display='block';
     return false;
    }else{
	   var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ., " + "abcdefghijklmnñopqrstuvwxyz. " + "áéíóú";
  var checkStr = $('descomentarios').value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Por favor escribe solo letras en el campo Comentarios"); 
    $('descomentarios').focus(); 
    $('descomentarios').value=""; 
    return false; 
  } 
	    }
  }
  
  if((form1.queja[2].checked) && (form1.queja[2].value=='Sugerencias')){
   
    if($('desugerencias').value.length==0){
     $('errordesugerencias').style.display='block';
     return false;
    }else{
	          var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ. " + "abcdefghijklmnñopqrstuvwxyz., " + "áéíóú";
              var checkStr = $('desugerencias').value;
              var allValid = true; 
              for (i = 0; i < checkStr.length; i++) {
                 ch = checkStr.charAt(i); 
                 for (j = 0; j < checkOK.length; j++)
                  if (ch == checkOK.charAt(j))
                   break;
                   if (j == checkOK.length) { 
                     allValid = false; 
                     break; 
                   }
              }
              
			  if (!allValid) { 
               alert("Por favor escribe solo letras en el campo Sugerencias"); 
               $('desugerencias').focus(); 
               $('desugerencias').value=""; 
               return false; 
              } 
	    }
  }
  
  
}


function habilitar(form1){

 if(form1=='comentarios'){
   document.form1.descomentarios.disabled=false;
   document.form1.descomentarios.className="sinfondo";
   document.form1.desugerencias.disabled=true;
   document.form1.desugerencias.className="fondo";
   document.form1.desqueja.disabled=true;
   document.form1.desqueja.className="fondo";
   document.form1.desocurrio.disabled=true;
   document.form1.desocurrio.className="fondo";
   document.form1.desmotivo.disabled=true;
   document.form1.desmotivo.className="fondo";
   document.form1.desugerencias.value="";
   document.form1.desqueja.value="";
   document.form1.desocurrio.value="";
   document.form1.desmotivo.value="";
 
 }
 if(form1=='sugerencias'){
   document.form1.desugerencias.disabled=false;
   document.form1.desugerencias.className="sinfondo";
    document.form1.desqueja.disabled=true;
   document.form1.desqueja.className="fondo";
   document.form1.desocurrio.disabled=true;
   document.form1.desocurrio.className="fondo";
   document.form1.desmotivo.disabled=true;
   document.form1.desmotivo.className="fondo";
  document.form1.descomentarios.disabled=true;
   document.form1.descomentarios.className="fondo";
     document.form1.desugerencias.value="";
   document.form1.desqueja.value="";
   document.form1.desocurrio.value="";
   document.form1.desmotivo.value="";
   document.form1.descomentarios.value="";
   
   
 }
 if(form1=='quejas'){
   document.form1.desqueja.disabled=false;
   document.form1.desqueja.className="sinfondo";
   document.form1.desocurrio.disabled=false;
   document.form1.desocurrio.className="sinfondo";
   document.form1.desmotivo.disabled=false;
   document.form1.desmotivo.className="sinfondo";
   document.form1.desugerencias.disabled=true;
   document.form1.desugerencias.className="fondo";
   document.form1.descomentarios.disabled=true;
   document.form1.descomentarios.className="fondo";
   document.form1.descomentarios.value="";
   document.form1.desugerencias.value="";
   
   
 }
}


var ventanaEncuesta = null;

function abrirEncuesta()
{
  if(ventanaEncuesta == null || ventanaEncuesta.closed)
  {
    ventanaEncuesta = window.open("http://www.sip.gob.mx/encuesta/index.php?id=104",
   "Encuesta", "width=510,height=695,menubar=no,toolbar=no,resizable=no,scrollbars=yes,status=yes"); //Sustituir la direccion Web por la correspondiente a tu dependencia.
  }
  else
  {
    ventanaEncuesta.focus();
  };
}

function esString(id,name){
	
	alert(id + name);
  var band;
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ " + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = $(id).value;
  var allValid = true;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  if (!allValid) {
    alert("Escriba sólo letras en el campo" + name +".");
    $(id).focus();
	band=false;
   return band;    
  } 
  

}


/*function ValidarCampos() {
	var emailRegEx = /^((\w|\.){2,}@)\w{3,}\.\w{2,4}((\.(\w{2}))?)?$/
	var numericoRegEx = /^\d*$/
	var esTelefono = /^((\d{1,2}-)(?!\d{10}))?\d{3}(\d{3})?\d{2}\d{2}(-(Ext|ext)\d{1,4})?$/
	var esString = /[a-z]/gi
   
   if($('name').value== "") {
		$('name').focus();
		mostrar("errorname","El campo 'Nombre' es obligatorio!");
		return false;
	}else{
		    var band;
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ " + "abcdefghijklmnñopqrstuvwxyzáéíóú " +".";
  var checkStr = $("name").value;
  var allValid = true;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  if (!allValid) {
    mostrar("errorname","Escriba sólo letras en el campo Nombre.");
    $("name").focus();
	return false;
  }
  
  $("errorname").style.display='none';
  
		 }
		 
	
	 if($('ocupacion').value== "") {
		$('ocupacion').focus();
		mostrar("errorocupacion","El campo 'Ocupacion' es obligatorio!");
		return false;
	}else{
		   var band;
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ " + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = $("ocupacion").value;
  var allValid = true;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  if (!allValid) {
    mostrar("errorocupacion","Escriba sólo letras en el campo Ocupación.");
    $("ocupacion").focus();
	return false;
  } 
   $("errorocupacion").style.display='none';
		 }
	
	
	 if($('institucion').value== "") {
		$('institucion').focus();
		mostrar("errorinstitucion","El campo 'Institucion' es obligatorio!");
		return false;
	}else{
		   var band;
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ " + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = $("institucion").value;
  var allValid = true;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  if (!allValid) {
    mostrar("errorinstitucion","Escriba sólo letras en el campo Institución.");
    $("institucion").focus();
	return false;
  } 
    $("errorinstitucion").style.display='none';
	
  }
		 
	 if($('telof').value== "") {
		$('telof').focus();
		mostrar("errortelof","El campo 'Telefono/Fax Oficina' es obligatorio!");
		return false;
	}else{
		   var checkOK = "0123456789-()";
  var checkStr = $('telof').value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid) {
    mostrar("errortelof","Escriba sólo dígitos en el campo Teléfono.");
    $('telof').focus();
    return (false);
  } 
   $("errortelof").style.display='none';
		 }	 
	
	 if($('dom').value== "") {
		$('dom').focus();
		mostrar("errordom","El campo 'Ciudad/Domicilio' es obligatorio!");
		return false;
	}else{
		    var band;
            var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ " + "abcdefghijklmnñopqrstuvwxyzáéíóú " + "#-,." + "0123456789";
            var checkStr = $("dom").value;
            var allValid = true;
            for (i = 0; i < checkStr.length; i++) {
              ch = checkStr.charAt(i);
                for (j = 0; j < checkOK.length; j++)
                  if (ch == checkOK.charAt(j))
                    break;
                  if (j == checkOK.length) {
                    allValid = false;
                    break;
                  }
             }
  
             if (!allValid) {
                mostrar("errordom","Escriba sólo letras en el campo Ciudad/Domicilio.");
                $("dom").focus();
	            return false;
  }  
   $("errordom").style.display='none';
		 }
	
	
  if($('responsable').value== "") {
	  $('responsable').focus();
	  mostrar("erroresp","El campo Responsable es obligatorio!");
	  return false;
  }else{
		   var band;
           var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ " + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
           var checkStr = $("responsable").value;
           var allValid = true;
           for (i = 0; i < checkStr.length; i++) {
              ch = checkStr.charAt(i);
                for (j = 0; j < checkOK.length; j++)
                  if (ch == checkOK.charAt(j))
                    break;
                  if (j == checkOK.length) {
                    allValid = false;
                    break;
                  }
           }
  
           if (!allValid) {
             mostrar("erroresp","Escriba sólo letras en el campo Responsable.");
             $("responsable").focus();
	         return false;
           } 
           
		   $("erroresp").style.display='none';
       }
	
	
	
	if($('correos').value == "") {
	   $('correos').focus();
	   mostrar("errorcorreo","El campo Correo Electronico es obligatorio!");
	   return false;
	}else {
		      if(($("correos").value.indexOf ('@', 0) == -1)||($("correos").value.length < 20)) {
                 mostrar("errorcorreo","Escriba una dirección de correo válida en el campo Correo Electrónico.");
                 $("correos").focus();
			     $("correos").value="";
				 return false;
               }
			   
			   	   $("errorcorreo").style.display='none';
  		   }
	
	
	if($("correocon").value == "") {
		$("correocon").focus();
		mostrar("errorcorreoe","El campo Correo Electronico-E es obligatorio!");
		return false;
	} else {
	         if(($("correocon").value.indexOf ('@', 0) == -1)||($("correocon").value.length < 20)) {
                 mostrar("errorcorreoe","Escriba una dirección de correo válida en el campo Correo Electrónico.");
			     return false;
		     }else{
				     if($("correocon").value !== $("correos").value) {
		                $("correocon").focus();
		  	            mostrar("errorcorreoe","El campo Correo Electronico-E debe ser igual!");
		                return false;
	        	     }
					 
					 $("errorcorreoe").style.display='none';
			      } 
	       }
	
	
	 if($('novisita').value== "") {
		$('novisita').focus();
		mostrar("errornov","El campo 'No Visitantes' es obligatorio!");
		return false;
	}else{
             if(!$("novisita").value.match(numericoRegEx)) {
			   mostrar("errornov","El campo No. Visitantes sólo puede contener números.");
			   $("novisita").focus();
			   $("novisita").value = "";
			   return false;
		     }
			 
			 $("errornov").style.display='none';
	     }
	
	
	 if($('fecha').value== "") {
		$('fecha').focus();
		mostrar("errorfecha","El campo Fecha es obligatorio!");
		return false;
	}else{
		    var checkOK = "0123456789-/";
            var checkStr = $('fecha').value;
            var allValid = true;
            var decPoints = 0;
            var allNum = "";
            for (i = 0; i < checkStr.length; i++) {
              ch = checkStr.charAt(i);
                for (j = 0; j < checkOK.length; j++)
                  if (ch == checkOK.charAt(j))
                     break;
                  if (j == checkOK.length) {
                     allValid = false;
                     break;
                  }
                 allNum += ch;
            }
 
            if (!allValid) {
               mostrar("errorfecha","Escriba la fecha en formato dd/mm/yyyy.");
               $('fecha').focus();
               return false;
            } 
			
			$("errorfecha").style.display='none';
		 }
		 
		 var uword = hex_md5(document.getElementById('uword').value);
		 
		 if (uword==cword[anum-1]) {
               return true;}
         else{
		 	  mostrar("Erroruword","Ingrese el texto exactamente como aparece abajo");
			  $("uword").focus();
			  return false;
		}else{ }
	
	return true;
}
 
function mostrar(id,error) {
	document.getElementById(id).innerHTML = '<strong>'+error+'</strong>';
	document.getElementById(id).style.background = "#E3EAEE";
	document.getElementById(id).style.color = "brown";
	
}*/