// JavaScript Document
//
function writeELGE(paramfile,optionParamStr){
	geIF="geif";
	fvars ='geparam=' + paramfile;
	if(optionParamStr!=undefined && optionParamStr!=null && optionParamStr!=''){
		fvars+="&"+optionParamStr;
	}
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="720" height="540" id="elge" align="middle">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="swf/'+geIF+'.swf" /><param name="FlashVars" value="'+fvars+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="swf/'+geIF+'.swf" FlashVars="'+fvars+'" quality="high" bgcolor="#ffffff" width="720" height="540" name="elge" id="elge" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
	//--------fscommand----------//
	document.write('<script Language="JavaScript">');
	// fscommandを呼び出した際に実行されるコード
	document.write('function elge_DoFSCommand(command, args) {');
	document.write('ELGEDoFSCommand(command, args);');
	document.write('}');
	document.write('if(navigator.appName.indexOf("Microsoft") != -1){');
	document.write('	GESWF = elge;');
	document.write('}else{');
	document.write('	GESWF = document.elge;');
	document.write('}');
	document.write('</script>');
	document.write('<script Language="VBScript">');
	document.write('Sub elge_FSCommand(ByVal command,ByVal args)');
	document.write('call elge_DoFSCommand(command,args)');
	document.write('End Sub');
	document.write('</script>');
};
//
function ELGEDoFSCommand(command, args){
	var aArgs = String(args).split(",");
	var paramStr = aArgs[2];
	for(var i=3;i<aArgs.length;i++){
		paramStr += ","+aArgs[i];
	}
	this[command](aArgs[0], aArgs[1], paramStr);
}
geAPIWrapper = null
//
function FindAPI(win, apistr) {
  if (typeof(win[apistr]) != 'undefined' && win[apistr] != null) {
    return win[apistr];
  } else if ((typeof(win.document.opener) == 'undefined') && (win.document.location == win.top.document.location)) {
    return null;
  } else {
    if (typeof(win.document.opener) != 'undefined') {
      var result = FindAPI(win.document.opener, apistr);
      if (result) {
        return result;
      }
    }
    if (win.document.location != win.top.document.location) {
      return FindAPI(win.parent, apistr);
    }
    return null;
  }
}
function GEGetAPI(retvarStr){
	geAPIWrapper = FindAPI(this,"GEBundle");
	if(geAPIWrapper==null){
		geAPIWrapper = FindAPI(this,"API");
		if(geAPIWrapper==null){
			GESWF.SetVariable(retvarStr,0);
			isGEBundle = 0;
		}else{
			GESWF.SetVariable(retvarStr,1);
			isGEBundle = 0;
		}
	}else{
		GESWF.SetVariable(retvarStr,1);
		isGEBundle=1;
	}
	GESWF.SetVariable("isGEBundle",isGEBundle);

}
//LMS functions
function GEInitialize(retvarStr){
	if(geAPIWrapper != null){
		GESWF.SetVariable(retvarStr, geAPIWrapper.LMSInitialize('')=='True'?1:0);
	}else{
		GESWF.SetVariable(retvarStr, 1);
	}
}
function GEGetValue(retvarStr, varNameStr){
	if(geAPIWrapper != null){
		GESWF.SetVariable(retvarStr, geAPIWrapper.LMSGetValue(varNameStr));
	}else{
		GESWF.SetVariable(retvarStr, '');
	}
}
function GESetValue(retvarStr, varNameStr, valstr){
	if(geAPIWrapper != null){
		GESWF.SetVariable(retvarStr, geAPIWrapper.LMSSetValue(varNameStr, valstr)=='True'?1:0);
	}else{
		GESWF.SetVariable(retvarStr, 1);
	}
}
function GECommit(retvarStr){
	if(geAPIWrapper != null){
		GESWF.SetVariable(retvarStr, geAPIWrapper.LMSCommit('')=='True'?1:0);
	}else{
		GESWF.SetVariable(retvarStr, 1);
	}
}
function GEFinish(retvarStr){
	if(geAPIWrapper != null){
		GESWF.SetVariable(retvarStr, geAPIWrapper.LMSFinish('')=='True'?1:0);
	}else{
		GESWF.SetVariable(retvarStr, 1);
	}
}
function GEGetLastError(retvarStr) {
	if(geAPIWrapper != null){
		GESWF.SetVariable(retvarStr, geAPIWrapper.LMSGetLastError());
	}else{
		GESWF.SetVariable(retvarStr, '0');
	}
}
function GEGetErrorString(retvarStr, valstr) {
	if (geAPIWrapper != null) {
		GESWF.SetVariable(retvarStr, geAPIWrapper.LMSGetErrorString(valstr));
	}else{
		GESWF.SetVariable(retvarStr, '0');
	}
}
function GEGetDiagnostic(retvarStr, valstr) {
	if (geAPIWrapper != null) {
		GESWF.SetVariable(retvarStr, geAPIWrapperI.LMSGetDiagnostic(valstr));
	}else{
		GESWF.SetVariable(retvarStr, '');
	}
}
////////
function GEExit(){
	if(isGEBundle){
		geAPIWrapper.GEExit();
	}
}
