$(document).ready( function() {
	if($("#slideImages")) {
		Gallery.start();
	}
});

var Gallery = new Object({
	
	clicked: "0",

	start: function() {
		
		$("#thumbs img").click( function() {
			Gallery.clicked = "1";
			var el = $(this);
			var elURL = el.parent("a").attr("href");
			var elSlide = $("#slideImages img");
			var elSlideURL = elSlide.attr("src");
			if(elURL==elSlideURL) return false;
			$('#thumbs *').removeClass('selected');
			$('div.galleryImages').fadeIn('slow');
			elSlide.fadeOut("fast", function() {
				elSlide.attr("src", elURL);
			});
			$(el).addClass('selected');
			el.blur();
			return false;
		});
		
		$("#slideImages img").load( function() {
			if(Gallery.clicked=="1") {
				var elSlide = $(this);
				var elWipe = $("#slideImages");
				var hoehe = elSlide.height() + 12;
				elWipe.animate( { height: hoehe }, "slow", function() {
					//$.scrollTo( '#contentleft', "normal");
					elSlide.fadeIn("fast");
					Gallery.clicked = "0";
					return false;
				});
			}
		});
		
	}
		
});
