var ELEMENTS_CACHE = {};

function $() {
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];
        if (ELEMENTS_CACHE[element]){element = ELEMENTS_CACHE[element]}
        else if (typeof element == 'string'){element = document.getElementById(element)}

        if (arguments.length == 1) return element;
        elements.push(element);
    }
    return elements;
}




/*
    JumpBox control
*/
function JumpBox(){
    this._isIE = ((navigator.userAgent.toLowerCase().indexOf("msie") != -1) && (!(window.opera)));
    this._JumpBoxListDelayTimer = null;
    this._ListBox = null;

    this.Toggle = function(ListId){
        if(this._ListBox != null){
            this._HideList();
        }
        this._ListBox = $(ListId);
        if(this._ListBox.offsetWidth == 0 && this._ListBox.innerHTML != ''){
            if(this._isIE){
                this._ListBox.filters[0].Apply();
                this._ListBox.filters[0].Play();
            }
            this._ListBox.style.display = 'block';
        }else{
            this._HideList();
        }
    }

    this.onListMouseOut = function(){
        if(this._ListBox != null){
            this._JumpBoxListDelayTimer = setTimeout("JumpBox._HideList()", 150);
        }
    }

    this.onListMouseOver = function(){
        if(this._JumpBoxListDelayTimer){
            clearTimeout(this._JumpBoxListDelayTimer);
        }
    }

    this._HideList = function(){
        this._ListBox.style.display = 'none';
    }

    this.onItemMouseOver = function(ItemObject){
        ItemObject.id = 'jump-box-current-element';
    }

    this.onItemMouseOut = function(ItemObject){
        ItemObject.id = '';
    }

    this.onSelect = function(UrlToGo, JumpBoxId, SelectedValue){
        this._HideList();
        this._ChangeValue(JumpBoxId, SelectedValue);
        if(UrlToGo != ''){
            document.location.href = UrlToGo;
        }
    }

    this._ChangeValue = function(JumpBoxId, SelectedValue){
        $(JumpBoxId).innerHTML = SelectedValue;
    }

    this.FillChildControl = function(ChildControlId, List){
        $(ChildControlId).innerHTML = List;
    }
}

var JumpBox = new JumpBox();



