$(document).ready(function() {
	$(".homeModule").mouseover(function(){
		$(this).css({"background-position":'0px 208px'});
	}).mouseout(function(){
		$(this).css({"background-position":'0px 0px'});
	});
	
	$(".greenMenuHeading").mouseover(function(){
		$('.primaryNav').show();
	}).mouseout(function(){
		$('.primaryNav').hide();
	});
	
	$(".primaryNav").mouseover(function(){
		$(this).show();
	}).mouseout(function(){
		$(this).hide();
	});
	
	$(".greyMenuHeading").mouseover(function(){
		$('.secondaryNav').show();
	}).mouseout(function(){
		$('.secondaryNav').hide();
	});
	
	$(".secondaryNav").mouseover(function(){
		$(this).show();
	}).mouseout(function(){
		$(this).hide();
	});
	
	/* PROJECT IMAGES AND CAPTIONS */
	
	totalImages = $('.totalImages').text();
	
	if(totalImages == 1) {
		$('.imageNavBgRight').css({'background-color' : 'white'});
	}
	
	currentImage = 1;
	//console.log(currentImage);
	
	$(".caption:first").show();
	$(".projectImage:first").show();
	
	$(".imageNavLeft").click(function () {
		imageLeft(currentImage);
	});
	
	$(".imageNavRight").click(function () {
		imageRight(currentImage);
	});
			
});

	function imageLeft(current) {
		currentImage = current;	
		//console.log(currentImage);
		totalImages = $('.totalImages').text();
		
		if(currentImage != 1) {
			$('.projectImages').animate({"left": "+=740px"}, "slow");
			currentImage--;
			$('.imageNumber').html(currentImage);
			currentCaption = currentImage -1;
			//alert(currentImage);
			$('.caption').hide();
			$(".caption").eq(currentCaption).show();
		}
		if(currentImage == 1) {
			$('.imageNavBgLeft').css({'background-color' : 'white'});
		} 
		if(currentImage != totalImages) {
			$('.imageNavBgRight').css({'background-color' : '#44ed9f'});
		}			
	}
	
	function imageRight(current) {
		currentImage = current;
		//console.log(currentImage);
		totalImages = $('.totalImages').text();
		
		if(currentImage != totalImages) {
			$('.projectImages').animate({"left": "-=740px"}, "slow");
			currentImage++;
			$('.imageNumber').html(currentImage);
			currentCaption = currentImage -1;
			//alert(currentImage);
			$('.caption').hide();
			$(".caption").eq(currentCaption).show();
			
		}
		if(currentImage == totalImages) {
			$('.imageNavBgRight').css({'background-color' : 'white'});
		}
		 
		if(currentImage != 1) {
			$('.imageNavBgLeft').css({'background-color' : '#44ed9f'});
		}
	}
	

