/*
 * Funciones ALKLA
 *
 * Copyright (c) 2010 Alkla Estudio de Diseņo
 * http://www.alkla.es
 *
 */
 
$(document).ready(function(){
	
	// Listeners
	$("#intro-menu ul li a").bind('click', ShowIndex);
	$(".entry-menu ul li a").bind('click', ShowSingle);
	
	$("#menu ul li.cat-item a").bind('click', ClearSearch);
	$(".entry-icons a").bind('click', ClearSearch);
	$(".entry-icons a.icon-imprimir").bind('click', SinglePrint);	
	$(".entry-info a").bind('click', ClearSearch);
	
	$("#listado-dormitorios a").bind('click', order_dormitorios);
	$("#listado-plazas a").bind('click', order_plazas);
	$("#listado-superficie a").bind('click', order_superficie);
	$("#listado-precio a").bind('click', order_precio);
	
	$("#contacto-form").bind('submit', validar_contacto);
	
	$("#hipoteca-form").bind('submit', validar_hipoteca);
	
	$("#elige ul li a").bind('click', elige_search);
	$("#search-form").bind('submit', validar_search);
	$("#search_venta-form").bind('submit', validar_search_venta);
	$("#filter-form").bind('submit', validar_filter);
	$("#filter_venta-form").bind('submit', validar_filter_venta);
	$("#reserva-form").bind('submit', validar_reserva);
	$("#cita-form").bind('submit', validar_cita);
	
	
	// Intro
	$("#intro").cycle({
    	delay:  -1000,
		timeout: 4000,
		pager:  '#nav'
	});
	
	
	// Fechas
	$('#search-fecha_in').val("");
	$('#search-fecha_out').val("");
	$('#search-fecha_in').datepicker({
		minDate: 0, 
		maxDate: "+1Y",
		dateFormat: 'dd/mm/yy',
		numberOfMonths: 3,
		showButtonPanel: true,
		onSelect: function(dateText, inst) { 
			$('#search-fecha_out').datepicker('destroy');
			$('#search-fecha_out').val("");
			$('#search-fecha_out').attr("disabled", false);
			$('#search-fecha_out').datepicker({
				minDate: dateText, 
				maxDate: "+1Y",
				dateFormat: 'dd/mm/yy',
				numberOfMonths: 3,
				showButtonPanel: true
			});
		}
	});
	$('#filter-fecha_in').datepicker({
		minDate: 0, 
		maxDate: "+1Y",
		dateFormat: 'dd/mm/yy',
		numberOfMonths: 3,
		showButtonPanel: true,
		onSelect: function(dateText, inst) { 
			$('#filter-fecha_out').datepicker('destroy');
			$('#filter-fecha_out').val("");
			$('#filter-fecha_out').attr("disabled", false);
			$('#filter-fecha_out').datepicker({
				minDate: dateText, 
				maxDate: "+1Y",
				dateFormat: 'dd/mm/yy',
				numberOfMonths: 3,
				showButtonPanel: true
			});
		}
	});
	$('#filter-fecha_out').datepicker({
		minDate: $("#filter-fecha_in").val(), 
		maxDate: "+1Y",
		dateFormat: 'dd/mm/yy',
		numberOfMonths: 3,
		showButtonPanel: true
	});
	$('#reserva-fecha_in').datepicker({
		minDate: 0, 
		maxDate: "+1Y",
		dateFormat: 'dd/mm/yy',
		numberOfMonths: 3,
		showButtonPanel: true,
		beforeShowDay: DisableDays,
		onSelect: function(dateText, inst) { 
			$('#reserva-fecha_out').datepicker('destroy');
			$('#reserva-fecha_out').val("");
			$('#reserva-fecha_out').attr("disabled", false);
			$('#reserva-fecha_out').datepicker({
				minDate: dateText, 
				maxDate: "+1Y",
				dateFormat: 'dd/mm/yy',
				numberOfMonths: 3,
				showButtonPanel: true,
				beforeShowDay: DisableDays,
				onSelect: function(dateText, inst) { 
					validar_desglose();
				}
			});
		}
	});
	$('#reserva-fecha_out').datepicker({
		minDate: $("#reserva-fecha_in").val(), 
		maxDate: "+1Y",
		dateFormat: 'dd/mm/yy',
		numberOfMonths: 3,
		showButtonPanel: true,
		beforeShowDay: DisableDays
	});
	
	// Calendario
	$('#calendar-fecha').datepicker({
		minDate: 0, 
		maxDate: "+1Y",
		dateFormat: 'dd/mm/yy',
		numberOfMonths: 3,
		showButtonPanel: true,
		beforeShowDay: DisableDays,
		onSelect: function(dateText, inst) { 
			validar_desglose();
		}
	});
	
	
	$("#reserva-form #reserva-personas").bind('change', validar_desglose);
	$("#reserva-form #reserva-fecha_out").bind('change', validar_desglose);
	
});




