var Registry = {};
Registry.objects = {};

var Popups = {};

Popups.instances = [];

Popups.register = function(name){
    Popups.instances[Popups.instances.length] = name;
}

Popups.hideAll = function(){
    for (var i = 0; i < Popups.instances.length; i ++){
        if (Registry.objects[Popups.instances[i]]){
            Registry.objects[Popups.instances[i]].hide();
        }
    }
}

Popups.hideAllButNotThis = function(notHideName){
    for (var i = 0; i < Popups.instances.length; i ++){
        if (Popups.instances[i] != notHideName) if (Registry.objects[Popups.instances[i]]){
            Registry.objects[Popups.instances[i]].hide();
        }
    }
}

document.observe( 'dom:loaded', function() {
    document.body.onclick = function(){
        Popups.hideAll();
    }
});


var Selects = {};

Selects.hide = function(){
    navigator.userAgent.match(new RegExp("MSIE (\\d{1})\\.0"));
    var version = parseInt(RegExp.$1);
    if (!isNaN(version) && version <= 6){
        var selects = document.getElementsByTagName("select");
        for (var i = 0; i < selects.length; i ++){
            selects[i].style.visibility = "hidden";
        }
    }
}

Selects.show = function(){
    navigator.userAgent.match(new RegExp("MSIE (\\d{1})\\.0"));
    var version = parseInt(RegExp.$1);
    if (!isNaN(version) && version <= 6){
        var selects = document.getElementsByTagName("select");
        for (var i = 0; i < selects.length; i ++){
            selects[i].style.visibility = "visible";
        }
    }
}

//Array.prototype.exists = function(element){
//    for (var i = 0; i < this.length; i ++){
//        if (this[i] == element){
//            return true;
//        }
//    }
//    return false;
//}
//
//Array.prototype.indexOf = function(element){
//    for (var i = 0; i < this.length; i ++){
//        if (this[i] == element){
//            return i;
//        }
//    }
//    return false;
//}