/* Template JS */

var Template = {
		
	start: function() {

		/* Home carousel */
		$('#carousel .tabdiv:not(:first)').animate({"opacity" : 0}, 1);

		$('#carousel a.carousel-item1').hover(function() {
			$('#carousel .tabdiv:not(#carousel-item1)').stop().animate({"opacity" : 0});
			$('#carousel-item1').stop().animate({"opacity" : 1});
		}, function() {});

		$('.tabnav a.carousel-item2').hover(function() {
			$('#carousel .tabdiv:not(#carousel-item2)').stop().animate({"opacity" : 0});
			$('#carousel-item2').stop().animate({"opacity" : 1});
		}, function() {});

		$('.tabnav a.carousel-item3').hover(function() {
			$('#carousel .tabdiv:not(#carousel-item3)').stop().animate({"opacity" : 0});
			$('#carousel-item3').stop().animate({"opacity" : 1});
		}, function() {});

		$('.tabnav a.carousel-item4').hover(function() {
			$('#carousel .tabdiv:not(#carousel-item4)').stop().animate({"opacity" : 0});
			$('#carousel-item4').stop().animate({"opacity" : 1});
		}, function() {});

		$('.tabnav a.carousel-item5').hover(function() {
			$('#carousel .tabdiv:not(#carousel-item5)').stop().animate({"opacity" : 0});
			$('#carousel-item5').stop().animate({"opacity" : 1});
		}, function() {});
	
		/* Add row end for product list */
		$("ul.ProductList li:nth-child(4n)").addClass("RowEnd");

		/* Home type selector animations */
		$("div.UhrtypSelector div.UhrtypSelection span").css({
			top: "70px",
			opacity: 0.0
		});
		$("div.UhrtypSelector div.UhrtypSelection").hover(function () {
			$(this).find("img:first").animate({ 
					opacity: 0.33
				}, {
					queue:false,
					duration:300
				});
			$(this).find("span:first").animate({ 
					top: "100px",
					opacity: 1.0
				}, {
					queue:false,
					duration:300,
					easing:"easeOutBack"
				});
	    }, function () {
			$(this).find("img:first").animate({ 
					opacity: 1.0
				}, {
					queue:false,
					duration:400
				});
			$(this).find("span:first").animate({ 
					top: "130px",
					opacity: 0.0
				}, {
					queue:false,
					duration:400,
					easing:"easeInBack",
					complete: function(){ 
						$(this).css({"top" : "70px", "opacity" : 0.0}); 
					} 
				});
	    });

		/* IE6 fixes */
		if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
			$("div.UhrtypSelector div.UhrtypSelection img").attr('galleryimg', 'no');
		}

		/* Hide breadcrumb strating from second */
		var i = 0;
		$("div#ProductBreadcrumb ul").map(function(){
			if (i++) {
	      		$(this).css('display', 'none');
			}
    	});

	}

}

$(document).ready(Template.start);

