/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Cookie script - Scott Andrew
Popup script, Copyright 2005, Sandeep Gangadharan */

function newCookie(name,value,days) {
 var days = 20;   // the number at the left reflects the number of days for the cookie to last
                 // modify it according to your needs
 if (days) {
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = "; expires="+date.toGMTString(); }
   else var expires = "";
   document.cookie = name+"="+value+expires+"; path=/"; }

function readCookie(name) {
   var nameSG = name + "=";
   var nuller = '';
  if (document.cookie.indexOf(nameSG) == -1)
    return nuller;

   var ca = document.cookie.split(';');
  for(var i=0; i<ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
  if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
    return null; }

function eraseCookie(name) {
  newCookie(name,"",1); }

function toMem(a) {
      // field you wish to have the script remember
	newCookie('theEmail', document.form.PRIMARY_EMAIL_ADDR.value); 
	newCookie('theFirstname', document.form.FIRST_NAME.value); 
	newCookie('theLastname', document.form.LAST_NAME.value); 
	newCookie('theConame', document.form.CoNAME.value); 
	newCookie('thePhoneNo', document.form.PhoneNo.value); 
	newCookie('thenumUsers', document.form.numUsers.value); 
}

function delMem(a) {
  
  eraseCookie('theEmail');
eraseCookie('theFirstname');
eraseCookie('theLastname')
eraseCookie('theConame')
  eraseCookie('thePhoneNo')
  eraseCookie('thenumUsers')
   document.form.PRIMARY_EMAIL_ADDR.value = '';
 document.form.FIRST_NAME.value = '';
  document.form.LAST_NAME.value = '';
   document.form.CoNAME.value = '';
   document.form.PhoneNo.value = '';
   document.form.numUsers.value = '';
   }

function remCookie() {

document.form.PRIMARY_EMAIL_ADDR.value = readCookie("theEmail");
document.form.FIRST_NAME.value = readCookie("theFirstname");
document.form.LAST_NAME.value = readCookie("theLastname");
document.form.CoNAME.value = readCookie("theConame");
document.form.PhoneNo.value = readCookie("thePhoneNo");
document.form.numUsers.value = readCookie("thenumUsers");
}

// Multiple onload function created by: Simon Willison
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  remCookie();
});

