// Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
// with VBScript code from Alastair Hamilton (now somewhat modified)



function isDefined(property) {
  return (typeof property != 'undefined');
}

var flashVersion = 0;
function getFlashVersion() {
	var latestFlashVersion = 9;
   var agent = navigator.userAgent.toLowerCase(); 
	
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               flashVersion = i;
               break;
            }
         }
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}
	return flashVersion;
}

flashVersion_DONTKNOW = -1;

//var requiredVersion = 6;

function makeFlash(requiredVersion,id,w,h,src,wmode,bg,fvar,hidecss,loadcss,loadnonflash,sc,sal,al,tagstart,tagend)
	{

	if (flashVersion ==0)
		{flashVersion = getFlashVersion();}
	if (flashVersion >= requiredVersion)
		{	
			document.writeln(tagstart);
			document.writeln('<object id="'+id+'" width="'+w+'" height="'+h+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+requiredVersion+',0,0,0" align="'+al+'">');
			document.writeln('<param name="movie" value="'+src+'"><param name="wmode" value="'+wmode+'"><param name="bgcolor" value="'+bg+'"><param name="FlashVars" value="'+fvar+'"><param name="Scale" value="'+sc+'"><param name="salign" value="'+sal+'">');
			document.writeln('<embed name="'+id+'" src="'+src+'"  width="'+w+'" height="'+h+'" flashvars="'+fvar+'" wmode="'+wmode+'" bgcolor="'+bg+'" scale="'+sc+'" salign="'+sal+'"  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>');
			document.writeln('</object>');
			document.writeln(tagend);
			if (hidecss!='')
				{
					document.writeln('<style type="text/css">');
					document.writeln(hidecss+'{display:none;}');
					document.writeln('</style>');
				}
		}
	else
		{
			if (loadcss!='')
				{
					document.writeln('<style type="text/css">');
					document.writeln('@import url("'+loadcss+'.css");');;
					document.writeln('</style>');					
				}
			if (loadnonflash!=0)
				{
					document.writeln('<div style="width:'+w+';height:'+h+';background:'+bg+';" class="non-flash">');
					document.writeln(aNonFlash[loadnonflash]);
					document.writeln('</div>');
				}
		}
	}

document.writeln('<style type="text/css">');
document.writeln('.non-flash{font-family:Arial;font-size:10px;color:#333333;}');;
document.writeln('.non-flash a{color:#FF0000;text-decoration:underline;}');;
document.writeln('.non-flash a:hover{color:#00FF00;text-decoration:underline;}');;
document.writeln('</style>');					

/*
makeFlash(int_flashplayerversion, 'str_id', int_width, int_height, 'str_source', 'str_windowmode', 'str_bgcolor', 'str_flashvar', 'str_hidecss', 'str_loadcss', int_loadnonflash, 'str_starttag', 'str_endtag')
*/

var aNonFlash = new Array()
// Just Logo
aNonFlash[1] = '<table width="100%" border="0" cellspacing="0" cellpadding="10"><tr><td align="center"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="js/flash_logo.gif" alt="" width="28" height="32" border="0"></a></td></tr></table>'

// Horizontal
aNonFlash[2] = '<div><img src="js/x.gif" alt="" width="1" height="60" border="0"></div><table border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="js/flash_logo.gif" alt="" width="28" height="32" border="0"></a></td><td><img src="js/x.gif" alt="" width="5" height="1" border="0"></td><td valign="top"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="js/tr.gif" alt="" width="205" height="36" border="0"></a><div><img src="js/x.gif" alt="" width="1" height="10" border="0"></div><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="js/en.gif" alt="" width="205" height="25" border="0"></a></td></tr></table>'

// Vertical 
aNonFlash[3] = '<div><img src="js/x.gif" alt="" width="1" height="40" border="0"></div><table border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="js/flash_logo.gif" alt="" width="28" height="32" border="0"></a><div><img src="js/x.gif" alt="" width="1" height="10" border="0"></div><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="js/tr.gif" alt="" width="205" height="36" border="0"></a><div><img src="js/x.gif" alt="" width="1" height="10" border="0"></div><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="js/en.gif" alt="" width="205" height="25" border="0"></a></td></tr></table>'

