// moock fpi [f.lash p.layer i.nspector]
// version: 1.3.5
// written by colin moock
// code maintained at: http://www.moock.org/webdesign/flash/detection/moockfpi/
// terms of use posted at: http://www.moock.org/terms/

function set_chk_flash_ini (ver, red, flpg, nofl, upg) {
	requiredVersion = ver;
	if (red == '0') {
		useRedirect = false;
	}
	if (red == '1') {
		useRedirect = true;
	}
	
	flashPage =flpg;
	noFlashPage = nofl;
	upgradePage = upg;

	flash2Installed = false;    // boolean. true if flash 2 is installed
	flash3Installed = false;    // boolean. true if flash 3 is installed
	flash4Installed = false;    // boolean. true if flash 4 is installed
	flash5Installed = false;    // boolean. true if flash 5 is installed
	flash6Installed = false;    // boolean. true if flash 6 is installed
	flash7Installed = false;    // boolean. true if flash 7 is installed
	flash8Installed = false;    // boolean. true if flash 8 is installed
	maxVersion = 8;             // highest version we can actually detect
	actualVersion = 0;          // version the user really has
	hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
	jsVersion = 1.0;            // the version of javascript supported

// ブラウザのチェック
	isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
	isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

	jsVersion = 1.1;

// Windows IEの場合はVB SCRIPTを使用
	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('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
		document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
		document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
	}
	
	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			flash2Installed = flashVersion == 2;
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion >= 7;
			flash8Installed = flashVersion >= 8;
		}
	}
  
	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(jsVersion > 1.0) {
				window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
			} else {
				window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
			}
	}
}

function put_swf(swf_filename, swf_width, swf_height, swf_play, swf_loop, swf_quality, swf_menu, swf_color) {
	if (!useRedirect) {
		if(hasRightVersion) {
			var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ 'width="' + swf_width +'" height="' + swf_height +'"'
			+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
			+ '<param name="movie" value="' + swf_filename +'">'
			+ '<param name="bgcolor" value="' + swf_color +'">'
			+ '<param name="play" value="' + swf_play +'">'
			+ '<param name="loop" value="' + swf_loop +'">'
			+ '<param name="quality" value="' + swf_quality +'">'
			+ '<param name="menu" value="' + swf_menu +'">'
			+ '<embed src="' + swf_filename +'"'
			+ 'bgcolor="' + swf_color +'"'
			+ 'width="' + swf_width +'" height="' + swf_height +'"'
			+ 'play="' + swf_play +'"'
			+ 'loop="' + swf_loop +'"'
			+ 'quality="' + swf_quality +'"'
			+ 'menu="' + swf_menu +'"'
			+ 'type="application/x-shockwave-flash"'
			+ 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
			+ '</embed>'
			+ '</object>';
			document.write(oeTags);
		}
	}
}
