function getCookieVal (offset)
{
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name)
{
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie(name,value,time,calling)
{
  exp = new Date();
  if((name==null)||(value==null)) return false;
  if(time==null) time=365*86400000;
  if(time==-1)
  {
    exp.setTime(1);
  }
  else
    exp.setTime(exp.getTime()+time);

  document.cookie=escape(name)+"="+escape(value)+
    "; "+"expires="+exp.toGMTString() +
    "; path=/";
  if (calling != null)
    alert (document.cookie + " " + calling)
  return true;
}

function checkSession(secs, startdate)
{
  timeB = new Date();
  timeBsec = Math.round(timeB/1000);
  if (startdate == "" || startdate == 0)
  {
    SetCookie("session_cookie", timeBsec)
    return 1
  }
  timeA = new Date(startdate * 1000)
  diff = timeB - timeA
  diff = Math.round (diff / 1000)
  if (diff > secs)
  {
    return 0;
  }
  return 1;
}

function SetSessionCookie(tm)
{
  SetCookie("session_cookie", tm)
}

function details(part)
{
  var title=part + " Details"
  if (! window.focus) return;
  var myWin=open("", "Details",
      "height=450,width=510, dependent=yes, scrollbars=yes");
  myWin.location.href="http://www.clscatalog.com/htdocs/catalog/smalldetail.phtml?type=docs&part=" + part;
  myWin.focus();
  this.target=title;
}

