
/************** Flash Electro-Filter Hybrid Version 1.3
 Copyright:  RazorX.com (c) 2003, 2004, 2005, 2006, 2007.
 
 **User Rights: Permission is granted for anyone to use this code as long as this entire notice
   area is kept intact. Keeping this notice intact, also provides important info for other web
   developers who grab this script from their cache. In order to maintain a fast loading script,
   please read all rights, legal agreements, disclaimers, and setup files located at: RazorX.com.
   
 **Code function: Detect for Flash player, then redirect only if lower or no version is detected.
 
 **Browser Design: Use for any browser version 4 or better. I have found that it is no longer
   worth the trouble to develop for browser versions of 3 or less, and it is more logical, based
   on current times, to force users to upgrade old browsers.
   
 **Code use: Copy the line below, also called  "sourcing in", to each page you need detection on
   or just your main or home page if everyone is entering in from that direction.
   <script type="text/javascript" language="javascript" src="/hybrid_flash_ef.js"></script>  Then copy
   the .js file into your main or root directory. It's usually easier to use a /root-relative address.   
**************/

/// Start of set-up area...
/// Personalize the notice pages with your web address. Do not include the http:// protocol.
/// This step is optional in this Hybrid version.
var web_SITE = "this web site"; /// Don't add www. unless your site doesn't work without it.

/// Important note: if the min. version is met there will be no redirect; the visitor will stay on the page.
/// Any Flash player in an operating system beyond Macintosh or Linux, will be defaulted to the Windows ver. needed.
/// Here we are implementing out-of-sync. ability, because not all Flash players for each operating system get released at
/// the same time. 
/// ** You can downlaod Flash players for various platforms here: http://www.adobe.com/shockwave/download/alternates/
/// ** You can download verious Flash Player versions here: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14266
var min_major_win_FLASH = 8; /// Minimum major Windows based Flash player ver. needed for your Flash site: 6, 7, 8, 9, etc.
var min_major_mac_FLASH = 8; /// Minimum major Macintosh based Flash player ver. needed for your Flash site: 6, 7, 8, 9, etc.
var min_major_linux_FLASH = 8; /// Minimum major Linux based Flash player ver. needed for your Flash site: 6, 7, 8, 9, etc.

/// Note: This area is for advanced Flashers who need to verify minor versions for ActionScript compatibility.
/// Macromedia also calls the minor version a release version. Either usage is correct and we use minor here.
var check_minor_FLASH = "on"; /// Leave "off" for default or "on" to check for minor Flash versions.

/// Any Flash player in an operating system beyond Macintosh or Linux, will be defaulted to the Windows ver. needed.
var min_minor_win_FLASH = 0; /// Leave as "0" for default. Minimum minor Windows based Flash player version required.   
var min_minor_mac_FLASH = 0; /// Leave as "0" for default. Minimum minor Macintosh based Flash player version required.
var min_minor_linux_FLASH = 0; /// Leave as "0" for default. Minimum minor Linux based Flash player version required.
/// Minor ver. examples: Flash player 5: 30,41,42. Flash player 6: 21,23,29,47,65,79,81. Flash player 7: 2,14,19.
/// Minor ver. examples: Flash player 8: 22,24,33,34,35.

/// If the mandatory_FLASH flag is set to "off" then the visitor will only be sent to the location in
/// redirect_nonflash_HTML if a Flash player is NOT found or if the Flash player is less than the
/// min_major_FLASH. Essentially the redirect_nonflash_HTML page can be a close copy of your Flash site. 
var mandatory_FLASH = "on"; /// Leave "on" for default or "off" for an HTML page if no or lesser Flash detected.
var redirect_nonflash_HTML = "html_only_en.htm"; /// This redirect only works if mandatory_FLASH is "off".

