var SLmodalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		try {
			$('#homepageRotation').cycle('resume');
		} catch(err){}
		
		$(".SLmodal-window").remove();
		$(".SLmodal-overlay").remove();
		if ($.browser.msie) {
			$('select').show();
		}
		$("#theSLSpinnerDiv").remove();
	},
	open:function()
	{
		try {
			$('#homepageRotation').cycle('pause');
			if ($.browser.msie) {	scroll(0,0); }
		} catch(err){}
		
		var SLmodal = "";
		SLmodal += "<div class=\"SLmodal-overlay\"></div>";


//		if (SLmodalWindow.height < $(window).height()) {
//			SLmodal += "<div id=\"" + this.windowId + "\" class=\"SLmodal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
//		} else {
			SLmodal += "<div id=\"" + this.windowId + "\" class=\"SLmodal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:0px; margin-left:-" + (this.width / 2) + "px;\">";
//		}
		SLmodal += this.content;
		SLmodal += "</div>";	
		
		var theSLSpinner = "";
		theSLSpinner += "<div id=\"theSLSpinnerDiv\"><img src=\"/System-Selector/img/largebusy.gif\" width=\"143\" height=\"143\" /></div>";
		$(this.parent).append(theSLSpinner);
		
		
		if ($.browser.msie) {
			$('select').hide();
		}

		$(this.parent).append(SLmodal);
		
		$(".SLmodal-window").append("<a class=\"SLclose-window\"></a>");
		$(".SLclose-window").click(function(){SLmodalWindow.close();});
		$(".SLmodal-overlay").click(function(){SLmodalWindow.close();});
	}
};


var openMySLModal = function(source, width, height)
{
	randnum = Math.random();
  SLmodalWindow.windowId = "mySLModal";
  SLmodalWindow.width = width;
  SLmodalWindow.height = height;
  SLmodalWindow.content = "<iframe id='"+ randnum +"' width='"+ SLmodalWindow.width +"' height='"+ SLmodalWindow.height +"' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'>&lt/iframe>";
  SLmodalWindow.open();
//	if (height > $(window).height()) {$('#'+SLmodalWindow.windowId).css({'top':'0'})}
};
