function borrarDatos() {
	var frm_elements = document.forms["AltaFormAction"].elements;
	for(i=0; i < frm_elements.length; i++) {
		if (frm_elements[i].type) {
			var field_type = frm_elements[i].type.toLowerCase(); 
			if(field_type == 'text' || field_type == 'password' || field_type == 'textarea')
				frm_elements[i].value = "";
		}
	}
}
function borrarCookie() {
	$.ajax({
		type: "GET",
		url: "/ajax/borrarCookie.cfm",
		cache: false,
		success: function(data, textStatus) {
			window.location.hash="precontactar";
			$("input[name='nombre'], input[name='tel']").val("");
			window.location.reload();
		},
		error: function(xmlRequest, error) { }
	});
}
function mostrarPaises() {
	$("#pais_inicial").hide();
	$("#paises").show();
}
function actualizarPaises(actual) {
	$.ajax({
		type: "GET",
		url: "/ajax/actualizarPaises.cfm",
		cache: false,
		dataType: "html",
		success: function(response) {
			$("select[name='cmbPais']").html(response.substring(0,response.search(/;/))).val(actual);
			actualizarProvincias();
		}
	});
}
function actualizarProvincias() {
	$.ajax({
		type: "GET",
		url: "/ajax/actualizarProvincias.cfm",
		cache: false,
		dataType: "html",
		data: "pais_codigo=" + $("select[name='cmbPais']").val(),
		success: function(data, textStatus) { $("#cmbProvincia").html(data.substring(0,data.search(/;/)));},
		error: function(xmlRequest, error) { }
	});
}
function verificarMail() {
	$("input[name='email']").val(($("input[name='email']").val()).toLowerCase());
	var email = ($("input[name='email']").val()).toLowerCase();
	if ((email.length != 0) && (validarMail(email))) {
		$.ajax({
			type: "GET",
			url: "/ajax/verificarMail.cfm",
			cache: false,
			dataType: "html",
			data: "Email="+ $("input[name='email']").val(),
			success: function(response) {actualizarMail(response.substring(0,response.search(/;/)));},
			error: function(xmlRequest, error) { }
		});
	}
}
function actualizarMail(response) {
	var res = $.trim(response);
	if (res=='1') {
		$("input[name='validardatos']").val("0");
		$("#datos_ocultables").hide();
		$("#clave").show();
		$("textarea[name='comentarios']").focus();
		
	}
	else {
		$("input[name='validardatos']").val("1");
		$("#clave").hide();
		$("#datos_ocultables").show();
		$("input[name='nombre']").focus();
	}
}
var imgWeb = getApplicationVar("imagenesWeb");
$("#checkbox").toggle(
	function() {
		this.src = imgWeb+"/checkbox_off.gif";
		$("#form_contacto input[type='checkbox']").attr("checked", "");
	},
	function() {
		this.src = imgWeb+"/checkbox_on.gif";
		$("#form_contacto input[type='checkbox']").attr("checked", "checked");
	}
);
$("#ayuda").hover(
	function(e) {
		$("#tooltip").css({left: e.pageX + 15, top: e.pageY + 15}).show();
	},
	function(e) {
		$("#tooltip").hide();	
	}
);
$("textarea[name='comentarios']").val("");