$(document).ready(function(){
	$("#background").hide();
	$("#body_container").hide();
	swfobject.embedSWF("http://test.modemaudio.com/am_web/am_header.swf", "header_swf", "880", "200", "9.0.0.0", "", {}, {allowscriptaccess:"always",wmode:"transparent"}, {id:"header_swf"});
	
	openPage = function(page,doSplash){
		if (doSplash == true) openSplash();
		if (page.length > 3){
			newPage = ajaxPull('pull_page.php','p='+page);
			if (newPage) $("#body_container").html(newPage);
		}
	}
	openSplash = function(){
		$("#background").fadeIn("fast");
		$("body").css("background","#000000");
		$("#body_container").fadeIn("slow");
	}
	
	ajaxPull = function(ajaxPage,ajaxData){
		var output = "";
		$.ajax({
			type: "GET",
			dataType: 'json',
			url: ajaxPage,
			data: ajaxData,
			cache: false,
			async: false,
			success: function(data) {
				if (data.errors) {
					alert("Error: "+data.errors);
				} else {
					output = data.page;
				}
			},
			error: function(result) {
				alert("Error (AJAX): "+result);
			}
		});
		return output;
	}
	$('img[@src$=.png]').ifixpng();
});