//***********************************//
// Desarrollada por Angel Soto       //
// angels0t0@hotmail.com             //
// Fecha:  17/06/2004                //
//***********************************//

function chequea() {

  if (isBlanco(document.fm_contact.nombres.value)) {
     alert("Debes ingresar tus nombres.");
     window.document.fm_contact.nombres.focus();
     return false;
  }
  if (isBlanco(document.fm_contact.apellidos.value)) {
     alert("Debes ingresar tus apellidos.");
     window.document.fm_contact.apellidos.focus();
     return false;
  }
    if (isBlanco(document.fm_contact.pais.value)) {
     alert("Debes seleccionar tu pais.");
     window.document.fm_contact.pais.focus();
     return false;
	}
	
  //if (isBlanco(document.fm_contact.comuna.value)) {
  //   alert("Debes seleccionar tu comuna.");
  //   window.document.fm_contact.comuna.focus();
  //   return false;
  //}
  if (!isValidEmail(document.fm_contact.email.value)) {
     alert("\"" + document.fm_contact.email.value + "\" no es un e-mail valido!");
     window.document.fm_contact.email.focus();
     return false;
  }
  if (!isNumber(document.fm_contact.codigo_area.value)) {
     alert("El código de área del teléfono ingresado no es valido, ingrese solo números.");
     window.document.fm_contact.codigo_area.focus();
     return false;
  }
  if (!isNumber(document.fm_contact.telefono.value)) {
     alert("El número de teléfono ingresado no es valido, ingrese solo números.");
     window.document.fm_contact.telefono.focus();
     return false;
  }
  if (isBlanco(document.fm_contact.asunto.value)) {
     alert("Debes seleccionar un asunto.");
     window.document.fm_contact.asunto.focus();
     return false;
  }
  
  if (!isBlanco(document.fm_contact.flag_upload.value)) {	// Si existe campo para subir archivo
     var campo_file = document.fm_contact.file;
	 var ext = campo_file.value.substring((campo_file.value.length - 3), campo_file.value.length);
	 if (ext != "doc" && ext != "pdf") {
		 alert("El documento debe ser Word o PDF.");
		 campo_file.focus();
		 return false;
	 }
  }
  if (isBlanco(document.fm_contact.mensaje.value)) {
     alert("Debes ingresar el mensaje.");
     window.document.fm_contact.mensaje.focus();
     return false;
  }
  xajax_botonEnviar();
  document.fm_contact.submit();
  xajax_botonEnviar();
}


function chequea_mail() {
  if (!isValidEmail(document.fm_buscar.email.value)) {
     alert("\"" + document.fm_buscar.email.value + "\" no es un e-mail valido!");
     window.document.fm_buscar.email.focus();
     return false;
  }	
  document.fm_buscar.submit();
}

//********************************************************************************

function vermes() {
  mes = document.fm_contact.mes.options[document.fm_contact.mes.selectedIndex].value;
  dia = document.fm_contact.dia.options[document.fm_contact.dia.selectedIndex].value;
  anio = document.fm_contact.anio.options[document.fm_contact.anio.selectedIndex].value;
  if ((mes==2) && (esbisiesto(anio)) &&(dia>29)) document.fm_contact.dia.selectedIndex=29;
  if ((mes==2) && (!esbisiesto(anio)) && (dia>28)) document.fm_contact.dia.selectedIndex=28;
  if (((mes==4) || (mes==6) || (mes==9) || (mes==11)) && (dia>30)) document.fm_contact.dia.selectedIndex=30;
}

//********************************************************************************

function mostrarComunas(idr) {
  document.fm_contact.action = self.location.href;
  document.fm_contact.submit();
}

//********************************************************************************

function chequeaRegion() {
  if (document.fm_contact.region.options[document.fm_contact.region.selectedIndex].value == 0) {
     alert("Debes seleccionar primero tu Región.");
  }
}

