function CreateWMObject(filename, width, height, autostart, playcount, uiMode, controls, statusbar, altText, pageid)
{
		document.write('<OBJECT id="VIDEO" width="' +width+ '" height="' +height+ '" ')
		document.write('	CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" ')
		document.write('	type="application/x-oleobject" ')
		document.write('    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" VIEWASTEXT> ')
		document.write('	<PARAM NAME="filename" VALUE="' +filename+ '"> ')
		document.write('	<PARAM NAME="SendPlayStateChangeEvents" VALUE="True"> ')
		document.write('	<PARAM NAME="showstatusbar" VALUE="'+statusbar+'"> ')
		document.write('	<param name="transparentatStart" value="1"> ')
		document.write('    <param name="WMode" value="Transparent"> ')		
		document.write('	<param name="autoStart" value="' +autostart+ '"> ')
		document.write('	<param name="uiMode" value="' +uiMode+ '"> ')
		document.write('	<param name="showcontrols" value="' +controls+ '"> ')
		document.write('	<param name="playcount" value="' +playcount+ '"> ')
		document.write('	<param name="alt" value="' + altText + '"> ')
		document.write('	<param name="WindowlessVideo" value="-1"> ')
		document.write(' <EMBED type="application/x-mplayer2" ')
		document.write(' pluginspage="http://microsoft.com/windows/mediaplayer/ en/download/" ')
		document.write(' id="mediaPlayer" name="mediaPlayer" displaysize="4" autosize="0" ')
		document.write(' showcontrols="' +controls+ '" showtracker="1" ')
		document.write(' width="' +width+ '" height="' +height+ '" src="' +filename+ '" autostart="' +autostart+ '" ')
		document.write(' alt="' +altText+ '" playcount="' +playcount+ '"> ')
		document.write(' </EMBED></OBJECT> ')

		// Append the accessibility text if it has been specified
		WriteAccessibilityText(altText, pageid);
}

function CreateQuicktimeObject(filename, width, height, autoplay, loop, controls, altText, pageid)
{
		document.write('<OBJECT width="' +width+ '" height="' +height+ '" ')
		document.write('   codebase="http://www.apple.com/qtactivex/qtplugin.cab" ')
		document.write('	CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ')
		document.write('	VIEWASTEXT> ')
		document.write('	<PARAM NAME="src" VALUE="' +filename+ '"> ')
		document.write('	<param name="autoplay" value="' +autoplay+ '"> ')
		document.write('	<param name="controller" value="' +controls+ '"> ')
		document.write('	<param name="Scale" value="TOFIT"> ')
		document.write('	<param name="loop" value="' +loop+ '"> ')
		document.write('	<param name="alt" value="' + altText + '"> ')
		document.write('    <param name="WMode" value="Transparent"> ')
		document.write(' <EMBED ')
		document.write(' pluginspage="http://www.apple.com/quicktime/download/" ')
		document.write(' width="' +width+ '" height="' +height+ '" src="' +filename+ '" autoplay="' +autoplay+ '" ')
		document.write(' alt="' +altText+ '" controller="' +controls+ '" loop="' +loop+ '"> ')
		document.write(' </EMBED></OBJECT> ')

		// Append the accessibility text if it has been specified
		WriteAccessibilityText(altText, pageid);
}

function CreateFlashObject(filename, width, height, bgcolor, title, img, loop)
{
    if (filename == "FileNotFound")
    {
        document.write(' <img src="' + img + '" height="' + height + '" width="' + width + '" alt="' + title + '" /> ')
    } 
    else
    {
        document.write(' <object style="width:' + width + 'px; height: ' + height + 'px; background-color: ' + bgcolor + ';" ')
        document.write(' type="application/x-shockwave-flash" data="' + filename + '" title="' + title + '" VIEWASTEXT> ')
        document.write(' <param name="movie" value="' + filename + '" /> ')
        document.write(' <param name="WMode" value="Transparent"> ')
        document.write(' <param name="menu"  value="false"> ')
        document.write(' <param name="loop" value="' + loop + '" /> ')
        document.write(' <param name="WindowlessVideo" value="-1"> ')
        document.write(' </object> ')
    }
}

function CreateRPObject(filename, width, height, autoplay, loop, alttext, pageid)
{
		document.write (' <OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ')
		document.write (' WIDTH="'+width+'" HEIGHT="'+height+'"> ')
		document.write (' <PARAM NAME="SRC" VALUE="'+filename+'"> ')
		document.write (' <PARAM NAME="AutoStart" VALUE="'+autoplay+'"> ')
		document.write (' <PARAM NAME="Loop" VALUE="'+loop+'"> ')		
		document.write (' <PARAM NAME="CONTROLS" VALUE="ImageWindow"> ')
		document.write('  <PARAM NAME="CONSOLE" VALUE="_master"> ')
		document.write('  <param name="WindowlessVideo" value="-1"> ')
		document.write(' <EMBED ')
		document.write(' width="' +width+ '" height="' +height+ '" src="' +filename+ '" autostart="' +autoplay+ '" ')
		document.write(' alt="' +alttext+ '" controls="ImageWindow" loop="' +loop+ '"> ')
		document.write(' </EMBED></OBJECT> ')

		// Append the accessibility text if it has been specified
		WriteAccessibilityText(altText, pageid);
}

