﻿function hotDealsTab(FirstTabToShow){
    this.firstTabToShow = FirstTabToShow;
    this.tabs = document.getElementsByClassName('carouselTab');
    this.pages = document.getElementsByClassName('carouselPage');
    
    this.hideAll = function(){
        for(var i = 0; i < this.tabs.length; i++){
            this.tabs[i].className = this.tabs[i].className.replace('galleryOn', 'galleryOff');
            this.pages[i].className = this.pages[i].className.replace('show', 'hide');
        }
    };
     
    this.showPage = function(indexToShow){
        this.tabs[indexToShow].className = this.tabs[indexToShow].className.replace('galleryOff', 'galleryOn');
        this.pages[indexToShow].className = this.pages[indexToShow].className.replace('hide', 'show');
    };
    
    this.addListenerOnTab = function(elt, index){
        var me = this;
        var displayDelegate = function() {me.hideAll(); me.showPage(index);};
        AddListener(elt, 'click', displayDelegate);
    };
    
    this.init = function(){
        //this.hideAll();
        //this.showPage(this.firstTabToShow);
        for(var i = 0; i < this.tabs.length; i++){
            this.addListenerOnTab(this.tabs[i], i);
        }
    };       
}
