// $Id: //placeware/main/build/placeware.ccc/lib/ccc/view-wmm.1/open.js#16 $
// Copyright(c) 2001 PlaceWare, Inc.

// Environments that launch a stand-alone player.
var isASX = is_sun;

var supportedOS      = isWin || is_sun;
var supportedBrowser =
       isNetscape4 && versionNum >= minNS && versionNum <= maxNS
    || isExplorer && versionNum >= minIE && versionNum <= maxIE && isWin;
var supportedPlayer  = hasWMP63 && is_sun || hasWMP64 || hasWMP7;

function brLink(url, name) {
  return '<a href="' + url + '" target="_blank">' + name + '</a>';
}

// Download links
var ieURL   = "http://www.microsoft.com/windows/ie/";
var nsURL   = "http://www.netscape.com/download/archive.html";
var nmURL   = "http://www.netscape.com/download/";
var piURL   = "http://www.microsoft.com/windows/windowsmedia/download/plugin.asp";
var wmpURL  = "http://www.microsoft.com/windows/windowsmedia/download/default.asp";
var ieLink  = brLink(ieURL,  "Microsoft Internet Explorer");
var nsLink  = brLink(nsURL,  "Netscape Communicator");
var nmLink  = brLink(nmURL,  "Netscape");
var piLink  = brLink(piURL,  "Windows Media Player plug-in for Netscape");
var wmpLink = brLink(wmpURL, "Windows Media Player");
var ieVersions = ieLink + " version " + minIE + " through " + maxIE;
var nsVersions = nsLink + " version " + minNS + " through " + maxNS;
var nmVersions = nmLink + " version " + minNM + " through " + maxNM;

// Function for Replay Wrapper on server
// Open the right size playback window depending on IE/NS, browser
// version, and display size (e.g. 800x600).
function openWMMPlaybackWindow(url, asxURL) {
    var attributes = "left=0,screenX=0,top=0,screenY=0";
    if (!supportedOS || !supportedBrowser) {
    	showConfigs();
    } else if (!supportedPlayer) {
    	noWMP();
    } else if (isNetscape4 && !hasPlugin) {
    	noPlugin();
    } else if (isASX && isNetscape4) {
	// open the ASX file directly
        location.href = asxURL;
    } else if (smScreen) { // 800x600 screen - innerW/H for Netscape
	attributes += ",innerWidth=790,innerHeight=575,width=790,height=575";
	window.open(url, "_blank", attributes);
    } else {
	// large screen : the QA section is smaller in IE.
	attributes += ",innerWidth=955,innerHeight=680,width=955,height=680";
	window.open(url, "_blank", attributes);
    }

}


// Function for Stand-aline Replay Wrapper
// Open the right size playback window depending on IE/NS, browser
// version, and display size (e.g. 800x600).
function openStandaloneWrapper(filename, asxURL) {
    var attributes = "left=0,screenX=0,top=0,screenY=0";
    if (!supportedOS || !supportedBrowser) {
    	showConfigs();
    } else if (!supportedPlayer) {
    	noWMP();
    } else if (isNetscape4 && !hasPlugin) {
    	noPlugin();
    } else if (isASX && isNetscape4) {
	// open the ASX file directly
        location.href = asxURL;
    } else if (smScreen) { // 800x600 screen - innerW/H for Netscape
	attributes += ",innerWidth=790,innerHeight=575,width=790,height=575";
	window.open('playback.htm?name='+filename, "_blank", attributes);
    } else {
	// large screen : the QA section is smaller in IE.
	attributes += ",innerWidth=955,innerHeight=680,width=955,height=680";
	window.open('playback.htm?name='+filename, "_blank", attributes);
    }

}

function showError(msg) {
    var attributes = "left=0,screenX=0,top=0,screenY=0,width=704,height=528";
    var win = window.open("", "_blank", attributes);

    win.document.open();
    win.document.write(msg);
    win.document.close();
}

function showMsg(msg1, msg2) {
    var msg =
         '<HTML><script src="/HeartBeat.js"></script>
<body onLoad="FixAllLinksFO();" >'
	+'<TABLE WIDTH="704" HEIGHT="528" BGCOLOR="gray" BORDER="0" CELLSPACING="0"><TR>'
	+ '<TD WIDTH="14">&nbsp;</TD>'
	+ '<TD><TABLE>'
	+     '<TR><TD HEIGHT="10">&nbsp;</TD></TR>'
	+     '<TR><TD><FONT SIZE="3" FACE="Arial,Helvetica,Sans-Serif">' + msg1 + '</FONT></TD></TR>'
	+     '<TR><TD HEIGHT="10">&nbsp;</TD></TR>'
	+     '<TR><TD><FONT SIZE="3" FACE="Arial,Helvetica,Sans-Serif">' + msg2 + '</FONT></TD></TR>'
	+     '</TABLE></TD>'
	+ '<TD WIDTH="14">&nbsp;</TD>'
	+ '</TR></TABLE>'
	+ '
 <script type="text/javascript">
 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
 </script>
 <script type="text/javascript">
 try{
 var pageTracker = _gat._getTracker("UA-9550953-1");
 pageTracker._setAllowAnchor(true);
 pageTracker._setDomainName("astm.org");
 pageTracker._trackPageview();
 } catch(err) {}
 </script>
</BODY></HTML>';

    showError(msg);
}

var dontForget = "(Don't forget to run the installer program after downloading it.)";

function noPlugin() {
    var msg1 = "To view this recording in Netscape, you must install the "
	     + "<b>Windows Media Player plug-in for Netscape</b>."
    var msg2;

    if (is_sun)
        msg2 = "Please contact your system administrator to install the "
             + "Windows Media Player 6.3 for Solaris in your browser."
    else
        msg2 = "Please install the " + piLink + ". " + dontForget;

    return showMsg(msg1, msg2);
}

function noWMP() {
    var msg1 = "To view this recording, you must install the "
	     + "<b>Windows Media Player</b>."
    var msg2 = "Please install " + wmpLink + " "
	     + (is_sun ? "6.3" : "6.4") + " or later. " + dontForget;

    return showMsg(msg1, msg2);
}

function showConfigs() {
    var msg1 = "To view this recording, you must change your configuration.";
    var msg2 = "You can use:<ul>"
	     + "<li>" + ieVersions + " and " + wmpLink + " 6.4 or later on Windows, or<p>"
	     + "<li>" + nmVersions + " and " + wmpLink + " 6.4 or later and "
		      + piLink + " on Windows, or<p>"
	     + "<li>" + nsVersions + " and " + wmpLink + " 6.4 or later and "
		      + piLink + " on Windows, or<p>"
	     + "<li>" + nsVersions + " and " + wmpLink + " 6.3 or later and "
		      + piLink + " on Solaris."
	     + "</ul><p>"
	     + dontForget + "<p>"
	     + "<b>Recommended:</b> Internet Explorer 5 or later and Windows Media "
	     + "Player 7 or later on Windows 98, Me, 2000, or XP.";

    return showMsg(msg1, msg2);
}
