$(document).ready(function () {
	if (Globals.show_overlay) {
		showOverlay(Globals.overlayurl);
	}
});

if (getCookie("overlay") != "true") {
	Shadowbox.init({
		// let's skip the automatic setup because we don't have any
		// properly configured link elements on the page
		skipSetup: true,
		// include the html player because we want to display some html content
		players: ["iframe"]
	});
}

var Overlay = new Map();
Overlay.url = null;

function showOverlay(url) {
	Overlay.url = url;
	setTimeout(nowReallyShowIt, 500);
}

function nowReallyShowIt() {
	if(getCookie("overlay") != "true" && Globals.showOverlay) {
		// open a welcome message as soon as the window loads
		Shadowbox.open({
			content: Overlay.url,
			player:  "iframe",
			width:	860,
			height:	388
		});
	}
}

function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}
