// JavaScript Document


jQuery(document).ready(function(){
	
	var slidetime = setInterval(ChangePic,5000);
	var currentIndex = 1;	
	var totalIndex = 4;
	SpotChange(currentIndex)
	
	function ChangePic() {
		if (currentIndex == totalIndex) { 
			currentIndex = 1;
			SpotChange(currentIndex);
		} else { 
			currentIndex++;
			SpotChange(currentIndex);
		}
	}

	function SpotChange($e) { 
		setHover($e);			
	}
	
    $('.parallax-layer').parallax(
	  { mouseport: $('#port') },   
	  { xparallax: '0.2',   yparallax: '0.3' },  
	  { xparallax: '0.3',   yparallax: '0.4' },    
	  { xparallax: '0.4',   yparallax: '0.2' },   
	  
	  { xparallax: '0.4',   yparallax: '0.2' },   
	  { xparallax: '0.3',   yparallax: '0.4' },   
	  { xparallax: '0.2',   yparallax: '0.3' }, 
	  
	  { xparallax: '0.2',   yparallax: '0.4' },    
	  { xparallax: '0.4',   yparallax: '0.3' },    
	  { xparallax: '0.3',   yparallax: '0.2' },   
	    
	  { xparallax: '0.3',   yparallax: '0.3' },   
	  { xparallax: '0.4',   yparallax: '0.4' }, 
	  { xparallax: '0.2',   yparallax: '0.2' }   
    );

	function setHover($e) {
		$('.nokta_1 img').attr('src', 'images/dot2.png');
		$('.nokta_2 img').attr('src', 'images/dot2.png');
		$('.nokta_3 img').attr('src', 'images/dot2.png');
		$('.nokta_4 img').attr('src', 'images/dot2.png');
		
		$('.nokta_' + $e + ' img').attr('src', 'images/dot1.png');
		
		$('.tool').hide();
		$('.time').hide();
		$('.team').hide();
		$('.people').hide();
		
		if ($e == 1) {
			$('.tool').show();
		} else if($e == 2) {
			$('.time').show();
		} else if($e == 3) {
			$('.team').show();
		} else if($e == 4) {
			$('.people').show();
		}
	}

	$('.nokta_1').hover( function() {
		clearInterval(slidetime);
		setHover(1);
	});
	
	$('.nokta_2').hover( function() {
		clearInterval(slidetime);
		setHover(2);
	});
	
	$('.nokta_3').hover( function() {
		clearInterval(slidetime);
		setHover(3);
	});
	
	$('.nokta_4').hover( function() {
		clearInterval(slidetime);
		setHover(4);
	});

});

