// This document holds common functions used by the site

function launchCourse($location){ // opens the course from the classroom
	// open in popup //
	//openPopup($location, 'coursewindow', 590, 440, 'scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=yes,menubar=no,status=yes');
	// open in same window //
	document.location=$location;
}

function launchQuiz($location){
	openPopup($location, 'quizwindow', 400, 500, 'scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=yes,menubar=no,status=yes');
}

function openPopup($location, $windowname, $width, $height, $options){ // generic window opener function
	$options= ($options) ? ','+$options : '';
	window.open($location, $windowname, 'width='+$width+',height='+$height+$options);
}

function getFlashMovie($fileAndPath, $width, $height, $centered){ // prints out the flash movie with embedded vars from get url
	var $swf=$fileAndPath+location.search; // prepends with path info, and appends with GET information in URL (eg "?course=legal&page=1&section=2")
	if($centered){ document.write('<div class="centeredFlash_'+$width+'x'+$height+'">'); } // there needs to be a div class with the specified size as the name if centered (eg centeredFlash_550x400, centeredFlash_800x600, etc)
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+$width+'" height="'+$height+'"> <param name="movie" value="'+$swf+'" /> <param name="menu" value="false"> <param name="quality" value="high" /> <embed src="'+$swf+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+$width+'" height="'+$height+'"></embed></object>');
	if($centered){ document.write('</div>'); }
}

function closeWindow(){ // close course popup window from flash. May want to end LMS session here.
	window.close();
}

function changeTitle($newTitle){ // changes the title of the HTML page to reflect the course page title
	if(typeof($newTitle)!="string"){ $newTitle=""; }
	document.title=$newTitle;
}