var $j = jQuery.noConflict();

var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$j(".modal-window").remove();
		$j(".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>";
        
        if(BrowserDetect.browser == 'Explorer'){
            $j(".modal-window").height(document.getElementsByTagName("html").item(0).offsetHeight);
        }

		$j(this.parent).append(modal);

		$j(".modal-window").append("<a class=\"close-window\"></a>");
		$j(".close-window").click(function(){modalWindow.close();});
	}
};

var openMyModal = function(source, width, height)
{
    
    modalWindow.windowId = "myModal";
	modalWindow.width = width;
	modalWindow.height = height;
	modalWindow.content = "<iframe width='"+ width +"' height='"+ height +"' id='modframe' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'></iframe>";
	modalWindow.open();
    
};

var closeReloadParent = function()
{
    modalWindow.close();
    window.location.reload();
}

var closeUrlParent = function(goto_url)
{
    modalWindow.close();
    window.location = goto_url;
}

var playerWindow = function(source, width, height, ps)
{
    openMyModal(source, width, height);
    if(typeof $j('#'+ps)[0] != 'undefined'){
        sendEvent(ps,'stop');
    }
};
