
// workaround 4 IE flushing bug: wait 0.1sec to dialog closes, before seting cookie
// old simply sets: top.document.cookie=(cookieName+"="+cookieValue+";EXPIRES="+expDate.toGMTString()+";PATH=/");

var timeID=new Object();
var jSessionCookie="";
var languageCookie="";
function setCookie(cookieName,cookieValue)
{
 jSessionCookie=getCookie("JSESSIONID");
 languageCookie=getCookie("LANG");
 pointPos=cookieName.indexOf(".");
 if(pointPos>-1)
 {
   do
   {
    eval("top."+cookieName.substring(0,pointPos)+"=new Object()");
    pointPos=cookieName.indexOf(".",pointPos+1);
   }
   while(pointPos>-1);
 }
 eval("top."+cookieName+"='"+cookieValue+"'");
 expDate=new Date();
 expDate=new Date(expDate.getYear()+1,expDate.getMonth(),expDate.getDate());
 timeId_=top.setTimeout("setCookie_('"+cookieName+"','"+cookieValue+";EXPIRES="+expDate.toGMTString()+";PATH=/')",100);
 eval("top."+cookieName+"TimeID=timeId_");
}

function setCookie_(cookieName,cookieValue)
{
 top.clearTimeout(eval("top."+cookieName+"TimeID"));
 top.document.cookie=(cookieName+"="+cookieValue);
 if(cookieName!="JSESSIONID")
  top.document.cookie=("JSESSIONID="+jSessionCookie);
 if(cookieName!="LANG")
  top.document.cookie=("LANG="+languageCookie);
}

function getCookie(cookieName)
{
 if(eval("(typeof top."+cookieName+")=='undefined'"))
 {
  var cLen=top.document.cookie.length;
  var i=0;
  while(i<cLen)
  {
   var j = i+cookieName.length;
   if (top.document.cookie.substring(i,j+1)==(cookieName+"="))
   {
    var cEnd=top.document.cookie.indexOf(";",j);
    if (cEnd==-1)
      cEnd=top.document.cookie.length;
    cookieValue=unescape(top.document.cookie.substring(j,cEnd));
    if(cookieValue.indexOf("=")!=-1)
       cookieValue=cookieValue.substring(cookieValue.indexOf("=")+1);
    if(cookieValue.indexOf(";")!=-1)
       cookieValue=cookieValue.substring(0,cookieValue.indexOf(";"));
    pointPos=cookieName.indexOf(".");
    if(pointPos>-1)
    {
      do
      {
       eval("top."+cookieName.substring(0,pointPos)+"=new Object()");
       pointPos=cookieName.indexOf(".",pointPos+1);
      }
      while(pointPos>-1);
    }
    eval("top."+cookieName+"='"+cookieValue+"'");
   }
   i++;
  }
 }
 return eval("top."+cookieName);
}


function setPageCookie(cookieName,cookieValue)
{
 expDate=new Date();
 expDate=new Date(expDate.getYear()+1,expDate.getMonth(),expDate.getDate());
 document.cookie=(cookieName+"="+cookieValue+";EXPIRES="+expDate.toGMTString()+";PATH="+window.location.pathname);
 if(cookieName!="JSESSIONID")
  top.document.cookie=("JSESSIONID="+jSessionCookie);
 if(cookieName!="L")
  top.document.cookie=("L="+languageCookie);
}

function getPageCookie(cookieName,cookieValue)
{
  var cLen=document.cookie.length;
  var i=0;
  while(i<cLen)
  {
   var j = i+cookieName.length;
   if (document.cookie.substring(i,j+1)==(cookieName+"="))
   {
    var cEnd=document.cookie.indexOf(";",j);
    if (cEnd==-1)
      cEnd=document.cookie.length;
    cookieValue=unescape(document.cookie.substring(j,cEnd));
    if(cookieValue.indexOf("=")!=-1)
       cookieValue=cookieValue.substring(cookieValue.indexOf("=")+1);
    if(cookieValue.indexOf(";")!=-1)
       cookieValue=cookieValue.substring(0,cookieValue.indexOf(";"));
    return cookieValue;
   }
   i++;
  }
  return null;
}
window.status="Done";