window.TopKarusel2 = {

	block : '#top_karusel2',
	duration : 200,
	pos : 1,
	maxPos : 2,
	onePos: 120,
	count: 4,

	next : function(){
		var self = this;
		var duration = self.duration;
		var current_pos = self.pos * self.onePos;
		current_pos = -current_pos;
		
		self.pos ++;
		if(self.pos > self.maxPos) {
			self.pos = 1;
			current_pos = 0;
			duration = 0;
		}
		
		$(self.block).animate({ 
			left: current_pos
		  }, duration );
	},

	prev : function(){
		var self = this;
		var duration = self.duration;
		
		this.pos --;
		
		var after_pos = self.pos-1;
		if(self.pos == 0 || self.pos < 0) {
			self.pos = self.maxPos;
			duration = 0;
			var after_pos = self.pos - 1;
		}
		var current_pos = after_pos * self.onePos;
		current_pos = -current_pos;
		
		$(self.block).animate({ 
			left: current_pos
		  }, duration );

		return false;
	},

	changeHits : function(num){
		var self = this;
		var html = $('#items_hit_' + num).html();
		$('#top_karusel2').html(html);
		var tabs = $("a[id^='hit_']");
		tabs.removeClass('main_nblock_tab_current');
		$('#hit_' + num).addClass('main_nblock_tab_current');
		self.init();
		return false;
	},
	
	init : function(count){
		var self = this;
		if (typeof(count) != 'undefined'){
			self.count = count;
		}
		
		var hp_kis = $("#top_karusel2 .lystalka_box2");
		self.maxPos = hp_kis.length - self.count + 1;
		$(self.block).css('left', 0);
		self.pos = 1;
		return false;
	}
};


