var isIE = (navigator.appVersion.indexOf ("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf ("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf ("Opera") != -1) ? true : false;
jsVersion = 1.1;

function JSGetSwfVer (i) {
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split (" ");
			tempArrayMajor = descArray[2].split (".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		} else {
			flashVer = -1;
		}
	}

	else if (navigator.userAgent.toLowerCase ().indexOf ("webtv/2.6") != -1) flashVer = 4;

	else if (navigator.userAgent.toLowerCase ().indexOf ("webtv/2.5") != -1) flashVer = 3;

	else if (navigator.userAgent.toLowerCase ().indexOf ("webtv") != -1) flashVer = 2;

	else {
		flashVer = -1;
	}
	return flashVer;
}

function DetectFlashVer (reqMajorVer, reqMinorVer, reqRevision) {
	reqVer = parseFloat (reqMajorVer + "." + reqRevision);

	for (i=25;i>0;i--) {
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer (i);
		} else {
			versionStr = JSGetSwfVer (i);
		}
		if (versionStr == -1 ) {
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray = versionStr.split(" ");
				tempString = tempArray[1];
				versionArray = tempString .split(",");
			} else {
				versionArray = versionStr.split(".");
			}
			versionMajor = versionArray[0];
			versionMinor = versionArray[1];
			versionRevision = versionArray[2];

			versionString = versionMajor + "." + versionRevision; // 7.0r24 == 7.24
			versionNum = parseFloat(versionString);

			if ((versionMajor > reqMajorVer) && (versionNum >= reqVer)) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
			}
		}
	}
	return (reqVer ? false : 0.0);
}

function viewSwf (id, swf, width, height, majarVer, minorVer, revisionVer, img, link) {
	var checkVer = this.DetectFlashVer (majarVer, minorVer, revisionVer);
	if (checkVer) {
		var htmlTags = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
				+ ' width="' + width + '"'
				+ ' height="' + height + '"'
				+ ' id="' + id + '"'
				+ ' align="top"'
			+ '>'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="movie" value="' + swf + '" />'
			+ '<param name="menu" value="false" />'
			+ '<param name="quality" value="best" />'
			+ '<param name="bgcolor" value="#FFFFFF" />'
			+ '<embed'
				+ ' src="' + swf + '"'
				+ ' menu="false"'
				+ ' quality="best"'
				+ ' bgcolor="#FFFFFF"'
				+ ' width="' + width + '"'
				+ ' height="' + height + '"'
				+ ' name="' + id + '"'
				+ ' align="top"'
				+ ' allowScriptAccess="sameDomain"'
				+ ' type="application/x-shockwave-flash"'
			+ ' />'
		+ '</object>';
	} else if (img) {
		var htmlTags = '<img src="' + img + '" alt="" border="0" />';
		if (link) {
			htmlTags = '<a href="' + link + '">' + htmlTags + '</a>';
		}
	}

	if (htmlTags) {
		document.write (htmlTags);
	}
}

function viewTopImage (id, swf, width, height, majarVer, minorVer, revisionVer) {
	var checkVer = this.DetectFlashVer (majarVer, minorVer, revisionVer);
	if (checkVer) {
		var htmlTags = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
				+ ' width="' + width + '"'
				+ ' height="' + height + '"'
				+ ' id="' + id + '"'
				+ ' align="middle"'
			+ '>'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="movie" value="' + swf + '" />'
			+ '<param name="menu" value="false" />'
			+ '<param name="quality" value="best" />'
			+ '<param name="bgcolor" value="#FFFFFF" />'
			+ '<embed'
				+ ' src="' + swf + '"'
				+ ' menu="false"'
				+ ' quality="best"'
				+ ' bgcolor="#FFFFFF"'
				+ ' width="' + width + '"'
				+ ' height="' + height + '"'
				+ ' name="' + id + '"'
				+ ' align="top"'
				+ ' allowScriptAccess="sameDomain"'
				+ ' type="application/x-shockwave-flash"'
			+ ' />'
		+ '</object>';
	} else {
		var htmlTags = '<img src="./img/topImage.jpg" alt="" width="' + width + '" height="' + height + '" border="0" usemap="#' + id + '" /></noscript>'
						+ '<map name="topImage" id="topImage">'
						+ '<area shape="circle" coords="66,104,49" href="./outline/" alt="山口銀行について" />'
						+ '<area shape="rect" coords="159,35,257,54" href="./corporate/" alt="法人のお客様" />'
						+ '<area shape="rect" coords="151,56,269,75" href="javascript: openInternetBanking (\'corporate\', \'guide\');" alt="インターネットバンキング" />'
						+ '<area shape="rect" coords="141,80,196,94" href="./corporate/finance/" alt="資金調達" />'
						+ '<area shape="rect" coords="141,96,196,110" href="./corporate/operating/" alt="資金運用" />'
						+ '<area shape="rect" coords="141,111,219,125" href="./corporate/risk-hedge/" alt="リスクヘッジ" />'
						+ '<area shape="rect" coords="202,80,279,94" href="./corporate/consultation/" alt="経営のご相談" />'
						+ '<area shape="rect" coords="202,96,279,110" href="./corporate/efficiency/" alt="事務の効率化" />'
						+ '<area shape="rect" coords="321,25,418,44" href="./personal/" alt="個人のお客様" />'
						+ '<area shape="rect" coords="296,46,449,66" href="javascript: openInternetBanking (\'personal\', \'guide\');" alt="インターネット・モバイルバンキング" />'
						+ '<area shape="rect" coords="306,72,350,86" href="./personal/save/" alt="ためる" />'
						+ '<area shape="rect" coords="305,87,359,101" href="./personal/operating/" alt="運用する" />'
						+ '<area shape="rect" coords="305,103,349,117" href="./personal/borrow/" alt="かりる" />'
						+ '<area shape="rect" coords="367,72,410,86" href="./personal/prepare/" alt="備える" />'
						+ '<area shape="rect" coords="367,87,442,101" href="./personal/convenience/" alt="便利につかう" />'
						+ '<area shape="rect" coords="497,75,578,91" href="./recruit/" alt="採用について" />'
						+ '<area shape="rect" coords="508,93,560,106" href="./recruit/fresh/" target="_blank" alt="新卒採用" />'
						+ '<area shape="rect" coords="508,107,560,120" href="./recruit/career/" alt="中途採用" />'
						+ '<area shape="rect" coords="508,121,570,135" href="./recruit/part/" alt="パート採用" />'
						+ '</map>';
	}

	if (htmlTags) {
		document.write (htmlTags);
	}
}

