$("<link>").attr("type", "text/css").attr("rel", "stylesheet").attr("href", "http://www.willoughbydesign.com/styles/homepage").appendTo("head");

var current_feature = 0;

$(function(){
	$("#feature-" + current_feature).hide();

	function swapFeature(f) {
		var header = $(f).children(".homepage-item-headline").text();
		var shortHeader = $(f).children(".homepage-item-short").text();
		var content = $(f).children(".homepage-item-content").html();
		var image = $(f).children(".homepage-item-image").children("img").attr("src");
		var small = $(f).children(".homepage-item-small").children("img").attr("src");
		var layout = $(f).data("layout");
		
		$(f).children(".homepage-item-headline").text($("#homepage-header").text());
		$(f).children(".homepage-item-short").text($("#homepage-short").text());
		$(f).children(".homepage-item-content").html($("#homepage-content-text").html());
		$(f).children(".homepage-item-image").children("img").attr("src", $("#homepage-image").children("img").attr("src"));
		$(f).children(".homepage-item-small").children("img").attr("src", $("#homepage-small").children("img").attr("src"));
		$(f).removeData("layout");
		$(f).data("layout", $("#homepage-feature").data("layout"));

		$("#homepage-header").text(header);
		$("#homepage-short").text(shortHeader);
		$("#homepage-content-text").html(content);
		$("#homepage-image").children("img").attr("src", image);
		$("#homepage-small").children("img").attr("src", small);
		$("#homepage-content").attr("class", "homepage-layout-" + layout);
		$("#homepage-feature").removeData("layout");
		$("#homepage-feature").data("layout", layout);

		updateHomepageHeader();
	}
	
	$(".homepage-item").click(function(event){
		event.preventDefault();
		swapFeature($(this));
	});

	//$(".homepage-item:last").trigger("click");
	
});
