function Billboard(init){
    this.billboard_change = function(tab_nr){
        clearTimeout(this_object.timeout);
        if ($(this_object.item_selector).length == tab_nr){
            tab_nr = 0;
        }
        else if (tab_nr < 0){
            tab_nr = $(this_object.item_selector).length-1;
        }
        if (!this_object.changing && tab_nr != this_object.current){
            this_object.changing = true;
            $(this_object.item_selector).eq(this_object.current).fadeOut('fast',function() {
                $(this_object.item_selector).eq(tab_nr).fadeIn('normal',function() {
                    this_object.current = tab_nr;
                    this_object.changing = false;
                });
                $(this_object.tab_selector).removeClass("current");
                $(this_object.tab_selector).eq(tab_nr).addClass("current");
            });
        }
        this_object.set_timer();
    }
    this.billboard_timer = function(){
        this_object.billboard_change(this_object.current+1)
    }
    this.set_timer = function(){
        this_object.timeout = setTimeout(function(){this_object.billboard_timer()}, this_object.timing);
    };
    var this_object = this;
    for (attr in init){this[attr] = init[attr]}
    this.slider_queue = 0;
    this.current = 0;
    this.changing = false;
    this.set_timer()
    $(this.tab_selector).click(function(){
        this_object.billboard_change($(this).prevAll().length);
        return false;
    });
    $(this.next_selector).click(function(){
        this_object.billboard_change(this_object.current+1)
        return false;
    });
    $(this.prev_selector).click(function(){
        this_object.billboard_change(this_object.current-1)
        return false;
    });
}


$(document).ready(function(){
    new Billboard({timing:5000,item_selector:".billBoard .billBoardItem",tab_selector:".billBoard .count",next_selector:".billBoard .rightPointer",prev_selector:".billBoard .leftPointer"})
});
