// JavaScript Document
function showLightbox() {
    document.getElementById('over').style.display='block';
    document.getElementById('fade').style.display='block';
    var d = document.createElement("div");
    d.setAttribute("id", "content");
    document.getElementById('over').appendChild(d);
}

function hideLightbox() {
    document.getElementById('over').innerHTML = '';
    document.getElementById('over').style.display='none';
    document.getElementById('fade').style.display='none';
}

function showDetails(id){
		document.getElementById('fade').style.display = 'block';
		var d = document.createElement("div");
		    d.setAttribute("id", "content");
		    document.getElementById('over').appendChild(d);
		//$("#fade").show("fast",function(){
    	//	var d = document.createElement("div");
		//  d.setAttribute("id", "content");
		//  document.getElementById('over').appendChild(d);});

	    $.ajax({
	        url: "destinosdetalle.php",
	        async:true,
	        beforeSend: function(objeto){
				loadingFunction();
	        	/*
	            alert("Adiós, me voy a ejecutar");
	            */
	        },
	        complete: function(objeto, exito){
	            /*
	            alert("Me acabo de completar")
	            if(exito=="success"){
	                alert("Y con éxito");
	            }
	            */
	        },
	        contentType: "application/x-www-form-urlencoded;",
	        dataType: "html",
	        data: "id="+id,
	        error: function(objeto, quepaso, otroobj){
	            //alert("Estas viendo esto por que fallé");
	            //alert("Pasó lo siguiente: "+quepaso);
	        },
	        global: true,
	        ifModified: false,
	        processData:true,
	        success: function(datos){
	        	$("#content").html(datos);
	        	$("#over").fadeIn("normal",function(){});
	        	$("#fade").html('');
	        	//alert($("#content").html());
//	            alert(datos);
	        },
	        timeout: 3000,
	        type: "GET"
		});

}

function showNewsletterSuscription(){
		document.getElementById('fade').style.display = 'block';
		var d = document.createElement("div");
		    d.setAttribute("id", "contentNews");
		    document.getElementById('over').appendChild(d);
		//$("#fade").show("fast",function(){
    	//	var d = document.createElement("div");
		//  d.setAttribute("id", "content");
		//  document.getElementById('over').appendChild(d);});

	    $.ajax({
	        url: "newslettersuscripcion.php",
	        async:true,
	        beforeSend: function(objeto){
				loadingFunction();
	        	/*
	            alert("Adiós, me voy a ejecutar");
	            */
	        },
	        complete: function(objeto, exito){
	            /*
	            alert("Me acabo de completar")
	            if(exito=="success"){
	                alert("Y con éxito");
	            }
	            */
	        },
	        contentType: "application/x-www-form-urlencoded;",
	        dataType: "html",

	        error: function(objeto, quepaso, otroobj){
	            //alert("Estas viendo esto por que fallé");
	            //alert("Pasó lo siguiente: "+quepaso);
	        },
	        global: true,
	        ifModified: false,
	        processData:true,
	        success: function(datos){
	        	$("#contentNews").html(datos);
	        	$("#over").fadeIn("normal",function(){});
	        	$("#fade").html('');
	        	//alert($("#content").html());
//	            alert(datos);
	        },
	        timeout: 3000,
	        type: "GET"
		});

}

function showContacto(){
		document.getElementById('fade').style.display = 'block';
		var d = document.createElement("div");
		    d.setAttribute("id", "contentContacto");
		    document.getElementById('over').appendChild(d);
		//$("#fade").show("fast",function(){
    	//	var d = document.createElement("div");
		//  d.setAttribute("id", "content");
		//  document.getElementById('over').appendChild(d);});

	    $.ajax({
	        url: "contacto.php",
	        async:true,
	        beforeSend: function(objeto){
				loadingFunction();
	        	/*
	            alert("Adiós, me voy a ejecutar");
	            */
	        },
	        complete: function(objeto, exito){
	            /*
	            alert("Me acabo de completar")
	            if(exito=="success"){
	                alert("Y con éxito");
	            }
	            */
	        },
	        contentType: "application/x-www-form-urlencoded;",
	        dataType: "html",

	        error: function(objeto, quepaso, otroobj){
	            //alert("Estas viendo esto por que fallé");
	            //alert("Pasó lo siguiente: "+quepaso);
	        },
	        global: true,
	        ifModified: false,
	        processData:true,
	        success: function(datos){
	        	$("#contentContacto").html(datos);
	        	$("#over").fadeIn("normal",function(){});
	        	$("#fade").html('');
	        	//alert($("#content").html());
//	            alert(datos);
	        },
	        timeout: 3000,
	        type: "GET"
		});

}

function loadingFunction(){
	var img = "<div style=\"width:31px;top:50%;left:50%;position:absolute;margin-left:-15px;margin-top:-15px\">HOLAAA<img src=\"imagenes/ajaxloader.gif\" border=\"0\" align=\"middle\" /></div>";
	$("#fade").html(img);
}

function cerrarLight2(){
	$("#contentNews").html('');
	$("#over").fadeOut("fast", function(){
		$("#fade").fadeOut("fast", function(){});
	});
}

function cerrarLight3(){
	$("#contentContacto").html('');
	$("#over").fadeOut("fast", function(){
		$("#fade").fadeOut("fast", function(){});
	});
	
	var d = document.getElementById('contentContacto');
	document.getElementById('over').removeChild(d);	
}

function graciasContacto(){
	$("#mensajeContacto").html('');
	$("#formularioContacto").html('Muchas gracias, nos pondremos en contacto a la brevedad.');
	setTimeout(cerrarLight3, 3000);
}

function graciasNewsletter(){
	$("#mensajeNewsletter").html('');
	$("#formularioNews").html('Muchas gracias, su suscripci&oacute;n se ha realizado con &eacute;xito.');
	setTimeout(cerrarLight2, 3000);
}

function cerrarLight(){
	$("#content").html('');
	$("#over").fadeOut("fast", function(){
		$("#fade").fadeOut("fast", function(){});
	});	
}

function thanksMessage(){
	$("#content").html('');
	$("#over").fadeOut("fast", function(){
		$("#fade").fadeOut("fast", function(){
			$("#thanksMessage").html('<img src="images/gracias.jpg" alt="Gracias" />');
			$("#thanksMessage").fadeIn("normal",function(){ setTimeout("closeThanksMessage()",4000);});
		});
	});	
}

function closeThanksMessage(){
	$("#thanksMessage").fadeOut("normal");
}

function closeLightBox(){
	$("#content").html('');
	$("#over").fadeOut("fast", function(){
		$("#fade").fadeOut("fast")});
}