/// Detect for WebTV because they have Flash players in them, but are usually older versions.
/// For example: Currently an MSN-WebTV version of 2.8 for Windows only supports a Flash 4 player.
/// AOLTV used to support Flash player 3, while MSN-WebTV versions 2.2 or less had no Flash player support.
var redirect_any_WEBTV = "webtv_en.htm"; /// Location of your WEBTV page.

/// Browser language detection. Use this area ONLY if your site supports multiple languages.
/// Turning "on" any lang_detect_XX will add the lanaguage code to the end of the redirect file.
/// Example: upgrade_flash_en.htm would be changed to upgrade_flash_de.htm if German detect was "on".
var lang_default = "en"; /// Default language is "en" for English. You do not have to have lang_detect_EN
///  turned "on". This option would be for other countries who want to serve the English page version.
var lang_detect_CS = "off"; /// Leave as "off" for default or "on" to detect for Czech language.
var lang_detect_DE = "off"; /// Leave as "off" for default or "on" to detect for German language.
var lang_detect_EN = "off"; /// Leave as "off" for default or "on" to detect for English language.
var lang_detect_ES = "off"; /// Leave as "off" for default or "on" to detect for Spanish language. 
var lang_detect_FR = "off"; /// Leave as "off" for default or "on" to detect for French language.
var lang_detect_JA = "off"; /// Leave as "off" for default or "on" to detect for Japanese language.
var lang_detect_RO = "off"; /// Leave as "off" for default or "on" to detect for Romanian language.  
var lang_detect_RU = "off"; /// Leave as "off" for default or "on" to detect for Russian language. 
var lang_detect_SV = "off"; /// Leave as "off" for default or "on" to detect for Swedish language.
var lang_detect_ZH = "off"; /// Leave as "off" for default or "on" to detect for Chinese language.

/// End of set-up area...
/// WARNING - No need to configure or change anything below this line. You shouldn't have to update
/// any of the JavaScript below. The global variables from the set-up area above are used below.
////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// Begin detection ///////////////////////////////////////////////////////////



var min_major_FLASH = 0; /// Set initial variable values to zero.
var min_minor_FLASH = 0; 
var flash_major_VER = 0; 
var flash_minor_VER = false; /// Set initial variable value to false.
var final_IE = 0; /// Set initial variable value to zero.

var user_AGENT = navigator.userAgent.toLowerCase(); /// Browser ver. type and op sys.

/// Note: Support for AOLTV is no longer - AOL shut down it's AOLTV service on November 30, 2003.

/// Note: MSNTV was formally called WebTV renamed in July 2001 to MSNTV. This service is still active.					
var detect_MSNTV = ((user_AGENT.indexOf("webtv") != -1) || (user_AGENT.indexOf("msntv") != -1));


var detect_IE = ((user_AGENT.indexOf("msie") != -1) && (user_AGENT.indexOf("opera") == -1)
                && (user_AGENT.indexOf("netscape") == -1) && (detect_MSNTV == false));
				  
if(detect_IE) { final_IE = parseFloat(user_AGENT.substring(4+user_AGENT.indexOf("msie"))) }

var detect_LINUX = (user_AGENT.indexOf("linux") != -1);
				  
/// Version of I.E. of 4.5 or less on Macintosh cannot handle VBscript, and therefore no client-side
/// detection will work according to Macromedia. We also do not want to write the VBscript to them as
/// it will produce an error message pop-up. So we let them pass through hoping that they have a
/// Flash Player installed. 
var MAC_IE_4pt5 = false; /// Set to false. Variable changes to true if MAC and I.E. 4.5 or less is detected.				  
var detect_MAC = ((user_AGENT.indexOf("mac") != -1) || (user_AGENT.indexOf("macintosh") != -1)
                  || (user_AGENT.indexOf("68k") != -1) || (user_AGENT.indexOf("68000") != -1) 
				  || (user_AGENT.indexOf("ppc") != -1) || (user_AGENT.indexOf("powerpc") != -1));				  

 if (detect_MAC && final_IE <= 4.5) { MAC_IE_4pt5 = true; }

