/*
 * 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";
	//var flashFilePath = "eccube/html/user_data/packages/default/img/brandpanel/BrandPanel.swf";
	
	// Flash横幅
	//var flashWidth = "400";
	var flashWidth = "245";
	var mainflashWidth = "690";
	
	// Flash縦幅
	//var flashHeight = "279";
	var flashHeight = "168";
	var mainflashHeight = "150";
	
	// Flashの必要バージョン
	//var reqVersion = 6;
	var reqVersion = 8;

	// Flashがインストールされていないときに表示するメッセージ
	/*
	var noFlashMsg =
		"<table width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" summary=\" \">"
		+"<tr><td colspan=\"3\"><img src=\"./img/flash/image_flash01.jpg\" width=\"400\" height=\"174\" alt=\"\"></td></tr>"
		+"<tr>"
		+"<td><img src=\"./img/flash/image_flash02.jpg\" width=\"140\" height=\"22\" alt=\"\"></td>"
		+"<td><a href=\"http://www.macromedia.com/shockwave/download/download.cgi?P5_Language=Japanese&Lang=Japanese&P1_Prod_Version=ShockwaveFlash&amp;Lang=Japanese\" target=\"_blank\"><img src=\"./img/flash/download.gif\" width=\"205\" height=\"22\" alt=\"\" border=\"0\"></a></td>"
		+"<td><img src=\"./img/flash/image_flash03.jpg\" width=\"55\" height=\"22\" alt=\"\"></td></tr>"
		+"</tr>"
		+"<tr><td colspan=\"3\"><img src=\"./img/flash/image_flash04.jpg\" width=\"400\" height=\"84\" alt=\"\"></td></tr>"
		+"</table>";
	*/


// ************** メイン *********************

	var maxVersion = 10;
	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 flash8Installed = false;
	var flash9Installed = false;
	var flash10Installed = false;
	var rightVersion = false;
	//ブラウザ分岐 windows&IE
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	jsVersion = 1.1;
	var panel_path = "user_data/packages/default/paneldata/";
	var main_path = "user_data/packages/default/img/main/";

	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('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n'); 
		document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \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;
				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 (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=\"#ffffff\">");
			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 {
			document.write(noFlashMsg);
		}
	}
	*/
	function mainFlash(flashname, flash_image) {
		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; //MIMEタイプの説明文字列
				//var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
				//parseInt : 整数変換  charAt : 一文字取り出す
				var flashVersion = parseInt(flashDescription.match(/\d+\.\d+/));
				
				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 >= 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=\"" + mainflashWidth + "\" height=\"" + mainflashHeight + "\">");
			document.write("<param name=\"movie\" value=\"user_data/packages/default/img/main/topimage.swf\">");
			document.write("<param name=\"quality\" value=\"high\">");
			document.write("<param name=\"bgcolor\" value=\"#ffffff\">");
			document.write("<param name=\"loop\" value=\"false\">");
			document.write("<embed src=\"user_data/packages/default/img/main/topimage.swf\" quality=\"high\" bgcolor=\"#ffffff\" loop=\"false\"  width=\"" + mainflashWidth + "\" height=\"" + mainflashHeight + "\" 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 {
			document.write("<img src=\"" + main_path + flash_image + "\" width=\"" + mainflashWidth + "\" height=\"" + mainflashHeight + "\" />");
		}
	}
	
	
	function detectFlash(panel_name, panel_name_image, url_address, methodflag) {
		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; //MIMEタイプの説明文字列
				//var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
				//parseInt : 整数変換  charAt : 一文字取り出す
				var flashVersion = parseInt(flashDescription.match(/\d+\.\d+/));
				
				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 >= 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=\"brandpanel/BrandPanel.swf\">");
			document.write("<param name=\"quality\" value=\"high\">");
			document.write("<param name=\"bgcolor\" value=\"#ffffff\">");
			document.write("<param name=\"loop\" value=\"false\">");
			document.write("<param name=\"FlashVars\" value=\"pname=" + panel_name + "&method= " + methodflag + "&url_path=" + url_address + "\">");
			document.write("<embed src=\"brandpanel/BrandPanel.swf\" FlashVars=\"pname=" + panel_name + "&method= " + methodflag + "&url_path=" + url_address + "\" 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 {
			document.write("<img src=\"" + panel_path + panel_name_image + "\" width=\"" + flashWidth + "\" height=\"" + flashHeight + "\" />");
		}
	}
	
	//detectFlash();
