﻿function ShowTab(tab, n){
    var aTab = getElementsByTag(n, 1);
    for(i = 0; i < aTab.length; i++)
    {
        var obj = document.getElementById('li' + aTab[i]);
        var cName = obj.className;    
        
        if (aTab[i] == tab)
        {
            setVis(aTab[i], true);
    
            if (cName.search(/LeftTab/) >= 0)
            {
                obj.className = 'LeftTabCurrent';                
            }
            else
            {
                obj.className = 'CenterTabCurrent';
            }
        }
        else
        {
            setVis(aTab[i], false);

            if (cName.search(/LeftTab/) >= 0)
            {
                obj.className = 'LeftTab';                
            }
            else
            {
                obj.className = 'CenterTab';
            }            
        }
    }
    
    //if(document.getElementById('aTop'))
        //document.getElementById('aTop').scrollIntoView(true);
}

function getElementsByTag(strAttributeName, strAttributeValue){
	var arrElements = document.body;
	if (!arrElements.all)
	{
	    arrElements = arrElements.getElementsByTagName('*');
	}
    else
    {
       arrElements = arrElements.all;
    }
	
	var oAttribVal = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	
	var aReturn = new Array();
	
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttribVal && oAttribVal.test(oAttribute))){
			    aReturn.push(oCurrent.id); 
			}
		}
	}
	return aReturn;
}

function setVis(id, vis, displayNone) {
    if (id != '') {
        if (displayNone == undefined || (displayNone != true && displayNone != false)) {
            displayNone = true;
        }
	    obj = MM_findObj(id);
	    if (obj == undefined) {
	        return;
	    }
	    if(document.getElementById || document.all){//all the modern browsers
		    obj.style.visibility = vis ? "visible" : "hidden";
		    if (displayNone) {
		        obj.style.display = vis ? "block" : "none";
		    }
	    }
	    else if(document.layers){//this is NS4
		    obj.visibility = vis ? "show" : "hide";
		    if (displayNone) {
    		    obj.display = vis ? "block" : "hide";
            }
	    }  
	}
}