﻿var defaultCountryId = -1;
var currentCountryId = defaultCountryId;
var hideMenu;

function ShowCities(countryId, countryCount, showFlag) {
    if (countryCount >= countryId) {
        clearTimeout(hideMenu);
        if (showFlag) {

            for (var i = 1; i <= countryCount; i++) {
                var ulObj = document.getElementById("ulLocSubMenu_" + i);
                if (ulObj != null) {
                    if (i != countryId) {
                        ulObj.style.display = "none";
                    }
                    else {
                        ulObj.style.display = "block";
                        
                    }
                }

            }
            currentCountryId = countryId;
            
        }
        else {
            if (currentCountryId > defaultCountryId) {
                hideMenu = setTimeout("HideCurMenu(" + countryId + ")", 1500);
            }
        }

        
    }

}

//Hide current menu
function HideCurMenu(countryId) {
    if (countryId == currentCountryId)
    clearTimeout(hideMenu);
    var ulObj = document.getElementById("ulLocSubMenu_" + countryId);
    if (ulObj != null) {
        ulObj.style.display = "none";        
    }
}

function KeepMenu(countryId, showFlag) {
    clearTimeout(hideMenu);
    
    var ulObj = document.getElementById("ulLocSubMenu_" + countryId);
    if (ulObj != null) {
        if (showFlag) {
            ulObj.style.display = "block";
//            if (countryId != currentCountryId)
                
        }
        else {
            ulObj.style.display = "none";
            currentCountryId = defaultCountryId;
        }
    }
}

function ShowOrHideOffices(curTableNum, tableCount) {
    if (!(isNaN(curTableNum) && isNaN(tableCount))) {        
        for (var i = 1; i < tableCount + 1; i++) {
            var tbObj = document.getElementById('tbBranch_' + i);
            var divTitleObj = document.getElementById('divBranchTitle_' + i);

            if (i != curTableNum) {
                if (tbObj != null && divTitleObj != null) {
                    tbObj.style.display = 'none';
                    divTitleObj.style.backgroundImage = 'url(images/arrow.jpg)';
                }
            }
            else {
                if (tbObj.style.display == 'block') {
                    tbObj.style.display = 'none';
                    divTitleObj.style.backgroundImage = 'url(images/arrow.jpg)';
                }
                else {
                    tbObj.style.display = 'block';
                    divTitleObj.style.backgroundImage = 'url(images/arrow_up.jpg)';
                }
            }
        }
    }
}
