

// AJAX functions

function AJAXload(filename, caller, listname)
{
	// Inline style is requitred because the DOM layout has already been calculated, and rewriting 
	// inner HTML does not force recalculation, so neither applying a class nor using 'margin 30px auto;' will work:
	$("#AJAXcontent").html("<img src='resources/img/spinner.gif' style='margin:30px 125px;'>");
	
	if(listname){clearList('.' + listname);}
	
	// activate the active element
	$(caller).addClass('active');
	
	$.ajax({
			   type: "GET",
			   url: filename,
			   success: function(msg){
				 $("#AJAXcontent").html(msg);
			   }
			 });
	return false;
	
}
function AJAXloadTest(filename, caller, id)
{
	// The ancap test menu is structured differently to the others, 
	// so set the active menu header before calling the ajax load
	
	$(".ancap_header").removeClass('active');
	$("#ancap_"+id).addClass('active');
	AJAXload(filename, caller, '');
	
}
function clearList(listName)
{
	// deactivate all of the lists' childrens' anchors:
	$(listName + " li a").removeClass('active');
}

function embed_sidebar(movieURL,fullScreen) {

	if (!fullScreen) {
		fullScreen = "false";	
	}

	var swfPath = "resources/swf/"
	var swfName = "player.swf";
	
	// MovieID: this is the id which SwfObject will attach to you flash object
	// You can target this in CSS to specificy a width and height (etc) for your flash movie
	var movieID = "flashSide"; 
	
	/***********************************************************
					  You don't need to touch these
	 ***********************************************************/
	 
	var width = "280";  // flash movie is non-scaling. use CSS to determine container size
	var height = "215"; // flash movie is non-scaling. use CSS to determine container size
	var flashVersion = "9.0.0";
	var flashvars = {flvSource:movieURL,fullScreen:fullScreen};
	
	var params = {wmode:"window",allowFullScreen:"true"};
	var attributes = {};
	attributes.id = movieID;
	
	
	swfobject.embedSWF(swfPath+swfName,"flashSide",width,height,
						flashVersion,swfPath+"expressInstall.swf",
						flashvars, params, attributes
					   );
}
function replace_table(table_id)
{
	$("#" + table_id).html('<p> <img src="resources/img/'+table_id+'.gif" alt="Understanding the ancap test table"/></p>');
}
