// browser/plugin config flags
var ie = false;
var ns = false;
var win = false;
var mac = false;
var browserVer = 0;

// right browser/plugin flag
var flashedAndReady = false;

// check whether or not browser is able to detect for plugin
function canDetectFlash() {
	// Determine the browser (IE or Netscape) using navigator.appName
	ie = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
	ns = (navigator.appName.toLowerCase().indexOf("netscape") != -1);

	// Determine the platform using navigator.userAgent
	win = (navigator.userAgent.toLowerCase().indexOf("win") != -1);
	mac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);

	// Determine the browser version
	browserVer = parseFloat(ie ? navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf("msie") + 4) : navigator.appVersion);

	// Return the appropriate value based on the browser, version and platform
	if (ie && win) return (browserVer >= 4.0) // Works in Windows IE 4.0 and better
	if (ie && mac) return (browserVer >= 5.0) // Works in Mac IE 5.0 and better
	if (ns) return (browserVer >= 3.0) // Works in Netscape 3.0 and up

	// If none of the above conditions matched, the browser is unknown and likely doesn't support detection
	return false;
}

// get flash plugin version
function getFlashVersion() {
	// Set local variables to avoid crashing bug
	var thearray = navigator.plugins;
	var arraylength = thearray.length;

	for (i=0; i < arraylength; i++) {
		// retrieve the plugin
		theplugin = thearray[i];

		// get the plugin name
		thename = theplugin.name;

		// get the plugin description
		thedesc = theplugin.description;

		// If the plugin is the flash player
		if (thedesc.indexOf("Flash") != -1) {
			// parse out the version
			versionString = thedesc.substring(thedesc.indexOf("Flash") + 5);

			// pet the major version
			majorVersion = parseInt(versionString);

			// and return it
			return majorVersion;
		}
	}
	// If we've went through the whole list of plugins without finding Shockwave, we return zero.
	return 0;
}

function getFlash() {
	var flashAnimation = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"" +
						 "  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,42,0\"" +
						 "  id=\"setOne\" width=\"767\" height=\"167\">" +
						 "<param name=\"movie\" value=\"/images/flash/ani_leftStranded.swf\">" +
						 "<param name=\"bgcolor\" value=\"#ffffff\">" +
						 "<param name=\"quality\" value=\"high\">" +
						 "<param name=\"wmode\" value=\"transparent\">" +
						 "<param name=\"allowscriptaccess\" value=\"samedomain\">" +
						 "<embed type=\"application/x-shockwave-flash\"" +
						 "  pluginspage=\"http://www.macromedia.com/go/getflashplayer\"" +
						 "  width=\"767\" height=\"167\" name=\"setOne\"" +
						 "  src=\"/images/flash/ani_leftStranded.swf\" bgcolor=\"#ffffff\"" +
						 "  wmode=\"transparent\" quality=\"high\" swLiveConnect=\"true\" allowScriptAccess=\"samedomain\">" +
						 "</embed>" +
						 "</object>";

	document.write(flashAnimation);
}

function getPhoto() {
	var homePhoto = "<img src=\"/images/img_leftStranded.jpg\" width=\"767\" height=\"167\" alt=\"Nobody wants to be left stranded.\">";

	document.write(homePhoto);
}

// if detectable browser and ie on windows (got to call VBScript to get plugin version)
if (canDetectFlash() && ie && win) {
	// if flash plugin version is 4 or greater
	if ( VBGetFlashVersion() >= 4) {
		// set ready for flash
		flashedAndReady = true;
	} else {
		// set not ready for flash
		flashedAndReady = false;
	}
// else if other detectable browser which are ie and ns on mac or ns on win (got to call JavaScript to get plugin version)
} else if ( ( (canDetectFlash() && mac) || (canDetectFlash() && ns) ) ) {
	// if flash plugin version is 4 or greater
	if ( getFlashVersion() >= 4) {
		// set ready for flash
		flashedAndReady = true;
	} else {
		// set not ready for flash
		flashedAndReady = false;
	}
} else {
	// set not ready for flash
	flashedAndReady = false;
}