/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

// **************  設定部分 *******************

	// Flashファイルへの相対パス
	var flashFilePath = "swf/index.swf";

	// Flash横幅
	var flashWidth = "400";

	// Flash縦幅
	var flashHeight = "279";

	// Flashの必要バージョン
	var reqVersion = 6;

	// Flashがインストールされていないときに表示するメッセージ
	var noFlashMsg = "<center><blink><font color='#FF0033'><b>このコンテンツには Adobe Flash Player が必要です。</b></font></blink><br /><a href='http://www.macromedia.com/shockwave/download/download.cgi?P5_Language=Japanese&Lang=Japanese&P1_Prod_Version=ShockwaveFlash&amp;Lang=Japanese' target='_blank'>Flash Player を入手する</a></center><br />"

    // 表示するかどうか
    var isDisplay  = false;
		
// ************** メイン *********************

	var maxVersion = 7;
	var actualVersion = 0;
	var jsVersion = 1.0;
	var noflashflag;
	var flash2Installed = false;
	var flash3Installed = false;
	var flash4Installed = false;
	var flash5Installed = false;
	var flash6Installed = false;
	var flash7Installed = false;
	var rightVersion = false;
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	jsVersion = 1.1;

	var isGetFlash = false;
	
	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('</SCR' + 'IPT\> \n');
	}

	function checkFlashPlugin() {
		str = "application/x-shockwave-flash";
		ver = 0;
		if (navigator.mimeTypes && navigator.mimeTypes[str] && navigator.mimeTypes[str].enabledPlugin) {
			for(i=0; i<navigator.plugins.length; i++) {
				str2 = navigator.plugins[i].description;
				ptr = str2.indexOf("Flash");
				if (ptr >= 0) ver = eval(str2.substring(ptr+6,ptr+9));
			}
		}
		return ver;
	}

	function detectFlash() {

		if (!isDisplay) {
			return false;
		}
		
		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;
				flash6Installed = flashVersion >= 7;
			}
		}

		for (var i = 2; i <= maxVersion; i++) {  
			if (eval("flash" + i + "Installed") == true) actualVersion = i;
		}

		if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;
		
		if(checkFlashPlugin() > actualVersion) actualVersion = checkFlashPlugin();
		
		if (actualVersion >= reqVersion) {
			rightVersion = true;
			document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"" + flashWidth + "\" height=\"" + flashHeight + "\">");
			document.write("<param name=\"movie\" value=\"" + flashFilePath + "\">");
			document.write("<param name=\"quality\" value=\"high\">");
			document.write("<param name=\"bgcolor\" value=\"#CCCC99\">");
			document.write("<param name=\"loop\" value=\"false\">");
			document.write("<embed src=\"" + flashFilePath + "\" quality=\"high\" bgcolor=\"#ffffff\" loop=\"false\"  width=\"" + flashWidth + "\" height=\"" + flashHeight + "\" type=\"application/x-shockwave-flash\" pluginspage=\"http://wsww.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" Name=\"opening\"></embed>");
			document.write("</object>");
		} else {
			// ２重表示の防止
			if(!isGetFlash) {
				document.write(noFlashMsg);
			}
			isGetFlash = true;
		}
	}



	detectFlash();
