$(document).ready(function() {
	$("a.mediaPlayerStart").click(function() {
		var mediaDirectory = $(this).attr("id");
		var xmlFilePath = pathPrefix+"galleries/rally/"+mediaDirectory+"/images.xml";
		var swfPath = pathPrefix+"swf/ssp-gallery-rally.swf";
		var expressInstallPath = pathPrefix+"js/expressinstall.fla";
		// construct the .swf
		var swf = "\n<script type='text/javascript'>";
			swf += "\n\tvar so = new SWFObject(\""+swfPath+"\", \"media-gallery\", \"950\", \"566\", \"9\", \"#000000\");";
			swf += "\n\t\tso.useExpressInstall('"+expressInstallPath+"');";
			swf += "\n\t\tso.addParam(\"quality\", \"high\");";
			swf += "\n\t\tso.addParam(\"align\", \"left\");";
			swf += "\n\t\tso.addParam(\"FlashVars\", \"xmlFilePath="+xmlFilePath+"\");";
			swf += "\n\t\tso.write(\"TB_flash_content\");";
			swf += "\n</script>";
		
		// append the swf to #TB_flash_content
		$('#TB_flash_content').append(swf);
		
		// start the media player
		$("#mediaGalleryCont").modal({
			containerId: 'rallyMediaCont'
		});
		$('#modalOverlay').css({height:($(document).height().toString() + "px"), overflow:"hidden"});
		
		// hide the Flash Rotator
		$("#flash_content950").addClass("hideVisability");
		// scroll to the top of the page
		window.scrollTo(0,0);
		return false;
	});
	
	$(".mediaPlayerClose").livequery('click', function() {
		closeModal();
	});
});

function closeModal() {
	$.modal.close();
	// destroy the flash object
	$('#TB_flash_content').empty();
	$("#flash_content950").removeClass("hideVisability");
}