
//-----------------------------------------------------------------------------
function ventana(mod,id)
	{
	var imgtop=(document.body.offsetHeight-100)/2;
	var imgleft=(document.body.offsetWidth-100)/2;
	$.ajax({
		type: "POST",
		url: "../_include/ajax.server.1.php",
		dataType: "html",
		data: "mod="+mod+"&id="+id,
		timeout: 15000,
		contentType: "application/x-www-form-urlencoded",
		beforeSend: function(){
			// $("#loading").css( { top: imgtop, left: imgleft, visibility: "visible" } );
			$("#loading").css( { visibility: "visible" } );
			},
		complete: function(xhr,status){
			$("#loading").css("visibility","hidden");
			//alert(status+"\n\n"+xhr.responseText);
			switch(status){
				case "success":
				var resultado=xhr.responseText.split("|@#$%&|");
				switch(resultado[0]){
					case "correcto":
					abrir_popup1(resultado[1]);
					break;
					case "error":
					alert("Ha ocurrido un error en el servidor.\n\nIntentelo nuevamente.");
					break;
					}
				break;
				case "timeout":
				alert("Tiempo de respuesta del servidor excedido·\n\nIntentelo nuevamente.");
				break;
				case "error":
				alert("Ha ocurrido un error en el servidor.\n\nIntentelo nuevamente.");
				break;
				}
			}
		});
	}

//-----------------------------------------------------------------------------
function img(id)
	{
	$("#img00").fadeOut("slow");
	$("#img01").fadeOut("slow");
	$("#img00").hide();
	$("#img01").hide();
	document.getElementById("img00").src=document.getElementById(id).src;
	document.getElementById("img01").innerHTML=document.getElementById(id).title;
	$("#img00").fadeIn("slow");
	$("#img01").fadeIn("slow");
	}

//-----------------------------------------------------------------------------
function abrir_popup1(popup)
	{
	$("#overlay1").remove();
	$("#modal1").remove();
	$("body").append("<div id=overlay1></div>");
	$("#overlay1").hide();
	$("#overlay1").css({ position: "absolute", top: "0", left: "0", width: "100%", height: "100%", zIndex: "20000" });
	$("#overlay1").css({ background: "#000000", filter: "alpha(opacity=50)", opacity: "0.5" });
	$("body").append("<div id=modal1></div>");
	$("#modal1").hide();
	$("#modal1").css({ position: "absolute", top: "50%", left: "50%", width: "0", height: "0", margin: "0", zIndex: "20001" });
	$("#modal1").css({ color: "#000", background: "#fa831b" });
	$("#modal1").append("<div id=contenido_modal1></div>");
	$("#contenido_modal1").hide();
	$("#contenido_modal1").html(popup);
	$("#overlay1").fadeIn("slow");
	$("#modal1").fadeIn("slow");
	$("#modal1").animate( { marginTop: "-215px", marginLeft: "-390px", width: "780px", height: "430px" }, "slow", function(){ $("#contenido_modal1").fadeIn("fast"); });
	}
function abrir_popup2(img)
	{
	var contenido_modal="<div class=\"ventana_img\"><div class=\"caja_boton\"><button onclick=\"javascript:cerrar_popup2();\" class=\"boton_cerrar\">CERRAR</button></div><div class=\"contenido\"><img src=\""+img+"\"></div></div>";
	$("#modal2").remove();
	$("body").append("<div id=modal2></div>");
	$("#modal2").hide();
	$("#modal2").css({ position: "absolute", top: "50%", left: "50%", width: "0", height: "0", margin: "0", zIndex: "30001" });
	$("#modal2").css({ color: "#000", background: "#fa831b", border: "" });
	$("#modal2").append("<div id=contenido_modal2></div>");
	$("#contenido_modal2").hide();
	$("#contenido_modal2").html(contenido_modal);
	$("#modal1").fadeOut("slow");
	$("#modal2").fadeIn("slow");
	$("#modal2").animate( { marginTop: "-100px", marginLeft: "-100px", width: "200px", height: "200px" }, "fast" );
	$("#modal2").animate( { marginLeft: "-390px", width: "780px" }, "fast");
	$("#modal2").animate( { marginTop: "-220px", marginLeft: "-100px", width: "200px", height: "440px" }, "fast");
	$("#modal2").animate( { marginLeft: "-390px", width: "780px" }, "fast", function(){ $("#contenido_modal2").fadeIn("fast"); });
	}
//-----------------------------------------------------------------------------
function cerrar_popup1()
	{
	$("#modal1").fadeOut("fast");
	$("#overlay1").fadeOut("fast", function(){ $("#modal1").remove(); $("#overlay1").remove(); });
	}
function cerrar_popup2()
	{
 	$("#modal2").fadeOut("fast", function(){ $("#modal1").fadeIn("fast"); $("#modal2").remove(); });
	}
//-----------------------------------------------------------------------------

