$(document).ready(function(){
	
	// fade content in
	$("div#content").fadeIn("slow");
	
	// slide content up before opening a new page
	$("ul#navi a,a.more").click(function(event) {
		event.preventDefault();
		$("div#content").fadeOut("slow", function() {
			window.location.href=event.target.href;
		});
	})
	
	// load latest chart to frontpage
	$("body#upcoming div.latest-chart").load("charts.htm ol:first", function(){
		createChart();
	}).fadeIn("slow");
	
	// load latest mix to frontpage
	$("body#upcoming div.latest-mix").load("mixes.htm div.latest", function(){
		createMix();
	}).fadeIn("slow");	
	
	$('.back-to-top').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
	});

});

function createChart() {
	$("body#upcoming div.latest-chart").prepend("<h2>Latest Chart</h2>");
	$("body#upcoming div.latest-chart").append("<a title='More charts' class='more' href='charts.htm'>More charts &raquo;</a>");	
}

function createMix(){
	$("body#upcoming div.latest-mix").append("<a title='More mixes' class='more' href='mixes.htm'>More mixes &raquo;</a>");	
}

