

function HighlightTMenu(e, sp, im){
	if (e.style){
		e.style.backgroundColor = "#8C8AD5";
	}
	if (sp){
	    sp.style.color = "White";
	}
	if (im){
	    im.src = ApplicationPath + "/Assets/Images/Main/Bullets/arrow_right_white.gif";
	}
}

function ShadowTMenu(e, sp, im){
	if (e.style){
		e.style.backgroundColor = "White";
	}
	if (sp){
	    sp.style.color = "#343434";
	}
	if (im){
	    im.src = ApplicationPath + "/Assets/Images/Main/Bullets/arrow_right.gif";
	}
}

function HideAllDropDowns(id) {
     var dropDown;
    if (id)    dropDown = document.getElementById(id).getElementsByTagName('select');
    else       dropDown = document.getElementsByTagName('select');
    if (!dropDown) return;
    var dropDownLength = dropDown.length;
    if (!dropDownLength) return;
    for (var i = 0; i < dropDownLength; i++) {
        if (dropDown[i].tabIndex != "-1")
            dropDown[i].style.visibility = "hidden"
    }
}
function ShowAllDropDowns(id) {
    var dropDown;
    if (id)    dropDown = document.getElementById(id).getElementsByTagName('select');
    else       dropDown = document.getElementsByTagName('select');
    if (!dropDown) return;
    var dropDownLength = dropDown.length;
    if (!dropDownLength) return;
    for (var i = 0; i < dropDownLength; i++) {
        if (dropDown[i].tabIndex != "-1")
            dropDown[i].style.visibility = "visible"            
    }
}
    var arraySize = 20;
    var arrayPosition = 0;
    
    var branchArray = new Array(arraySize);
    
    var timeoutID;
    
    function Expand(n){
        var div = nameCell(n);
        if(div)
			if (arrayPosition + 1 < arraySize && branchArray[arrayPosition] != div && div != 'Div01'){
			    HideAllDropDowns();
				branchArray[arrayPosition] = div;
				if (div.style.visibility != "visible") div.style.visibility="visible";
				arrayPosition++;
			}
    }
    
    function HideBranch(){
        var div;
        if(arrayPosition >=0){
            for(var i = 0; i <= arrayPosition; i++){
                div = branchArray[i];
                if(div) if(div.style.visibility != "hidden") div.style.visibility = "hidden";
                branchArray[i] = null;
            }
            arrayPosition = 0;
            ShowAllDropDowns('');
        }
    }
    
    function HideLastSubBranch(n){
        var sampleDiv = nameCell(n);
        var div;
        var isFound = false;
        var copyPosition = arrayPosition;
        if(sampleDiv && arrayPosition >=0){
            for(var i = 0; i < arrayPosition; i++){
                div = branchArray[i];
                if(isFound){
                    copyPosition--;
                    if(div.style.visibility != "hidden") div.style.visibility = "hidden";
                    branchArray[i] = null;
                }
                if(div == sampleDiv) isFound = true;
            }
            arrayPosition = copyPosition;
        }
    }
    
    
    function SetWaiting(){
        timeoutID = setTimeout("HideBranch();", 500);
    }
   
   
    
    function ResetWaiting(n){
        HideLastSubBranch(n);
        clearTimeout(timeoutID);
    }
    
    function isAdminArea(){
        var loadingDiv = document.getElementById("AdminLoadingDiv");
        if (loadingDiv)
            return true;
        return false;    
    }

    function ShowLoadingMessageInit(){        
       var loadingTimeID = setTimeout("ShowLoadingMessage();", 500);
    }
    
    function showAdminLoadinMessage(){
        var divWindow = document.getElementById("AdminLoadingDiv");
        if (divWindow){    
            divWindow.style.left=((WinWidth / 2) - 70).toString() + "px";
            divWindow.style.top=((WinHeight / 2) - 35).toString() + "px";
            divWindow.style.display = "block";
        }
        
        var shadowDivWindow = document.getElementById("ShadowAdminLoadingDiv");
        if (shadowDivWindow){    
            shadowDivWindow.style.left=((WinWidth / 2) - 66).toString() + "px";
            shadowDivWindow.style.top=((WinHeight / 2) - 31).toString() + "px";
            shadowDivWindow.style.display = "block";
        }
    }
    
    function showElement(elementName){
        var element = document.getElementById(elementName);
        if (element){
            element.style.display = "block";
        }
    }
    
    function hideElement(elementName){
        var element = document.getElementById(elementName);
        if (element){
            element.style.display = "none";
        }
    }
    
    function ShowLoadingMessage(){   
      if (isAdminArea()){
        // Display backgroundDiv
        //showElement("backgroundDiv");
        
        setSize("backgroundDiv", WinWidth, document.body.clientHeight);
        // Show Loading Message
        showAdminLoadinMessage();
        return;
      }
      var loadingDIV = document.getElementById("LoadingDIV");
      if (loadingDIV != null){         
        loadingDIV.style.display  = "block";
      } 
    }