// Profile-Like Functions which use cookies
// Written by D. Burger, EMail: dietmar.burger at nickl.de

function ProfileGetProperty(strEntry, strDefaultValue)
  {
  var strCookie="";
  var nColStart;
  var nColEnd;
  var nLen;

  if(document.cookie)
    strCookie=document.cookie;
  nColStart=strCookie.indexOf(strEntry+"=");
  nLen=strCookie.length;
  if(nColStart>=0)
    {
    nColEnd=nLen;
    nColEnd=strCookie.substring(nColStart,nColEnd).indexOf(";");
    if(nColEnd==-1)
      nColEnd=nLen;
    else
      nColEnd+=nColStart;
    strCookie=strCookie.substring(nColStart+strEntry.length+1,nColEnd);
    }
  else
    strCookie=strDefaultValue;
  return(strCookie);
  }


function ProfileSetProperty(strEntry, strValue)
  {
  var strCookie="";
  var nColStart;
  var nColEnd;
  var nLen;
  var dtNow=new Date;
  var dtExpiration=new Date(dtNow.getTime()+1000*60*60*24*3);

  if(document.cookie)
    strCookie=document.cookie;
  nColStart=strCookie.indexOf(strEntry+"=");
  nLen=strCookie.length;
  if(nColStart>=0)
    {
    nColEnd=nLen;
    nColEnd=strCookie.substring(nColStart,nColEnd).indexOf(";");
    if(nColEnd==-1)
      nColEnd=nLen;
    else
      nColEnd+=nColStart+1;
    }
  strCookie=strCookie.substring(0,nColStart)+strEntry+"="+strValue+";"+strCookie.substring(nColEnd,nLen)
  if(strCookie.indexOf("expires=")<0)
    strCookie+="expires="+dtExpiration.toGMTString();
  document.cookie=strCookie;
  }


