
$(document).ready(function() {
	
	// Title-Tags ein bissel hübscher machen 
	registerTooltips();

	// Vorschaubilder in mittlerer Größe anzeigen
	$('#galleryPreview img.thumb').click(function() {
		// den gepunkteten Rahmen rund um das Bild loswerden
		$(this).parent().blur(); 
		// stattdessen gibts die Klasse active
		$('img.thumb').parent().parent().parent().removeClass('active');
		$(this).parent().parent().parent().addClass('active'); 
		
		pic = $(this).attr('id');
		pic_p = pic.split('_');
		pic_id = pic_p[1];
		if(!pic_id) {
			pic = $(this).attr('id');
			pic_p = pic.split('_');
			pic_id = pic_p[1];
		}
		$.ajax({
			type: "GET", 
			url: "./?pic_id=" + pic_id + '&showMediumSized=1',
			success: function(msg) {
				
				$("#mediaHolder")
					.animate({
						height: 'hide',
						opacity: 'hide'
					}, 'slow', 'swing', function() {
						$(this).empty().append(msg)
						.animate({
							height: 'show',
							opacity: 'show'
						}, 'slow', 'swing', function() {
							$('#mediaHolder a').tooltip({
								showURL: false,
								track: true, 
								delay: 0, 
								fade:250
							});
						});
					});
			}
		});
		
		return false;
	});
	
	function registerTooltips() {
		
		// Kleine hovernde Hinweistextchen
		jQuery('.tooltip').tooltip({
			showURL: false,
			track: true, 
			delay: 0, 
			fade: 250
		});
	}
	
	
});