// JavaScript Document
$(function() {

	$(".forward").bind("mouseover", function() { $(this).attr("src", "/img/btn_clients-next-hover.gif"); });
	$(".forward").bind("mouseout", function() { $(this).attr("src", "/img/btn_clients-next.gif"); });


	$(".back").bind("mouseover", function() { $(this).attr("src", "/img/btn_clients-prev-hover.gif"); });
	$(".back").bind("mouseout", function() { $(this).attr("src", "/img/btn_clients-prev.gif"); });

	// intialize the galleries
	var offset = new Array();
	var imgSize = new Array();
	var count = new Array();
	var total = new Array();
	
	for(i=1;i<=$('.gallery').length;i++){
		offset[i] = 0;	
		count[i] = 0;
		total[i] = $("#gal"+i+" img").length;
	}
	imgSize = 195;
	totalViewable = 3;
	$(".back").bind("click", function() { 
		var galId = $(this).attr("id").substring(6);
		if(count[galId] > 0){
			offset[galId] = offset[galId] - imgSize;
			$("#gal"+galId).animate({left:-offset[galId]}, 750);
			count[galId]--;
		}

	});

	$(".forward").bind("click", function() { 
		var galId = $(this).attr("id").substring(6);
		if(count[galId] < total[galId]-totalViewable){
			offset[galId] =  offset[galId] + imgSize;
			$("#gal"+galId).animate({left:-offset[galId]}, 750);
			count[galId]++;
		}else{
		}
	});

});
