function playVideo(doc, videoList) {
   playFlashVideo(doc, videoList);
}


function playFlashVideo(doc, videoList) {
    flashPlayer.sendEvent("STOP");
    flashPlayer.sendEvent("ITEM", videoList.selectedIndex);
}


function createPlayer(videoURL, imageURL) {
    var flashvars = {
        //plugins: "googlytics-1",
        file: videoURL,
        image: imageURL,
        type: "video"
    };

    var params = {
        allowscriptaccess: "always"
    };

    var attributes = {
        id: "flashplayer",
        name: "flashplayer"
    };

    swfobject.embedSWF("flash/mediaplayer.swf", "flashcontent", "320", "260", "7", false, flashvars, params, attributes);
}


function playWindowsMediaVideo(videoList, windowsMediaPlayer) {
    var streamURL;

    streamURL = videoList.options[videoList.selectedIndex].value;
    windowsMediaPlayer.stop();
    windowsMediaPlayer.FileName = streamURL;
    windowsMediaPlayer.play();
}

function embedWindowsMediaPlayer(doc) {
    var WMP7;
    var previewList;
    var url;


    previewList = doc.getElementById("previewlist");
    if (previewList != undefined && previewList.options.length > 1) {
        url = previewList.options[1].value;
    }

    if ( navigator.appName != "Netscape" ) {
        try {
            WMP7 = new ActiveXObject('WMPlayer.OCX');
        } catch(e) {
        }
    }

    // Note: the size of the low-res video is 352x240 but the size of the
    // media players control needs to be accounted for
    // Windows Media Player 7 Code
    if (WMP7) {
        doc.writeln('<OBJECT classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="windowsmediaplayer" width="352" height="304">');

        if (url != "") {
            doc.writeln('<PARAM NAME="url" VALUE="' + url + '">');
        } else {
            doc.writeln('<PARAM NAME="url" VALUE="">');
            doc.writeln('<PARAM NAME="enabled" VALUE="false">');
        }

        doc.writeln('<PARAM NAME="AutoStart" VALUE="1">');
        doc.writeln('<PARAM NAME="ShowControls" VALUE="1">');

        doc.writeln('</OBJECT>');
    } else {
        // Windows Media Player 6.4 Code

        // IE Code
        doc.writeln('<OBJECT id="windowsmediaplayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="352" height="304">');
        if (url != "") {
            doc.writeln('<PARAM NAME="FileName" VALUE="' + url + '">');
        } else {
            doc.writeln('<PARAM NAME="FileName" VALUE="">');
            doc.writeln('<PARAM NAME="enabled" VALUE="false">');
        }
        doc.writeln('<PARAM NAME="AutoStart" VALUE="1">');
        doc.writeln('<PARAM NAME="ShowControls" VALUE="1">');
        doc.writeln('<PARAM NAME="width" VALUE="352"');
        doc.writeln('<PARAM NAME="height" VALUE="304"');

        //Netscape code
        doc.writeln('    <EMBED type="application/x-mplayer2"');
        doc.writeln('           pluginspage="http://www.microsoft.com/windows/windowsmedia/"');
        doc.writeln('           border="0"');
        doc.writeln('           autostart="1"');
        doc.writeln('           width="352"');
        doc.writeln('           height="304"');
        if (url != "") {
            doc.writeln('           FileName="' + url + '"');
        } else {
            doc.writeln('           Enabled="false"');
        }
        doc.writeln('           Name="MediaPlayer"');
        doc.writeln('           ShowControls="1"');
        doc.writeln('           ShowDisplay="0"');
        doc.writeln('           ShowStatusBar="0"');
        doc.writeln('    </EMBED>');
        doc.writeln('</OBJECT>');
    }
}
