var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
    source:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class='modal-overlay'></div>";
		modal += "<div id='" + this.windowId + "' class=\"modal-window\" style=\"width:" + 
		         this.width + "px; height:" + this.height + "px; margin-top:-" + 
				 (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		if(this.content!=null){ modal += this.content; }
		modal += "</div>";	
                
		$(this.parent).append(modal);
        $(".modal-window").append("<img src='imagenes/cargando.gif' style='position: absolute; top: 43%; left: 35%;' />");
		if(this.content==null)
			$("#modal").load(this.source, {}, function() {
			   $(".modal-window").append("<a class=\"close-window\"></a>");
			   $(".close-window").click(function(){if  (recargarPagina) document.location.href = document.location.href.replace('&votar=1', ''); else modalWindow.close();});
			   // (".modal-overlay").click(function(){modalWindow.close();});
			});
		else
		{
		   $(".modal-window").append("<a class=\"close-window\"></a>");
		   $(".close-window").click(function(){modalWindow.close();});
		   // (".modal-overlay").click(function(){modalWindow.close();});
		}	
	}
};

var abrirModal = function(source, height, width, iframe)
{
	modalWindow.windowId = "modal";
	modalWindow.width = width;
	modalWindow.height = height;
    modalWindow.source = source;
	if(iframe==true)
		modalWindow.content = "<iframe width='"+width+"' height='"+height+
		                      "' frameborder='0' scrolling='no' allowtransparency='true' src='"+source+
							  "'>&lt/iframe>";
	modalWindow.open();
};