// bump-cookie  invoke via < script src=bump-cookie.js defer > <!-- no document.write in here ?? -->
// DGG 10/08/01 add delete of junk U , C, and UC
// This function writes or replaces the cookie N/V (browser will decide if only update or new)

function WM_setCookie (name, value, hours, path, domain) {
 if (typeof(hours) == "string") { var numHours = hours; } // he gave us date string
 else { var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString(); }
 document.cookie = name + "=" + escape(value) +
         ((hours)?  ";expires=" + numHours  : null ) +
         ((path)?   ";path=   " + path      : null ) +  //careful about the path
	 ((domain)? ";domain= " + domain    : null ); 
// did he accept a persistant cookie?   : nope a try session cookie (i.e. date=0)
if ( document.cookie == null ) {
  document.cookie = name + "=" + escape(value) +
          
         ((path)?   ";path=   " + path      : null ) + 
	 ((domain)? ";domain= " + domain    : null );  
                                                          }        //if he didn't like persistant
}
// get a SINGLE value from the cookie   or  .FALSE.
function WM_getCookieValue(name) {
  var firstChar, lastChar;
  var theBigCookie = document.cookie;    // Why not just use document.cookie? (objectness?)
  firstChar = theBigCookie.indexOf(name);
  if(firstChar != -1) {
    firstChar += name.length + 1;
    lastChar = theBigCookie.indexOf(";", firstChar);
    if(lastChar == -1) lastChar = theBigCookie.length;   // no ending ; so must be last n=v pair
    return theBigCookie.substring(firstChar, lastChar);
  } else { return false; } ;
}

//------------- now bump counter  cookie           6 months =24 * 7 *26 = 4368
var User, Cnt, LastVisit ;
LastVisit = new Date().getTime(); 
if(      !(  WM_getCookieValue("U") )   ){  User = LastVisit;
                                            WM_setCookie("U",User ,4368);
                                            WM_setCookie("C","0"  ,4368);  };
User= WM_getCookieValue("U");
Cnt = WM_getCookieValue("C");
document.cookie = "U=0"  + "; expires=Fri, 13-Apr-1970 00:00:00 GMT" ; //seems that there are
document.cookie = "C=0"  + "; expires=Fri, 13-Apr-1970 00:00:00 GMT" ;  //some junk cookies
document.cookie = "UC=0" + "; expires=Fri, 13-Apr-1970 00:00:00 GMT" ; //previous error
Cnt = parseInt( Cnt ); 
if(isNaN(Cnt) ) Cnt =1000;
if(Cnt>9999)    Cnt%=1000;   
Cnt++; 
if(isNaN(User) ) { User = LastVisit; WM_setCookie("x", LastVisit ,24) ; };
WM_setCookie("U",User     ,4368);   // put the UserID back out with new expire         
WM_setCookie("C",Cnt + "" ,4368);  
WM_setCookie("L",LastVisit,4368)
//                             ////  end of bump-cookie.js ///                    ////// 
