function centrar()
{
    iz=(screen.width-document.body.clientWidth) / 2;
    de=(screen.height-document.body.clientHeight) / 2;
    moveTo(iz,de);
}

function Clasifcalen()
 {
  if (document.forma1.cla_titulo.value == "")
   {
    missinginfo = 'No ha ingresado el "Titulo del clasificado"';
    document.forma1.cla_titulo.focus();
	alert(missinginfo);
	return false;
   }
  else
   {
    if (document.forma1.nom_contacto.value == "")
     {
      missinginfo = 'No ha ingresado el "Nombre de Contacto"';
      document.forma1.nom_contacto.focus();
	  alert(missinginfo);
	  return false;
     }
    else
	 {
      if (document.forma1.tel_contacto.value == "")
       {
        missinginfo = 'No ha ingresado el "Teléfono de Contacto"';
        alert(missinginfo);
	    document.forma1.tel_contacto.focus();
	    return false;
       }
      else
	   {
		  if ((document.forma1.cla_email.value.indexOf('@') == -1) || (document.forma1.cla_email.value.indexOf('.') == -1))
		   {
            missinginfo = "Rectifique el E-Mail";
            alert(missinginfo);
	        document.forma1.cla_email.focus();
	       return false;
		 }
        else
		 {
		  if (document.forma1.cla_ciudad.value == 0)
          {
           missinginfo = 'Seleccione una  "Ciudad"';
           alert(missinginfo);
	       document.forma1.cla_ciudad.focus();
	       return false;
          }
         else
		  {
           if (document.forma1.cla_categoria.value == 0)
            {
             missinginfo = 'Seleccione una "Categoría/Subcategoría"';
             alert(missinginfo);
	         document.forma1.cla_categoria.focus();
	         return false;
            }
           else
			{
  		     if (document.forma1.tipo.value == 0)
              {
               missinginfo = 'Seleccione el "Tipo de Clasificado"';
               alert(missinginfo);
	           document.forma1.tipo.focus();
	           return false;
              }
             else
			  {
			  	if (document.forma1.dias.value == 0)
                 {
                  missinginfo = 'Seleccione "Dias de Disponibilidad"';
                  alert(missinginfo);
	              document.forma1.dias.focus();
	              return false;
                }
               else
				{
                  var max12=336;
				  var tam12=document.forma1.cla_texto.value.length;
				  tam1=tam12-max12;
				  if (tam12 > max12)
				   {
				    alert("Por favor reduzca la descipcion "+tam1+" caracter(es)");
	                document.forma1.cla_texto.focus();
	                return false;
                   }
				}
			  }
			}
		  }

		 }
	   }
	 }
   }
 }

function ventana1 ()
{
 opener.location.href='olvido_password.php';
 window.close();
 return false;
}
function ventana2 ()
{
 opener.location.href='registro.php';
 window.close();
 return false;
}

function ventana3 ()
{
 opener.location.href='cam_pass_datos.php';
 window.close();
 return false;
}
function ventana2 ()
{
 opener.location.href='registro.php';
 window.close();
 return false;
}

function registro()
 {
  missinginfo = "";
  if (document.frm.nombre.value == "")
   {
    missinginfo = 'No ha ingresado el "Nombre"';
    alert(missinginfo);
    document.frm.nombre.focus();
    return false;
   }
  else
   {
    if (document.frm.apellido.value == "")
	 {
      missinginfo = 'No ha ingresado el "Apellido"';
      alert(missinginfo);
      document.frm.apellido.focus();
	  return false;
     }
    else
     {
      if (document.frm.docum1.value == "")
       {
        missinginfo = 'No ha ingresado el "Documento de Identidad"';
        alert(missinginfo);
        document.frm.docum1.focus();
        return false;
       }
      else
       {
        if (document.frm.direccion.value == "")
         {
          missinginfo = 'No ha ingresado la "Direccion"';
          alert(missinginfo);
          document.frm.direccion.focus();
          return false;
         }
        else
         {
          if (document.frm.telefono.value == "")
           {
            missinginfo = 'No ha ingresado la "Telefono"';
            alert(missinginfo);
            document.frm.telefono.focus();
            return false;
           }
          else
           {
            if ((document.frm.mail.value == "")|| (document.frm.mail.value.indexOf('@') == -1) || (document.frm.mail.value.indexOf('.') == -1) )
	         {
              missinginfo = "Rectifique el E-Mail";
              alert(missinginfo);
	          document.frm.mail.focus();
	          return false;
             }
	        else
	    	 {
		      if (document.frm.tipo.value == 0)
               {
                missinginfo = 'No ha seleccionado "Tipo de Afiliado"';
                alert(missinginfo);
                document.frm.tipo.focus();
	            return false;
               }
              else
			   return true;
			 }
	        }
     	   }
	      }
	     }
       }
 }

