// $Id: //placeware/main/build/placeware.ccc/lib/ccc/view-wmm.1/env.js#10 $
// Copyright 2001 PlaceWare, Inc.

// Detect user's screen area
function smallScreen() { return screen.availWidth <= 940 || screen.availHeight <= 730; }
var smScreen = smallScreen();

// --- Detect version of the Windows Media Player ---
//   http://www.nwlink.com/~zachd/pss/detectwmp7.htm
var hasWMP63 = false, hasWMP64 = false, hasWMP7 = false, hasPlugin = false;

function testMimeType(typeName) {
    return navigator.mimeTypes && navigator.mimeTypes[typeName];
}

function testPlugin(typeName) {
    var mimeType = testMimeType(typeName);
    return mimeType && mimeType.enabledPlugin;
}

if (isExplorer) {
    // Assume that Windows Media Player 7 is installed Windows Me because it does not
    // have an option for uninstalling WMP7 and WMP64 comes with WMP7
    // The code to detect WMP7 causes errors in WinMe.
    if (isWinMe) {
	hasWMP7  = true;
	hasWMP64 = true;
    } else {
	// test-instantiate a player7 object
	document.writeln('<OBJECT ID="WMP7TEST" height="1" width="1" '
	    + ' CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'
	    + '</OBJECT>');

	// test-instantiate a player6 object
	document.writeln('<OBJECT ID="WMP64TEST" WIDTH="1" HEIGHT="1" '
	    + ' CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">'
	    + '</OBJECT>');

	document.writeln('<SCRIPT LANGUAGE="VBScript">\n'
	    + ' On error resume next\n'
	    + ' hasWMP7  = (WMP7TEST.URL = "")\n'
	    + ' hasWMP64 = (WMP64TEST.FileName = "")\n'
	    + '</SCRIPT>');
    }
} else {
    hasWMP63  = testMimeType("video/x-ms-asf");
    hasWMP64  = testMimeType("video/x-ms-wm") && testMimeType("video/x-ms-wmv");
    hasPlugin = testPlugin("video/x-ms-asf") || testPlugin("video/x-ms-asf-plugin");
    // WMP7 is not detectable within Navigator at this time.
}

