$(document).ready(function() {
	$(".link-file").attr('target', '_blank');
	$(".n1").css('text-decoration','underline');
	
	function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

};

jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};

// Ride the carousel...
    jQuery("#newsteaser-j").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
		easing: 'BounceEaseOut',
        animation: 2000
    });
	
$(".n1").click(function() {
		for (i=1;i < 4;i++) {
			$(".n"+i).css('text-decoration','none');
		} 
		$(this).css('text-decoration','underline');
	});

$(".n2").click(function() {
		for (i=1;i < 4;i++) {
			$(".n"+i).css('text-decoration','none');
		} 
		$(this).css('text-decoration','underline');
	});	
	
$(".n3").click(function() {
		for (i=1;i < 4;i++) {
			$(".n"+i).css('text-decoration','none');
		} 
		$(this).css('text-decoration','underline');
	});

//Bilderwechsel
$('#headerpic').innerfade({
						animationtype: 'fade',
						speed: 2000,
						timeout: 5000,
						type: 'sequence',
						containerheight: 'auto'
					});

//Produktzoom
$(".Produkt .Pics a").fancybox({ 
	'hideOnContentClick': true, 
	'zoomSpeedIn': 800, 
	'zoomSpeedOut': 800, 
	'overlayShow': true
});

$("#in1").click(function() {
		$("#in2").css('text-decoration','none');
		$('#pic2').fadeOut(2000);
		$('#pic1').fadeIn(2000);
		$(this).css('text-decoration','underline');
	});
	
$("#in2").click(function() {
		$("#in1").css('text-decoration','none');
		$('#pic1').fadeOut(2000);
		$('#pic2').fadeIn(2000);
		$(this).css('text-decoration','underline');
	});
  
  
  /** ------------------------- Autocomplete -------------------------**/
  function formatItem(row) {
      return row[0];
    }
    function formatResult(row) {
      return row[1].replace(/(<.+?>)/gi, '');
    }
	

  $("#suchwort").autocomplete("storage/scripts/general/autocomplete.php", {
      minChars: 3,
      width: 123,
      highlight: false,
      selectFirst: false,
      formatItem: formatItem,
      formatResult: formatResult
    }).result(function() {
      $('#searchform').submit();
    });
/** ------------------------- Autocomplete -------------------------**/ 

});

