var FF_agt=navigator.userAgent.toLowerCase();
var FF_is_macintosh = (FF_agt.indexOf("macintosh")!=-1);
//===========================================================================================================
// Audio
//===========================================================================================================
function createAudioObj(_tId,_tSrc,_tType)
{	
	var _tTypePlay = '';
	if(FF_is_macintosh)// MAC OS
	{
		if(_tType == 'WAV')
		{
			_tTypePlay = "audio/wav";
		}
		else if(_tType == 'MP3')
		{
			_tTypePlay = "audio/mpeg";
		}
		else if(_tType == 'MID')
		{
			_tTypePlay = "audio/mid";
		}

		document.writeln("<DIV style='width:0;height:0;visibility:hidden'>");
		document.writeln("<OBJECT id='"+_tId+"' width='0' height='0'>TrainerAudio</OBJECT>");
		document.writeln("</DIV>");
	}
	else// WINDOWS
	{
		document.writeln("<DIV style='width:0;height:0;visibility:hidden'>");
		document.writeln("<OBJECT ID='"+_tId+"' width='0' height='0'");
		document.writeln("	classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'");
		document.writeln("	codebase='' standby='Loading Microsoft® Windows® Media Player components...'");
		document.writeln("	type='application/x-oleobject'>TrainerAudio");
		document.writeln("	<param name='FileName' value='"+_tSrc+"'>");
		document.writeln("	<param name='ShowStatusBar' value='False'>");
		document.writeln("	<param name='AutoSize' value='False'>");
		document.writeln("	<param name='AutoStart' value='0'>");
		document.writeln("	<param name='ShowControls' value='False'>");
		document.writeln("</OBJECT>");
		document.writeln("</DIV>");
	}
	
	var obj = document.getElementById(_tId);
	obj.className = 'TrainerAudio';
	
	obj._id = _tId;
	obj._src = _tSrc;
	obj._type = _tType;
	obj._typePlay = _tTypePlay;
		
	if(FF_is_macintosh)
	{
		obj.Play = createAudioObj.Play;
		obj.Stop = createAudioObj.Stop;
	}
	
	return obj;
}
createAudioObj.Play = function()
{
	if(this._type == 'WAV' || this._type == 'MP3' || this._type == 'MID')
	{
		this.innerHTML='<embed src="' + this._src +'" type="'+this._typePlay+'" name="'+this._id+'" height="0" width="0" autostart="true"></embed>';
	}
}

createAudioObj.Stop = function()
{
	if(this._type == 'WAV' || this._type == 'MP3' || this._type == 'MID')
	{
		this.innerHTML=' ';
	}
}
//===========================================================================================================
// Video
//===========================================================================================================
function createVideoObj(_tId,_tSrc,_tType,_tWidth,_tHeight,_tAutostart,_tShowcontrols,_tLoop,_tAltText)
{
	var _tTypePlay = '';
	if(FF_is_macintosh)// MAC OS
	{
		if(_tType == 'AVI')
		{
			_tTypePlay = "video/avi";
		}
		else if(_tType == 'MPG')
		{
			_tTypePlay = "video/mpeg";
		}
		
		if(_tShowcontrols)
		{
			_tController = 1;
		}
		else
		{
			_tController = 0;
		}

		document.writeln("<embed src='"+_tSrc+"'");
		document.writeln("  id='"+_tId+"'");
		document.writeln("  type='"+_tTypePlay+"'");
		document.writeln("  width = '"+_tWidth+"'");
		document.writeln("  height = '"+_tHeight+"'");
		document.writeln("  autostart='"+_tAutostart+"'");
		document.writeln("  loop = '"+_tLoop+"'");
		document.writeln("  alt='"+_tAltText+"'");
		document.writeln("  controller = '1'");
		document.writeln("  enablejavascript='true' mastersound>");
		document.writeln("</embed>");
	}
	else// WINDOWS
	{
		document.writeln("<OBJECT ID='"+_tId+"' width='"+_tWidth+"' height='"+_tHeight+"' alt='"+_tAltText+"'");
		document.writeln("	classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'");
		document.writeln("	codebase='' standby='Loading Microsoft® Windows® Media Player components...'");
		document.writeln("	type='application/x-oleobject'>TrainerVideo");
		document.writeln("	<param name='FileName' value='"+_tSrc+"'>");
		document.writeln("	<param name='ShowStatusBar' value='False'>");
		document.writeln("	<param name='AutoSize' value='False'>");
		document.writeln("	<param name='AutoStart' value='"+_tAutostart+"'>");
		document.writeln("	<param name='ShowControls' value='"+_tShowcontrols+"'>");
	    document.writeln("  <param name='Repeat' value='" + _tLoop + "'>");
		document.writeln("</OBJECT>");
	}
	
	var obj = document.getElementById(_tId);
	obj.className = 'TrainerVideo';
	obj._id = _tId;
	obj._src = _tSrc;
	obj._type = _tType;
	obj._typePlay = _tTypePlay;
	
	return obj;
}