// JavaScript Document

$(document).ready(function() {
	$("#imgGallery ul li a").click(function() {
		var href = $(this).attr('href');
		$("#imgGallery ul a").removeClass("active");
		$(this).addClass("active");
		$("#box img").fadeOut('slow', function() {
			$(this).attr("src", href);
			$(this).load(function() {
				$(this).fadeIn('slow');
			});
		});
		$("#Pos").html($(this).parent().index()+1);
		return false;
	});
	// get number of elements in gallery...
	var num = $("#imgGallery ul").find("li").length;
	// set the width for each element in the gallery...
	var w = $("#imgGallery ul li").width();
	// now set the width of the ul
	$("#imgGallery ul").width(num*w);
	// now add cal for next and back
	
	var total = 6;
	
	$("#rightArrow").click(function() {
		var dest = $("#imgGallery ul").position().left - (w*total);
		if(dest <= -$("#imgGallery ul").width()) {
			dest = 0;	
		}
		$("#imgGallery ul").animate({
			left: dest
		}, 1000, 'swing');
		return false;
	});
	
	$("#leftArrow").click(function() {
		var dest = $("#imgGallery ul").position().left + (w*total);
		if(dest > 0) {
			var dest = 0;
			while(dest > -$("#imgGallery ul").width()) {
				dest -= (w*4);
			}
			dest += (w*4);	
		}
		$("#imgGallery ul").animate({
			left: dest	 
		}, 1000, 'swing');
		return false;
	});
	
	$(".showEstimate").click(function() {
		Shadowbox.open({
			content: 	"/estimate.php",
			player: 	"iframe",
			width: 		405,
			height: 	690
		});
		return false;
	});	
	
	$(".international").click(function() {
		Shadowbox.open({
			content:	"/international.html",
			player:		"iframe",
			width: 		305,
			height: 	400
		});
		return false;
	});
	
});