$('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("rel");
			var elSlide = $("#slideImages img");
			var elSlideURL = elSlide.attr("src");
			//if(elURL==elSlideURL) return false;
			$('#thumbs *').removeClass('selected');
			$('div.galleryImages').fadeIn('slow');
			
			var innerdet=$('#slideImages').html();
				
			if($(this).attr('id')=='video'){
			$('#slideImages').fadeOut('fast');
			$('#slideVideo').css('display','block');
			
			
				return false;
			}
			 
			 if($(this).attr('id')=='image'){
				
				 $('#slideVideo').css('display','none');
				 $('#slideImages').fadeIn('100');
			 }
			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;
				});
			}
		});
		
	}
		
});
