
/*  scroll bar functions */ 

var total_photos = 0;
var current_photo = 0;
var visible_photos = 5;
var $ol;

$(function(){
	init_photo_scroller();
	});

function init_photo_scroller()
{
	total_photos = $('.scroll_bar ol li').length;
	$ol = $('.scroll_bar ol');
	
	$('.scroll_bar .prev').click(prev_photo);
	$('.scroll_bar .next').click(next_photo);
	
	if(current_photo + visible_photos < total_photos)
	{
		$('.scroll_bar .next').show();
	}
}

function next_photo()
{
	if( current_photo+visible_photos < total_photos )
	{
		// hide current photo and display last one
		$('li:eq('+current_photo+')',$ol).hide();
		current_photo++;
		$('li:eq(' + ( current_photo + visible_photos) + ')',$ol).show();

		// if it is last photo then hide next button 
		if(current_photo + visible_photos >= total_photos)
		{
			$('.scroll_bar .next').hide();
		}
		// show prev button 
		$('.scroll_bar .prev').show();
	}
}	

function prev_photo()
{
	if( current_photo > 0 )
	{
		// hide last photo and display prev one
		$('li:eq(' + ( current_photo + visible_photos) + ')',$ol).hide();
		current_photo--;
		$('li:eq('+current_photo+')',$ol).show();

		// if it is last photo then hide next button 
		if(current_photo + visible_photos < total_photos)
		{
			$('.scroll_bar .next').show();
		}
		// show prev button
		if(current_photo <= 0)
		{
			$('.scroll_bar .prev').hide();
		} 
	}
}	

/*  scroll bar functions end */