
var ie=document.all?1:0

var ns6=document.getElementById&&!document.all?1:0

var ns4=document.layers?1:0

var timerID=0;

var reentrance=0;

var step=5,latency=30;

var secCur=null,secLast=null;

var maxHeight, curHeight, curSelectedLink, curStyleIndex;




function Init() {

  //alert("count:"+document.all.length);

  for (i=0; i< menuItemCount; i++) {

    //alert(document.all["sec"+i].id+"="+document.all["sec"+i].style.height);

    document.all["sec"+i].old_height=heights[i-1];//document.all["sec"+i].height;

    //document.all["sec"+i].expanded=false;

  }
}


function doSection(sNum){

  //display the section if it's not displayed; hide it if it is displayed

  if (!ie) { // damned Netscape goes here

    if (ns4) {

        alert("This page works incorrectly on Netscape4");

        return;

    } else {

        //alert("NS6");

      secNum =	document.getElementById("sec"+sNum);

    }

  } else {

    secNum=document.all["sec"+sNum];

    //alert("IE doSection fired:"+secNum.id);

  }



  if (reentrance || (secLast != null && secNum == secLast)) return;

  reentrance=1;

  //alert("doSec: Num:"+ secNum);

  if (secLast != null) {

    //alert("last:"+secLast.id);

    secCur=secLast;

    curHeight=parseInt(secCur.style.height);

    timerID=setInterval("collapse()",latency);

  } else {

    secCur=secNum;

    secCur.style.display="";

    maxHeight=getHeight(secNum);

    curHeight=0;

    timerID=setInterval("expand()",latency);

  }

  secLast=secNum;

  //getHref(secNum);

  //reentrance=0;

}



function expand()

{

  //alert("enlarge"+secCur.style.height);

  if (curHeight>=maxHeight) {

    clearInterval(timerID);

    reentrance=0;

  } else {

    curHeight += step;

    secCur.style.height = curHeight;

  }

}



function collapse()

{

  //alert("enlarge"+secCur.style.height);

  if (curHeight <= step) {

    clearInterval(timerID);

    secCur.style.display="none";

    secCur.style.height=1;

    secCur=secLast;

    secCur.style.display="";

    maxHeight=getHeight(secNum);

    timerID=setInterval("expand()",latency);

  } else {

    curHeight -= step;

    secCur.style.height = curHeight;

  }

}



function getHeight(sec) {

  return heights[parseInt(sec.id.slice(3),10)];

}



function getHref(secNum) {

  i=parseInt(secNum.id.slice(3))-1;

  parent.frames["main"].location=hrefs[i];

  return hrefs[i];

}



function OnSectionClick(oObj, iSec, iStyleInd, sUrl,sTarget,MenuLangPrefix)

{  

  if( sUrl != '' )

  {

    if( sTarget == '@' )

      window.location.href = sUrl;

    else if( sTarget != '' )

      window.top.frames[sTarget].location.href = sUrl;

    else

      window.open(sUrl);

  }

  if (curSelectedLink != null) curSelectedLink.className=MenuLangPrefix + 'MainMenuLink_' + curStyleIndex;
  oObj.className= MenuLangPrefix + 'MainMenuLinkOn_' + iStyleInd;
  curSelectedLink = oObj;
  curStyleIndex=iStyleInd;
  
  doSection(iSec);

}

