$(document).ready(function(){
	
	
	//normal dockSlider
	$('.dockSlider').each(function() {
		var $this = $(this);
		var small = $this.hasClass('slide-holder');
		var $images = $this.find('.images');
		
		var rightClickCount = '0';
		var leftClickCount = '1';
		
		var move = parseFloat(0);	
		var imageWidth = 102; //dont change unless width og image changes
		
		var $numberOfImages = $this.find('.images img');
		
		$images.jqDock({
			size:100,
			duration: 200,
			flow:true,
			coefficient: 1.5,
			distance: 100
		});
		
		function showArrows(viewImage){	
			if($numberOfImages.length-1 > viewImage ){
				$this.find('.arrow').show();
				$this.addClass('arrows');
			} else {
				$this.find('.arrow').hide();
				$this.removeClass('arrows');
			}
		}
		
		var viewImage = 6; //starts from 0, so 0 === 1
		var numberOfImagesShown = $numberOfImages.length - viewImage;	
		showArrows(viewImage);
		
		$('a.arrow-left').click(function(){
			if(numberOfImagesShown == rightClickCount){
				//nothing?
			}
			
			if(rightClickCount > 0){
				move = move - imageWidth;
		  		$images.stop().animate({
					left: - move
	 	  		}, 500 );
	 	  		
	 	  		rightClickCount --;
				leftClickCount --;
	 	  	}
		});
		
		$('a.arrow-right').click(function(){
			if(numberOfImagesShown == leftClickCount){
				//nothing?
			} else {
				move = move + imageWidth;
		  		$images.stop().animate({
					left: - move
				}, 500 );
				
				leftClickCount ++;
				rightClickCount ++;
			}
		});
		
	}); //end nomalSlider
	
	$('.slide-holder').each(function() {
		var $this = $(this);
		var $slide = $this.find('.slide');
		var rightClickCount = '0';
		var leftClickCount = '1';
		var move = parseFloat(0);	
		var imageWidth = 100; //dont change unless width og image changes
		var imagesLenght = $this.find('ul img').length;	
		
		var pos = 0;
		
		$this.find('.next').click(function() {	
			if(pos < imagesLenght-1){
				move = move + imageWidth;
		  		$slide.stop().animate({
					left: - move
				}, 500 );
				pos++;
			} else {
				//nothing
			}
			return false;
		});
		
		$this.find('.prev').click(function() {
			if(pos === 0){
				//nothing
			} else {
				pos--;
				move = move - imageWidth;
		  		$slide.stop().animate({
					left: - move
				}, 500 );
			}
			return false;
		});
		
	});
		
});
