// JavaScript Document

function retroceder1() {window.onmousedown = history.go(-1);}

/**************************************************************************************/

function validarDisponibilidad()
{
	var form = window.document.forms[0];
	if (form.idtipo.value == "")
	{
		alert("Seleccione un tipo");
		form.idtipo.focus();
		return (false);
	}
	if (form.idmunicipio.value == "")
	{
		alert("Seleccione un municipio");
		form.idmunicipio.focus();
		return (false);
	}
	if (form.fechaaux1.value == "")
	{
		alert("Seleccione una fecha de entrada");
		form.fechaaux1.focus();
		return (false);
	}
	if (form.fechaaux2.value == "")
	{
		alert("Seleccione una fecha de salida");
		form.fechaaux2.focus();
		return (false);
	}

return (true);
} 

/*******************************************************************************************************/

	function checkUncheckAllPueblos(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm.idmunicipio1.checked = theElement.checked;
	  theForm.idmunicipio2.checked = theElement.checked;
	  theForm.idmunicipio3.checked = theElement.checked;
	  theForm.idmunicipio4.checked = theElement.checked;
	  theForm.idmunicipio5.checked = theElement.checked;
	  theForm.idmunicipio6.checked = theElement.checked;
	  theForm.idmunicipio7.checked = theElement.checked;
	  theForm.idmunicipio8.checked = theElement.checked;
	  theForm.idmunicipio9.checked = theElement.checked;
	  theForm.idmunicipio10.checked = theElement.checked;
	  theForm.idmunicipio11.checked = theElement.checked;
	  theForm.idmunicipio12.checked = theElement.checked;
	  
	  }
     }
    }

/**************************************************************************************/

	function checkUncheckAllTipos(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm.idtipo1.checked = theElement.checked;
	  theForm.idtipo3.checked = theElement.checked;
	  theForm.idtipo4.checked = theElement.checked;
	  theForm.idtipo5.checked = theElement.checked;
	  theForm.idtipo8.checked = theElement.checked;
	  theForm.idtipo9.checked = theElement.checked;
	  theForm.idtipo12.checked = theElement.checked;
	  
	  }
     }
    }

/**************************************************************************************/

	function checkUncheckAllTipos2(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm.idtipo1.checked = theElement.checked;
	  theForm.idtipo3.checked = theElement.checked;
	  theForm.idtipo4.checked = theElement.checked;
	  theForm.idtipo5.checked = theElement.checked;
	  theForm.idtipo8.checked = theElement.checked;
	  theForm.idtipo9.checked = theElement.checked;
	  theForm.idtipo12.checked = theElement.checked;
	  theForm.idtipo2.checked = theElement.checked;
	  theForm.idtipo13.checked = theElement.checked;
	  }
     }
    }
	
/**************************************************************************************/

	function checkUncheckAllCategorias(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm.idcategoria1.checked = theElement.checked;
	  theForm.idcategoria2.checked = theElement.checked;
	  theForm.idcategoria3.checked = theElement.checked;
	  theForm.idcategoria4.checked = theElement.checked;
	  theForm.idcategoria5.checked = theElement.checked;
	  theForm.idcategoria6.checked = theElement.checked;
	  theForm.idcategoria7.checked = theElement.checked;
	  theForm.idcategoria8.checked = theElement.checked;
	  theForm.idcategoria9.checked = theElement.checked;
	  theForm.idcategoria10.checked = theElement.checked;
	  theForm.idcategoria11.checked = theElement.checked;
	  }
     }
    }
	
/**************************************************************************************/
	
	function checkUncheckIdmunicipio(theElement) {
 var theForm = theElement.form, z = 0,i=0;
 for(z=0; z<theForm.length;z++){
  if(theForm[z].type == 'checkbox' && theForm[z].id =='idmunicipio'){
  theForm.idmunicipio[i].checked = theElement.checked;
  i=i+1;
  
  }
 }
}

/**************************************************************************************/
	
	function checkUncheckIdtipo(theElement) {
 var theForm = theElement.form, z = 0,i=0;
 for(z=0; z<theForm.length;z++){
  if(theForm[z].type == 'checkbox' && theForm[z].id =='idtipo'){
  theForm.idtipo[i].checked = theElement.checked;
  i=i+1;
  
  }
 }
}

/*******************************************************************************************************/

function validarBusqueda(theForm)
{
// sección de municipio //	
var count = false;
var count2 = false;
var docLength = eval("document.forms[0]." + "idmunicipio" + ".length");
var docLength2 = eval("document.forms[0]." + "idtipo" + ".length");

if (typeof docLength == 'undefined')
{
	if (eval("document.forms[0]." + "idmunicipio" + ".checked"))
	{
		count = true;
	}
} else
{
   for (i = 0; i < document.forms[0].idmunicipio.length; i++)
   {
	   if (document.forms[0].idmunicipio[i].checked)
	   {
			count = true;
	   }
   }
}

	if (count ==false)
	{
	   alert ("Debe Seleccionar por lo menos un municipio");
	   return (false);
	}
	
	
// sección de tipo //	
if (typeof docLength2 == 'undefined')
{
	if (eval("document.forms[0]." + "idtipo" + ".checked"))
	{
		count2 = true;
	}
} else
{
   for (i = 0; i < document.forms[0].idtipo.length; i++)
   {
	   if (document.forms[0].idtipo[i].checked)
	   {
			count2 = true;
	   }
   }
}

	if (count2 ==false)
	{
	   alert ("Debe Seleccionar por lo menos un tipo");
	   return (false);
	}
	
return (true);
}


/*******************************************************************************************************/

function validarBusquedaR(theForm)
{
// sección de municipio //    
var count = false;          
var docLength = eval("document.forms[0]." + "idmunicipio" + ".length");   

if (typeof docLength == 'undefined')
{
    if (eval("document.forms[0]." + "idmunicipio" + ".checked"))
    {
        count = true;
    }
} else
{
   for (i = 0; i < document.forms[0].idmunicipio.length; i++)
   {
       if (document.forms[0].idmunicipio[i].checked)
       {
            count = true;
       }
   }
}

    if (count ==false)
    {
       alert ("Debe Seleccionar por lo menos un municipio");
       return (false);
    }
               
    
return (true);
}
