// Copyright 2003, NandoMedia InSite registration system

function GetCookie(Name) {
  var cookies=document.cookie;
  if (cookies.indexOf(Name+'=')==-1) return null;
  var start=cookies.indexOf(Name+'=')+(Name.length+1);
  var finish=cookies.substring(start,cookies.length);
  finish=(finish.indexOf(';')==-1)?cookies.length:start+finish.indexOf(';');
  return unescape(cookies.substring(start,finish));
}
function SaveCookie(cname,cvalue,cdays,cpath) {
 ex = new Date; ex.setTime(ex.getTime() + (cdays*86400000));
 if (cpath == null) { cpath = "/" }
 else { cpath = "; path=" + cpath }
 document.cookie=cname + '=' + cvalue + '; expires=' + ex.toGMTString() + cpath + "; domain=.chron.com";
}


// Cookie Cleanup Script
var insitecookie="chron_user_auth";
var pluckcookie="hd";
var loginpage="http://www.chron.com/apps/pluck/login.mpl?url=";
var tmpvalue3=0;

var thePluckCookie = GetCookie(pluckcookie);
if (thePluckCookie == ".null") {
   thePluckCookie = "";
}
var theInsiteCookie= GetCookie(insitecookie);
if (theInsiteCookie == ".null") {
   theInsiteCookie = "";
}
//alert("PluckCookie: " + thePluckCookie + "\nInsiteCookie: " + theInsiteCookie);

// silly logic...
var redir = 0; // do nothing
if (theInsiteCookie) {
   if (! thePluckCookie) {
     document.location=loginpage+escape(document.location);
   }
} else {
   if (thePluckCookie) {
     SaveCookie(pluckcookie,'',0,'/');
     //document.location=loginpage+escape(document.location);
   }
}