/// Now we write VBScript to I.E. and loop through until we find the Flash major and minor version.			  
 if (detect_IE && MAC_IE_4pt5 == false)
    {
      document.write(
       '<scr' + 'ipt type=text\/vbscript language=vbscript>' + '\n' +
         'Function FlashVerString(i)' + '\n' +
         'on error resume next' + '\n' +
         'Dim palette, flashplayer' + '\n' +
         'flashplayer = 0' + '\n' +            
            'set palette = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))' + '\n' +
            'if (IsObject(palette)) then' + '\n' +
               'flashplayer = palette.GetVariable("$version")' + '\n' +
            'end if' + '\n' +
            'FlashVerString = flashplayer' + '\n' +
         'End Function' + '\n' +
       '<\/sc' + 'ript>'
       );

	
     for (i=25;i>0;i--)
     {      
     IE_flash_string = FlashVerString(i);
     }
/// To see the actual string in IE for testing, uncomment the alert function below.
///alert (IE_flash_string);

//var flash_major_VER = parseInt(IE_flash_string.substring(IE_flash_string.indexOf(",")-1))
var flash_major_VER = parseInt(IE_flash_string.substring(IE_flash_string.indexOf(",")-2))

var flash_minor_VER = parseInt(IE_flash_string.substring(3+IE_flash_string.indexOf(",")))

///alert("Flash major ver: "+flash_major_VER+"\nFlash Minor Ver: "+flash_minor_VER);
   } /// End of IE Flash detect


//////////////////// Begin Mozilla/Netscape type detection ////////////////////////////////
///Here we detect with mimeTypes property instead of the plugins property unlike most flash detection
///schemes on the Web. A little known bug in Netscape Navigator 4.x can cause the plugins property
///to fail to expand out or work as needed, the mimeTypes property doesn't have this problem.
var flash_MIME = (navigator.mimeTypes &&
                  navigator.mimeTypes["application/x-shockwave-flash"])
	              ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
    
 if (flash_MIME)
    {
    //var flash_major_VER = parseInt(flash_MIME.description.substring(flash_MIME.description.indexOf(".")-1))
    var flash_major_VER = parseInt(flash_MIME.description.substring(flash_MIME.description.indexOf(".")-2))
	var flash_minor_VER = parseInt(flash_MIME.description.substring(2+flash_MIME.description.indexOf("r")-1))
	}
///alert("Flash version in Mozilla: "+flash_major_VER+"\nMinor: "+flash_minor_VER);

/// Flash player will still be zero for Mac I.E. 4.5 unless we change it here, and we need to let them pass
/// through, as if they had a Flash player, so they don't get redirected to the No Flash Found screen. 	
	if (MAC_IE_4pt5) { flash_major_VER = 99; flash_minor_VER = 99; }
	
	
/// Here we synthesize the final major and minor Flash player required based on the operating system detected.
	if (detect_MAC) { min_major_FLASH = min_major_mac_FLASH; min_minor_FLASH = min_minor_mac_FLASH }
	else if (detect_LINUX) { min_major_FLASH = min_major_linux_FLASH; min_minor_FLASH = min_minor_linux_FLASH }
	else { min_major_FLASH = min_major_win_FLASH; min_minor_FLASH = min_minor_win_FLASH }
	
	
/// Double check for any user set-up typos in our FLASH flags; check order is based on defaults.
 if ( mandatory_FLASH != "off" ) { mandatory_FLASH = "on" }
 if ( mandatory_FLASH != "on" ) { mandatory_FLASH = "off" }
 
 if ( check_minor_FLASH != "on" ) { check_minor_FLASH = "off" }
 if ( check_minor_FLASH != "off" ) { check_minor_FLASH = "on" }


