var previousShowBigger = false;

$(function() {
	// Open link in new window
	$(".external").attr("target","_blank");
	
	$("input").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	// Write elements when javascript is enabled
	$(".content-iutp").append("<img src='images/backgrounds/top-corner.gif' class='top-content' alt='' />");
	$("body#home #container").prepend("<img src='images/backgrounds/pointer-active.gif' class='active-home' alt='' />");
	$("body#home .visual-home").prepend("<img src='images/globals/hoekje-lt.png' class='corner-lt' alt='' />");
	$("body#home .visual-home").prepend("<img src='images/globals/hoekje-rb.png' class='corner-rb' alt='' />");
	
	// Stripe
	$(".table-overview tr:nth-child(even), .sidebar table tr:nth-child(even), .column-576 table tr:nth-child(even)").addClass("striped");

	$('.page-options').prepend('<li class="print"><a href="#print">Seite ausdrucken</a></li>');
	$('.page-options li.print a').click(function() {
		window.print();
		return false;
	});
	
	// Display items on a different way
	$(".table-overview dl dd:last-child").addClass("last-dd");
	
	
	// Write elements when javascript is enabled
	$(".image-thumbs dd a").prepend("<img src='images/globals/pixel.gif' class='hide' alt='' />");
	
	window.bind_click = function(){
		// remove ALL click handlers - including PrettyPhoto.click()
		$('.show-bigger').unbind('click');
	
		// Show 2nd size image in bigger image box
		// allow 3rd size image to be shown in prettyphoto box.
		$('.show-bigger').click(function(){
			relSplit = this.rel.split(/\s/);
			
			image_id = relSplit[1];
			image_url = relSplit[2];
			
			$('#' + image_id).attr('src', image_url);
			$('#' + image_id).attr('alt', this.childNodes[1].alt);
			$('#' + image_id).parent().attr('href', this.href);

			return false;
		});
	}
	window.bind_click();
	
	// PNG fix for IE
	$('img[@src$=.png], .learn-more, .visual-home span p, .visual-home span h1, .visual-home span form').ifixpng();
	
});