/**********************************************/
/*
/*      COOKIES
/*
/**********************************************/

function createCookie(name,value,days)
{
	if (days) {
		var date = new Date();
		 date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}




/**********************************************/
/*
/*      VARIOS
/*
/**********************************************/

function DisableDays(date)
{
    var isd = true;
	var rd = $("#reserva-ocupacion").html().split(",");
	if (rd) {
		var m = date.getMonth();
		var d = date.getDate();
		var y = date.getFullYear();
		for (i = 0; i < rd.length; i++) {
			var ds = rd[i];
			var di, df;
			var m1, d1, y1, m2, d2, y2;
	
			di = ds.split('/');
			m1 = parseInt(di[1], 10);
			d1 = parseInt(di[0], 10);
			y1 = parseInt(di[2], 10);
			if (y1 == y && m1 == (m + 1) && d1 == d) return [!isd];
			
		}
		return [isd];
	}else{
		return false;
	}
}

function ShowIndex()
{	
	$("#intro-menu ul li").removeClass("active");
	$(this).parent().addClass("active");
	
	var id = "#" + $(this).parent().attr('id').replace("intro-", "index-");
	$(".intro-box").hide();
	$(id).show();
	
	return false;
}

function ShowSingle()
{
	$(".entry-menu ul li").removeClass("active");
	$(this).parent().addClass("active");
	
	var id = "#" + $(this).parent().attr('id').replace("single-", "post-");
	$(".single-box").hide();
	$(id).show();
	if (id == "#post-localizacion") { initialize();	}
	
	return false;
}

function ClearSearch()
{
	eraseCookie("wp-inmoalkla-fecha_in");
	eraseCookie("wp-inmoalkla-fecha_out");
	eraseCookie("wp-inmoalkla-personas");
	eraseCookie("wp-inmoalkla-localidad");
	eraseCookie("wp-inmoalkla-tipo");
	eraseCookie("wp-inmoalkla-dormitorios");
	eraseCookie("wp-inmoalkla-superficie");
	eraseCookie("wp-inmoalkla-precio");
	eraseCookie("wp-inmoalkla-orderkey");
	eraseCookie("wp-inmoalkla-order");
	return true;
}

function SinglePrint()
{
	window.print();
	return false;
}



/**********************************************/
/*
/*   HIPOTECA
/*
/**********************************************/

function validar_hipoteca()
{
	
	
	var precio = $("#hipoteca-precio").val();
	var prestamo = $("#hipoteca-prestamo").val();
	var anos = $("#hipoteca-anos").val();
	var interes = $("#hipoteca-interes").val();
	var cuota = $("#hipoteca-cuota").val();
	var primera = $("input[@name='hipoteca-primera']:checked").val();
	var path = $("#hipoteca-path").val();
	var error = "";
	var count = 0;
	
	if (precio == ""){
		error = error + $("#hipoteca-error_precio").val() + '<br/>';
		$("#hipoteca-msg").html(error);
	}
	if (precio.indexOf('.') != -1 || prestamo.indexOf('.') != -1 || cuota.indexOf('.') != -1 || precio.indexOf(',') != -1 || prestamo.indexOf(',') != -1 || cuota.indexOf(',') != -1){
		error = error + $("#hipoteca-error_coma").val() + '<br/>';
		$("#hipoteca-msg").html(error);
	}
	
	if (prestamo == ""){ count = count + 1; }
	if (anos == ""){ count = count + 1; }
	if (interes == ""){ count = count + 1; }
	if (cuota == ""){ count = count + 1; }
	if (count > 1){
		error = error + $("#hipoteca-error_datos").val() + '<br/>';
		$("#hipoteca-msg").html(error);
	}
	
	
	if (!error){
		$("#hipoteca-msg").html("");
		var param = "precio=" + precio + "&prestamo=" + prestamo + "&anos=" + anos + "&interes=" + interes + "&cuota=" + cuota + "&primera=" + primera;
		$.ajax({
			async:true,
			type: "post",
			dataType: "xml",
			contentType: "application/x-www-form-urlencoded",
			url: path + "/library/hipoteca.php",
			data:param,
			success:validar_hipoteca_complete,
			timeout:10000,
			error:null
		});
	}
	return false;
}
function validar_hipoteca_complete(t)
{	
	var prestamo = $("prestamo", t).text();
	var anos = $("anos", t).text();
	var cuota = $("cuota", t).text();
	
	var iva = $("iva", t).text();
	var iaj = $("iaj", t).text();
	
	var notario = $("notario", t).text();
	var registro = $("registro", t).text();
	var gestion = $("gestion", t).text();
	var gastos_iva = $("gastos_iva", t).text();
	
	var notario2 = $("notario2", t).text();
	var registro2 = $("registro2", t).text();
	var gestion2 = $("gestion2", t).text();
	var gastos_iva2 = $("gastos_iva2", t).text();
	
	var comision = $("comision", t).text();
	var tasacion = $("tasacion", t).text();
	var seguro = $("seguro", t).text();
	var iaj2 = $("iaj2", t).text();

	var total1 = $("total1", t).text();
	var total2 = $("total2", t).text();
	var total = $("total", t).text();
	
	$("#hipoteca-prestamo").val(prestamo);
	$("#hipoteca-anos").val(anos);
	$("#hipoteca-cuota").val(cuota);
	
	$("#hipoteca-iva").val(iva);
	$("#hipoteca-iaj").val(iaj);
	
	$("#hipoteca-notario").val(notario);
	$("#hipoteca-registro").val(registro);
	$("#hipoteca-gestion").val(gestion);
	$("#hipoteca-gastos_iva").val(gastos_iva);
	
	$("#hipoteca-compraventa").val(total1);
	
	$("#hipoteca-iaj2").val(iaj2);
	
	$("#hipoteca-notario2").val(notario2);
	$("#hipoteca-registro2").val(registro2);
	$("#hipoteca-gestion2").val(gestion2);
	$("#hipoteca-gastos_iva2").val(gastos_iva2);
	
	$("#hipoteca-comision").val(comision);
	$("#hipoteca-tasacion").val(tasacion);
	$("#hipoteca-seguro").val(seguro);
	
	$("#hipoteca-hipoteca").val(total2);
	
	$("#hipoteca-total").val(total);
}




/**********************************************/
/*
/*      BUSQUEDA Y FILTRO
/*
/**********************************************/

function elige_search()
{
	var obj = $(this).attr('id');
	
	if (obj == 'elige-alquilar') {
		obj = '#consulta';
	}else {
		obj = '#consulta-venta';
	}
	
	$('#elige').fadeOut(400, function() {
		$(obj).fadeIn(400);
  	});
	return false;
}

function validar_search()
{
	
	var fecha_in = $("#search-fecha_in").val();
	var fecha_out = $("#search-fecha_out").val();
	var personas = $("#search-personas").val();
	var error = false;
	var error_msg = "";

	if (fecha_in == ""){
		error = true;
		error_msg = error_msg + $("#search-error_fecha_in").val() + '<br/>';
	}
	if (fecha_out == ""){
		error = true;
		error_msg = error_msg + $("#search-error_fecha_out").val() + '<br/>';
	}
	
	if (error){
		$("#search-msg").html(error_msg);
		return false;
	}else{
		createCookie("wp-inmoalkla-fecha_in", fecha_in);
		createCookie("wp-inmoalkla-fecha_out", fecha_out);
		createCookie("wp-inmoalkla-personas", personas);
		eraseCookie("wp-inmoalkla-localidad");
		eraseCookie("wp-inmoalkla-tipo");
		eraseCookie("wp-inmoalkla-dormitorios");
		eraseCookie("wp-inmoalkla-superficie");
		eraseCookie("wp-inmoalkla-precio");
		eraseCookie("wp-inmoalkla-orderkey");
		eraseCookie("wp-inmoalkla-order");
		return true;
	}
}

function validar_search_venta()
{
	var localidad = $("#search_venta-localidad").val();
	var tipo = $("#search_venta-tipo").val();
	var precio = $("#search_venta-precio").val();
	var path = $("#search_venta-path").val();
	var lang = $("#search_venta-lang").val();

	createCookie("wp-inmoalkla-localidad", localidad);
	createCookie("wp-inmoalkla-tipo", tipo);
	createCookie("wp-inmoalkla-precio", precio);
	eraseCookie("wp-inmoalkla-dormitorios");
	eraseCookie("wp-inmoalkla-superficie");
	eraseCookie("wp-inmoalkla-orderkey");
	eraseCookie("wp-inmoalkla-order");
	var param = "tipo=" + tipo + "&localidad=" + localidad + "&lang=" + lang;
	$.ajax({
		async:true,
		type: "post",
		dataType: "xml",
		contentType: "application/x-www-form-urlencoded",
		url: path + "/library/search.php",
		data:param,
		success:validar_search_venta_complete,
		timeout:10000,
		error:null
	});
	return false;
}
function validar_search_venta_complete(t)
{	
	var url = $("url", t).text();
	$("#search_venta-form").attr('action', url);
	document.getElementById("search_venta-form").submit();
}

function validar_filter()
{
	
	var fecha_in = $("#filter-fecha_in").val();
	var fecha_out = $("#filter-fecha_out").val();
	var personas = $("#filter-personas").val();
	var localidad = $("#filter-localidad").val();
	var tipo = $("#filter-tipo").val();
	var precio = $("#filter-precio").val();
	var path = $("#filter-path").val();
	var lang = $("#filter-lang").val();

	createCookie("wp-inmoalkla-fecha_in", fecha_in);
	createCookie("wp-inmoalkla-fecha_out", fecha_out);
	createCookie("wp-inmoalkla-personas", personas);
	createCookie("wp-inmoalkla-localidad", localidad);
	createCookie("wp-inmoalkla-tipo", tipo);
	createCookie("wp-inmoalkla-precio", precio);
	var param = "tipo=" + tipo + "&localidad=" + localidad + "&lang=" + lang;
	$.ajax({
		async:true,
		type: "post",
		dataType: "xml",
		contentType: "application/x-www-form-urlencoded",
		url: path + "/library/filter.php",
		data:param,
		success:validar_filter_complete,
		timeout:10000,
		error:null
	});
	return false;
}
function validar_filter_complete(t)
{	
	var url = $("url", t).text();
	$("#filter-form").attr('action', url);
	document.getElementById("filter-form").submit();
}

function validar_filter_venta()
{
	var localidad = $("#filter_venta-localidad").val();
	var tipo = $("#filter_venta-tipo").val();
	var precio = $("#filter_venta-precio").val();
	var dormitorios = $("#filter_venta-dormitorios").val();
	var superficie = $("#filter_venta-superficie").val();
	var path = $("#filter_venta-path").val();
	var lang = $("#filter_venta-lang").val();

	createCookie("wp-inmoalkla-localidad", localidad);
	createCookie("wp-inmoalkla-tipo", tipo);
	createCookie("wp-inmoalkla-precio", precio);
	createCookie("wp-inmoalkla-dormitorios", dormitorios);
	createCookie("wp-inmoalkla-superficie", superficie);
	var param = "tipo=" + tipo + "&localidad=" + localidad + "&lang=" + lang;
	$.ajax({
		async:true,
		type: "post",
		dataType: "xml",
		contentType: "application/x-www-form-urlencoded",
		url: path + "/library/filter_venta.php",
		data:param,
		success:validar_filter_venta_complete,
		timeout:10000,
		error:null
	});
	return false;
}
function validar_filter_venta_complete(t)
{	
	var url = $("url", t).text();
	$("#filter_venta-form").attr('action', url);
	document.getElementById("filter_venta-form").submit();
}

function order_dormitorios()
{
	createCookie("wp-inmoalkla-orderkey", "dormitorios");
	order();
	return true;	
}
function order_plazas()
{
	createCookie("wp-inmoalkla-orderkey", "plazas");
	order();
	return true;	
}
function order_superficie()
{
	createCookie("wp-inmoalkla-orderkey", "superficie");
	order();
	return true;	
}
function order_precio()
{
	createCookie("wp-inmoalkla-orderkey", "precio");
	order();
	return true;	
}

function order() 
{
	if (readCookie("wp-inmoalkla-order") == "ASC"){
		createCookie("wp-inmoalkla-order", "DESC");
	}else{
		createCookie("wp-inmoalkla-order", "ASC");
	}
}




/**********************************************/
/*
/*      RESERVA
/*
/**********************************************/

function validar_desglose()
{
	var fecha_in = $("#reserva-fecha_in").val();
	var fecha_out = $("#reserva-fecha_out").val();
	var personas = $("#reserva-personas").val();
	var vivienda = $("#reserva-vivienda").val();
	var path = $("#reserva-path").val();
	var param = "fecha_in=" + fecha_in + "&fecha_out=" + fecha_out + "&personas=" + personas + "&vivienda=" + vivienda;
	$.ajax({
		async:true,
		type: "post",
		dataType: "xml",
		contentType: "application/x-www-form-urlencoded",
		url: path + "/library/desglose.php",
		data:param,
		success:validar_desglose_complete,
		timeout:10000,
		error:null
	});
}
function validar_desglose_complete(t)
{	
	var disponibilidad = $("disponibilidad", t).text();
	var rango = $("rango", t).text();
	var error = false;
	if (!disponibilidad) {
		$("#reserva-msg").html($("#reserva-error_fechas").val());
		var error = true;
	}
	if (!rango) {
		$("#reserva-msg").html($("#reserva-error_rango").val());
		var error = true;
	}
	
	if (!error) {
		var desglose = $("desglose", t).text();
		var precio = $("precio", t).text();
		$("#reserva-msg").html(desglose);
		$("#reserva-precio").val(precio);
	}
}

function validar_reserva()
{
	
	var fecha_in = $("#reserva-fecha_in").val();
	var fecha_out = $("#reserva-fecha_out").val();
	var personas = $("#reserva-personas").val();
	var nombre = $("#reserva-nombre").val();
	var telefono = $("#reserva-telefono").val();
	var email = $("#reserva-email").val();
	var vivienda = $("#reserva-vivienda").val();
	var precio = $("#reserva-precio").val();
	var path = $("#reserva-path").val();
	var error = false;
	var error_msg = "";
	
	if ($("#reserva-paso2").hasClass('hide')){

		if (fecha_in == ""){
			error = true;
			error_msg = error_msg + $("#reserva-error_fecha_in").val() + '<br/>';
		}
		if (fecha_out == ""){
			error = true;
			error_msg = error_msg + $("#reserva-error_fecha_out").val() + '<br/>';
		}
		
		if (error){
			$("#reserva-msg").addClass("error");
			$("#reserva-msg").html(error_msg);
		}else{
			$('#reserva-paso1').fadeOut(400, function() {
				$("#reserva-paso2").fadeIn(400,	function() {
					$("#reserva-paso2").removeClass('hide');
				});
			});
			var param = "fecha_in=" + fecha_in + "&fecha_out=" + fecha_out + "&personas=" + personas + "&vivienda=" + vivienda;
			$.ajax({
				async:true,
				type: "post",
				dataType: "xml",
				contentType: "application/x-www-form-urlencoded",
				url: path + "/library/desglose.php",
				data:param,
				success:validar_desglose_complete,
				timeout:10000,
				error:null
			});
		}
		
	}else{
		
		if (nombre == ""){
			error = true;
			error_msg = error_msg + $("#reserva-error_nombre").val() + '<br/>';
		}
		if (telefono == ""){
			error = true;
			error_msg = error_msg + $("#reserva-error_telefono").val() + '<br/>';
		}
		if (email == ""){
			error = true;
			error_msg = error_msg + $("#reserva-error_email").val() + '<br/>';
		}else{
			var patron = /^[^@ ]+@[^@ ]+.[^@ .]+$/;
			var t1=patron.test(email);
			if (t1 == false){
				error = true;
				error_msg = error_msg + $("#reserva-error_email_failure").val() + '<br/>';
			}	
		}
		
		if (error){
			$("#reserva-msg").addClass("error");
			$("#reserva-msg").html(error_msg);
		}else{
			$("#reserva-msg").html("");
			var param = "fecha_in=" + fecha_in + "&fecha_out=" + fecha_out + "&personas=" + personas + "&nombre=" + nombre + "&telefono=" + telefono + "&email=" + email + "&vivienda=" + vivienda + "&precio=" + precio;
			$.ajax({
				async:true,
				type: "post",
				dataType: "xml",
				contentType: "application/x-www-form-urlencoded",
				url: path + "/library/reserva.php",
				data:param,
				success:validar_reserva_complete,
				timeout:10000,
				error:null
			});
		}
		
	}
	
	return false;
}
function validar_reserva_complete(t)
{	
	var resultado = $("resultado", t).text();
	if (!resultado){
		$("#reserva-msg").html($("#reserva-error_fechas").val());
	}else{
		$("#reserva-msg").addClass("msg_ok");
		$("#reserva-msg").html($("#reserva-ok1").val() + '<br/>' + $("#reserva-ok2").val());
		document.getElementById("reserva-form").reset();
	}
}


function validar_cita()
{
	var nombre = $("#cita-nombre").val();
	var telefono = $("#cita-telefono").val();
	var email = $("#cita-email").val();
	var mensaje = $("#cita-mensaje").val();
	var vivienda = $("#cita-vivienda").val();
	var path = $("#cita-path").val();
	var error = false;
	var error_msg = "";

	if (nombre == ""){
		error = true;
		error_msg = error_msg + $("#cita-error_nombre").val() + '<br/>';
	}
	if (telefono == ""){
		error = true;
		error_msg = error_msg + $("#cita-error_telefono").val() + '<br/>';
	}
	
	if (error){
		$("#cita-msg").addClass("error");
		$("#cita-msg").html(error_msg);
	}else{
		$("#cita-msg").html("");
		var param = "nombre=" + nombre + "&telefono=" + telefono + "&email=" + email + "&vivienda=" + vivienda + "&mensaje=" + mensaje;
		$.ajax({
			async:true,
			type: "post",
			dataType: "xml",
			contentType: "application/x-www-form-urlencoded",
			url: path + "/library/cita.php",
			data:param,
			success:validar_cita_complete,
			timeout:10000,
			error:null
		});
	}
	return false;
}
function validar_cita_complete(t)
{	
	$("#cita-msg").addClass("msg_ok");
	$("#cita-msg").html($("#cita-ok").val());
	document.getElementById("cita-form").reset();
}





				 
/**********************************************/
/*
/*   CONTACTO
/*
/**********************************************/

function validar_contacto()
{
	
	var email = $("#contacto-email").val();
	var nombre = $("#contacto-nombre").val();
	var telefono = $("#contacto-telefono").val();
	var mensaje = $("#contacto-mensaje").val();
	var path = $("#contacto-path").val();
	var error = false;
	var error_msg = "";

	if (nombre == ""){
		error = true;
		error_msg = error_msg + $("#contacto-error_nombre").val() + '<br/>';
	}
	if (telefono == ""){
		error = true;
		error_msg = error_msg + $("#contacto-error_telefono").val() + '<br/>';
	}
	
	if (!error){	
		var param = "email=" + email + "&nombre=" + nombre + "&telefono=" + telefono + "&mensaje=" + mensaje;
		$("#contacto-msg").html("...");
		$.ajax({
			async:true,
			type: "post",
			dataType: "xml",
			contentType: "application/x-www-form-urlencoded",
			url: path + "/library/contacto.php",
			data:param,
			success:validar_contacto_complete,
			timeout:10000,
			error:null
		});
	}else{
		$("#contacto-msg").html(error_msg);
	}
	return false;
}
function validar_contacto_complete(t)
{	
	var path = $("#contacto-path").val();
	var error_msg = $("#contacto-ok").val();
	$("#contacto-msg").addClass("msg_ok");
	$("#contacto-msg").html(error_msg);
	document.getElementById("contacto-form").reset();
}
