
$(document).ready(function(){
	
	//check for image gallery on page
	if($("#photoTxt").size()==0) return false;
	
	var current=0;
	picCount=$("#photo img:not(#imgObj)").size();
	updatePhoto=$("#imgObj");
	updateTxt=$("#photoTxt span.blue");
	$("span.browseBtn").click(function(){
		doPhoto(false)
		return false;
	})
	$("#photoThumbs a").each(function(){
		$(this).click(function(){
			doPhoto($(this).html());
			return false;
		});
	});
	function doPhoto(newCurrent){
		if(newCurrent)
			current=newCurrent-1;
		else if(current<picCount-1){
			current ++;
		}
		else
			current=0;
		updatePhoto.fadeOut("fast", function(){doPhotoSwap()});
		function doPhotoSwap(){
		updatePhoto.attr({
			"src" : $("#photo").find("#img"+current).attr("src"),
			"alt" : $("#photo").find("#img"+current).attr("alt")
		});
		var counter=0;
		$("#photoThumbs a").each(function(){
			$(this).removeClass("active");
			if(counter==current) $(this).addClass("active");
			counter++;
		})
		updateTxt.html($("#photo").find("#photoTxt"+current).html());
		updatePhoto.fadeIn("fast");
		}
		
	}
	$(".mainContentTxt p:first").css({"padding-top":"0"});
})
