var	bHandleSessionTimeoutCalled = false;

function getWhlCookie()
{	
	var url = "/whalecomlocalhost:6001/whalecom0/InternalSite/?WhlST";
	try 
	{		
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch(e)
	{		
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E)
		{
			xmlhttp = false;
		}
	}
	try
	{
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
		{
			xmlhttp = new XMLHttpRequest();
		}
				
		if (xmlhttp)
		{			
			xmlhttp.onreadystatechange = function()
			{
				try
				{
					if (xmlhttp.status == '404' && !bHandleSessionTimeoutCalled)
						handleSessionTimeout();
				}
				catch(e)
				{}
			}
			xmlhttp.open("GET", url, true);
			xmlhttp.send("");
			
		}
	} 
	catch (E)
	{}
}

function handleSessionTimeout()
{	
	if (bHandleSessionTimeout)
	{
		bHandleSessionTimeoutCalled = true;
		var sessionTimeout = 120000;
		var time = getCookie("WhlST");		
		if (time != null)
			sessionTimeout = time;
		window.setTimeout("endSession()",sessionTimeout);
	}
}

function endSession()
{
	if (document.images)
		document.location.replace(timeoutURL);
	else
		document.location.href = timeoutURL;	
}

function getCookie(sName)
{
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
			return unescape(aCrumb[1]);
	}
	return null;
}