// called in body onload()
var headerRotationFreq = 10000;
var headerCount=5;
	var AgntUsr=navigator.userAgent.toLowerCase();
	var DomYes=document.getElementById?1:0;
	var NavYes=AgntUsr.indexOf('mozilla')!=-1&&AgntUsr.indexOf('compatible')==-1?1:0;
	var ExpYes=AgntUsr.indexOf('msie')!=-1?1:0;
	var Opr=AgntUsr.indexOf('opera')!=-1?1:0;
	var DomNav=DomYes&&NavYes?1:0;
 	var DomExp=DomYes&&ExpYes?1:0;
	var Nav4=NavYes&&!DomYes&&document.layers?1:0;
	var Exp4=ExpYes&&!DomYes&&document.all?1:0;
	var PosStrt=(NavYes||ExpYes)&&!Opr?1:0;

function initHomePage()
{
    // preloadImages(MPImgNames);
    setTimeout("doHeader()",headerRotationFreq);    
}

function preloadImages(ImgNames)
{
    if (document.images)
    {
        var i, len=MPImgNames.length;
        var Imgs=new Array(len);
        for (i=0; i < len; i++)
        {
            Imgs[i]= new Image();
            Imgs[i].src = ImgNames[i];
        }
    }
}

function swapPic(imageSrc) {
	layerName = 'pic';
	imageName = 'pic1';
	if (imageSrc != null) {
	    if (Nav4) theImage = eval('document.layers.' + layerName + '.document.images.' + imageName);	
	    else theImage = eval('document.images.' + imageName);
	    theImage.src = imageSrc;
    }
}

var headerIndex=0;
function doHeader() {
    if (headerCount > 1)
    {
        var hideHeaderName='header' + headerIndex;
        headerIndex = (headerIndex + 1) % headerCount;
        var showHeaderName='header' + headerIndex;

        hide(hideHeaderName);
        show(showHeaderName);
        setTimeout("doHeader()", headerRotationFreq);
    }
}

function getObject(obj){
	if (Nav4) {
		var coll = 'layers[\'';
		var styleObj = '\']';
	} else if (DomYes) {
		var coll="getElementById('";
		var styleObj = "').style";
	} else { //IE4
		var coll = 'all.';
		var styleObj = '.style';
	}
	
	var theObj;
	if (typeof obj == 'string') {
		theObj = eval("document." + coll + obj + styleObj);
	} else {
		theObj = obj;
	}
	return theObj;
}


function hide(obj) {
	var theObj = getObject(obj);
	if (theObj != null) {
	theObj.visibility = "hidden";
	}
}

function show(obj) {
	var theObj = getObject(obj);
	if (theObj != null) {
	theObj.visibility = "visible";
	}
}	

// PopUp functions                        
function showPopUp(i)
{
    if (PopUpCntnrs && (i < PopUpCntnrs.length))
    {
        var CntnrPtr = PopUpCntnrs[i];
        Initiate(); // hide left nav
        if (CurrentPopUp && (CurrentPopUp != CntnrPtr)) hidePopUp();
        CurrentPopUp=CntnrPtr;
        var CntnrStyle = Nav4?CntnrPtr:CntnrPtr.style;
        CntnrStyle.visibility = M_Show;
    }
}

function hidePopUp()
{
    if (CurrentPopUp)
    {
        var CntnrStyle = Nav4?CurrentPopUp:CurrentPopUp.style;
        CntnrStyle.visibility = M_Hide;
        CurrentPopUp = null;
    }
}

// not used
function MNClose()
{
    if (CloseTmr) clearTimeout(CloseTmr);
    CloseTmr = setTimeout('Init(CurrentPopUp)', DissapearDelay);
}

var CurrentPopUp=null;
var PopUpCntnrs = null;    // store containers
function AfterBuild()
{
    var Cntnr=null;
    var Prefix;
    var CCnt, T, L;
    PopUpCntnrs = new Array(PopUpCount);
    PopUpCntnrs[0]=null;
    for (var i=1; i <= PopUpCount; i++)
    {
        Prefix = PopUpPrefix + eval(i);
        CCnt = eval(Prefix + "[0]");
        T = eval(Prefix + "[1]");
        L = eval(Prefix + "[2]");
        if(WebMasterCheck){	if(!Check(Prefix+"_",CCnt)){status='build aborted';return}}    
        Cntnr=CreateMenuStructure(Prefix+"_", CCnt);
        PosMenu(Cntnr, T,L);
        Cntnr.Level=2;      // so menu will behave like a child
        PopUpCntnrs[i] = Cntnr;
    }
}

// Clean PopUps when switching to Left Nav
function BeforeFirstOpen()
{
    if (CurrentPopUp)
    {
        hidePopUp();
        CloseCb();

    }
}
function BeforeStart(){return}
function AfterCloseAll(){return}

// swap Pic when PopUp closes
function CloseCb()
{ // swapPic(MPImgNames[0]); 
CurrentPopUp=null;}