Cufon.replace("h1.replace, #delivery h3", {fontFamily: 'Gill Sans MT'});

$(function() {
	
	if(!($.browser.msie && $.browser.version=="6.0")) {
		$("#assortiment img").hover(function() {
		
			$(this).stop(true).animate({height: 182, width: 182, top: -15, left: -25}, 300);
		
		}, function() {
		
			$(this).stop(true).animate({height: 137, width: 137, top: 7, left: -3}, 300);
		
		});
		
		setTimeout(function() {
			
			$("#assortiment img").stop(true).animate({height: 182, width: 182, top: -15, left: -25}, 300, function() {
				setTimeout(function() { $("#assortiment img").stop(true).animate({height: 137, width: 137, top: 7, left: -3}, 300); }, 500);
			});
		
		}, 4000);
		
	}
		
	$("#slideshow").each(function() {
	
		$(this).append('<ul id="slideNav"></ul>');
		
		var i=0;
		var slides = new Array();
		var slideLoc = 0;
		var slideTot = $("li", this).size();
		var slideOut;
		
		function slide() {
			
			slideLoc++;
			if(slideLoc == slideTot)
				slideLoc = 0;
			
			$("#slides").append('<li>' + slides[slideLoc] + '</li>');
			if(!$.browser.msie)
				$("#slides").find("li:last > div").hide();
			$("#slides").animate({left: -671}, 800, function() {
				
				if(!$.browser.msie)
					$(this).find("li:last > div").fadeIn(800);
				$(this).css("left", 0).find("li:first").remove();
			
			});
			
			$("#slideNav li").removeClass("active");
			$("#slideNav li:eq(" + slideLoc + ")").addClass("active");
			
		}
		
		$("li", this).each(function() {
				
			slides[i] = $(this).html();
			
			if(i!=0)
				$(this).remove();
			
			$("#slideNav").append('<li><a href="#" title="Slide ' + (++i) + '"></a>');
			
		});
		
		if(!$.browser.msie) {
			$("#slides img:first").load(function () {
				$("#slides").find("li:last > div").hide().fadeIn(800);
			});
		}
		
		$("#slideNav a").click(function() {
			
			slideLoc =$(this).parent().parent().find("li").index($(this).parent());
			
			$("#slides").append('<li>' + slides[slideLoc] + '</li>');
			if(!$.browser.msie)
				$("#slides").find("li:last > div").hide();
			$("#slides").animate({left: -671}, 800, function() {
				
				if(!$.browser.msie)
					$(this).find("li:last > div").fadeIn(800);
				$(this).css("left", 0).find("li:first").remove();
			
			});
			
			$("#slideNav li").removeClass("active");
			$(this).parent().addClass("active");
			
			clearInterval(slideOut);
			slideOut = setInterval(function() { slide(); }, 8000);
		
			return false;
		
		});
		
		$("#slideNav li:first").addClass("active");
		
		slideOut = setInterval(function() { slide(); }, 8000);
	
	});
	
	$("#overview .zoom").fancybox({
		transitionIn: 'elastic',
		transitionOut: 'elastic'
	});
	
	$("#product .zoom ul img:first").css("z-index", 1);
	
	$("#product .zoom a[rel=group]").fancybox({
		transitionIn: 'elastic',
		transitionOut: 'elastic'
	});
	
	$(".linkZoom").click(function() {
	
		$(this).prev().find("a:first").click();
	
	});
	
	$("#menu > ul > li > a").click(function() {
		
		if($(this).parent().find("ul").size()) {
		
			if($(this).parent().find("ul:visible").size()) {
				$(this).parent().find("ul").slideUp(250);
				$(this).parent().find(".active").fadeOut(250);
				$(this).append('<span class="closed" />').parent().find(".closed").hide().fadeIn(250);
			}
			else {
				$(this).parent().find("ul").slideDown(250);
				$(this).parent().find(".closed").fadeOut(250);
				$(this).append('<span class="active" />').parent().find(".active").hide().fadeIn(250);
			}
		
			
			return false;
			
		}
		else
			return true;
	
	});
	
	$(":submit").hover(function() {
	
		$(this).addClass("hover");
	
	}, function() {
	
		$(this).removeClass("hover");
	
	});

});
