var dom = (document.getElementById) ? true:false;
var ns6 = (dom && navigator.appName=="Netscape" && parseInt(navigator.appVersion)>=5) ? true:false;
var ns4 = (document.layers && parseInt(navigator.appVersion)>=4) ? true:false;
var ie4 = (document.all && !dom) ? true:false;
var browser=((dom || ns4 || ie4) && parseInt(navigator.appVersion)>=4)

var blnActivated=false;
var strVisible = "visible";
var strHidden = "hidden";
        if(ns4)
        {
                strVisible = "show";
                strHidden = "hide";
        }
/************************************************************************************
Making cross-browser objects
************************************************************************************/
function makeMenu(obj,nest){
        nest=(!nest) ? '':'document.'+nest+'.'

        if(dom)
        {
                this.css=document.getElementById(obj).style;
                this.ref=eval('document');
                this.height=document.getElementById(obj).offsetHeight;
                this.width=document.getElementById(obj).offsetHeight;
                this.x=this.css.left;
                this.y=this.css.top;
        }
        if(ns4)
        {
                this.css=eval(nest+'document.'+obj);
                this.ref=eval(nest+'document.'+obj+'.document');
                this.height=this.ref.height;
                this.width=this.ref.width;
                this.x=this.css.left;
                this.y=this.css.top;
        }
        if(ie4)
        {
                this.css=eval('document.all.'+obj+'.style');
                this.ref=eval('document');
                this.height=eval(obj+'.offsetHeight');
                this.width=eval(obj+'.offsetWidth');
                this.x=this.css.pixelLeft;
                this.y=this.css.pixelTop;
        }
        this.hideIt=b_hideIt;
        this.showIt=b_showIt;
        this.vis=b_vis;
        this.moveIt=b_moveIt
        return this;
}
function b_showIt(){this.css.visibility=strVisible;}
function b_hideIt(){this.css.visibility=strHidden;}
function b_vis(){if(this.css.visibility==strHidden) return true;}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}

/************************************************************************************
Initiating the page. Just add to the arrays here to get more menuitems
and add divs in the page
************************************************************************************/

var active=false;
var activeNr=-1;
var intTimeOutCount=0;

function init()
{
        var intX=0;
        if(document.all)
                intX=document.body.clientWidth;
        else
        {
                intX=window.innerWidth;
                if(ns6)
                        intX-=15;
                else
                        intX-=16;
        }

                 intX=59;

    aSub = new Array();
    aSub[0] = 65;
    aSub[1] = 65+28;
    aSub[2] = 65+28+28;
    aSub[3] = 65+28+28+28;
    aSub[4] = 65+28+28+28+28;
   // aSub[5] = 65+28+28+28+28+28;
   // aSub[6] = 65+28+28+28+28+28+28;

    oSub=new Array();
    oSub[0]=new makeMenu('divSub1','');
    oSub[1]=new makeMenu('divSub2','');
    oSub[2]=new makeMenu('divSub3','');
    oSub[3]=new makeMenu('divSub4','');
    oSub[4]=new makeMenu('divSub5','');
   // oSub[5]=new makeMenu('divSub6','');
   // oSub[6]=new makeMenu('divSub7','');

    for(i=0;i<oSub.length;i++){ oSub[i].moveIt(121, intX+aSub[i]) }
    blnActivated=true;
}
/************************************************************************************
This is the function that changes the sub menus to folded or unfolded state.
************************************************************************************/
function menu_over(num)
{
    if(!blnActivated || !oSub[num])
                return;

    if(num==activeNr)
    {
                active=true;
                return;
    }

    active = true;
    activeNr = num;

    if(browser)
    {
                for(i=0;i<oSub.length;i++)
        {
            if(i!=num)
            {
                                imgInact('img'+i);
                                oSub[i].hideIt()
            }
        }
        imgAct('img'+num);
        oSub[num].showIt();
    }
}

function menu_out(num)
{
    if(!blnActivated || !oSub[num])
                return;

    active = false;
        intTimeOutCount++;
    setTimeout("CheckActivity()",800);
}

function submenu_over(num,sub)
{
    if(!oSub[num])
                return;
    active = true;
        oSub[num].ref["img"+num+sub].src = eval('img'+num+sub+'on.src');
}

function submenu_out(num,sub)
{
        if(!oSub[num])
                return;

        oSub[num].ref["img"+num+sub].src = eval('img'+num+sub+'off.src');
    active = false;
        intTimeOutCount++;
    setTimeout("CheckActivity()",800);
}

function CheckActivity()
{
        intTimeOutCount--;
        if(intTimeOutCount>0) return;
    if(!active && activeNr>-1)
    {
                again=0;
        imgInact('img'+activeNr);
        HideAll();
        }
}

function Hide(num)
{
    if( !oSub[num])
        return;
    oSub[num].hideIt();
}

function HideAll()
{
    if(activeNr!=-1)
    {
        activeNr = -1;
                for(i=0;i<oSub.length;i++) {oSub[i].hideIt();}
    }
}

function window_resize()
{
        document.location.reload(false);
}

//Initiating the menus onload, if it's a 4.x+ browser.
if(browser)
{
    onload=init;
        onresize=window_resize;
}