function checkFields()
 {
  missinginfo = "";
  if (document.frm.Usuar1.value == "")
   {
    missinginfo += "No ha ingresado  USUARIO";
    alert(missinginfo);
   }
 if(document.frm.Pass.value == "")
  {
   missinginfo = "No ha ingresado PASSWORD";
   alert(missinginfo);
  }
 if (missinginfo != "")
  {
   return false;
  }
 else return true;
}

function credito()
 {
  missinginfo = "";
  if (document.frm.Monto.value == "")
   {
    missinginfo += 'No ha ingresado el Monto del Credito';
    document.frm.Monto.focus();
	alert(missinginfo);
    return false;
   }
  else
   {
   	if (document.frm.Plazo.value == "")
     {
      missinginfo += 'No ha ingresado el Plazo';
      document.frm.Plazo.focus();
	  alert(missinginfo);
      return false;
     }
	else
     return true;
   }
}

function actualizar()
 {
  missinginfo = "";
  if (document.frm.nombre.value == "")
   {
    missinginfo = 'No ha ingresado el "Nombre"';
    alert(missinginfo);
    document.frm.nombre.focus();
	return false;
   }
  else
   {
   	if (document.frm.apellido.value == "")
     {
      missinginfo = 'No ha ingresado el "Apellido"';
      alert(missinginfo);
      document.frm.apellido.focus();
	  return false;
     }
	else
	 {
	  if (document.frm.docum1.value == "")
       {
        missinginfo = 'No ha ingresado el "Documento de Identidad"';
        alert(missinginfo);
        document.frm.docum1.focus();
	    return false;
       }
	  else
       {
        if (document.frm.direccion.value == "")
         {
          missinginfo = 'No ha ingresado la "Direccion"';
          alert(missinginfo);
          document.frm.direccion.focus();
	      return false;
         }
	    else
         {
          if (document.frm.telefono.value == "")
           {
            missinginfo = 'No ha ingresado la "Telefono"';
           alert(missinginfo);
           document.frm.telefono.focus();
	        return false;
          }
         else
		  {
           if ((document.frm.mail.value == "")|| (document.frm.mail.value.indexOf('@') == -1) || (document.frm.mail.value.indexOf('.') == -1) )
		    {
             missinginfo = "Rectifique el E-Mail";
             alert(missinginfo);
	         document.frm.mail.focus();
	         return false;
            }
	      else
	       return true;
		  }

     	 }
	   }
	 }
   }
}

function esDigito(sChr){
    var sCod = sChr.charCodeAt(0);
    return ((sCod > 47) && (sCod < 58));
   }

   function valSep(oTxt){
    var bOk = false;
    bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
    bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
    return bOk;
   }

   function finMes(oTxt){
    var nMes = parseInt(oTxt.value.substr(3, 2), 10);
    var nAno = parseInt(oTxt.value.substr(6), 10);
    var nRes = 0;
    switch (nMes){
     case 1: nRes = 31; break;
     case 2: nRes = 28; break;
     case 3: nRes = 31; break;
     case 4: nRes = 30; break;
     case 5: nRes = 31; break;
     case 6: nRes = 30; break;
     case 7: nRes = 31; break;
     case 8: nRes = 31; break;
     case 9: nRes = 30; break;
     case 10: nRes = 31; break;
     case 11: nRes = 30; break;
     case 12: nRes = 31; break;
    }
    return nRes + (((nMes == 2) && (nAno % 4) == 0)? 1: 0);
   }

   function valDia(oTxt){
    var bOk = false;
    var nDia = parseInt(oTxt.value.substr(0, 2), 10);
    bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
    return bOk;
   }

   function valMes(oTxt){
    var bOk = false;
    var nMes = parseInt(oTxt.value.substr(3, 2), 10);
    bOk = bOk || ((nMes >= 1) && (nMes <= 12));
    return bOk;
   }

   function valAno(oTxt){
    var bOk = true;
    var nAno = oTxt.value.substr(6);
    bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
    if (bOk){
     for (var i = 0; i < nAno.length; i++){
      bOk = bOk && esDigito(nAno.charAt(i));
     }
    }
    return bOk;
   }

   function valFecha(oTxt){
    var bOk = true;
    if (oTxt.value != ""){
     bOk = bOk && (valAno(oTxt));
     bOk = bOk && (valMes(oTxt));
     bOk = bOk && (valDia(oTxt));
     bOk = bOk && (valSep(oTxt));
     return bOk;
    }
   }

   function fechaMayorOIgualQue(fec0, fec1){
    var bRes = false;
    var sDia0 = fec0.value.substr(0, 2);
    var sMes0 = fec0.value.substr(3, 2);
    var sAno0 = fec0.value.substr(6, 4);
    var sDia1 = fec1.value.substr(0, 2);
    var sMes1 = fec1.value.substr(3, 2);
    var sAno1 = fec1.value.substr(6, 4);
    if (sAno0 > sAno1) bRes = true;
    else {
     if (sAno0 == sAno1){
      if (sMes0 > sMes1) bRes = true;
      else {
       if (sMes0 == sMes1)
        if (sDia0 >= sDia1) bRes = true;
      }
     }
    }
    return bRes;
   }

