// *** DEFINO TEXTOS DE ERRORES *** //
var ErrorNombre 		= new Array();
ErrorNombre['es'] 	= "Debe ingresar el Nombre y Apellido.";
ErrorNombre['fr'] 		= "Debe ingresar el Nombre y Apellido.";
ErrorNombre['it'] 		= "Debe ingresar el Nombre y Apellido.";
ErrorNombre['pt'] 		= "Debe ingresar el Nombre y Apellido.";

var ErrorCiudad 		= new Array();
ErrorCiudad['es'] 		= "Debe ingresar la Ciudad.";
ErrorCiudad['fr'] 		= "Debe ingresar la Ciudad.";
ErrorCiudad['it'] 		= "Debe ingresar la Ciudad.";
ErrorCiudad['pt'] 		= "Debe ingresar la Ciudad.";

var ErrorPais 			= new Array();
ErrorPais['es'] 			= "Debe ingresar el País.";
ErrorPais['fr'] 			= "Debe ingresar el País.";
ErrorPais['it'] 			= "Debe ingresar el País.";
ErrorPais['pt'] 			= "Debe ingresar el País.";

var ErrorTelefono 	= new Array();
ErrorTelefono['es'] 	= "Debe ingresar el Teléfono.";
ErrorTelefono['fr'] 	= "Debe ingresar el Teléfono.";
ErrorTelefono['it'] 	= "Debe ingresar el Teléfono.";
ErrorTelefono['pt'] 	= "Debe ingresar el Teléfono.";

var ErrorEmail 		= new Array();
ErrorEmail['es'] 		= "Debe ingresar un Correo válido.";
ErrorEmail['fr'] 			= "Debe ingresar un Correo válido.";
ErrorEmail['it'] 			= "Debe ingresar un Correo válido.";
ErrorEmail['pt'] 		= "Debe ingresar un Correo válido.";

var ErrorCodSeguridad 		= new Array();
ErrorCodSeguridad['es'] 	= "Debe ingresar el código de seguridad.";
ErrorCodSeguridad['fr'] 		= "Debe ingresar el código de seguridad.";
ErrorCodSeguridad['it'] 		= "Debe ingresar el código de seguridad.";
ErrorCodSeguridad['pt'] 	= "Debe ingresar el código de seguridad.";

var ErrorCodSeguridadError 		= new Array();
ErrorCodSeguridadError['es'] 		= "El código de seguridad es incorrecto.";
ErrorCodSeguridadError['fr'] 		= "El código de seguridad es incorrecto.";
ErrorCodSeguridadError['it'] 		= "El código de seguridad es incorrecto.";
ErrorCodSeguridadError['pt'] 		= "El código de seguridad es incorrecto.";
// *** FIN DEFINO TEXTOS DE ERRORES *** //


function valiContacte(frm) {
	var Idioma = frm.idioma.value;
	
	if (frm.from_nom.value == "") {
		alert(ErrorNombre[Idioma]);
		frm.from_nom.focus();
		return false;
	}
	if (frm.ciudad.value == "") {
		alert(ErrorCiudad[Idioma]);
		frm.ciudad.focus();
		return false;
	}
	if (frm.pais.value == "") {
		alert(ErrorPais[Idioma]);
		frm.pais.focus();
		return false;
	}
	if (frm.telefono.value == "") {
		alert(ErrorTelefono[Idioma]);
		frm.telefono.focus();
		return false;
	}
	var filtro = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@+([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$/;
	if (!filtro.test(frm.from_email.value)) {
		alert(ErrorEmail[Idioma]);
		frm.from_email.focus();
		return false;
	}
	if (frm.codigo_seg_img.value == "") {
		alert(ErrorCodSeguridad[Idioma]);
		frm.codigo_seg_img.focus();
		return false;
	}
	
	VerificaCod(frm, Idioma);
	
	return false;
}

function VerificaCod(frm, Idioma) {
	var codigo_seg_img = frm.codigo_seg_img.value;
	
	EnviaGet('/cont/tools/verifica_cod.php', "codigo_seg_img="+codigo_seg_img, function () {ImprimeCod(frm, Idioma)});
}


function ImprimeCod(frm, Idioma) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var Respuesta = http_request.responseText;
			if (Respuesta == "<div>1</div>") {
					alert(ErrorCodSeguridadError[Idioma]);
					frm.codigo_seg_img.focus();
			} else {
				frm.submit();
			}
		} else {
			alert('There was a problem with the request.');
		}
	}
}


