
// workGallerySlideCount
var workGallerySlidePosition = 0;
var workGallerySlideInProgress = false;
var workGallerySlideSpeed = 500;
var workGalleryButtonFade = 500;

function onWorkGalleryPrev() {
	
	if( workGallerySlideInProgress == false ) {
		
		workGallerySlideInProgress = true;
		
		$("#work-gallery").animate( {
				left: "+=290"			
			}, workGallerySlideSpeed, function() {
				workGallerySlideInProgress = false;		
			}
		);
		
		workGallerySlidePosition--;
		
		if( workGallerySlidePosition < 1 ) {
			$("#work-gallery-prev").fadeOut( workGalleryButtonFade );
		}
		
		if( workGallerySlidePosition >= 0 ) {
			$("#work-gallery-next").fadeIn( workGalleryButtonFade );
		}
	}
	
	return false;
}

function onWorkGalleryNext() {
	
	//console.log("onWorkGalleryNext ");
	
	if( workGallerySlideInProgress == false ) {
		
		workGallerySlideInProgress = true;
		
		$("#work-gallery").animate( {
				left: "-=290"			
			}, workGallerySlideSpeed, function() {
				workGallerySlideInProgress = false;		
			}
		);
		
		workGallerySlidePosition++;
		
		if( workGallerySlidePosition > 0 ) {
			$("#work-gallery-prev").fadeIn( workGalleryButtonFade );
		}
		
		if( workGallerySlidePosition > workGallerySlideCount - 3 - 1 ) {
			$("#work-gallery-next").fadeOut( workGalleryButtonFade );
		}
	}
	
	return false;
}

$(document).ready(function() {
	
	$("#work-gallery-prev").click( onWorkGalleryPrev );
	$("#work-gallery-next").click( onWorkGalleryNext );
	
	if( workGallerySlideCount > 0 ) {
		$("#work-gallery-prev").hide();
		$("#work-gallery-next").show();
	}
});