function reservas()
 {
  missinginfo = "";
  if ((document.fcalen.acomod1.value == 0))
   {
    missinginfo += 'No ha seleccionado acomodacion';
    alert(missinginfo);
    return false;
   }
  else
   {
    if (document.fcalen.Valor.value == "")
     {
       missinginfo += 'No ha ingresado el "Valor de la Reserva"';
       document.fcalen.Valor.focus();
       alert(missinginfo);
       return false;
     }
    else
     {
      if (document.fcalen.Pago.value == 0)
       {
        missinginfo += 'Seleccione una "Forma de Pago"';
        document.fcalen.Pago.focus();
        alert(missinginfo);
        return false;
       }
	  else
       {
	   	var bRes = false;
   	    if (valFecha(document.fcalen.fecha1))
	     {
          if (valFecha(document.fcalen.fecha2))
	       {
             if (fechaMayorOIgualQue(document.fcalen.fecha2, document.fcalen.fecha1))
		     {
              return true;
             }
		  else
		   {
            alert("Rango inválido");
            document.fcalen.fecha1.focus();
			return false;
           }
         }
		else
		 {
          alert("Fecha inválida");
          document.fcalen.fecha2.focus();
          return false;
         }
		}
	   else
	    {
         alert("Fecha inválida");
         document.fcalen.fecha1.focus();
         return false;
        }
	   }
	 }
	}
  }
  
function actualiza()
 {
  missinginfo = "";
  if (document.forma1.apellido.value == "")
   {
    missinginfo += 'No ha ingresado el Apellido';
    document.forma1.apellido.focus();
	alert(missinginfo);
    return false;
   }
  else
   {
   	if (document.forma1.nombre.value == "")
     {
      missinginfo += 'No ha ingresado Nombre';
      document.forma1.nombre.focus();
	  alert(missinginfo);
      return false;
     }
	else
     {
      if (document.forma1.docum.value == "")
       {
        missinginfo += 'No ha ingresado Numero de Documento';
        document.forma1.docum.focus();
	    alert(missinginfo);
        return false;
       }
	  else
       return true;
    }
   }
 }
 
 function olvido()
 {
  missinginfo = "";
  if (document.frm.docu.value == "")
   {
    missinginfo += 'No ha ingresado el Documento';
    document.frm.docu.focus();
	alert(missinginfo);
    return false;
   }
  else
   {
   	if (document.frm.nombre.value == "")
     {
      missinginfo += 'No ha ingresado su Nombre';
      document.frm.nombre.focus();
	  alert(missinginfo);
      return false;
     }
	else
     {
     if ((document.frm.mail.value == "")|| (document.frm.mail.value.indexOf('@') == -1) || (document.frm.mail.value.indexOf('.') == -1) )
      {
        missinginfo += 'Requitifique su E-Mail';
        document.frm.mail.focus();
	    alert(missinginfo);
        return false;
       }
	  else
       return true;
	 }
   }
}

function mesaje ()
 {
  document.fcalen1.submit();
  window.open('mensaje_res.php','Estado','scrollbars=no,width=300,height=110');
  
 }

 function cambio()
 {
  missinginfo = "";
  if (document.frm.docu.value == "")
   {
    missinginfo += 'No ha ingresado el Documento';
    document.frm.docu.focus();
	alert(missinginfo);
    return false;
   }
  else
   {
   	if (document.frm.passAc.value == "")
     {
      missinginfo += 'No ha ingresado su Contraseña';
      document.frm.passAc.focus();
	  alert(missinginfo);
      return false;
     }
	else
     {
     if ((document.frm.passnu.value == "") )
      {
        missinginfo += 'No ha ingresado la nueva Contraseña';
        document.frm.passnu.focus();
	    alert(missinginfo);
        return false;
       }
	  else
       {
        if ((document.frm.passnuc.value == "") )
         {
          missinginfo += 'No ha ingresado la confirmacion de la Contraseña';
          document.frm.passnuc.focus();
	      alert(missinginfo);
          return false;
         }
	    else
         {
          if ((document.frm.passnuc.value != document.frm.passnu.value) )
           {
            missinginfo += 'No coinciden las Contraseñas';
            document.frm.passnu.focus();
	        alert(missinginfo);
            return false;
           }
	    else
         return true;
		 }
        }
	 }
   }
}


