function newCookie(name,value,days) {
 var days = 1;   // 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()+(60*60*1000));
   var expires = "; expires="+date.toGMTString(); }
   else var expires = "";
   document.cookie = name+"="+value+expires+"; path=/";
   // alert(document.cookie);
   
   }
   
function newCookie_default(name,value,days) {
 var days = 1;   // 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()+(60*60*24*days));
   var expires = "; expires="+date.toGMTString(); }
   else var expires = "";
   document.cookie = name+"="+value+expires+"; path=/"; 
   
  // alert(document.cookie);
   }
   
function newCookieperm(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()+(60*60*24*days));
   var expires = "; expires="+date.toGMTString(); }
   else var expires = "";
   document.cookie = name+"="+value+expires+"; path=/"; 
   // alert(document.cookie);
   }


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('theW2GoUserName', document.form.username.value);    // add a new cookie as shown at left  
                                                        // for every field you wish to have the script remember
}

function tokeepLogin(field,fieldValue) {
    newCookie(field, fieldValue);    // add a new cookie as shown at left  
                                                        // for every field you wish to have the script remember
}

function tokeepLoginPerm(field,fieldValue) {
    newCookieperm(field, fieldValue);    // add a new cookie as shown at left  
                                                        // for every field you wish to have the script remember
}


function delMem(a) {
  eraseCookie('theW2GoUserName');   // make sure to add the eraseCookie function for every field
  document.form.username.value = '';   // add a line for every field
}


function remCookie() {
document.form.username.value = readCookie("theW2GoUserName");
}

function doClick(buttonName,e)
{
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
    var key;

    if(window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox
   
    if (key == 13)
    {
        //Get the button the user wants to have clicked
         var btn = document.getElementById(buttonName);
         if (btn != null)
          { //If we find the button click it
              btn.click();
              event.keyCode = 0
          }
     }
}



