// Shadowbox
Shadowbox.init({troubleElements: ["embed"]});

// Cufon
Cufon.replace("#payoff", { fontFamily: "Gotham Bold", textShadow: "1px 1px rgba(0, 0, 0, 0.8)"});
Cufon.replace("#topmenu a, #mainItems a, a.cta, div#submenu a", { fontFamily: "Gotham Bold", hover: true });
Cufon.replace("h1, h2, h3, h4, span.title, div.title, td.title, #headerSlider p, #content table.shop .price", { fontFamily: "Gotham Bold" });
Cufon.replace("#logo", { fontFamily: "Gotham Ultra" });

/**
  * Alert configuration
**/
$(function() {
	$.alerts.overlayOpacity = 0.75;
	$.alerts.overlayColor = "#000";
});

// DOM replacements
$(function() {
	
	// Read More-buttons
	$("#content a.cta").wrap("<span class=\"ctaWrapper\"></div>");

	// Youtube max-width
	$("param[value*='youtube'], embed[src*='youtube']").each(function() {
		$(this).closest("object").attr("width", 275).attr("height", 220);
		$(this).parent().find("embed").attr("width", 275).attr("height", 220);
	});

});

// Weather 
$(function() {
	$("#weather").weatherfeed(['NLXX0012'], { highlow: false, wind: false, link: false, showerror: false, location: false, temp: true, description: false });
});

// Equal heights 
$(function() {
	var maxHeight = 0;
	$("body.home section.item").each(function() {
		if ($(this).height() > maxHeight) {
			maxHeight = $(this).height();
		}
	}).css("min-height", maxHeight);

});

$(function() {
	$("#headerSlider").each(function() {
		var $paging = $("<div class=\"paging\"></div>").appendTo($(this));
		var $list = $paging.siblings("ul");
		var $scroller = $list.wrap("<div class=\"scroller\"></div>");
		var numItems = $list.find("li").length;
		var width = $list.find("li").width();
		for (var i = 0; i < numItems; i++) {
			$("<div class=\"page\"></div>").appendTo($paging);
		}
		$list.width(numItems * width);
		$paging.find(".page").each(function(index) {
			$(this).click(function() {
				$(this).siblings().removeClass("active");
				$(this).addClass("active");
				// scrollTo
				$scroller = $paging.siblings(".scroller");
				$scroller.animate({
					left: -($scroller.width() * index)
				});
			});
		});				
		$paging.find(".page:first-child").addClass("active");
	});
});
