

function dates() {
var d = new Date(); //creates a new date
var dd = d.getDate(); //retrieves the date from the system
dd = dd + "";

if (dd.length == 1)
   {
   dd = "0" + dd;
   }
var MM = d.getMonth() + 1; //retrieves the month JS starts counting at zero, so add a 1 to start January at 1
MM = MM + "";

if (MM.length == 1)
   {
   MM = "0" + MM;
   }
var yyyy = d.getFullYear().toString().slice(2); //retrieves the year
var hr = d.getHours(); //retrieves the hour
hr = hr + "";

if (hr.length == 1)
   {
   hr = "0" + hr;
   }
var mm = d.getMinutes(); //retrieves the minute
mm = mm + "";

if (mm.length == 1)
   {
   mm = "0" + mm;
   }
var ss = d.getSeconds(); //retrieves the second
ss = ss + "";

if (ss.length == 1)
   {
   ss = "0" + ss;
   }
var now = yyyy + "" + MM + "" + dd + "" + hr + "" + mm + "" + ss; //formats the date*/

document.formName.ConfirmationNumber.value = now; //puts the value retrieved from the system in the sysDt field
}



function newCookie(name,value,days) {
 var days = 365;   // 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) {
    newCookie('theCompanyName', document.formName.CompanyName.value);     // add a new cookie as shown at left for every
    newCookie('theContact', document.formName.Contact.value);
	newCookie('thePhone', document.formName.Phone.value);
    newCookie('theExt', document.formName.Ext.value);
	newCookie('theemail', document.formName.email.value);
	newCookie('theemail2', document.formName.email2.value);// field you wish to have the script remember
}

function delMem(a) {
  eraseCookie('theCompanyName');   // make sure to add the eraseCookie function for every field
  eraseCookie('theContact');
  eraseCookie('thePhone');
  eraseCookie('theExt');
  eraseCookie('theemail');
  eraseCookie('theemail2');

   document.formName.CompanyName.value = '';   // add a line for every field
   document.formName.Contact.value = '';
   document.formName.Phone.value = '';
   document.formName.Ext.value = '';
   document.formName.email.value = '';
   document.formName.email2.value = '';}


function remCookie() {
document.formName.CompanyName.value = readCookie("theCompanyName");
document.formName.Contact.value = readCookie("theContact");
document.formName.Phone.value = readCookie("thePhone");
document.formName.Ext.value = readCookie("theExt");
document.formName.email.value = readCookie("theemail");
document.formName.email2.value = readCookie("theemail2");
}



// 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(dates);

addLoadEvent(function() {
  remCookie();
  
});