/*------------------------------------------------------------------------------
	portfolio thumbnail slider thingy
------------------------------------------------------------------------------*/

var $paneTarget = $('#portfolio_thumbs_window');
var current_page = 1;
var speed = 200;


function scrollThumbnails(whichDir,maxPage) {
	
	if(whichDir == 'right_arrow') {
		if(current_page <= maxPage) {
			$('#portfolio_thumbs_window').stop().scrollTo( {top:'0px', left:'+=576px'}, 350 );
			current_page++;
		}
	}
	
	//arrow_off
	
	if(whichDir == 'left_arrow') {
		if(current_page > 1) {
			$('#portfolio_thumbs_window').stop().scrollTo( {top:'0px', left:'-=576px'}, 350 );
			current_page--;
		}
	}
	//alert('current page: ' + current_page + ' --- max # of pages: ' + maxPage);
	
	$('#contentTopSection a.thumbs_nav').removeClass('arrow_off');
	
	if(current_page == 1) {
		$('#contentTopSection a#left_arrow').addClass('arrow_off');
	}
	
	if(current_page >= maxPage) {
		$('#contentTopSection a#right_arrow').addClass('arrow_off');
	}
	
}

$(document).ready(function() {
	max_thumbnails = $('#portfolio_thumb_wrap .thumbnail').length;
	max_page = max_thumbnails/8;
	
	if(max_thumbnails > 8) {
		$('#contentTopSection .thumbs_nav').css('display','block');
	}
	
	//alert(max_thumbnails);
	
	$('.thumbs_nav').click(function() {
		var direction = $(this).attr('id');
		
		scrollThumbnails(direction,max_page);
		return false;
	});

});