/// Query string info tack. This part appends the user's flash info and required info to the redirect URL.
var final_req_major_VER = min_major_FLASH;  /// Need a seperate variable for next line if majors are equal but minor is different.
if (flash_major_VER == min_major_FLASH  &&  flash_minor_VER < min_minor_FLASH ) { final_req_major_VER = min_major_FLASH+"0"+min_minor_FLASH };




var value_string = new String ("?usrmjr="+flash_major_VER+"&usrmnr="+flash_minor_VER+"&reqmjr="+final_req_major_VER+"&reqmnr="+min_minor_FLASH+"&chkmnr="+check_minor_FLASH+"&ws="+web_SITE+" "); /// Keep two quotes on end.
var qry_str = value_string.replace(/ /g,""); /// Remove any spaces globally.

//// Browser language detection
var check_lang = false;
var brow_lang = new String(); /// Nothing as default.
if (navigator.language) { brow_lang = navigator.language; } /// For Netscape based.
if (navigator.systemLanguage) { brow_lang = navigator.systemLanguage; }  /// For Web TV.
if (navigator.browserLanguage) { brow_lang = navigator.browserLanguage; } /// For IE.
var brow_lang_final = brow_lang.substring(0,2);

  if (brow_lang_final != lang_default)
  {
   if (lang_detect_CS == "on") { check_lang = true; }
   if (lang_detect_DE == "on") { check_lang = true; }
   if (lang_detect_EN == "on") { check_lang = true; }
   if (lang_detect_ES == "on") { check_lang = true; }  
   if (lang_detect_FR == "on") { check_lang = true; }
   if (lang_detect_JA == "on") { check_lang = true; }
   if (lang_detect_RO == "on") { check_lang = true; }
   if (lang_detect_RU == "on") { check_lang = true; }
   if (lang_detect_SV == "on") { check_lang = true; }
   if (lang_detect_ZH == "on") { check_lang = true; }
  }
 


function lang_insert(rdrct,lngcd)
{
var rdrct_string = new String(rdrct)
  if ( rdrct_string.indexOf("_"+lang_default) ) {var rdrct_clean = rdrct_string.replace("_"+lang_default,""); }
  else { var rdrct_clean = rdrct_string }
var rdrct_string2 = new String(rdrct_clean);
var rdrct_splice = rdrct_string2.replace(/\./,"_"+lngcd+".");
return( rdrct_splice )
}



function no_flash_docwrite(width,height,bgtablecolor)
{

  document.write('<table width='+width+' height='+height+' border="0" cellpadding="0" cellspacing="0" bgcolor='+bgtablecolor+'><tr>')
  document.write('<td><div align="center" class="flef-body-sm">To view video content, please update your Flash Player.<br>')
  document.write('<div align="center" class="flef-body-sm">A version of: <strong> '+flash_major_VER+'.0.'+flash_minor_VER+'  </strong>was detected, but version <strong> '+min_major_FLASH+'.0.'+min_minor_FLASH+' </strong>is required.<br>')
  document.write('<a href="http://www.adobe.com/products/flashplayer" target="_blank" class="flef-link-sm">Please update your Flash Player</a></div></td></tr></table>')	
}

function update_flash_docwrite(width,height,bgtablecolor)
{
//  document.write('<table width='+width+' height='+height+' border="0" cellpadding="0" cellspacing="0" bgcolor='+bgtablecolor+'><tr>')
    document.write('<table width='+width+' height='+height+' border="0" cellpadding="0" cellspacing="0" bgcolor='+bgtablecolor+'><tr>')
  document.write('<td><div align="center" class="flef-body-sm">To view video content, please update your Flash Player.<br>')
  document.write('<div align="center" class="flef-body-sm">A version of: <strong> '+flash_major_VER+'.0.'+flash_minor_VER+'</strong> was detected, but version <strong> '+min_major_FLASH+'.0.'+min_minor_FLASH+' </strong>is required.<br>')
  document.write('<a href="http://www.adobe.com/products/flashplayer" target="_blank" class="flef-link-sm">Please update your Flash Player</a></div></td></tr></table>')	
}

