// ****************************** Cookie.js ************************************

// This file has functions to read and write to the cookie.
// We are attempting to avoid the writing of a cookie with no value.

	function getCookie(cookieName) 
	{
		var cookieValue = null;
		var posName = document.cookie.indexOf(escape(cookieName) + '=');
		if (posName != -1) 
			{
			var posValue = posName + (escape(cookieName) + '=').length;
			var endPos = document.cookie.indexOf(';', posValue);
			if (endPos != -1)
				cookieValue = unescape(document.cookie.substring(posValue,endPos));
			else
				cookieValue = unescape(document.cookie.substring(posValue));
			}
		if (cookieValue=="--Null--") cookieValue="";
		return cookieValue;
	}
	
	function SetCookie(name, value, expires)
	{
		if (value=="") value="--Null--"
		document.cookie= name+ "=" + escape (value) + "; expires=" +expires.toGMTString() + ";path=/";
	}
	
	//This is the version used in displayQuery.asp.  It's basically the same, but I kept it just in case.
	function getCookieDisplayQueryVersion(name)
	{
		var arg= name + "=";
		var alen=arg.length;
		var clen=document.cookie.length;
		var i=0;
		while(i< clen){
			var j=i+alen;
			if (document.cookie.substring(i,j)==arg){
				var endstr=document.cookie.indexOf(";",j);
				if (endstr==-1)
					endstr=document.cookie.length;
				return unescape(document.cookie.substring(j, endstr));
			}
			i= document.cookie.indexOf(" ", i) +1;
			if (i==0) break;
		}
		return null;
	}
	
	
