// JavaScript Document

var toMail;

$(document).ready(function(){

$(document).keypress(function(event) {
    if (event.keyCode == 27) {
		cerrar();	
	}  // esc   (does not work)
});

$("#forCont").click(function(){
	cerrar();
});

});



function contacto(toMal)
{
	toMail=toMal;
	$("#forCont").fadeIn(350);
	$("#form").fadeIn(350);
}
function enviar()
{
	var textoArea = document.getElementById("nombre").value;
	var numeroCaracteres = textoArea.length;
	var textoAreaB = document.getElementById("empresa").value;
	var numeroCaracteresB = textoAreaB.length;
	var textoAreaC = document.getElementById("pais").value;
	var numeroCaracteresC = textoAreaC.length;
	var textoAreaD = document.getElementById("ciudad").value;
	var numeroCaracteresD = textoAreaD.length;
	var textoAreaE = document.getElementById("telefono").value;
	var numeroCaracteresE = textoAreaE.length;
	var textoAreaF = document.getElementById("email").value;
	var numeroCaracteresF = textoAreaF.length;
	var textoAreaG = document.getElementById("comentarios").value;
	var numeroCaracteresG = textoAreaG.length;
	
	if(numeroCaracteres>3 && numeroCaracteresB>3 && numeroCaracteresC>3 && numeroCaracteresD>3 && numeroCaracteresE>3 && numeroCaracteresF>3 && numeroCaracteresG>3){
		var dataString = 'nombre='+ $("#nombre").val() + '&empresa=' + $("#empresa").val()+ '&pais=' + $("#pais").val()+ '&ciudad=' + $("#ciudad").val()+ '&telefono=' + $("#telefono").val()+ '&email=' + $("#email").val()+  '&comentarios=' + $("#comentarios").val()+  '&toMail=' + toMail;
	
		$.ajax({
			type		: "POST",
			cache	: false,
			url		: "data/send.php",
			data	: dataString,
			success :function(data) {
				alert( "Información Enviada");
			}	
		});
		cerrar();
	}else
		alert( "Para enviar este formulario debe estar completamente diligenciado");	
}

function cerrar()
{	
	$("#forCont").fadeOut(350);		
	$("#form").fadeOut(350);
	$("#nombre").val(' ');
	$("#empresa").val(' ');
	$("#pais").val(' ');
	$("#ciudad").val(' ');
	$("#telefono").val(' ');
	$("#email").val(' ');
	$("#comentarios").val(' ');
}
