function setCookie( sName, sValue, bSetExpiryDate, path )
{
  date = new Date();
  date.setFullYear( date.getFullYear() + 1 );

  var sCookie = sName + '=' + escape( sValue );

  if ( bSetExpiryDate )
    sCookie += '; expires=' + date.toGMTString();

  if ( path != null )
    sCookie += '; path=' + path;
    
  document.cookie = sCookie;
}

function getCookie( sName, sDefaultValue )
{
  if ( sDefaultValue == null )
    sDefaultValue = "";

  // cookies are separated by semicolons
  var aCookie = document.cookie.split( '; ' );
  for ( var i = 0; i < aCookie.length; i++ )
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split( '=' );
    if ( sName == aCrumb[ 0 ] ) 
    {
			var oCrumb = aCrumb[ 1 ];
			return ( oCrumb == null ) ? "" : unescape( oCrumb );
    }
  }

  // a cookie with the requested name does not exist
  return sDefaultValue;
}

function delCookie( sName, path )
{
	var sCookie = sName + '=; expires=Fri, 31 Dec 1999 23:59:59 GMT;';

	if ( path != null )
		sCookie += 'path=' + path;

  document.cookie = sCookie;
}
