
//check for ie and load lightwindow if not

if(!Prototype.Browser.IE){
	var libraryName = 'js/lightwindow/lightwindow.js';
	document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
}

var SwitchIt = Class.create();

SwitchIt.prototype = {
    initialize : function (elem){
        this.elem = new Array();
        if(elem!=null || elem!='undefined'){
            this.elem = $H(elem);
            this.resetToFirst();
            this.addClick();
        }
    },
    doSwitch : function (e){
        var curr_elem = Event.element(e);
        this.hideAll();
        this.show(curr_elem.id);
    },
    resetToFirst : function(){
        this.hideAll();
        if(this.elem.size()>0){
            this.show(this.elem.keys()[0]);
        }
    },
    hideAll : function (){
    	var val = this.elem.values();
        val.each(function(arr){
        	arr.each(function(value){
    	    	$(value).hide();
        	});
        });
    },
    show : function (curr_key){
        if(this.elem[curr_key]!=null){
            this.elem[curr_key].each(function(value){
            	$(value).show();
            });
        }
    },
    addClick : function (){
    	var keys = this.elem.keys();
	var self = this;
	keys.each(function(elem){
    		Event.observe(elem, 'click', self.doSwitch.bindAsEventListener(self));
    	});
    }
   
};
