var src="";
var thisImage="1";

$(document).ready(function() {
						   
	if(extras[thisImage]!=0) {
		$("#extras").show();
		$("a.one").attr("title",thisImage).attr("class", "one extra on");
		$("a.two").attr("title",thisImage + "a").attr("class", "two extra");
		if(extras[thisImage]==3) {
			$("a.three").show().attr("title",thisImage + "b").attr("class", "three extra");
		} else {
			$("a.three").hide();
		}
	} else {
		$("#extras").hide();
	}
	
	$(".scrollable img").click(function() {
		src = "images/" + thisPage + "/gallery/" + $(this).attr("title") + ".jpg";
		$("img.featimage").fadeOut(250, function() {
			$(this).attr("src",src);
			$(this).load(function() {
				$(this).fadeIn(250);
			});
		});
		thisImage=$(this).attr("title");
		if(extras[thisImage]!=0) {
			$("#extras").show();
			$("a.one").attr("title",thisImage).attr("class", "one extra on");
			$("a.two").attr("title",thisImage + "a").attr("class", "two extra");
			if(extras[thisImage]==3) {
				$("a.three").show().attr("title",thisImage + "b").attr("class", "three extra");
			} else {
				$("a.three").hide();
			}
		} else {
			$("#extras").hide();
		}
	});
	
	$("a.extra").click(function() {
		$("a.extra").removeClass("on");						
		$(this).attr("class", $(this).attr("class") + " on");						
		src = "images/" + thisPage + "/gallery/" + $(this).attr("title") + ".jpg";
		$("img.featimage").fadeOut(250, function() {
			$(this).attr("src",src);
			$(this).load(function() {
				$(this).fadeIn(250);
			});
		});	
	});
	
	$("#.scrollable img").hover(function () {
		$(".scrollable img").css("opacity", 0.6);
		$(this).css("opacity",1);
	}, function () {
		$("#.scrollable img").css("opacity", 1);
	});		
	
});
