function fix_png() {
	$(this).livequery(function() {
		$("#kunden_logos div img").ifixpng();
	});
}

$(document).ready(function() {

	//fix PNG-BUG IE<=6
	$('img[@src$=.png]').ifixpng();
	$("#sparten").ifixpng();
	$('#content_top').ifixpng();
	$('#content').ifixpng();
	$('#content_bottom').ifixpng();
	$("#kunden_logos div img").iunfixpng();
	$("#news_img img").iunfixpng();

	//Navigation HOVER
	$(".sparten_image").hover(function(){
        s = $(this).attr("rel_up");
        $(this).attr("src", s);
        $(this).ifixpng();
    }, function() {
		s = $(this).attr("rel_do");
        $(this).attr("src", s);
        $(this).ifixpng();
	});

	//Kunden Logos
	$("#kunden_logos div").cycle({
	    fx:'curtainX',
	    speed:1500,
	    cssAfter:{
	        width: 150,
	        height: 75
	    },
	    after:fix_png
	 });

	$("#kunden_logos div").hover(function(){
        $('#kunden_logos div').cycle("pause");
    }, function() {
		$('#kunden_logos div').cycle("resume", true);
	});

	//Kundenlogos onclick
	$($("#kunden_logos img")).livequery("click", function() {
		window.location.href  = $(this).attr("rel");
	});

	//Tabelle Referenzen sortieren
	$("#referenzen")
		.tablesorter({sortList: [[1,0]], widgets: ['zebra']})
		.tablesorterPager({container: $("#pager")});

	//Hilfe zur Suche einblenden
	$("#suche_hilfe").click(function() {

		if ($("#suche_hilfe_content").css("display") == "none") {
			$("#suche_hilfe_content").fadeIn(1000);
		} else {
			$("#suche_hilfe_content").fadeOut(1000);
		}

	});

	//Produkte HOVER
	$(".produkte").hover(function(){
        s = $(this).attr("rel_up");
        $("#produkte_img").attr("src", s);
        $("#produkte_img").ifixpng();
    }, function() {
		s = $(this).attr("rel_do");
        $("#produkte_img").attr("src", s);
        $("#produkte_img").ifixpng();
	});

	//Kontaktformular validieren
	$("#kontaktform").validate();

	//Captcha neu laden
	$("#captcha_div").livequery("click", function () {

		var random = Math.floor(Math.random()*25600);

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

	});

	$("#suche").defaultvalue("Suche");

	//Suggest für Suche
	$("#suche").autocomplete("../inc/suchbegriffe.inc.php", {
		delay: 750,
		minChars: 2,
		width: 179,
		max: 20,
		scrollHeight: 300,
		matchContains: true,
		selectFirst: false
	});

	//Bookmarks
	$('#bookmark').bookmark({
		sites: ['google', 'misterwong', 'digg', 'delicious', 'facebook', 'furl', 'myspace', 'yahoo', 'yigg', 'technorati']
	});

	//alle externen Links in Analytics
	$("a[target*='_blank']").click(function(){

		var site = $(this).attr('href');
		site = site.replace("http://", "");

 		pageTracker._trackPageview('/external/'+ site);

	});

});