/* VERSION = $Rev: 4 $ $Date: 2007-04-11 22:32:00 -0700 (Wed, 11 Apr 2007) $ */

/* http://www.webmonkey.com/webmonkey/01/49/index2a.html?tw=multimedia */
/*
You'll notice that there are <OBJECT> tags surrounding the <EMBED> tags. 
It's important to preserve this order because the <OBJECT> tags are recognized 
by Internet Explorer, while Netscape Navigator recognizes the <EMBED> tags 
and ignores the <OBJECT> tags.
*/
/* http://www.webforumz.com/lo-fi/t-4407.html */
var browserRadioTest = null;

function playasound(thesound, thename, thecolor)
{
	var s = top.sounder.document;
	s.write('<html><head></head><body bgcolor=', thecolor);
	s.write('><table border="0" cellpadding="3" cellspacing="1" width="520">');
	s.write('<tr><td width="20"> &nbsp; </td><td width="500">');
	s.write('Now playing <i>' , thename, '</i>.');
	s.write('<embed src=', thesound, ' height=20 width=100 hidden autoplay="true">');
	s.write('</td></tr></table></body></html>');
	s.close();
}

function getMediaPlayerVersion(type)
{
    var objMediaPlayer, playerVersion;
    try {
        objMediaPlayer = new ActiveXObject("WMPlayer.OCX");
        playerVersion = objMediaPlayer.versionInfo;
        objMediaPlayer = null;
        if (type == 'full')
            return playerVersion;
        else 
            return parseInt(playerVersion);
    } catch(objError){
            return 0;
    }
}

function getRealPlayerVersion(type)
{
    var objRealPlayer, playerVersion;
    try {
        objRealPlayer = new ActiveXObject("rmocx.RealPlayer G2 Control.1")
        playerVersion = objRealPlayer.GetVersionInfo();
        objRealPlayer = null;
        if (type == 'full')
            return playerVersion;
        else 
            return parseInt(playerVersion);
    } catch(e) {
            return 0;
    }
}

function browserHasReal()
{
   return (getRealPlayerVersion() >= 5);
}

function browserHasWMP()
{
   return (getMediaPlayerVersion() >= 7);
}

function browserHasRadio()
{
    if ( browserRadioTest == null )
    {
        browserRadioTest = browserHasWMP();
    }
    return browserRadioTest;
}

function embedSound (id, fileName)
{
    alert("embedSound " + fileName);
    var elemID = document.getElementById(id);
    if ( elemID != null )
    {            
        var winContent = "<object width='300' height='42'>";
        winContent += "<param name='src' value='" +  fileName + "'>";
        winContent += "<param name='autoplay' value='true'>";
        winContent += "<param name='controller' value='false'>";
        winContent += "<param name='bgcolor' value='#FF9900'>";
        winContent += "<embed src='" + fileName + "' autostart='true'";
        winContent += " loop='false' controller='false' bgcolor='#FF9900'></embed>";
        winContent += "</object>";
        elemID.appendChild(winContent);
        return true;
    }
    return false;
}

function InsertPlayer(fileName)
{
    var winContent = "<object classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74c7E95'\n";
    winContent += "  codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715'\n";
    winContent += "  width='280' height='18'\n";
    winContent += "  standby='Loading Microsoft Windows Media Player components...'\n";
    winContent += "  type='application/x-oleobject'>\n";
    winContent += "  <param name='autostart' value='false'>\n";
    winContent += "  <param name='filename' value='" + fileName + "'">\n";
    winContent += "  <param name='showcontrols' value='true'>\n";
    winContent += "  <param name='ShowStatusBar' value='false'>\n";
    winContent += "  <embed type='application/x-mplayer2'\n";
    winContent += "    pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' \n";
    winContent += "    src='" + fileName + "' width='280' height='18'\n’);
    winContent += "    autostart='0' showcontrols='1' showstatusbar='0'>\n";
    winContent += "   </embed>\n";
    winContent += "</object>\n";
    document.write(winContent);
}

function InsertQuickTime(fileName)
{
    var winContent = "<object classid='CLSID:02bf25d5-8c17-4b23-bc80-d3488abddc6b' width='280' height='18' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>\n";
    winContent += "  <param name='src' value='" + fileName + "' />\n";
    winContent += "  <param name='autostart' value='false' />\n";
    winContent += "  <param name='loop' value='false' />\n";
    winContent += "  <param name='controller' value='true' />\n";
    winContent += "</object>\n";
    document.write(winContent);
}

function InsertWinMed(fileName)
{
    var winContent = "<embed type='application/x-mplayer2'");
    winContent += "pluginspage = 'http://www.microsoft.com/Windows/MediaPlayer/'";
    winContent += "src='" + fileName + "'";
    winContent += "name='MediaPlayer1' width='160' height='162' AutoStart='true'>";
    winContent += "</embed>";
    document.write(winContent);
}

