$(function(){
	// initialize in-field-labels
	$("#footer .footer-email label, .ban_nl label").inFieldLabels();

	// show hide info-overlay on product icons
	$(".features .icons li span.active").mouseover(function(){
		var span = $(this),
			top = span.offset().top + 28,
			left = $(".features").offset().left,
			className = span.attr("class").substring(0, span.attr("class").indexOf(" "));
			
		if (c_region == 'se')
		{
			top = span.offset().top - $(".legend").find(".legend_" + className).height() - 30;
		}
			
		$(".legend").css({"top": top, "left": left}).find(".legend_" + className).fadeIn();
	}).mouseout(function(){
		$(".legend li").hide();
	});

	// bottom alignment of dealer locator buttons

	// initialize show-links for technology-texts / product detail
	$("#technology .tech-texts li").each(function(index){
		$(this).data("c_height", $(this).height());
	});
	$("#technology ul.tech-texts").css({"position":"static"}).find("li:not(:first)").hide();
	$("#technology ul.tech-texts li:first").css({"height":$("#technology ul.tech-texts li:first").data("c_height")})
	$("#technology .tech-links li").click(function(){
		var index = $(this).index(),
			currLink = $("#technology .tech-links li"),
			currText = $("#technology .tech-texts li:eq("+index+")");
		$("#technology .tech-texts li:visible").fadeOut(150, function(){
			currText.fadeIn(300, function(){
				currText.animate({height: currText.data("c_height")}, 300);
			});
		});
		currLink.removeClass("curr").parent().find("li:eq("+index+")").addClass("curr");
	});

	// scroll product detail images
	$(".turn_images a").click(function(ev){
		var clickedLink = $(this),
			images = $("#product_image_large li"),
			images_length = images.length,
			curr_image = $("#product_image_large li:visible").index();
		ev.preventDefault();
		
		if (clickedLink.hasClass("next")){
			if (curr_image < images_length-1){
				if (curr_image==0){
					$(".turn_images a.back").removeClass("back_inactive")
				}
				$("#product_image_large li:eq("+curr_image+")").hide().next().fadeIn();
				curr_image +=2;
				$("#curr_img").html(curr_image);
				if (curr_image==images_length){
					clickedLink.addClass("next_inactive")
				}
			}
		}
		if (clickedLink.hasClass("back")){
			if (curr_image > 0){
				if (curr_image==images_length-1){
					$(".turn_images a.next").removeClass("next_inactive")
				}
				$("#product_image_large li:eq("+curr_image+")").hide().prev().fadeIn();
				$("#curr_img").html(curr_image);
				if (curr_image==1){
					clickedLink.addClass("back_inactive")
				}
			}
		}
	});

	// news detail image slides
	$("#news_gallery .gallery_nav a").click(function() {
		if ( $("#" + this.rel).is(":hidden") ) {
			$("#news_gallery .gallery_output img").slideUp();
			$("#" + this.rel).slideDown();
		}
	});

	// init accordion (download-page)
	$("#download_accordion").accordion({
		autoHeight: false,
		active: false,
		navigation: true,
		collapsible: true
	});

});
