﻿var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	marginTop:null,
	marginLeft:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
	    ///IE6 detection - returns 999 for non ie.
        var IEBrowser = {  Version: function() {    var version = 999;    if (navigator.appVersion.indexOf("MSIE") != -1)     version = parseFloat(navigator.appVersion.split("MSIE")[1]); return version;  }}
        if (IEBrowser.Version() < 7) {this.marginTop = ((document.documentElement.clientHeight - this.height) / 2);}else{this.marginTop =-(this.height / 2);}
	     
		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.marginTop + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	

		$(this.parent).append(modal);

		$(".modal-window").append("<a class=\"close-window\"></a><div class=\"modal-bottom\"></div>");
		$(".close-window").click(function(){modalWindow.close();});
		$(".modal-overlay").click(function(){modalWindow.close();});
	}
};

var openMyModal = function(source)
{
	modalWindow.windowId = "myModal";
	modalWindow.width = 473;
	modalWindow.height = 450;

	modalWindow.content = "<iframe width='"+ modalWindow.width +"' height='"+ modalWindow.height +"' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'>&lt/iframe>";
	modalWindow.open();
};	
