// Embedding a special CSS file for Mac Computers because of typo/pixel differences
if ((navigator.appVersion.indexOf("Mac") != -1)) {
document.write("<link rel='stylesheet' href='http://fanclub.typo3.katzer-neumann.de/dfb-toolbox/stylesheets/mac.css' type='text/css'>"); 
}

var start;

function RotationStart(position) {
	var duration = 8000;
	if(!position || position > 3) position = 1;
	if(position == 1) {
		$("div#News3").fadeOut("1000");
		hides = window.setTimeout( "HideMe('false', 'true', 'true')", 1000);
		$('#RotationQueue1').css('backgroundColor', '#d3d3d3');
		$('#RotationQueue2').css('backgroundColor', '#ededed');
		$('#RotationQueue3').css('backgroundColor', '#ededed');		
		$("div#News1").fadeIn("1000");
		interval = window.setTimeout("RotationStart(2)", duration );
	}
	if(position == 2) {
		$("div#News1").fadeOut("1000");
		hides = window.setTimeout( "HideMe('true', 'false', 'true')", 1000);
		$('#RotationQueue1').css('backgroundColor', '#ededed');
		$('#RotationQueue2').css('backgroundColor', '#d3d3d3');
		$('#RotationQueue3').css('backgroundColor', '#ededed');				
		$("div#News2").fadeIn("1000");
		interval = window.setTimeout("RotationStart(3)", duration );
	}
	if(position == 3) {
		$("div#News2").fadeOut("1000");
		hides = window.setTimeout( "HideMe('true', 'true', 'false')", 1000);
		$('#RotationQueue1').css('backgroundColor', '#ededed');
		$('#RotationQueue2').css('backgroundColor', '#ededed');
		$('#RotationQueue3').css('backgroundColor', '#d3d3d3');				
		$("div#News3").fadeIn("slow");
		interval = window.setTimeout("RotationStart(1)", duration );
	}
}
function RotationStop() {
	window.clearTimeout(interval);
	window.clearTimeout(hides);
	window.clearTimeout(start);
}
function Display(id) {
	if(id == 1) {
		$('#RotationQueue1').css('backgroundColor', '#d3d3d3');
		$('#RotationQueue2').css('backgroundColor', '#ededed');
		$('#RotationQueue3').css('backgroundColor', '#ededed');
		$('#News1').show();
		$('#News2').hide();
		$('#News3').hide();
	}
	if(id == 2) {
		$('#RotationQueue1').css('backgroundColor', '#ededed');
		$('#RotationQueue2').css('backgroundColor', '#d3d3d3');
		$('#RotationQueue3').css('backgroundColor', '#ededed');
		$('#News1').hide();
		$('#News2').show();
		$('#News3').hide();
	}
	if(id == 3) {
		$('#RotationQueue1').css('backgroundColor', '#ededed');
		$('#RotationQueue2').css('backgroundColor', '#ededed');
		$('#RotationQueue3').css('backgroundColor', '#d3d3d3');
		$('#News1').hide();
		$('#News2').hide();
		$('#News3').show();
	}
}
function HideMe(n1, n2, n3) {
	if(n1 == 'true') $('#News1').hide();
	if(n2 == 'true') $('#News2').hide();
	if(n3 == 'true') $('#News3').hide();
}
function RotationResume(id) {
	if(id == 1) {
		start = window.setTimeout('RotationStart(2)', 1000);
	}
	if(id == 2) {
		start = window.setTimeout('RotationStart(3)', 1000);
	}
	if(id == 3) {
		start = window.setTimeout('RotationStart(1)', 1000);
	}
}

// Searchbox reset values
function clearInputDefaults(formitem, defaultvalue) {
	if(document.getElementById(formitem).value == defaultvalue) document.getElementById(formitem).value="";
}

$(document).ready(function() {
	  // Navigation functions
	  //Hover functions for the drop down effects
	  $(".nav_level_1").hover(
		function() {
	      $(this).children(".nav_level_2").stop(true, true).fadeIn('fast');
	    },
		function() {
	      $(this).children(".nav_level_2").stop(true, true).fadeOut('fast');
	    }
	  );

	    $(".moretab").hover(
		function() {
	      $(this).children(".moretab_level_2").stop(true, true).fadeIn('fast');
	      $(this).addClass('opened');
	    },
		function() {
	      $(this).children(".moretab_level_2").stop(true, true).fadeOut('fast');
	      $(this).removeClass('opened');
	    }
	  );

	// Showing only 3 level 3 menuitems. All others will be hidden.
	  $('.nav_level_3').each(function(){ 

	    var counter = 0;
	    $(this).children('li.visible').each(function(){
	      if(counter > nav_level_3_items_low) {
	        $(this).hide();
	        $(this).addClass('hidden');
	      }
	      counter++;
	    }); 
	    if(counter < nav_level_3_items_high) {
	      $(this).children('li.morelink').hide();
	    }
	  });

	// functions to display additional menu items throught the "more" link
	  $('.more').click(function() {
	    if ($(this).hasClass('opened')) {
	      $(this).parents('.nav_level_2 li').removeClass('highlight').find('li.hidden').hide();
	      $(this).text('mehr >>');
	      $(this).removeClass('opened');
	    } else {
	      $(this).parents('.nav_level_2 li').addClass('highlight').find('li').show();
	      $(this).text('<< weniger');
	      $(this).addClass('opened');
	    }

	  });
	
	// function to display the "Tip a friend" page in a fancybox
	$(".fancy_recform").fancybox({
	    'titleShow'     	: false,
	    'autoScale'     	: false,
		'width'				: 550,
		'height'			: 440,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});
	// activate fancybox_image_galleries 
	$("a[rel=photo_gallery]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
		}
	});
	// function to display the A-Z page from the A-Z Button in a fancybox
	$(".fancy_az").fancybox({
			    'titleShow'     	: false,
				'width'				: 215,
				'height'			: 480,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});	
	
});
