var langPagePath = new Array();

function writeZoomSightButtonJa(instPath){

	//Default ZoomSight button.
	document.write('<span id="ZoomSightButtonXML" style="display:none"></span>');
	document.write('<script type="text/javascript" src="'+instPath+'bin/TranslationLangSet.js" charset="UTF-8"></script>');
	document.write('<script type="text/javascript" src="'+instPath+'bin/ZoomSightButtonFunctions.js" charset="UTF-8"></script>');
	document.write('<script type="text/javascript" src="'+instPath+'lang/ja/bin/LangInfo.js" charset="UTF-8"></script>');
	document.write('<script type="text/javascript" src="'+instPath+'lang/en/bin/LangInfo.js" charset="UTF-8"></script>');
	document.write('<script type="text/javascript" src="'+instPath+'lang/zh-CN/bin/LangInfo.js" charset="UTF-8"></script>');
	document.write('<a id="ZoomSightButtonJaA" href="'+instPath+'lang/ja/html/index.html"><img id="ZoomSightButtonJaImg" src="'+instPath+'lang/ja/zoomsightlaunch.gif" border=0 alt="ズームサイト起動ボタン" /></a>');

	//Attach the event to body tag.
	try{
		if(window.attachEvent){
			window.attachEvent("onload", function(){rewriteZoomSightButtonJa(instPath)});
		}else{
			if(window.addEventListener){
				window.addEventListener("load", function(){rewriteZoomSightButtonJa(instPath)}, false);
			}else{
				//No-operation instruction.
			}
		}
	}catch(e){
		//No-operation instruction.
	}

}

function rewriteZoomSightButtonJa(instPath){

	try{
		//Detach the event from body tag.
		if(window.detachEvent){
			window.detachEvent("onload", function(){rewriteZoomSightButtonJa(instPath)});
		}else{
			if(window.removeEventListener){
				window.removeEventListener("load", function(){rewriteZoomSightButtonJa(instPath)}, false);
			}else{
				//No-operation instruction.
			}
		}
	}catch(e){
		//No-operation instruction.
	}

	try{
		//Define the default lang code.
		var defaultLangCode = "ja";
		var langCode = defaultLangCode;

		//Define the default alt attribute.
		var altZoomSightButtonJaImg = "ズームサイト起動ボタン";
		var altZoomSightButtonEnImg = "Start button of ZoomSight";
		var altZoomSightButtonZhCNImg = "ZoomSight启动按钮";
		var altZoomSightButtonImg = altZoomSightButtonJaImg;

		//Check the Translation.
		var originalURL = checkTranslated();
		if(originalURL != ""){

			instPath = convertInstPath(instPath, originalURL);

			langCode = getLangCode(defaultLangCode);

			//To check the lang code.
			langCode = searchLangSet(langCode);
			if(langCode == ""){
				langCode = defaultLangCode;
			}

			//To ckeck the installation.
			if(langPagePath[langCode] == null){
				langCode = defaultLangCode;
			}

			//Switch the alt attribute.
			switch(langCode){
				case "ja":
					altZoomSightButtonImg = altZoomSightButtonJaImg;
					break;
				case "en":
					altZoomSightButtonImg = altZoomSightButtonEnImg;
					break;
				case "zh-CN":
					altZoomSightButtonImg = altZoomSightButtonZhCNImg;
					break;
				default:
					altZoomSightButtonImg = altZoomSightButtonJaImg;
					break;
			}

			document.getElementById("ZoomSightButtonJaA").href = instPath+"lang/"+langCode+"/html/index.html";
			document.getElementById("ZoomSightButtonJaImg").src = instPath+"lang/"+langCode+"/zoomsightlaunch.gif";
			document.getElementById("ZoomSightButtonJaImg").alt = altZoomSightButtonImg;

		}else{
			if(chkBrowser()){
				if(document.getElementById("LaunchSettings")==null){
					var objSpan = document.getElementById("ZoomSightButtonXML");
					var objXML = document.createElement("xml");
					objXML.id = "LaunchSettings";
					objXML.src = instPath+"launchsetting.xml";
					objXML.charset = "UTF-8";
					objSpan.appendChild(objXML);
				}
				document.getElementById("ZoomSightButtonJaA").href = 'javascript:OpenZoomSight(\"'+langCode+'\");';
			}else{
				document.getElementById("ZoomSightButtonJaA").href = instPath+"lang/"+langCode+"/html/index.html";
			}
			document.getElementById("ZoomSightButtonJaImg").src = instPath+"lang/"+langCode+"/zoomsightlaunch.gif";
			document.getElementById("ZoomSightButtonJaImg").alt = altZoomSightButtonImg;
		}

	}catch(e){
		//No-operation instruction.
	}

}
