/***  (C)Stephen Chalmers 

 Info: www.hotspot.freeserve.co.uk/scripterlative 

***** DO NOT EDIT BELOW THIS LINE ******/ 
 
var XCookie=/*2843295374657068656E204368616C6D657273*/
{
 supportStatus:false, escFunc:encodeURIComponent||escape, unescFunc:decodeURIComponent||unescape,
   
 read:function(cookieName) /** Returns the value of named cookie or "" on failure ****/
 {
  var cValue="";
 
  if(typeof document.cookie!='undefined')
   cValue=(cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : "";
  
  return this.unescFunc(cValue);
 },

 set:function(cName, cValue, duration, path, domain, secure)  /*** Set a cookie called cName. duration==days ***/
 {
  if(typeof path!='string' || !/\S/.test(path))
   path='/';   
   
  if(!this.supportStatus) 
   this.supportStatus=this.enabled();
   
  if(this.supportStatus)
  {
   var cs="", expDate=new Date();
   
   expDate.setDate(expDate.getDate() + duration);
   
   cValue = this.escFunc(cValue);
      
   cs=cName+"="+cValue+';'+'path='+path;
   
   if(duration)
    cs+=";expires=" + expDate.toGMTString();
   
   if(domain) 
    cs += ';domain=' + domain;
   
   if(secure==true)
    cs += ';secure' ;
   
   document.cookie=cs; 
  } 
  
  return this.read(cName);
  
 },

 /**Refresh the duration of an existing cookie cName by duration days**/
  
 refresh:function(cName, duration, path, domain, secure) 
 {              
  if(path==undefined)
   path='/';
     
  var val = this.read(cName);
  
  if(val != "")
   this.set(cName, val, duration, path, domain, secure);
   
  return this.read(cName); 
 },
 
 refreshAll:function( days, path, domain, secure )
 {
  var rslt, rxp=/([^;=\s]+)=([^;]*);?/g, cString, count=0;
  
  if(days==undefined)
   days=30;
  
  if( typeof(cString=document.cookie)=='string' )
   while( (rslt=rxp.exec(cString)) )
   {
    this.set( rslt[1], rslt[2], days, path, domain, secure );
    count++;
   }
   
  return count; 
 },

 bump:function( cName, increment, duration, path, domain, secure )  
 {                     /** Increment the numeric integer value of an existing **/                            
  if(path==undefined)  /** cookie by value 'increment'. If cookie does not exist **/                            
   path='/';           /** create it with an initial value of increment. **/
    
  var v;   
  
  this.set( cName, !isNaN( v=parseInt(this.read( cName ), 10) ) ? v+increment : increment, duration, path, domain, secure );
 },
 
 exists:function(cName) /**Returns existence status of cookie cName**/
 {
  return((document.cookie && document.cookie.indexOf(cName)>-1)?true:false );
 },

 clear:function(cName, path)
 {
  this.set(cName,0,-1,path);
 },

 clearAll:function(path)
 {
  this.refreshAll(-1, path||'/'); 
 },

 enabled:function()
 {
  var rv=false, expDate=new Date(), cString;
  
  if(typeof document.cookie!='undefined')
  {
   expDate.setDate(expDate.getDate() -1);
  
   for(var i=0; this.exists("XCookieSupport"+i); i++)
   ;
  
   cString="XCookieSupport"+i;
   
   document.cookie=cString + "=OK";
 
   rv=this.exists("XCookieSupport"+i);
  
   document.cookie=cString+"=OK;expires="+expDate.toGMTString();
  }

  return rv;
 }
 
}


function clearAllCookies()
{
 var rslt, rxp=/([^;=\s]+)=([^;]*);?/g, cString, 
     thePast=new Date();
  
 thePast.setDate(thePast.getDate() -1);
 
 thePast=thePast.toGMTString();
 
 if( typeof(cString=document.cookie)=='string' )
  while( (rslt=rxp.exec(cString)) )
   document.cookie=rslt[1]+'='+rslt[2]+';expires='+thePast;
}

/*** End of listing ******/ 