function setCookie(name,value)
{
  var next = new Date();
  next.setTime(next.getTime() + 100 * 3600 * 24 * 360); // increment one business year -- error free method
  document.cookie = name + '=' + value + '; expires=' + next.toGMTString() + '; path=/;';
}
function setTempCookie(name,value)
{
  document.cookie = name + '=' + value + '; path=/;';
}

function getCookie(name)
{
  var cookieFound = false;
  var start = 0;
  var end = 0;
  var cookieString = document.cookie;
  var i = 0;
  while (i <= cookieString.length)
  {
    start = i;
    end = start + name.length;
    if (cookieString.substring(start,end) == name)
    {
      cookieFound = true;
      break;
    }
    i++;
  }
  if(cookieFound)
  {
    start = end + 1;
    end = document.cookie.indexOf(";",start); 
    if (end < start)
      end = document.cookie.length; 
    return document.cookie.substring(start,end); 
  }
  return "";
}
function deleteCookie(name)
{
  var thepast = new Date();
  thepast.setTime(0); // set expirary to instantaneous
  document.cookie = name + '=; expires=' + thepast.toGMTString() + '; path=/;';
}
