	var sBrowserType = document.all ? "IE" : document.getElementById ? "MOZ" : document.layers ? "NS" : "OTHER";
	
	document.onkeydown = handleKeyDown;
	
	function handleKeyDown(MozEvent) 
	{ 
		var evt;
		if (sBrowserType == "IE")
			evt = window.event;
		else if (sBrowserType == "MOZ")
			evt = MozEvent;
		else 
			return true;
		
		var iKeyCode = evt.keyCode;
		
		switch (iKeyCode)
		{
			case 120 :
				TurnOnDebug();
				break;
			case 121 :
				alert("The debugging will be turned off !");
				ClearCookie("UserID");
				break;
		}
		
		if (sBrowserType == "MOZ")
		{
			evt.cancelBubble = true; 
			evt.returnValue = false; 
			return false; 
		}
	}
	
	function TurnOnDebug()
	{
		var url = '../../ClientInc/UserID.htm';
		var winprops = 'height=180'
								 + ',width=220'
								 + ',top=100'
								 + ',left=100'
								 + ',scrollbars=no'
								 + ',toolbar=no'
								 + ',location=no'
								 + ',directory=no'
								 + ',status=no'
								 + ',menubar=no'
								 + ',resizable=no';
	
		var sName = 'Window';
		winUserID = window.open(url, sName, winprops);
	}
	
	function GetUserID(bUserID, value)
	{
		//alert("I have been called !" + "\n\n" + value);
		if (bUserID==1 && value.length>0)
			SetCookie("UserID", value.toLowerCase());
		try
		{
			winUserID.close();
		} catch(e){}
	}
	
	function SetCookie(sCookieName, sCookieValue, sPath, sExpires)
	{
		dt = new Date();
		dt.setMinutes( dt.getMinutes()+30 );
		var sCookie;
		
		sCookie = String(sCookieName) + "=" + escape(String(sCookieValue)) + ";";
		
		sCookie += "path=";
		if (typeof(sPath) == "string")
		{
			if (sPath != "")
				sCookie += sPath;
			else
				sCookie += "/";
		} else {
			sCookie += "/";
		}
		sCookie += ";";
		
		if (typeof(sExpires) != "undefined" && sExpires.length>0)
			sCookie += "expires=" + sExpires + ";";
	  else
	  	sCookie += "expires=" + dt.toString() + ";";
		
		document.cookie = sCookie;
	}
	
	function GetCookie(sCookieName)
	{
	  // cookies are separated by semicolons
	  var Cookies, Crumb, i;
	  Cookies = document.cookie.split(";");
	  for (i=0; i < Cookies.length; i++)
	  {
	    // a name/value pair (a crumb) is separated by an equal sign
	    Crumb = Cookies[i].split("=");
	    if ( sCookieName == trim(Crumb[0]) )
	      return unescape(Crumb[1]);
	  }
		
		// a cookie with the requested name does not exist
		return "";
	}

	function ClearCookie(sCookieName)
	{
		dt = new Date();
		dt.setMinutes( dt.getMinutes()-30 );
		document.cookie = sCookieName + "='';expires=" + dt.toString() + ";";
	}
	
	function trim(s)
	{
		var d = String(s); 
		if (!d.length) return "";
		var i_begin = 0, i_end = d.length - 1;
		while (i_begin < i_end && d.charAt(i_begin) == " ") i_begin++;
		while (i_begin <= i_end && d.charAt(i_end) == " ") i_end--;
	
		return d.substr(i_begin, i_end + 1 - i_begin);
	}
