// Funciones de la Forma Cotizacion (CotizacionFrm.php)
// Actualizacion: DVG 14feb08

function cvalidosn(campo) {
	var checkOK = "ABCDEFGHIJKLMNÃ‘OPQRSTUVWXYZ. "+"abcdefghijklmnÃ±opqrstuvwxyzáéíóúñÑ ";
	var checkStr = campo.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) {
		campo.focus();
		return (false);
	}
}


function cvalidost(campo) {
	var checkOK = "ABCDEFGHIJKLMNÃ‘OPQRSTUVWXYZ./-@ !?Â¡Â¿ "+"abcdefghijklmnÃ±opqrstuvwxyz1234567890./-@ !?Â¡Â¿ ";
	var checkStr = campo.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) {
		campo.focus();
		return (false);
	}
}

function Acentos(campo) {
	var checkOK = "ABCDEFGHIJKLMNÃ‘ÑOPQRSTUVWXYZ.´/-@ !?Â¡Â¿ ~Ñ "+"abcdefghijklmnÃ±ñopqrstuvwxyz1234567890./-@ !?Â¡Â¿´áéíóú ~ñÑÃ¡Ã©Ã*Ã³ÃºÃ±Ã¼ ";
	var checkStr = campo.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) {
		campo.focus();
		return (false);
	}
}

 function cvalidos(campo) {
	var checkOK = "-./1234567890";
	var checkStr = campo.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) {
		campo.focus();
		return (false);
	}
}

function textCounter(field, maxlimit) {
	if (field.value.length>maxlimit) {
		field.value = field.value.substring(0, maxlimit);

		alert("El area de Texto es limitada");
	}
}


function validarEmail(campo) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo)) {
		//  alert("La direcciÃ³n de email " + valor    + " es correcta.") 
		return (true);
	} else {

		return (false);
	}
}

function validarmenu(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)) {
		//  alert("La direcciÃ³n de email " + valor    + " es correcta.") 
		return (true);
	} else {

		return (false);
	}
}

function validafrmContacto() {

	if ((document.forms['frmContacto'].nombre.value == '')) {
		alert("Por Favor Inserte su Nombre  !!");
	} else {
		if (cvalidosn(document.forms['frmContacto'].nombre) == false) {
			alert("Verifique su  Nombre.");
		} else {
			if ((document.forms['frmContacto'].telefono.value == '')) {
				alert("Por Favor Inserte su Telefono  !!");
			} else {
				if (cvalidos(document.forms['frmContacto'].telefono) == false) {
					alert("Verifique su nÃºmero de Telefono.");
				} else {
					if (validarEmail(document.forms['frmContacto'].email.value) == false) {
						alert("La direccion de email es incorrecta.");
					} else {
					if ((document.forms['frmContacto'].localizacion.value == '')) {
				alert("Por Favor Inserte su Ubicacion  !!");
					} else {
				if ((document.forms['frmContacto'].empresa.value == '')) {
		alert("Por Favor Inserte el nombre de la empresa  !!");
	} else {
		if (cvalidosn(document.forms['frmContacto'].nombre) == false) {
			alert("Verifique el nombre de la Empresa.");
				} else {
				if (document.forms['frmContacto'].localizacion.selectedIndex==0){ 
       alert("Debe seleccionar una Localidad o Estado.") 
   
    } else {
				if ((document.forms['frmContacto'].comentario.value == '')) {
				alert("Por Favor Inserte su Comentario  !!");
			} else {
				if (Acentos(document.forms['frmContacto'].comentario) == false) {
					alert("Verifique su Comentario");
				} else {
					
						document.forms['frmContacto'].submit();

					}
				}
			}
			}
		}
	}
	
	}
		}
	}
}
	}
}