function graphic_docwrite(imagevalue,imgwidth,imgheight)
{

  document.write('<a href="http://www.adobe.com/products/flashplayer" target="_blank"><img src='+imagevalue+' width='+imgwidth+' height='+imgheight+' border="0"></a>')	
}


///////////////////////////// Filter the results and apply accordingly ///////////////////////////  
/// Catch WebTV based browsers and redirect them first as they have lesser Flash player versions.
/// Use the replace() method to prevent history trapping and use of the back button if needed.
/// Note: the replace() method only works for NS 3 or better and IE 4 or better, but you should
/// already be forcing major browsers of 3 or less to an upgrade link instead of accommodating them.
 if ( detect_MSNTV )
     if ( check_lang == true ) { window.location.replace( lang_insert( redirect_any_WEBTV, brow_lang_final ) ); }
     else { window.location.replace( redirect_any_WEBTV ); }
	 

 if ( mandatory_FLASH == "off"  &&  flash_major_VER < min_major_FLASH  )
      { 
      if ( check_lang == true ) { window.location.replace( lang_insert( redirect_nonflash_HTML, brow_lang_final ) ); }
      else { window.location.replace( redirect_nonflash_HTML ); }
	  }


///////////////////////////////////////////////////////////////////////////////////////////////////////
function flash_hybrid(objectvalue,imagevalue,imgheight,imgwidth,onlygraphic,bgtablecolor)
{

var width = parseInt(objectvalue.substring(7+objectvalue.indexOf("width=")))
var height = parseInt(objectvalue.substring(8+objectvalue.indexOf("height=")))

var flash_STATUS = "sawgood";


////////////////////////////////////////////////////////////////////////////////////////////
	 
 if ( mandatory_FLASH == "on"  &&  flash_major_VER == 0  )
      {   
		    if (onlygraphic == "on") {  graphic_docwrite(imagevalue,imgwidth,imgheight);  }  
            else {  no_flash_docwrite(width,height,bgtablecolor);  }
			flash_STATUS = "bad";
	  }	 
 	 
  if ( mandatory_FLASH == "on"  &&  flash_major_VER != 0  &&  check_minor_FLASH == "on"  &&  flash_minor_VER != 0 )
    {	
      if ( flash_major_VER < min_major_FLASH || ( flash_major_VER == min_major_FLASH  &&  flash_minor_VER < min_minor_FLASH ) )
	     { 
	        if (onlygraphic == "on") {  graphic_docwrite(imagevalue,imgwidth,imgheight);  }  
            else { update_flash_docwrite(width,height,bgtablecolor); }
			flash_STATUS = "bad";
		 } 	
     }
	 
  if ( mandatory_FLASH == "on"  &&  flash_major_VER != 0  &&  check_minor_FLASH == "on" &&  flash_minor_VER == 0 )
    {      
      if ( flash_major_VER < min_major_FLASH )
	     {  
		    if (onlygraphic == "on") {  graphic_docwrite(imagevalue,imgwidth,imgheight);  }  
            else { update_flash_docwrite(width,height,bgtablecolor); }
			flash_STATUS = "bad";
		 } 	
     }
	 
  if ( mandatory_FLASH == "on"  &&  flash_major_VER != 0  &&  check_minor_FLASH == "off" )
    {	
      if ( flash_major_VER < min_major_FLASH )
	     {
	        if (onlygraphic == "on") {  graphic_docwrite(imagevalue,imgwidth,imgheight);  }  
            else { update_flash_docwrite(width,height,bgtablecolor); }
			flash_STATUS = "bad";
		 }	
     }
 
  if (flash_STATUS == "sawgood")
   {
            if (onlygraphic == "on") {  graphic_docwrite(imagevalue,imgwidth,imgheight);  } 
            else { document.write(objectvalue); }	///Here we just write the Flash object out if all is good.
	}		
  
} ///Closing curly brace for flash_hybrid function

///End of script
