function loadJsonData(url){
	$("#content").fadeOut(100, function(){
		$.ajaxSetup({cache:true});
		$.getJSON(url, function(data){
			if(data.images[0]){
				$("div#content").css("background-image", "url("+data.images[0].src+")");
			}else{
				$("div#content").css("background-image", "none");
			};
		
			$("div#item").children().remove();
					
			$("div#item").append("<h2>"+data.title+"</h2>");
			$("div#item").append(data.content);	
			if(data.download != ''){
				$("div#item").append("<a href='"+data.download+"' id='download'>download</a>");			
			};
			
			Cufon.replace('h2');
			$("#content").fadeIn(100);
		});
	});
};

$(document).ready(function(){
	$("ul ul").find('a').click(function(){
		hash = $(this).attr('id');
					
		if(hash != window.location.hash.substring(1)){
			loadJsonData("/media/json/"+hash+".json");	
			
			window.location = "#"+hash;
			
			$("ul ul").find('a').removeClass("active");				
			$(this).addClass("active");
		}		
		
		return false;
	});

	// load first data
	hash = window.location.hash.substring(1) ||	$('ul ul').find('a')[0].id;		
	loadJsonData("/media/json/"+hash+".json");
	$('#'+hash).addClass("active");
		
	Cufon.replace('h2');
	Cufon.now()
});