function CreateRPObjectWithGui(filename, width, height, autoplay, loop, alttext, pageid)
{
		document.write (' <OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ')
		document.write (' WIDTH="'+width+'" HEIGHT="'+height+'"> ')
		document.write (' <PARAM NAME="AutoStart" VALUE="'+autoplay+'"> ')
		document.write (' <PARAM NAME="Loop" VALUE="'+loop+'"> ')		
		document.write (' <PARAM NAME="CONTROLS" VALUE="ImageWindow"> ')
		document.write('  <PARAM NAME="CONSOLE" VALUE="_master"> ')
		document.write('  <param name="WindowlessVideo" value="-1"> ')
		document.write(' <EMBED ')
		document.write(' name="player" type="audio/x-pn-realaudio-plugin" console="_master" width="' +width+ '" height="' +height+ '" autostart="' +autoplay+ '" ')
		document.write(' alt="' +alttext+ '" controls="ImageWindow" loop="' +loop+ '"> ')
		document.write(' </EMBED></OBJECT> ')
		
		document.write ('<div><OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ')
		document.write (' WIDTH="'+width+'" HEIGHT="55"> ')
		document.write (' <PARAM NAME="SRC" VALUE="'+filename+'"> ')
		document.write (' <PARAM NAME="AutoStart" VALUE="'+autoplay+'"> ')
		document.write (' <PARAM NAME="Loop" VALUE="'+loop+'"> ')		
		document.write (' <PARAM NAME="CONTROLS" VALUE="Default"> ')
		document.write('  <PARAM NAME="CONSOLE" VALUE="video1"> ')
		document.write('  <param name="WindowlessVideo" value="-1"> ')
		document.write(' <EMBED ')
		document.write(' name="player" type="audio/x-pn-realaudio-plugin" console="video1" width="'+width+'" height="55" src="' +filename+ '" autostart="' +autoplay+ '" ')
		document.write(' alt="' +alttext+ '" controls="Default" loop="' +loop+ '"> ')
		document.write('</EMBED></OBJECT> ')

		// Append the accessibility text if it has been specified
		WriteAccessibilityText(altText, pageid);
}

function CreateFLVObject(filename, width, height, bgcolor, title, img, loop)
{    
    if (filename == "FileNotFound")
    {
        document.write(' <img src="' + img + '" height="' + height + '" width="' + width + '" alt="' + title + '" /> ')
    }
    else
    {
        document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"')
        document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ')
        document.write(' width="' + width + '" height="' + height + '" bgcolor="' + bgcolor + '"> ')
        document.write(' <param name="movie" value="' + filename + '" />')
        document.write(' <param name="quality" value="high" /> ')
        document.write(' <param name="loop" value="' + loop + '" /> ')
        document.write(' <param name="wmode" value="Opaque"> ')
        document.write(' <param name="allowFullScreen" value="true" /> ')
        document.write(' <embed src= "' + filename + '" wmode="Transparent"')
        document.write(' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" allowFullScreen="true" ')
        document.write(' type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" bgcolor="' + bgcolor + '" /> ')
        document.write(' </object> ')
    }
}

function WriteAccessibilityText(altText, pageid)
{
    var outputAltText = false;

    if (altText !== null &&
		    altText !== undefined &&
		    altText.length !== null &&
		    altText.length !== undefined &&
		    altText.length > 0)
    {
        outputAltText = true;
    }

    var outputPageLink = false;

    if (pageid !== null &&
	    pageid !== undefined &&
	    pageid.length !== null &&
	    pageid.length !== undefined &&
	    pageid.length > 0 &&
	    parseInt(pageid, 10) !== NaN)
    {
        outputPageLink = true;
    }

    if (outputAltText || outputPageLink)
    {
        var htmlToWrite = "";

        htmlToWrite += "<div class=\"MediaPlugin_ItemDescription\">";

        if (outputAltText)
        {
            htmlToWrite += altText;
        }

        if (outputAltText && outputPageLink)
        {
            htmlToWrite += " ";
        }

        if (outputPageLink)
        {
            htmlToWrite += "<a href=default.aspx?page=" + pageid + ">Click here for textual description.</a>";
        }

        htmlToWrite += "</div>";

        document.write(htmlToWrite);
    }
}






 
