$(document).ready(function(){
 
  if($('#j-recos-list')){
	  bt.tool.slide.init({distance:740,delay: 3765,list: $('#j-recos-list'),listItem:'div.recoDeal',direction: 'left',pageList: $('#j-recos-page'),pageItem: 'li'});
	 }
});


$reg=function(a,b){
	for(var c=a.split("."),d=window;c.length>0;){
		var e=c.shift();
		d[e]||(d[e]={});
		d=d[e]
	}b()
};
Object.extend=function(a,b){for(var c in b)a[c]=b[c];return a};
Object.extend(String.prototype,{trim:function(){return this.replace(/^\s+|\s+$/,"")}});
Object.extend(Array.prototype,{
	_each:function(a,b){
	    var c=[];
	    try{
		    for(var d=0,e=this.length;d<e;d++){
			    var g=a(this[d],d);
			    b&&typeof g!="undefined"&&c.push(g)
		    }
	    }catch(f){}
	    return c
	},
	collect:function(a){return this._each(a,true)},
	each:function(a){this._each(a,false);return this},
	include:function(a){return this.index(a)!=-1},
	index:function(a){for(var b=0,c=this.length;b<c;b++)if(this[b]==a)return b;return-1},
	unique:function(){for(var a=0;a<this.length;a++)for(var b=this[a],c=this.length-1;c>a;c--)this[c]== b&&this.splice(c,1);return this},
	del:function(a){a=this.index(a);a>=0&&a<this.length&&this.splice(a,1);return this}
});
var Class={
	create:function(){
		for(var a=function(){this.initialize.apply(this,arguments)},b=0,c=arguments.length,d;b<c;b++){d=arguments[b];d!=null&&Object.extend(a.prototype,d)}
		return a
	}
};
function customEvent(a){
	a._e_={};
	a.on=function(b,c){a._e_[b]||(a._e_[b]=[]);this._e_[b].push(c)};
	a.fire=function(b){var c=a._e_[b],d=[];if(c){for(var e=1,g=arguments.length;e<g;e++)d.push(arguments[e]);for(e=0;e<g;e++){var f=c[e];f&&f.apply(null,d)}}};
	a.un=function(b,c){for(var d=a._e_[b],e=d.length,g=0;g<e;g++)if(d[g]==c)a.event[b]=d.splice(g,1)}
}
Object.extend(Function.prototype,{
	bind:function(){
		for(var a=this,b=arguments[0],c=[],d=1,e=arguments.length;d<e;d++)c.push(arguments[d]);
		return function(){
			for(var g=c.concat(),f=0,h=arguments.length;f<h;f++)g.push(arguments[f]);
			return a.apply(b,g)
		}
	},
	bindEvent:function(){
		for(var a=this,b=arguments[0],c=[],d=1,e=arguments.length;d<e;d++)c.push(arguments[d]);
		return function(g){
			var f=c.concat();
			f.unshift(g||window.event);
			return a.apply(b,f)
		}
	}
});
$reg("bt.El",function(){
	bt.El.getOst=function(a){
		for(var b=0;a.offsetParent;){b+=a.offsetTop;a=a.offsetParent}
		return b
	}
});
$reg("bt.tool.Tab",function(){
	bt.tool.Tab=Class.create({
		initialize:function(a){
			customEvent(this);
			this.list=$(a.list);
			this.item=a.item;
			var b=a.selected||"on",c=this,d=a.callback||function(){};
			this.currentItem=this.list.children(a.item+"."+b);
			this.list.children(this.item).click(function(){
				var e=$(this);
				c.currentItem&&c.currentItem.removeClass(b);
				e.addClass(b);c.currentItem=e;
				d(this);
				c.fire("selected",this)
			})
		}
	});
	bt.tool.Tab.init=function(a){return new bt.tool.Tab(a)}
});


bt.tool.slide={
	init:function(a){
		this.distance=a.distance;
		this.list=a.list;
		this.listItem=a.listItem;
		this.direction=a.direction;
		this.pageList=a.pageList;
		this.pageItem=a.pageItem;
		this.delay=a.delay;
		this.currentIndex=1;
		this.autoStart=a.autoStart||1;
		this.autoState=0;
		this.listCount=$(this.listItem,this.list).length;
		this.list.css("position","absolute");
		this.list.css("width",this.listCount*this.distance+20+"px");
		this.pageList&&this.initPageList();
		if(this.listCount>1){this.initEvent();this._autoStart()}
	},
	initEvent:function(){
		var a=this;
		this.pageList&&$(this.pageItem,this.pageList).click(function(){var b=$(this),c=b.attr("data-index"),d=a.pageList.find(".on");d&&d.removeClass("on");if(c){b.addClass("on");a.select(c)}});
		this.list.mouseenter(function(){a.inMoving=true});
		this.list.mouseleave(function(){a.inMoving=false;a._autoStart()})
	},
	initPageList:function(){
		for(var a=[],b=1;b<=this.listCount;b++)b==1?a.push('<li class="on" data-index="'+b+'"><a href="javascript:void(0)">'+b+"</a></li>"):a.push('<li data-index="'+ b+'"><a href="javascript:void(0)">'+b+"</a></li>");
		this.pageList.html(a.join(""))
	},
	_autoStart:function(){
		if(this.autoStart!=2)if(!this.inAutoDelay){
			this.inAutoDelay=true;
			setTimeout(function(){this.inAutoDelay=false;if(!this.inMoving){if(this.currentIndex==this.listCount)this.autoState=1;if(this.currentIndex==1)this.autoState=0;if(this.autoState)this.currentIndex--;else this.currentIndex++;this.select(this.currentIndex)}}.bind(this),this.delay)
		}
	},
	onComplete:function(){this.inMoving=false;this._autoStart()},
	select:function(a){
		var b=$(this.pageItem,this.pageList).eq(a-1),c=this.pageList.find(".on");
		c&&c.removeClass("on");
		b.addClass("on");
		this.currentIndex=a;this.move(a)
	},
	move:function(a){
		if(!this.inMoving){
			this.inMoving=true;a-=1;
			this.list.animate({left:-this.distance*a},{duration:500,queue:false,easing:"easeInOutExpo",complete:this.onComplete.bind(this)})
		}
	}
};