//__This file contains the javascript functions used for playing a slideshow.

/**
 * Writes an audio player to a given document.
 * @param myDocument The document to write to.
 * @param mySoundFilePath The path of the sound file to initialize the player to.
 * @param isAutoStart Flag telling whether the audio player should autostart on loading.
 */
function writeAudioPlayer(myDocument, mySoundFilePath, isAutoStart) 
{ 
	//__Init the player content.
	var playerContent = "";
	playerContent += "<div>";
	
	//__Because of Internet Explorer 5.5 and up on Windows, we need to wrap the 
	//__usual <embed> stuff that Netscape made semi-standard with an <object> tag 
	//__that makes it work for IE on Win.  We are going to use the Quicktime plugin
	//__from Apple because it's good and it's standard.  A source for this is:
	//__http://developer.apple.com/documentation/QuickTime/Conceptual/QTScripting_HTML/QTScripting_HTML_Document/chapter_1000_section_3.html
	playerContent += "<object";
	playerContent += " classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'";
	playerContent += " codebase='http://www.apple.com/qtactivex/qtplugin.cab'";
	playerContent += " width='250' height='40'";
	playerContent += " >"; 
	playerContent += "<param name='src' value='" + mySoundFilePath + "'/>";
	playerContent += "<param name='autoplay' value='" + isAutoStart + "'/>"; 
	playerContent += "<param name='controller' value='true'/>";
	
	//__Now do the usual <embed> tag pioneered by Netscape.
	playerContent += "<embed";
	playerContent += " type='audio/x-mpeg'";
	playerContent += " src='" + mySoundFilePath + "'";
	playerContent += " autostart='" + isAutoStart + "'";
	playerContent += " loop='false' width='250' height='40' controller='true'";
	playerContent += " pluginspage='http://www.apple.com/quicktime/download/'";
	playerContent += " >";
	playerContent += "</embed>"; 
	
	//__Close up the <object> and <div> tags.
	playerContent += "</object>";
	playerContent += "</div>"; 

	//__Write it all to the document.
	myDocument.write(playerContent); 
}	//__End writeAudioPlayer().
 

/* Old version: Only works on Macs, not PCs.
function writeAudioPlayer(myDocument, mySoundFilePath, isAutoStart) 
{ 
	var playerContent = "";
	playerContent += "<div>";
	playerContent += "<object width='250' height='42'>"; 
	playerContent += "<param name='src' value='../../../common/javascripts/" + mySoundFilePath + "'>";
	playerContent += "<param name='autoplay' value=" + isAutoStart + ">"; 
	playerContent += "<param name='controller' value='true'>";
	playerContent += "<embed name='audioPlayer' src='../../../common/javascripts/" + mySoundFilePath + "' autostart=" + isAutoStart + " loop='false' width='250' height='42' controller='true'></embed>";
	playerContent += "</object>"; 
	playerContent += "</div>"; 

	myDocument.write(playerContent); 
}	//__End writeAudioPlayer().
*/

/**
 * Writes the document banner for a given course and lecture.
 * @param myDocument The document to write to.
 * @param photoFileName The name of the photo file to use, if any.  
 * If this is empty, no photo is used.
 * @param courseTitle The title of the course.
 * @param lectureTitle The title of the lecture within the course.
 * @param sectionTitle The title of the section within the lecture.
 * If this is empty, then only the lectureTitle is displayed.
 */
function writeBanner(myDocument, photoFileName, courseTitle, lectureTitle, sectionTitle)
{
	if (courseTitle.length == 0)
		courseTitle = "Course Title";
	if (lectureTitle.length == 0)
		lectureTitle = "Lecture Title";
	if (sectionTitle.length > 0)
		lectureTitle += ": " + sectionTitle;
	myDocument.write('<div id="slideBanner">');
	if (photoFileName.length > 0)
		myDocument.write('<img src="../../common/images/' + photoFileName + '" width="120" height="150" class="bannerImageRight" />');
	myDocument.write('<h1>' + courseTitle + '</h1>');
	myDocument.write('<h2>' + lectureTitle + '</h2>');
	myDocument.write('</div>');
}	//__End writeBanner().

