
currentY = 0;
lastScrollY = 30;

sLayer1 = "";
sLayer2 = "";
iFlag=0;
iPos=0;


function UserInfo()
{
  this.appName = null;
  this.appVersion = null;

  if (navigator.appName != null)
  {
    if (navigator.userAgent.indexOf("Opera") != -1)
      this.appName = "Opera";
    else
      this.appName = navigator.appName;
  }

  if (navigator.appVersion != null)  // get browser version number
  {
    this.appVersion = navigator.appVersion;
    var index = this.appVersion.indexOf(" ");
    this.appVersion = this.appVersion.substring(0,index);
    if (this.appName.indexOf("Microsoft Internet Explorer") != -1) // fix for IE 5.0 appVersion bug
    {                                         // (returns 4.0 version number)
      var i=navigator.userAgent.indexOf("MSIE");
      var j=navigator.userAgent.indexOf(";",i);
      this.appVersion = navigator.userAgent.substring(i+5,j);
    }
  }
}

var user = new UserInfo();

if (user.appName=="Microsoft Internet Explorer")
  sAppname="Microsoft Internet Explorer";
else if (user.appName=="Netscape")
  sAppname="Netscape";
else if (user.appName=="Opera")
  sAppname="Opera";
else
  sAppname="Unknown";

if (user.appVersion.indexOf(".")!=-1)
  sVersion=user.appVersion.substring(0,user.appVersion.indexOf("."));
else
  sVersion=user.appVersion.substring(0);

if (sAppname=="Microsoft Internet Explorer" && sVersion>=4 && screen.height>700)
  script=true;
else
  script=false;

// current scroll layer...

function adjust_toc()
{
  if (!script)
    return;
  // has the last layer been loaded? If not, HTML page gets currently loaded, so please return, i.e. wait for the next cycle.
  if (document.getElementById!=null)
  {
    if (document.getElementById('content')==null)
      return;
  }
  else if (document.all!=null)
  {
    if (document.all['content']==null)
      return;
  }
  else if (document.layers!=null)
  {
    if (document.layers['content']==null)
      return;
  }
  if (iFlag>0)
  {
    // scroll another layer into view: sLayer1 is visible, but sLayer2 should be made visible...
    if (iFlag==1)
    {
      // First part: Scroll old layer out of view...
      iPos=iPos-10;
      if (document.getElementById!=null)
      {
        document.getElementById(sLayer2).style.top=lastScrollY;
        document.getElementById(sLayer1).style.left=iPos;
      }
      else if (document.all!=null)
      {
        document.all(sLayer2).style.pixelTop =document.all(sLayer1).style.pixelTop;
        document.all(sLayer1).style.left=iPos;
      }
      else if (document.layers!=null)
      {
        document.layers[sLayer2].top = document.layers[sLayer1].top;
        document.layers[sLayer1].left=iPos;
      }
      if (iPos<=-180)
        iFlag=2;
    }
    else if (iFlag==2)
    {
      iPos=iPos+5;
      if (document.getElementById!=null)
        document.getElementById(sLayer2).style.left=iPos;
      else if (document.all!=null)
        document.all(sLayer2).style.left=iPos;
      else if (document.layers!=null)
        document.layers[sLayer2].left=iPos;
      if (iPos==5)
      {
        sScrollLayer=sLayer2;
        iFlag=0;
      }
    }
  }
  if (iFlag==0)
  {
    if (document.all!=null)
      diffY=document.body.scrollTop;
    else if (document.layers!=null)
      diffY = window.pageYOffset;
    else if (document.getElementById!=null)
      diffY = window.pageYOffset;
    else
      diffY=0;
    diffY+=30;
    if(diffY != lastScrollY)
    {
      if (diffY - lastScrollY>0)
      {
        rolling = 0.1*(diffY - lastScrollY);
        rolling = Math.ceil(rolling);
      }
      else
      {
        rolling = -0.1*(lastScrollY-diffY);
        rolling = Math.floor(rolling);
      }
      if (document.getElementById!=null) document.getElementById(sScrollLayer).style.top = lastScrollY + rolling;
      else if (document.all!=null) document.all(sScrollLayer).style.pixelTop += rolling;
      else if (document.layers!=null) document.layers[sScrollLayer].top += rolling;
      lastScrollY = lastScrollY + rolling;
    }
  }
}

function info(st)
{
  if (script=="1")
  {
    window.status=st;
    return true;
  }
}
function infoff(src)
{
  if (script)
    window.status='';
}

function show_layer(sLayerNameHide,sLayerNameShow)
{
  if (script==true)
  {
  	sLayer1=sLayerNameHide;
	  sLayer2=sLayerNameShow;
  	iPos=0;
	  iFlag=1;
	}
	else
	{
    if (document.getElementById!=null)
    {
	    document.getElementById(sLayerNameHide).style.visibility="hidden";
	    document.getElementById(sLayerNameShow).style.visibility="visible";
	    document.getElementById(sLayerNameShow).style.left=5;
    }
    else
    if (document.all!=null)
    {
	    document.all(sLayerNameHide).style.visibility="hidden";
	    document.all(sLayerNameShow).style.visibility="visible";
	    document.all(sLayerNameShow).style.left=5;
    }
    else
    if (document.layers!=null)
    {
	    document.layers[sLayerNameHide].visibility="hide";
	    document.layers[sLayerNameShow].visibility="visible";
	    document.layers[sLayerNameShow].left=5;
    }
	}
}

if (script==true)
{
  ret = window.setInterval("adjust_toc()",20);
}

// Sets cookie values. Expiration date is optional//
function setCookie(name, value, expire)
{
  document.cookie = name + "=" + escape(value)
  + ((expire == null) ? "" : ("; expires=" + expire))
}

function getCookie(Name)
{
var search = Name + "="

  if (document.cookie.length > 0)
  { // if there are any cookies
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { // if cookie exists
      offset += search.length;
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
        end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end));
    }
  }
  return(" ");
}

var isCookie = false;

if (document.cookie != null)
{
  document.cookie = "name=value";  // cookies enabled?
  if (document.cookie != "")
    isCookie=true;
}

if (isCookie)
{
  sCookie=getCookie("CPHOME12");
  if (sCookie==" ")
  {
    ud=new Date();
    mstr=ud.getDate() + "." + ud.getMonth() + "." + ud.getYear() + "_" + ud.getHours() + "." + ud.getMinutes() + "." + ud.getSeconds();
    setCookie("CPHOME12",mstr,"Tuesday, 04-APR-2020 00:00:00 GMT");
  }
}
else
  sCookie="CookieDisabled";

