
$(document).ready(function() {

	//fix PNG-BUG IE<=6
	$("img").ifixpng();
	$("div#header").ifixpng();
	$("div#navileft").ifixpng();
	$("div.content_rubrik_header").ifixpng();
	$("div.content_rubrik_footer").ifixpng();
	$("div.footer").ifixpng();

	$(".header_nav").hover(

		//mouseover
		function () {

			if ($(this).attr("rel")) {

				var bu_up = $(this).attr("rel");

				$(this).attr("rel", $(this).children("img").attr("src"));

				$(this).children("img").attr("src", bu_up);

				$("#" + $(this).attr("id") + "_content").show();

			}

		},

		//mouseout
		function () {

			if ($(this).attr("rel")) {

				var bu_do = $(this).attr("rel");

				$(this).attr("rel", $(this).children("img").attr("src"));

				$(this).children("img").attr("src", bu_do);

				$("#" + $(this).attr("id") + "_content").hide();

			}

		}

	);

////////////////////////////////////////////////////////////////////////

	$("#navileft img").hover(

		//mouseover
		function () {

			$(this).attr("src", $(this).parent("a").attr("rel_up"));

			$(this).ifixpng();

		},

		//mouseout
		function () {

			$(this).attr("src", $(this).parent("a").attr("rel_do"));

			$(this).ifixpng();

		}

	);

////////////////////////////////////////////////////////////////////////////

	//$(".content_rubrik").click(function() {

		//window.location.href = $(this).children("div.content_rubrik_footer").children("a").attr("href");
		//alert(window.location.href);
	//});

	$(".header_nav").click(function() {
	window.location.href = $(this).children("div.content_rubrik").children("div.content_rubrik_footer").children("a").attr("href");
	//alert(window.location.href);
	});


	// Captcha
	$("#captcha").click(function(){
		var random = Math.floor(Math.random()*25600);

		$("#captcha img").attr("src", "/captcha/image.php?new_captcha=true&" + random);

	});

	//Prüfung ob alle Pflichtfelder ausgefüllt sind.
	$(".validate").validate();

    //drucken
    $("#drucken").click(function () {
    	window.print();
    });

    //bookmark
    $("#bookmark").click(function () {

		var url = $(this).attr("rel_url");
		var title = $(this).attr("rel_title");

		if (window.sidebar) { // Mozilla Firefox
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite(url, title);
		} else if(window.opera) { // Opera 7+
			var elem = document.createElement('a');
		    elem.setAttribute('href',url);
		    elem.setAttribute('title',title);
		    elem.setAttribute('rel','sidebar');
		    elem.click();
		} else {
			alert('Ihr Browser unterstützt diese Aktion leider nicht. Bitte fügen Sie diese Seite manuell zu Ihren Favoriten hinzu.');
		}

    });

});

