// courseHtml.js

/************************************************************************
 *	DisplayHtml	-	displays the given course module object's HTML page *
 *					removes the video player from the screen first, if	*
 *					it is there											*
 *	@var courseModule	-	course module object with the filename link	*
 *							to the html content							*
 ************************************************************************/
DisplayHtml = function( courseModule )
{	
	if( courseModule == null ) {
		alert("DisplayHtml :: No course module specified.");
		return;		
	}
	
	contentPath = "htmls/";
		
	courseContentDiv = document.getElementById('course-content');
	
	if( courseContentDiv == null ) {
		alert("DisplayHtml :: Error locating document element 'course-content'.");
		return;		
	}
	
	//close any players
	closePlayer();
		
	Content = document.getElementById('HtmlContent');
	
	/* create an iframe to place the html content in */	
	if(Content == null)
	{
		courseContentDiv.innerHTML = '<iframe scrolling="auto" allowtransparency="1" frameborder="0" id="HtmlContent" src=""></iframe>';
		Content = document.getElementById('HtmlContent');		
	}
	
	Content.src = contentPath + courseModule.fileName;
	courseContentDiv.style.textAlign='right';
}

/************************************************************************
 *	closePlayer	-	removes the video player from the screen, if it is  *
 *					currently there										*
 ************************************************************************/
closePlayer = function()
{
	// Media player object
	Player = document.getElementById('MediaPlayer');
	
	// stop windows media player and then unload the object from memory
	if(Player != null) {
		try {
			Player.close();
			delete Player;
		} catch(e) { 
			// skip no objects found error.
			if(e.name != 'TypeError')
				alert("Debug. " + e.message + " " + e.name);
		}
	}
}

// end of file