	/* or replace with your favorite cookie functions */
	function getCookie(sName) {
		var cookie = "" + document.cookie;
		var start = cookie.indexOf(sName);
		if (cookie == "" || start == -1) 
			return "";
		var end = cookie.indexOf(';',start);
		if (end == -1)
			end = cookie.length;
		return unescape(cookie.substring(start+sName.length + 1,end));
	}
	
	function setCookieForXDays(sName,value,ndays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+ndays);
		document.cookie = sName+ "=" +escape(value) + ";path=/;expires=" + exdate.toGMTString();
	}
	
	function PageGate(pagePath)
	{
		// use silverlight.js to sniff (dont want to prompt when can't install)
		if (!Silverlight.isInstalled("0.90.0") && Silverlight.ua.OS == "Windows" && Silverlight.ua.Browser == "MSIE")
		{
			// check for cookie, if set keep quiet, otherwise prompt for installation
			var slCookieName = "SLInstallPostponed7";
			var cookie= getCookie(slCookieName);
			
			// **** start: for testing only ***
			if (location.search.substring(1).indexOf("resetcookie") != -1)
				cookie = "";
			// **** end: for testing only ***
			
			if (cookie != "ok")
			{
				// set timeout to keep trying if a new installation on IE
				if ( !Silverlight.available &&  Silverlight.ua.Browser == 'MSIE' )
				{
					TimeoutDelegate = function()
				    {
						if (Silverlight.isInstalled("0.90.0"))
							window.location.reload(false);
						else
							setTimeout(TimeoutDelegate, 3000);
					}
					setTimeout(TimeoutDelegate, 3000);
				}
									
				Telligent_Modal.Open(pagePath, 492, 267, null);

				setCookieForXDays(slCookieName,"ok",7);
			}
		}
	}
