function flash_player(strCommand)
{
	/*
http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
	*/
	
	//  Handle special cases where we need different code for Internet Explorer vs. Netscape Navigator
	//var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	
	//  IE and Navgiator have slightly different document object models
	//  IE treats objects as members of "window" while in Navigator, 
	//  embedded objects are members of "window.document"
	//var mc = InternetExplorer ? window.mapcontrols : window.document.mapcontrols;
		
	switch( strCommand )
	{
		case "stop":
		mc = window.document.mapcontrols;
		mc.TCallFrame("/", 4);
		break;
		
		case "test":
		mc = window.document.myFlash;
		mc.SetVariable("myVar", "This is a test");
		break;
		
	}	//end switch
	
}	//end function

function play(strMedia, strAutoStart)
{
	//default value is true
	if( strAutoStart != "false" )
			strAutoStart = "true";
			
	//if the autostart is true, then stop the flash player
	if( strAutoStart == "true" )
		flash_player("stop");
	
	//get the player based on the os
	strOS = get_users_os();
	
	//get the player based on the os
	switch ( strOS )
	{
		case "Mac":
		var strPlayer = get_quicktime_player(strMedia, strAutoStart);
		break;
		
		case "Windows":
		var strPlayer = get_media_player_html(strMedia, strAutoStart);
		break;
		
		default:
		var strPlayer = get_media_player_html(strMedia, strAutoStart);
		break;
		
	}	//end case 
	
	document.getElementById('mediaplayer').innerHTML=
			"\n\n<!-- PLAYER OBJECT START -->\n" + 
			strPlayer + "\n" + 
			"<!-- PLAYER OBJECT END -->\n\n";
			
	return false;
	
}	//end function

function play_noflash(strMedia)
{
	
	strAutoStart = 'true';
	
	//get the player based on the os
	strOS = get_users_os();
	
	//get the player based on the os
	switch ( strOS )
	{
		case "Mac":
		var strPlayer = get_quicktime_player(strMedia, strAutoStart);
		break;
		
		case "Windows":
		var strPlayer = get_media_player_html(strMedia, strAutoStart);
		break;
		
		default:
		var strPlayer = get_media_player_html(strMedia, strAutoStart);
		break;
		
	}	//end case 
	
	document.getElementById('mediaplayer').innerHTML=
			"\n\n<!-- PLAYER OBJECT START -->\n" + 
			strPlayer + "\n" + 
			"<!-- PLAYER OBJECT END -->\n\n";
			
	return false;
	
}	//end function

function get_media_player_html(strMedia, strAutoStart)
{
	var strPlayer = "<!-- The CLASSID for Windows Media Player 7, 9 and 10 -->\n" + 
					"<!-- CLASSID player 7+:  6BF52A52-394A-11d3-B153-00C04F79FAA6 -->\n" + 
					"<!-- CLASSID plaeyr 6.4: 22D6F312-B0F6-11D0-94AB-0080C74C7E95 -->\n" + 
					"\t<OBJECT id=\"media1\" \n" + 
					"\t\twidth=\"220\" \n" + 
					"\t\theight=\"45\" \n" + 
					"\t\tCLASSID=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" \n" + 
					"\t\ttype=\"application/x-oleobject\"> \n\n" + 
					"\t<PARAM NAME=\"URL\" VALUE=\"" + strMedia + "\"> \n" + 
					"\t<PARAM NAME=\"AutoStart\" VALUE=\"" + strAutoStart + "\"> \n" + 
					"\t<PARAM name=\"uiMode\" value=\"full\"> \n" + 
					"\t<PARAM name=\"PlayCount\" value=\"9999\"> \n" + 
					"\t<PARAM name=\"showstatusbar\" value=\"False\"> \n\n" + 
					"\t<embed \n" + 
					"\t\ttype=\"application/x-mplayer2\" \n" + 
					"\t\tpluginspage = \"http://www.microsoft.com/Windows/MediaPlayer/\" \n" + 
					"\t\tsrc=\"" + strMedia + "\"  \n" + 
					"\t\twidth=\"220\" \n" + 
					"\t\theight=\"45\" \n" + 
					"\t\tshowstatusbar=\"False\" \n" + 
					"\t\tAutoStart=\"" + strAutoStart + "\"  \n" + 
					"\t\tuiMode=\"full\"> \n" + 
					"\t</embed> \n" + 
					"</OBJECT>\n" + 
					"<!-- WINDOWS MEDIA PLAYER END -->\n";
					
	return strPlayer;
	
}	//end function

function get_quicktime_player(strMedia, strAutoStart)
{
	strPlayer = "<!-- QUICKTIME START -->\n" + 
				"<OBJECT \n " +
				"\tid=\"quicktime1\" \n" + 
				"\tCLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" \n" + 
				"\tWIDTH=\"160\" \n" + 
				"\tHEIGHT=\"20\" \n" + 
				"\tCODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab\"> \n\n" + 
				"\t<PARAM name=\"SRC\" VALUE=\"" + strMedia + "\"> \n" + 
				"\t<PARAM name=\"AUTOPLAY\" VALUE=\"" + strAutoStart + "\"> \n" + 
				"\t<PARAM name=\"CONTROLLER\" VALUE=\"true\"> \n\n" + 
				"\t<EMBED \n" + 
				"\t\tSRC=\"" + strMedia + "\" \n" + 
				"\t\tWIDTH=\"160\" \n" + 
				"\t\tHEIGHT=\"20\" \n" + 
				"\t\tAUTOPLAY=\"" + strAutoStart + "\" \n" + 
				"\t\tCONTROLLER=\"true\" \n" + 
				"\t\tPLUGINSPAGE=\"http://www.apple.com/quicktime/download/\"> \n" + 
				"\t</EMBED> \n\n" + 
				"</OBJECT>\n" + 
				"<!-- QUICKTIME END -->\n";
				
	return strPlayer;
				
}	//end function

function get_users_os()
{
	
	var OS = "";
	
	var detect = navigator.userAgent.toLowerCase();
	
	if (checkIt(detect, 'linux')) OS = "Linux";
	else if (checkIt(detect, 'x11')) OS = "Unix";
	else if (checkIt(detect, 'mac')) OS = "Mac"
	else if (checkIt(detect, 'win')) OS = "Windows"
	else OS = "an unknown operating system";
	
	return OS;
	
}	//end function

function checkIt(detect, string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
	
}	//end function


