var DOM = (document.getElementById ? true : false);
var uselay = (document.layers)? true:false;
var usediv = (document.all)? true:false;
var opera = (navigator.userAgent.indexOf("Opera")!=-1)?true:false;

var vis, width, left, top, height;
if(usediv || DOM){
   vis = "hidden";
   width = 275;
   left = 179;
   top = 134;
   height = 20;
}else if(uselay){
   vis = "hide";
   width = 310;
   left = 175;
   top = 130;
   height = 20;
}else{
   vis = "hidden";
   width = 275;
   left = 175;
   top = 130;
   height = 20;

}
var BGcolor = "#CCCCCC";
var sBGcolor = "#006699";
var hBGcolor = "#FFFFFF";
var Delay = 900;
var Current, StopTimer;

var Set1Top = top;
var Set2Top = top + 21;
var Set3Top = Set2Top + 21;
var Set4Top = Set3Top + 21;
var Set5Top = Set4Top + 21;

function m_init(){

    Markup = Create(Set1, Set1Count, Set1Top);
    Markup += Create(Set2, Set2Count, Set2Top);
    Markup += Create(Set3, Set3Count, Set3Top);
    Markup += Create(Set4, Set4Count, Set4Top);
    Markup += Create(Set5, Set5Count, Set5Top);
    return Markup;
}

function Create(ThisArray, ThisCount, thisTop){
    var Name = ThisArray[0];
    var t = height;
    var totalHeight = 0;
    var tHTML = "";
    var twidth = width + 3;
    for(var x = 1; x <= ThisCount; x++){
        tHTML += addItem(ThisArray, Name, x, totalHeight);
        t += height;
        totalHeight += height;
    }

    if(usediv || DOM){cHTML = "<div ID='"+Name+"' style='cursor:arrow; position:absolute; left:"+left+"px; top:"+thisTop+"px; width="+width+"px; z-index:5; visibility:'"+vis+";' onmouseover=\"show('"+Name+"');\" onmouseout=\"hideLater('"+Name+"');\" class='BlackBox'>";}
    if(uselay){cHTML = "<layer ID='"+Name+"' bgcolor='"+BGcolor+"' width="+width+" visibility='"+vis+"' left="+left+" top="+thisTop+" z-index=5 onmouseover=\"show('"+Name+"');\" onmouseout=\"hideLater('"+Name+"');\">";}
    if(DOM && !usediv){ cHTML += "<table cellpadding=0 cellspacing=0 border=0 width="+twidth+"><TR><TD bgcolor='#000000' align='right' class='MenuBorder'><a href=\"javascript:hide('"+Name+"');\" class='MenuBText'>close [x]</a></TD></TR></TABLE>";}
    cHTML += tHTML;
    if(usediv || DOM){cHTML += "</div>";}
    if(uselay){cHTML += "</layer>";}
    return cHTML;
}


function addItem(iArray, iName, i, t){
    var aHTML = "";
    var tagName = iName+""+i;
    var twidth = width + 3;
    if(!iArray[i][1]){
        var SetClass = "";
        //var SetClass = " class='MenuBorder'";
        BGcolor = sBGcolor;
    }else{
        BGcolor = "#CCCCCC";
        var SetMouseOver = " onmouseover=\"SwitchColor('"+tagName+"', '"+hBGcolor+"');\" onmouseout=\"SwitchColor('"+tagName+"', '"+BGcolor+"');\"";
    }

    if(usediv || DOM){aHTML = "<div ID='"+tagName+"' style='cursor:arrow; background-color: "+BGcolor+"; position:relative; width="+twidth+"px; z-index:10'"+SetMouseOver+""+SetClass+"  class='WhiteLine'>";}
    if(uselay){aHTML = "<layer ID='"+tagName+"' bgcolor='"+BGcolor+"' top='"+t+"' width='"+width+"' visibility='inherit' z-index='10'>";}
    aHTML += "<table cellpadding=2 cellspacing=0 border=0 width="+width+"><TR><TD>";

    if(!iArray[i][1]){
          aHTML += "<font class='MenuBText'>";
          aHTML += iArray[i][0];
          aHTML += "</font>";
    }else{
          aHTML += "<a href='"+iArray[i][1]+"'";
          aHTML += " class='MenuText'";
          aHTML += ">"+iArray[i][0]+"</a>";
    }
    aHTML += "</TD></TR></table>";
    if(usediv || DOM){aHTML += "</div>"};
    if(uselay){aHTML += "</layer>";}

    return aHTML;
}

function SwitchColor(id, color){

        if(usediv || DOM){
              document.all[id].style.backgroundColor = color;
        }
        if(uselay){
              document.layers[id].document.bgColor = color;
        }
}

function show(id) {
        var obj;
        //document.form.tmp.value = Current+" "+id;
        if(Current == id){ clearTimeout(StopTimer); }
        if (uselay){
                document.layers[id].visibility = "show";
        }else if (usediv){
                document.all[id].style.visibility = "visible";
        }else if (DOM) {
                obj = document.getElementById(id);
                if (!document.getElementById)
                return
                obj.style.display="";
        }

}

function hide(id) {
        var obj;

        if (uselay){
                document.layers[id].visibility = "hide";
        }else if (usediv){
                document.all[id].style.visibility = "hidden";
        }else if (DOM){
                obj = document.getElementById(id);
                if (!document.getElementById)
                return
                obj.style.display="none";
        }

}

function hideLater(id){
   Current = id;
   if(Current == "guide"){
        StopTimer = setTimeout("hide('guide')", Delay);
   }else if(Current == "forms"){
        StopTimer = setTimeout("hide('forms')", Delay);
   }else if(Current == "acu"){
        StopTimer = setTimeout("hide('acu')", Delay);
   }else if(Current == "biometh"){
        StopTimer = setTimeout("hide('biometh')", Delay);
   }else if(Current == "train"){
   		StopTimer = setTimeout("hide('train')", Delay);
   }
}



function hideAll(){

        hide('guide');
        hide('forms');
        hide('acu');
        hide('biometh');
		hide('train');

}