// File:	quickview-utils.js
// Author:	VMS <http://www.vmsinfo.com/>
// Date:	10/11/2004
// Updated:	10/11/2004
//
// First cut of basic QuickView library. (c) VMS 2004.
//
// To access QuickView functionality, load this JavaScript library in your HTML page. You
// can then insert a player into your document by calling the 'insertPlayer()' function. To
// play a clip, pass the source URL provided by VMS (which will be the value of the 'videoSource'
// element in standard XML feeds) to the 'playClip' function.
//
// Limitations:
//
//	- this initial implementation provides only for a single embedded player, named 'player'
//  - this initial implementation supports only Microsoft Internet Explorer on Windows (because 
//    scripting of embedded Windows Media players is not possible on other platforms or browsers)
//  - there are no options to configure player parameters.
//  - there is no error-checking to gracefully handle cases where the player is missing
//
// Advantages
//
//  - scripting player embeds ducks around issues raised by Microsoft's retro-hacks of Explorer
//    to conform to the EOLAS patent settlement.
//
// =================================================================================================

// insertPlayer
//
// Embed a Windows Media player in the web page.

function insertPlayer() {
	document.writeln('<object viewastext="viewastext" name="player" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"');
	document.writeln('width="240" archive="" height="244" datasrc="" id="player">');
	insertParam("URL","");
	insertParam("rate",1);
	insertParam("balance",0);
	insertParam("currentPosition",0);
	insertParam("defaultFrame","");
	insertParam("playCount",1);
	insertParam("autoStart",-1);
	insertParam("currentMarker",0);
	insertParam("invokeURLs",-1);
	insertParam("baseURL","");
	insertParam("volume",50);
	insertParam("mute",0);
	insertParam("uiMode","full");
	insertParam("stretchToFit",-1);
	insertParam("windowlessVideo",0);
	insertParam("enabled",-1);
	insertParam("enableContextMenu",-1);
	insertParam("fullScreen",0);
	insertParam("SAMIStyle","");
	insertParam("SAMILang","");
	insertParam("SAMIFilename","");
	insertParam("captioningID","");
	insertParam("enableErrorDialogs",0);
	insertParam("_cx",8975);
	insertParam("_cy",6731);
	document.write('<embed height="244" width="240" name="player" ');
	document.write('pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&amp;sbp=mediaplayer&amp;ar=Media&amp;sba=Plugin&amp;" ');
	document.writeln('type="application/x-mplayer2" /' + '>');
	document.writeln('<' + '/embed>');
	document.writeln('<' + '/object>');
}

// insertParam
//
// Write a parameter name-value pair.

function insertParam(name,value) {
	document.writeln('<param value="' + value + '" name="' + name + '" /' + '>');
}

// playClip
//
// Play an encoded QuickView video clip.

function playClip(url) {
	document.getElementById('player').URL = url;
}


