/* checks what agent is used; if no flash capability suspected als img is supplied else agent is checked for flash;
if no flash agent is rerouted, else swf is suplied 
needs script that checks ua */
//*************** Check the browser and platform
function detectFlash (rv) {
var updatePage = "http://www.bonaireoceanfront.com/updateFlash.html";
	if (is.mac && navigator.plugins["Shockwave Flash"]) {
		if (detectMacFlash(rv)) {
		return true;}
		else {
		window.location = updatePage;
			}
	}
	if(is.msie && is.win ){
		if (detectWinIeFlash(rv)) {
		return true; }
		else {
		window.location = updatePage
			};
	}
	return false;
}
//************************** DETECT ON MAC
function detectMacFlash (rv) {
	var flashDescription = navigator.plugins["Shockwave Flash"].description;
	// A flash plugin-description looks like this: Shockwave Flash 4.0 r5
	// We can get the major version by grabbing the character before the period
	var actualVersion = parseInt(flashDescription.substring(16));
	// check against requiredVersion
	return (actualVersion >= rv) ? true	: false;
}

// set vars and prove em wrong...
var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var flash7Installed = false;    // boolean. true if flash 7 is installed
var flash8Installed = false;    // boolean. true if flash 8 is installed
var flash9Installed = false;    // boolean. true if flash 9 is installed
//************************** DETECT ON WIN
function detectWinIeFlash (rv) {
// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
  
  // Loop through all versions we're checking, and
  // set actualVersion to highest detected version.
  for (var i = 2; i <= 9; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }

  // check against requiredVersion
   return (actualVersion >= rv) ? true	: false;
}

// SWF
function runSWF(asset, title, w, h, v) {
(v) ? v=v: v=6;
var swf = ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + v + ',0,0,0" width="'+w+'" height="'+h+'" title="'+title+'">\n');
swf += ('<param name="movie" value="'+asset+'" />\n');
swf += ('<param name="allowScriptAccess" value="sameDomain" />\n')
swf += ('<param name="quality" value="high" />\n')
swf += ('<embed src="'+asset+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" allowScriptAccess="sameDomain"></embed>\n');
swf += ('</object>\n');
document.write(swf);
}
// IMG
function setIMG (img, w, h, title) {
document.write ('<img src="' + img + '" height="' + h + '" width="' + w + '" alt="" />');
}
// check for flash
function wrapSWF (asset, title, w, h, v, img) {
	if (detectFlash(v)) {
		runSWF(asset, title, w, h, v); 
		} else {
		setIMG (img, w, h, title);
		}
	}