// 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 showProducto(url_form){
		document.getElementById('miniaturas_000').style.display = 'none';
		
		document.getElementById('miniaturas_0').style.display='';
		
		if(!document.getElementById('content')) {
			var d = document.createElement("div");
		    d.setAttribute("id", "content");
		    document.getElementById('miniaturas').appendChild(d);
		}
		//$("#fade").show("fast",function(){
    	//	var d = document.createElement("div");
		//  d.setAttribute("id", "content");
		//  document.getElementById('over').appendChild(d);});

	    $.ajax({
	        url: url_form,
	        async:true,
	        beforeSend: function(objeto){
	        	/*
	            alert("Adiós, me voy a ejecutar");
	            */
				if(!$("#miniaturas").is(":hidden")) $("#miniaturas").slideUp("normal",function(){});
				
				
	        },
	        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+"&hash="+hash,
	        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);
				
				$("#miniaturas").slideDown("normal",function(){});
				
				
				
				var clearQueue = true;
				$(".miniaturas-listado li").each(function(){
					var $ttl = $(this).find('.tooltip-linea');
					$(this).hover(
						function(){
							var clearQueue = true;
							var gotoEnd= true;
							$ttl.stop(clearQueue, gotoEnd).fadeIn(300);
						},
						function(){
							var clearQueue = true;
							var gotoEnd= true;
							$ttl.stop(clearQueue, gotoEnd).fadeOut(300);
						}
					);
				});
	        },
	        timeout: 3000,
	        type: "GET"
		});

}

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")});
}
