var lightBoxFirstRun=true;

function doLightBox(snapshotVersion, asType, isPreroll, adSchedulePath, title, type){

snapshotVersion=unescape(snapshotVersion);
asType=unescape(asType);
isPreroll=unescape(isPreroll);
adSchedulePath=unescape(adSchedulePath);
title=unescape(title);
type=unescape(type);
				
	var defaultHeight=790;
	var defaultWidth=820;
	if (defaultHeight>$(window).height()){
		 defaultHeight = $(window).height() - 50;
	}
	if (defaultWidth>$(window).width()){
		 defaultWidth = $(window).width() - 50;
	}
	
				
	var lbURL = "http://www.scanscout.com/adgallery/liveWebsiteDemo/?1=1&snapshotVersion=" + snapshotVersion + "&asType=" + asType + "&isPreroll=" + isPreroll + "&adSchedulePath=http://www.scanscout.com/adgallery/" + adSchedulePath + "/adschedule.xml";
	
	//alert (lbURL);
	$overlay_close = function() {
		$("#overlay_iframe").html(' ');
		
		$("#overlay").fadeOut();
		
	}
	
	var iframeWidth= defaultWidth-70;
	var iframeHeight= defaultHeight-80;
	
	if (lightBoxFirstRun){
		 
		lightBoxFirstRun=false;
		$("#overlay").html("<div id='overlay_inner' class='curvyRedraw' style='width:" +defaultWidth+ "px; height:" + defaultHeight + "px;' ></div>");
		$("#overlay_inner").html("<div id='overlay_title'><b>" + title +":</b> "+ type + "</div><div id='overlay_iframe' style='width:" +iframeWidth+ "px; height:" + iframeHeight + "px;'></div><div id='overlay_close'></div>");
		$("#overlay").bind('click', $overlay_close);
	    $("#overlay_close").bind('click', $overlay_close);
		
	}
	else {
		$("#overlay_inner").html("<div id='overlay_title'><b>" + title +":</b> "+ type + "</div><div id='overlay_iframe' style='width:" +iframeWidth+ "px; height:" + iframeHeight + "px;'></div><div id='overlay_close'></div>");
	}

	$("#overlay_iframe").html("<iframe id='overlay_iframe_inner' SCROLLING='yes'  style='width:" +iframeWidth+ "px; height:" + iframeHeight + "px;' frameborder='0' hspace='0' src='" + lbURL + "'></iframe>");
	
	
	$("#overlay").fadeIn();
	
	sIFR.replace(memphis_med, {
			  selector: '#overlay_title',
			  css: '.sIFR-root {  color: #ffffff; font-size:16px; cursor:arrow;}'
		});
	curvyCorners.init();
}


$(document).ready(function() {
	$("body").append("<div id=\"overlay\"></div>");
});


