(function () {
	$.suning || ($.suning = {});
	//类式继承
	$.suning.extend = function(c, s) {
		var f = function() {};
		f.prototype = s.prototype;
		c.superClass = s;
		c.prototype = new f();
	}
})();
//import namespace

//Tab

$.suning.ebayTab = (function (){
		return function (tabs,datas){
			this.tabs = tabs;
			this.datas = datas;
		}
	})();
$.suning.ebayTab.prototype = {
	init: function (){
		this.loc = 0;
		var that = this;
		this.tabs.each(function(i){
			$(this).click(function (e){
				if(i == that.loc){return;}
				that.change(i);
				e.preventDefault();
			});
		});
	},
	change: function (i){
		var data= this.datas.eq(i);
		data.fadeIn('fast');
		this.datas.eq(this.loc).fadeOut('fast');
		this.tabs[i].className = 'on';
		this.tabs[this.loc].className = '';
		this.loc = i;
	}
}

$.suning.picsScroll = function (num){
	var w = 100;
	var speed = 1;
	var dis = 1;
	var inerval;
	var num = num || 1;
	var base = 0;
	var ul = $('#bank_list').find('ul');
	var lis = $('#bank_list').find('li');
	var len = w * lis.length - 680;
	return {
		init: function(){
			var that = this;	
			ul.css('width',lis.length*w+'px','left','0','position','absolute');
			$('#left_button').mouseover(function(){					
				dis = 1;
				interval = setInterval(that.loop,10);
			}).mouseout(function(){clearTimeout(interval);});
			$('#right_button').mouseover(function(){
				dis = 0;
				interval  = setInterval(that.loop,10);
			}).mouseout(function(){clearTimeout(interval);});
		},
		loop: function (){
			if (dis == 1) {
				if (base > -len) {
					base -= speed;
					ul.css('left',base + 'px');
				}
			} else if (dis == 0) {
				if (base < 0) {
					base += speed;
					ul.css('left',base + 'px');
				}
			}
		}
	}
}

$.suning.ebaySideScroll = function() {
	var box = $('#column01');
	var h = box[0].scrollHeight;
	
	
	var cur = 0;
	
	var str = box.html();
	box.html(str + str);
	var f = box.find('h5').eq(0);
	var timer = setInterval(loop, 30);
							
	function loop() {
		cur += 1;
		f.css('marginTop', -cur + 'px');
		if (cur >= h) {
			cur = 0;
		}
	}
}
$(document).ready(function(){
	//易付宝tab
	new $.suning.ebayTab($('#ebay_tabs li a'),$('#datas > div')).init();
	
	//银行图标滚动
	new $.suning.picsScroll().init();
	
	//左侧滚动
	new $.suning.ebaySideScroll();
	
});
