// 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 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(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 TelÃ©fono  !!");
			} else {
				if (cvalidos(document.forms['frmContacto'].telefono) == false) {
					alert("Verifique su nÃºmero de TelÃ©fono.");
				} else {
					if (validarEmail(document.forms['frmContacto'].email.value) == false) {
						alert("La direcciÃ³n de email es incorrecta.");
					} else {
						document.forms['frmContacto'].submit();

					}
				}
			}
		}
	}

}
