var i = 1;
var j = 0;
var images = ["/img/site/header_01.jpg", "/img/site/header_02.jpg", "/img/site/header_03.jpg", "/img/site/header_04.jpg"];
var logos  = ["/img/site/logo_sv.png", "/img/site/logo_en.png"];

$(document).ready(function(){
	setTimeout("image_changer()", 5000);
	setTimeout("logo_changer()", 5000);
	show_hide_dropdown();
	
	$("a[rel=group]").fancybox({
		'padding'			: 0,
		'cyclic'			: true,
		'centerOnScroll'	: true,
		'hideOnContentClick': false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
});

function image_changer(){

	$(".change").fadeOut(200,function(){
		$(".change").attr("src",images[i]).fadeIn(200);
	});
	
	i++;
	if(i == images.length){ i = 0; }
	
	setTimeout("image_changer()", 5000);
}

function logo_changer(){

	$(".logo IMG").fadeOut(200,function(){
		$(".logo IMG").attr("src",logos[j]).fadeIn(200);
	});
	
	j++;
	if(j == logos.length){ j = 0; }
	
	setTimeout("logo_changer()", 5000);
}

function show_hide_dropdown(){

	$("#menu li").hover(
	function(){
		var submenu = "#"+$(this).attr("id")+" ul";
		$(submenu).css({"display" : "block"});
	},
	function(){
		var submenu = "#"+$(this).attr("id")+" ul";
		$(submenu).css({"display" : "none"});
	});
}

function scroller() {
	$.each($.browser, function(i) {
		if(i=="mozilla" || i=="opera" || i=="webkit"){
			if($(".table_head").scrollFollow({
				speed: 100,
				offset: 25,
				onText: 'Disable Follow',
				offText: 'Enable Follow'
			})){
				if(i=="mozilla" || i=="opera"){
                    $(".table_head").css({"margin-top" : "-20px", "background-color" : "#ffffff"});
				} else{
					$(".table_head").css({"margin-top" : "360px", "background-color" : "#ffffff"});
				}
		   }
		} else if(i=="msie"){
			if($(".table_head").scrollFollow({
				speed: 100,
				offset: 29,
				onText: 'Disable Follow',
				offText: 'Enable Follow'
			})){
				$(".table_head").css({"margin-top" : "356px", "background-color" : "#ffffff"});
				$("#diesel").css({"padding-bottom" : "5px"});
			}
		}
	});
}
