function newCookie(name,value,days) {
 var days = 60;   // 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('theName', document.tstest.name.value);     // add a new cookie as shown at left for every
    newCookie('theConsultant', document.tstest.consultant.value);   // field you wish to have the script remember
    newCookie('thePhone', document.tstest.phone.value);
    newCookie('theFax', document.tstest.fax.value);
    newCookie('theMobile', document.tstest.mobile.value);
    newCookie('theEmail', document.tstest.email.value);
    newCookie('theEmailoffice', document.tstest.emailoffice.value);
    newCookie('thePostal', document.tstest.postal.value);
    newCookie('theCountry', document.tstest.country.value);
}

function delMem(a) {
  eraseCookie('theName');   // make sure to add the eraseCookie function for every field
  eraseCookie('theConsultant');
  eraseCookie('thePhone');
  eraseCookie('theFax');
  eraseCookie('theMobile');
  eraseCookie('theEmail');
  eraseCookie('theEmailoffice');
  eraseCookie('thePostal');
  eraseCookie('theCountry');

   document.tstest.name.value = '';   // add a line for every field
   document.tstest.consultant.value = '';
   document.tstest.phone.value = '';
   document.tstest.fax.value = '';
   document.tstest.mobile.value = '';
   document.tstest.email.value = '';
   document.tstest.emailoffice.value = '';
   document.tstest.postal.value = '';
   document.tstest.country.value = ''; }


function remCookie() {
document.tstest.name.value = readCookie("theName");
document.tstest.consultant.value = readCookie("theConsultant");
document.tstest.phone.value = readCookie("thePhone");
document.tstest.fax.value = readCookie("theFax");
document.tstest.mobile.value = readCookie("theMobile");
document.tstest.email.value = readCookie("theEmail");
document.tstest.emailoffice.value = readCookie("theEmailoffice");
document.tstest.postal.value = readCookie("thePostal");
document.tstest.country.value = readCookie("theCountry");
}

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();
  Tooltip.init();
}

);

