window.addEvent('domready', function() {
var BBSubNavClass = new Class({
	Implements: [Options, Events],
	initialize: function(){
		this.alltabs = new Array(19);
                this.slides = $$('.panel');
                this.ShowSlide(19);
              this.mainline = $('mainline');
              this.mainScroller = new Scroller(this.mainline, {
                area: 100
              });
              this.BBScroll();
        },
      BBScroll: function(){
              this.mainScroller.start();
      },
        BBProcess: function(bbind,bbslideind){
		this.alltabs[bbind] = new SimpleCarousel($('slideshow_'+bbslideind), $$('#slideshow_'+bbslideind+' li.slide'), $$('#tabset_'+bbslideind+' div.button'), {
			rotateAction: 'click',
			rotateActionDuration: 700,
			slideInterval: 2000
        	});
                if(!this.slideFx){
                        this.slideFx = [];
                }
                this.slideFx[bbind] = new Fx.Slide($('info_'+bbslideind), {
				mode: 'horizontal'
		}, this).hide();
                $('slideshow_'+bbslideind).addEvents({
			'click': function(event){
                               	event.stop();
			        this.alltabs[bbind].stop();
                             	this.RevealInfo(bbind);
			}.bind(this),
			'mouseover': function(event){
			}.bind(this),
			'mouseout': function(event){
			}.bind(this)
		}, this);
                $('close_info_'+bbslideind).addEvents({
			'click': function(event){
                               	event.stop();
                                this.slideFx[bbind].slideOut();
			        this.alltabs[bbind].autoplay();
			}.bind(this),
			'mouseover': function(event){
			}.bind(this),
			'mouseout': function(event){
			}.bind(this)
		}, this);
        },
        RevealInfo: function(currentindex){
                  var slidesstate={};
                  this.alltabs.each(function(item,index){
                    if(index==currentindex) {
                        slidesstate[index] = 0;
                    } else {
                        slidesstate[index] = 1;
                    }
                  }, this);
                  this.alltabs.each(function(item,index){
                  	if(slidesstate[index] == 0) {
                            this.slideFx[index].slideIn.delay(800,this.slideFx[index]);
			    this.alltabs[index].stop();
                        } else {
                            // this.slideFx[index].slideOut();
                        };
                  }, this);
                  return this;
        },
        ShowSlide: function(currentindex){
                  var newind = 0; 
                  this.slides.each(function(item,index){
			if(!($chk(this.alltabs[index]))){
                            newind=index+50;
			    var req = new Request.HTML({
				method: 'get',
				noCache: 'true',
				url: 'http://www.aladisposition.com/concept-store/index.php?route=product/product&product_id='+newind+'&a='+$time()+$random(1,10000),
				update: item,
				evalScripts: true,
				onSuccess: function() {
                                     this.BBProcess(index,index+50); 
				}.bind(this)
			    }, this).send();
			};
                  }, this);
                  return this;
        }
});

var navsubnavlinks = new BBSubNavClass();

});
