var requiredVersion = 5;
var useRedirect = false;
var flashPage = ""
var noFlashPage = ""
var upgradePage = ""

var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var maxVersion = 6;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
jsVersion = 1.1;
if(isIE && isWin){
  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('</SCR' + 'IPT\> \n');
}

function detectFlash() {  
  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion >= 6;
    }
  }
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  
  if (actualVersion >= requiredVersion) {
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace(flashPage);  
      } else {
        window.location = flashPage;
      }
    }
    hasRightVersion = true;                
  } else {  
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}

function fpi2exec(requiredVer,width,height,quality,loop,menu,swfsrc,play,altimgsrc,altredirectsrc,altredirectspeed, homepage){
  requiredVersion=requiredVer;
  noFlashPage=altredirectsrc;
  upgradePage=altredirectsrc;
  flashPage=altredirectsrc;
  detectFlash();

  if (!useRedirect) {
    if(hasRightVersion) {
      if (requiredVer=''){ requiredVer='5'; }
	  if (requiredVer='5'){ requiredVer='5,0,41,0'; }
	  else if (requiredVer='6'){ requiredVer='6,0,0,0'; }
      var oeTags='<div style="text-align:center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+requiredVer+'"><param name="movie" value="'+swfsrc+'">'
	
	  if (loop !=''){ oeTags +='<PARAM NAME="LOOP" VALUE="'+loop+'">' }
	  if (quality !=''){ oeTags +='<PARAM NAME="QUALITY" VALUE="'+quality+'">' }
	  if (menu !=''){ oeTags +='<PARAM NAME="MENU" VALUE="'+menu+'">' }
	  if(homepage == "true" || altimgsrc == './customimages/crisscrossNonFlash.jpg') { oeTags += '<param name="wmode" value="transparent">' }
      oeTags +='<embed src="'+swfsrc+'" width="'+width+'" height="'+height+'"'
	  if(homepage == "true" || altimgsrc == './customimages/crisscrossNonFlash.jpg') { oeTags += ' wmode="transparent"' }
	  if (play !=''){ oeTags +=' PLAY="'+play+'"' }
	  if (loop !=''){ oeTags +=' LOOP="'+loop+'"' }
	  if (quality !=''){ oeTags +=' QUALITY="'+quality+'"' }
	  if (menu !=''){ oeTags +=' MENU="'+menu+'"' }
	  oeTags +='TYPE="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></div>';
      document.write(oeTags);
    } else {
	  var alternateContent='';
	  if (altimgsrc != "") {
            alternateContent = '<img src="'+altimgsrc+'" width="'+width+'" height="'+height+'" border="0" cellpadding="0" cellspacing="0">';

	  } else if (homepage == "true") {
	    alternateContent = '<table width="100%" align="center"><tr><td><table width="60%" align="center"><tr><td><br /><img align="left" hspace="0" src="./custom/images/welcome/nonflash_church.jpg" /><br /><img align="center" src="./custom/images/welcome/nonflash_welcome.jpg" hspace="0" /><br /><table width="300px" cellpadding="10"><tr><td><span style="font-size:1.2em;font-family:Arial, Helvetica, sans-serif;">We are so grateful that you are visiting Flemings Chapel Online.  As you browse through this site, I hope you will catch a glimpse of what God is doing in and through our church family.  Take your time and explore the many facets of our ministry...<br /><br /><br /></span></td></tr></table></td></tr></table></td></tr></table>'; 
	  }
      document.write(alternateContent);
    }
  }
}
