var modalWindow = {
    parent:"body",
    windowId:null,
    content:null,
    width:null,
    height:null,
    type: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;\">";
        modal += this.content;
        modal += "</div>";

        $(this.parent).append(modal);

        /*
        if (this.type == 'frame') {
            $(".modal-window").append("<div class=\"lb-titlebar\" style=\"position:absolute;margin-top:-" + (780 - this.height) + "px;margin-left:18px\"><a href=\"\"></a></div>");
        }*/
        
        $(".lb-titlebar").click(function() {
            modalWindow.close();
        });
        /*$(".modal-overlay").click(function() {
         modalWindow.close();
         });*/
    }
};


var openModalUrl = function(width, height, sourceurl)
{
    modalWindow.windowId = "myModal";
    modalWindow.width = width;
    modalWindow.height = height;
    modalWindow.type = 'frame';
    modalWindow.content = "<iframe width='" + width + "' height='" + height + "' frameborder='0' scrolling='no' allowtransparency='true' src='" + sourceurl + "'>&lt/iframe>";
    modalWindow.open();
};

var openModalDiv = function(width, height, divid)
{
    modalWindow.windowId = "myModal";
    modalWindow.width = width;
    modalWindow.height = height;
    modalWindow.content = document.getElementById(divid).innerHTML;
    modalWindow.open();
};

var closeModal = function()
{
    modalWindow.windowId = "myModal";
    modalWindow.close();
};
