(function($){
	$(function(){
		$("#bgloader").html('<img src="http://www.gamingtruth.com/raw/images/loader.gif" width="31" height="31" alt="loading background" />');
		/*$.get(
				"getgamer.php?gamertag=Birthmark111",
				function(result){
					$(document.body).append('<img src="'+result.getElementsByTagName("TileUrl")[0].firstChild.nodeValue+'" />');
					console.log(result.getElementsByTagName("TileUrl")[0].firstChild.nodeValue);
				},
				"xml"
		 );*/
		$.getJSON(
			"http://www.gamingtruth.com/raw/bgs.json",
			function(result){
				var list = result.list;
				var rnd = Math.floor(Math.random()*(list.length));
				rnd=(rnd>list.length)?list.length:rnd;
				var url = list[rnd];
				$("<img />").attr({src:"http://www.gamingtruth.com/raw/"+url}).load(function(){
					$("#inner")
						.css({backgroundImage: "url(http://www.gamingtruth.com/raw/"+url+")"})
						.animate({opacity:1}, 800)
					;
					$("#bgloader").empty();
				});
			}
		);
	});
})(jQuery);
