$(document).ready(function(){

	// Gallery

	var slideshow_pics = new Array(
		'/images/gallery/glinde.jpg',
		'/images/gallery/bergkramerhof.jpg',
		'/images/gallery/birnbach.jpg',
		'/images/gallery/elfrathermuehle.jpg',
		'/images/gallery/hilzhofen.jpg',
		'/images/gallery/hockenberg.jpg',
		'/images/gallery/kosaido.jpg',
		'/images/gallery/mariabildhausen.jpg',
		'/images/gallery/schaerding.jpg',
		'/images/gallery/strelasund.jpg',
		'/images/gallery/sinsheim',
		'/images/gallery/wittenbeck.jpg',
		'/images/gallery/wildenrath.jpg'
	);

	function randOrd() {
		return (Math.round(Math.random())-0.5);
	}
	
	slideshow_pics.sort(randOrd);

	idx = 0;

	function loadData() {

		if(idx >= slideshow_pics.length)
			idx = 0;

		var img = new Image();
	
		$(img).load(function () {

			$(this).css("display","none");
			$('#slideshow').append(this);
			$(this).fadeIn(2500, function() {
				if($('#slideshow').children('img').length > 1)
				{
					$('#slideshow').children('img:first').remove();
				}
			});

		}).attr('src', slideshow_pics[idx]);

		idx++;
	};

	loadData();
	setInterval( loadData, 7000 );

	// zebra table
	$(".zebra tr:odd td").css("background-color", "#fff");

	// target blank
	$("a.blank").attr("target","_blank");

	// partnerclubs menü
	$("#partnerclubs").hover(function (){
		$("#partnerclubs ul").css("visibility","visible");
	},
	function (){
		$("#partnerclubs ul").css("visibility","hidden");
	});

	// kontakt menü
	$("#kontakt").hover(function (){
		$("#kontakt ul").css("visibility","visible");
	},
	function (){
		$("#kontakt ul").css("visibility","hidden");
	});

	// hover highlight
	$(".hover tr").mouseover(function () { $(this).addClass("highlight"); });
	$(".hover tr").mouseout(function () { $(this).removeClass("highlight"); });	

	// Fix PNGS IE6
	$("#logo").pngfix();
	$("#header_pic").pngfix();
	$(".home h2").pngfix();
	$(".generic h2").pngfix();
	$(".guide h3").pngfix();
	$(".sidebar h3").pngfix();
	$(".sidebar a.cart").pngfix();
	$(".sidebar a.pdf").pngfix();
	$("li a.icon_pdf").pngfix();
	$(".shop div a.icon_pdf").pngfix();
	$("a.mail").pngfix();
	$(".home a").pngfix();
	$(".home h4").pngfix();
	$(".home cite").pngfix();
	$("li.title").pngfix();
	$("td span").pngfix();
	$(".shop th span").pngfix();
	$("span.done").pngfix();
	$("span.error").pngfix();
	$("#toggle_liefer_adresse").pngfix();
	$(".map_eu a").pngfix();
	$(".map_eu a").css("cursor","pointer")
	$(".map_de a").pngfix();
	$(".map_de a").css("cursor","pointer")
});
	
	// Image Preloader
	
	var preloaded = new Array();
	function preload_images() {
		for (var i = 0; i < arguments.length; i++){
			preloaded[i] = document.createElement('img');
			preloaded[i].setAttribute('src',arguments[i]);
		};
	};
	
	preload_images(
		'/images/misc/home_arrow.png',
		'/images/misc/loader.gif'
	);

	// Shop

	function goBack(step_val) {
		document.forms['form1'].step.value= step_val;
		$('#form1').attr('action','index.php');
		document.forms['form1'].submit();
	}

	function submit_payment_form() {
		document.payment_form.submit();
	}