$(document).ready(function() {

	//fix PNG-BUG IE<=6
	$("img").ifixpng();
	$("a.button_hell").ifixpng();
	$("a.button_dunkel").ifixpng();
	$("#footer_bg").ifixpng();

	//Lupe hinzufügen
	$("a.shadowbox").each(function() {

		$(this).append('<div class="lupe"></div>');

		$("div.lupe").ifixpng();

	});

	//drucken
	$("div#drucken").click(function() {
		window.print();
	});


	//Headerlinks
	$("img.headerlink").hover(

		function () {

			var bu_up =	$(this).parent().attr("rel");

			$(this).parent().attr("rel", $(this).attr("src"));
			$(this).attr("src", bu_up);

		},

		function () {

			var bu_do =	$(this).parent().attr("rel");

			$(this).parent().attr("rel", $(this).attr("src"));
			$(this).attr("src", bu_do);

		}

	);

	//Metanavigation
	$("li.metalink").hover(

		function () {

			//alle anderen ausblenden falls noch welche aktiv sind -> bugfix
			$(".metalink").children("ul").hide();

			var bu_up =	$(this).children("a").attr("rel");

			var pos = $(this).position();

			$(this).children("a").attr("rel", $(this).children("a").children("img").attr("src"));
			$(this).children("a").children("img").attr("src", bu_up);

			$(this).children("ul").css("left", pos.left);
			$(this).children("ul").css("top", pos.top + 53);
			$(this).children("ul").show();

		},

		function () {

			var bu_do =	$(this).children("a").attr("rel");

			$(this).children("a").attr("rel", $(this).children("a").children("img").attr("src"));
			$(this).children("a").children("img").attr("src", bu_do);

			$(this).children("ul").hide();

		}

	);

	//alle externen Links kennzeichnen
	$('a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).addClass('external');

	//alle externen Links in Analytics
	$("a.external").click(function(){

		var site = $(this).attr('href');
		site = site.replace("http://", "");

 		pageTracker._trackEvent("external", site);

	});

});
