<!-- begin script

//////// JavaScript to save Personal Form data for recall on next use. //////

//////  3-Mar-1996 Copyright (C) 1996 by Geoff Inglis. You may use these
//////  routines in your pages (commercial or noncommercial) as long as
//////  you include these four lines. You may not Re-sell this code. 
//////  Questions (or if you use this code) E-mail: inglis@axsnet.com 

//////////  ** Here is the CookieName *///////
TheCookieName = 'NETSCAPE_LIVEWIRE.BigCookieinthesky';
numDays       = 183;  //Days 'till Cookie expires.(eg. 183 days = 6 months)

//** Edit this function to add form entries:
// Add one line like this for each form entry you wish to save in a Cookie
// WholeCookie = WholeCookie + '`' + document.login.Entry2.value;
//                                                     ||||||
// Entry2 (above) should be replaced by the "name value" for each form item.   
// Note that each form TYPE has a slightly different method. In my
// Next version (depending on Netscape 3.0's javascript), I will automatically
// test the TYPE and do the correct thing. At that time editing this routine
// for your OWN form should be made MUCH easier!!! 3.0 has FORM TYPE. Yea!

// Write One Big Cookie with all the values in it.
function WriteOneBigCookie () {
   var expire = new Date ();
   expire.setTime (expire.getTime() + (numDays * 24 * 3600000)); //6 months from now!
//                                     (dd) (hr) (ms in hr)
   var WholeCookie = expire ;

//Text entry
   WholeCookie = WholeCookie + '`' + document.login.clientcode.value;

//Put cookie in the Oven Bake 'till done.
  document.cookie = TheCookieName +"=" + escape (WholeCookie) +
                    "; expires=" + expire.toGMTString() ;

// alert('Your Personal information has been stored, ready for the next time you use this page.');
}

//**Edit this function for each corresponding function above.
//  They are numbered in the order they are placed in the Cookie
//  starting with zero which is ALWAYS the expriation date.

function UpdateForm () {

//Get the Cookievalue then use a Cookie Cutter to slice it up in an array.
MakeCookieArray(GetCookie(TheCookieName));

//TEXT input Form

//alert('ckArray: ' + ckArray[0]);
 if (ckArray[0] != "*") {

  document.login.clientcode.value   = ckArray[1];
 }
}


//Get the cookie from a list of possible cookies. Honest!
function GetCookie (CookieName) {
  var cname = CookieName + "=";
  var i = 0;
  while (i < document.cookie.length) {
    var j = i + cname.length;
    if (document.cookie.substring(i, j) == cname){
        var leng = document.cookie.indexOf (";", j);
        if (leng == -1) leng = document.cookie.length;
        return unescape(document.cookie.substring(j, leng));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; //thats -1 plus 1, duh.
  }
  return "*";
}

//Set the Cookie with expire date in the past - 2 days to get it for sure.
function DelEatCookie (name) {
  var expire = new Date();
  expire.setTime (expire.getTime() - 2 * 86400001);  //-2 days ago. Stale Cookie
  document.cookie = name + "=*; expires=" + expire.toGMTString();
}

//Parse Big  Cookie. A CookieCutter if you will.
function MakeCookieArray(cookieValue) {
  var i = 0,indx = 0, citemlen =0;
  ckArray = new Array();
   if ( cookieValue == null ) {ckArray[0]= "*";return}//Data has expired or never entered.
   if ( cookieValue == "*"  ) {ckArray[0]= "*";return}//Data has expired or never entered.
  while (citemlen < cookieValue.length) {
    citemlen=(cookieValue.indexOf("`", indx)>0)
             ?cookieValue.indexOf("`", indx):cookieValue.length;
    ckArray[i]= cookieValue.substring(indx, citemlen); i++;
    indx = citemlen + 1;
  }
}

// end script -->

