//<!--
/*
このファイルの中身は、NTT オープンソースライセンス　バージョン 1.0（「本
契約」という）の適用を受けます。
本契約を遵守しない限り、このファイルを使用してはなりません。
本契約のコピーは、次のＵＲＬから入手できます。
【配布サイトのURL】 http://www.oss.ecl.ntt.co.jp/lms/

本契約に基づき頒布されるソフトウェアは、現状のまま、明示又は黙示のあらゆ
る種類の保証なしで、頒布されます。本契約に基づく権利及び制限を律する特定
の文言については、本契約を参照してください。

「オリジナルコード」は、 NTT Cyber Space Laboratories Code です。 
「オリジナルコード」の「初期開発者」は、日本電信電話株式会社です。  
日本電信電話株式会社により創作された部分は、Copyright (C) 2004 
日本電信電話株式会社 です。
全ての権利が留保されます。 
「コントリビュータ」：_____________________________________ 


The contents of this file are subject to the NTT Opensource License
Version 1.0 (the License); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
【配布サイトのURL】 http://www.oss.ecl.ntt.co.jp/lms/

Software distributed under the License is distributed on an AS IS
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.

The Original Code is NTT Cyber Space Laboratories Code .

The Initial Developer of the Original Code is NIPPON TELEGRAPH AND 
TELEPHONE CORPORATION.
Portions created by the NIPPON TELEGRAPH AND TELEPHONE CORPORATION 
are Copyright (C) 2004 NIPPON TELEGRAPH AND TELEPHONE CORPORATION. 
All Rights Reserved.

Contributor(s) ______________________________________.
*/
//-->

function chg_str1(s){
	if(s == null){
		return "";
	}else{
		return decodeURIComponent(s);
	}
}

function chg_str2(s){
	if(s == null){
		return "";
	}else{
		return encodeURIComponent(s);
	}
}
// ---------------------------- start ---------------------------------------
var ErrorNum = 0;

var EM = new Array();
EM["0"]   = "no error";
EM["101"] = "General Exception";
EM["201"] = "Invalid argument error";
EM["202"] = "Element cannot have children";
EM["203"] = "Element not an array - Cannot have count";
EM["301"] = "Not initialized";
EM["401"] = "Not implemented error";
EM["402"] = "Invalid set value, element is a keyword";
EM["403"] = "Element is read only";
EM["404"] = "Element is write only";
EM["405"] = "Incorrect Data Type";



// ---------------------------- end ---------------------------------------

// ---------------------------- start ---------------------------------------
function preRmvB(s){
	var spos,epos;
	s = s.replace(/\s+/g," ");
	spos = (s.charAt(0)==" ")?1:0;
	epos = (s.charAt(s.length-1)==" ")?s.length-1:s.length;
	return s.substring(spos,epos);
}


function t_GetDT(s){
	var dA=new Array(2);var tA=new Array(2);
	var nowday = new Date();
	if(s=="m")return nowday.getTime();

	dA[0]=nowday.getFullYear();dA[1]=nowday.getMonth()+1;dA[2]=nowday.getDate();
	tA[0]=nowday.getHours();tA[1]=nowday.getMinutes();tA[2]=nowday.getSeconds();

	for(i=0;i<3;i++){
		if(dA[i]<=9)dA[i]="0"+dA[i];
		if(tA[i]<=9)tA[i]="0"+tA[i];
	}

	if(s=="d") return dA.join("/");
	else if(s=="t") return tA.join(":");
	else return dA.join("/") + " " + tA.join(":");
}

function t_GetST(n){
	var ms,ss,mm,hh,tmp;
	var num = Math.floor(n/10);

	ms = num % 100;
	num = Math.floor(num / 100);
	ss = num % 60;
	num = Math.floor(num / 60);
	mm = num % 60;
	num = Math.floor(num / 60);
	hh = num % 60;
	num = Math.floor(num / 60);

	if(ms <= 9)ms="0"+ms;
	if(ss <= 9)ss="0"+ss;
	if(mm <= 9)mm="0"+mm;
	if(hh <= 9)hh="000"+hh;
	else if(hh <= 99)hh="00"+hh;
	else if(hh <= 999)hh="0"+hh;

	return hh + ":" + mm + ":" + ss + "." + ms;
}

function t_GetMS(t){
	var num = 0;
	var buf = t.split(":");
	num += eval(buf[0] * 60 * 60 * 1000);
	num += eval(buf[1] * 60 * 1000);
	num += eval(buf[2] * 1000);
	return num;
}


function nullToEmp(s){
	if(s == null){
		return "";
	}else{
		return s;
	}
}


function t_DelS(s,i){
	if(s!=""){
		if(i<0){
			s = s.substring(-i,s.length);
		}else{
			s = s.substring(0,s.length-i);
		}
	}
	return s;
}

function t_DelCrLf(s){
	var pos = s.charAt(s.length - 1);
	while((pos == "\r")||(pos =="\n")){
		s = s.substring(0,s.length - 2);
		pos = s.charAt(s.length - 1);
	}
	return s;
}

function t_AddNode(dom,org,elm){
	if(org.selectSingleNode(elm)==null){
		var nn = dom.createElement(elm);
		org.appendChild(nn);
		return false;
	}else{
		return true;
	}
}

function t_AddText(dom,p,nn,s){
	var pn = dom.selectSingleNode(p)
	if(pn.selectSingleNode(nn)==null){
		var tn = dom.createElement(nn);
		tn.text = s;
		pn.appendChild(tn);
		return false;
	}else{
		return true;
	}
}

// ---------------------------- end ---------------------------------------
function RetErr(s){
	s = t_DelCrLf(s);
	this.error      = "";
	this.error_text = "";
	this.version    = "";
	var i,buf;
	s = s.replace("\r","");
	buf = s.split("\n");
	for(i=0;i<buf.length;i++){
		if(buf[i].indexOf("error=") == 0){
			this.error = parseInt(buf[i].replace("error=",""));
		}else if(buf[i].indexOf("error_text=") == 0){
			this.error_text = buf[i].replace("error_text=","");
		}else if(buf[i].indexOf("version=") == 0){
			this.error_text = buf[i].replace("version=","");
		}else{
			;
		}
	}
}

function RetSco(dom,s){
	s = t_DelCrLf(s);
	var root = dom.createElement("cmi");
	dom.appendChild(root);
	s = s.replace(/\r/g,"");
	var i,buf,mode;
	var suspend_data = "";
	var launch_data = "";
	var comments_data = "";
	buf = s.split("\n");
	for(i=0;i<buf.length;i++){
		if(buf[i]=="[Core]"){
			if(t_AddNode(dom,root,"core")){
				return false;
			}
			mode = 0;
		}else if(buf[i]=="[Core_Lesson]"){
			mode = 1;
		}else if(buf[i]=="[Core_Vendor]"){
			mode = 2;
		}else if(buf[i]=="[Comments]"){
			mode = 3;
		}else if(buf[i]=="[Evaluation]"){
			if(t_AddNode(dom,root,"evaluation")) return false;
			mode = 4;
		}else if(buf[i]=="[Objectives_Status]"){
			if(t_AddNode(dom,root,"objectives")) return false;
			mode = 5;
		}else if(buf[i]=="[Student_Data]"){
			if(t_AddNode(dom,root,"student_data")) return false;
			mode = 6;
		}else if(buf[i]=="[Student_Demographics]"){
			if(t_AddNode(dom,root,"student_demographics")) return false;
			mode = 7;
		}else if(buf[i]=="[Student_Preferences]"){
			if(t_AddNode(dom,root,"student_preferences")) return false;
			mode = 8;
		}else{
			if(mode==0){
				if(SetCoreData(dom,buf[i])){
					alert(buf[i] + "\nError Core Data!");
					return false;
				}
			}else if(mode==1){
				suspend_data += chkNull2(buf[i]) + "\r\n";
			}else if(mode==2){
				launch_data += chkNull2(buf[i]) + "\r\n";
			}else if(mode==3){
				comments_data += buf[i] + "\r\n";
			}else if(mode==4){
				if(SetEvaData(dom,buf[i])){
					alert(buf[i] + "Error Evaluation Data!");
					return false;
				}
			}else if(mode==5){
				if(SetObjData(dom,buf[i])){
					alert(buf[i] + "Error Obj Data!");
					return false;
				}
			}else if(mode==6){if(SetStuData(dom,buf[i])){alert(buf[i] + "Error Student Data!");return false;}
			}else if(mode==7){if(SetDemoData(dom,buf[i])){alert(buf[i] + "Error Demo Data!");return false;}
			}else if(mode==8){if(SetPreData(dom,buf[i])){alert(buf[i] + "Error Pre Data!");return false;}
			}else{alert("Error SCO Init!");return false;}
		}
	}
	if(t_AddText(dom,"/cmi","suspend_data",suspend_data) || t_AddText(dom,"/cmi","launch_data",launch_data) || t_AddText(dom,"/cmi","comments",comments_data)){
		return false;
	}
	return true
}

function SetPreData(dom,s){
	if(s.indexOf("Audio=")==0){
			s = s.replace("Audio=","");
			return t_AddText(dom,"/cmi/student_preferences","audio", s);
	}else if(s.indexOf("Language=")==0){
			s = s.replace("Language=","");
			return t_AddText(dom,"/cmi/student_preferences","language",s);
	}else if(s.indexOf("Lesson_Type=")==0){
			s = s.replace("Lesson_Type=","");
			return t_AddText(dom,"/cmi/student_preferences","lesson_type",s);
	}else if(s.indexOf("Speed=")==0){
			s = s.replace("Speed=","");
			return t_AddText(dom,"/cmi/student_preferences","speed",s);
	}else if(s.indexOf("Text=")==0){
			s = s.replace("Text=","");
			return t_AddText(dom,"/cmi/student_preferences","text",s);
	}else if(s.indexOf("Text_Color=")==0){
			s = s.replace("Text_Color=","");
			return t_AddText(dom,"/cmi/student_preferences","text_color",s);
	}else if(s.indexOf("Text_Location=")==0){
			s = s.replace("Text_Location=","");
			return t_AddText(dom,"/cmi/student_preferences","text_location",s);
	}else if(s.indexOf("Text_Size=")==0){
			s = s.replace("Text_Size=","");
			return t_AddText(dom,"/cmi/student_preferences","text_size",s);
	}else if(s.indexOf("Video=")==0){
			s = s.replace("Video=","");
			return t_AddText(dom,"/cmi/student_preferences","video",s);
	}else if(s.indexOf("Window.")==0){
		s = s.replace("Window.","");
	}else{return true;}
	return false;
}

function SetDemoData(dom,s){
	if(s.indexOf("City=")==0){s = s.replace("City=","");return t_AddText(dom,"/cmi/student_demographics","city",s);
	}else if(s.indexOf("Class=")==0){s = s.replace("Class=","");return t_AddText(dom,"/cmi/student_demographics","class",s);
	}else if(s.indexOf("Company=")==0){s = s.replace("Company=","");return t_AddText(dom,"/cmi/student_demographics","company",s);
	}else if(s.indexOf("Country=")==0){s = s.replace("Country=","");return t_AddText(dom,"/cmi/student_demographics","country",s);
	}else if(s.indexOf("Experience=")==0){s = s.replace("Experience=","");return t_AddText(dom,"/cmi/student_demographics","experience",s);
	}else if(s.indexOf("Familiar_Name=")==0){s = s.replace("Familiar_Name=","");return t_AddText(dom,"/cmi/student_demographics","familiar_name",s);
	}else if(s.indexOf("Instructior_Name=")==0){s = s.replace("Instructior_Name=","");return t_AddText(dom,"/cmi/student_demographics","instructor_name",s);
	}else if(s.indexOf("Job_Title=")==0){s = s.replace("Job_Title=","");return t_AddText(dom,"/cmi/student_demographics","title",s);
	}else if(s.indexOf("Native_Language=")==0){s = s.replace("Native_Language=","");return t_AddText(dom,"/cmi/student_demographics","native_language",s);
	}else if(s.indexOf("State=")==0){s = s.replace("State=","");return t_AddText(dom,"/cmi/student_demographics","state",s);
	}else if(s.indexOf("Street_Address=")==0){s = s.replace("Street_Address=","");return t_AddText(dom,"/cmi/student_demographics","street_address",s);
	}else if(s.indexOf("Telephone=")==0){s = s.replace("Telephone=","");return t_AddText(dom,"/cmi/student_demographics","telephone",s);
	}else if(s.indexOf("Years_Experience=")==0){s = s.replace("Years_Experience=","");return t_AddText(dom,"/cmi/student_demographics","years_experience",s);
	}else{return true;}
	return false;
}

function SetStuData(dom,s){
	if(s.indexOf("Attempt_Number=")==0){s = s.replace("Attempt_Number=","");return t_AddText(dom,"/cmi/student_data","attempt_number",s);
	}else if(s.indexOf("Mastery_Score=")==0){
		s = s.replace("Mastery_Score=","");
		return t_AddText(dom,"/cmi/student_data","mastery_score",s);
	}else if(s.indexOf("Max_Time_Allowed=")==0){s = s.replace("Max_Time_Allowed=","");s = ReBTime(s);return t_AddText(dom,"/cmi/student_data","max_time_allowed",s);
	}else if(s.indexOf("Time_Limit_Action=")==0){
		s = s.replace("Time_Limit_Action=","");
		return t_AddText(dom,"/cmi/student_data","time_limit_action",s);
	}else if(s.indexOf("Lesson_Status.")==0){
		s = s.replace("Lesson_Status.","");
	}else if(s.indexOf("Score.")==0){
		s = s.replace("Score.","");
	}else{return true;}
	return false;
}

function SetObjData(dom,s){
	return false;
}

function SetEvaData(dom,s){
	if(s.indexOf("Course_ID=")==0){s = s.replace("Course_ID=","");return t_AddText(dom,"/cmi/evaluation","course_id",s);
	}else if(s.indexOf("Comments_File=")==0){
	}else if(s.indexOf("Interactions_File=")==0){
	}else if(s.indexOf("Objectives_Status_File=")==0){
	}else if(s.indexOf("Path_File=")==0){
	}else if(s.indexOf("Performance_File=")==0){
	}else{return true;}
	return false;
}

var Status = new Array();Status["p"] = "passed";Status["c"] = "completed";Status["f"] = "failed";Status["i"] = "incomplete";Status["p"] = "passed";Status["b"] = "browsed";Status["n"] = "not attempted";
var Entry = new Array();Entry["a"] = "ab-initio";Entry["r"] = "resume";Entry["n"] = "";
var Credit = new Array();Credit["c"] = "credit";Credit["n"] = "no-credit"

function SetCoreData(dom,s){
	if(s.indexOf("Student_ID=")==0){
		s = s.replace("Student_ID=","");
		s = chg_str1(s);
		return t_AddText(dom,"/cmi/core","student_id",s);
	}else if(s.indexOf("Student_Name=")==0){
		s = s.replace("Student_Name=","");
		s = chg_str1(s);
		return t_AddText(dom,"/cmi/core","student_name",s);
	}else if(s.indexOf("Output_File=")==0){
	}else if(s.indexOf("Credit=")==0){
		s = s.replace("Credit=","");
		if(s == "") s = "n";
		s = s.charAt(0).toLowerCase();
		return t_AddText(dom,"/cmi/core","credit",Credit[s]);
	}else if(s.indexOf("Lesson_ID=")==0){
	}else if(s.indexOf("Lesson_Location=")==0){
		s = chg_str1(s);
		s = s.replace("Lesson_Location=","");
		return t_AddText(dom,"/cmi/core","lesson_location",s);
	}else if(s.indexOf("Lesson_Status=")==0){
		s = s.replace("Lesson_Status=","");
		s = chg_str1(s);

		var buf = s.split(",");
		if(buf.length == 3){
			if((buf[0] == "unknown")&&(buf[1] == "unknown")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","not attempted");
			}else if((buf[0] == "unknown")&&(buf[1] == "incomplete")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","incomplete");
				ADP.flgWrite = 1;
			}else if((buf[0] == "unknown")&&(buf[1] == "completed")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","completed");
				ADP.flgWrite = 1;
			}else if((buf[0] == "failed")&&(buf[1] == "unknown")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","failed");
				ADP.flgWrite = 1;
			}else if((buf[0] == "failed")&&(buf[1] == "incomplete")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","failed");
				ADP.flgWrite = 1;
			}else if((buf[0] == "failed")&&(buf[1] == "completed")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","failed");
				ADP.flgWrite = 1;
			}else if((buf[0] == "passed")&&(buf[1] == "unknown")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","passed");
				ADP.flgWrite = 1;
			}else if((buf[0] == "passed")&&(buf[1] == "incomplete")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","passed");
				ADP.flgWrite = 1;
			}else if((buf[0] == "passed")&&(buf[1] == "completed")){
				buf[0] = t_AddText(dom,"/cmi/core","lesson_status","passed");
				ADP.flgWrite = 1;
			}

			buf[2] = t_AddText(dom,"/cmi/core","entry",buf[2]);
		}else{
			return true;
		}
	}else if(s.indexOf("Path=")==0){
	}else if(s.indexOf("Score=")==0){
		s = s.replace("Score=","");
		s = chg_str1(s);

		var tmp0,tmp1,tmp2,tmp3,tmp4;
		tmp0 = t_AddNode(dom,dom.selectSingleNode("/cmi/core"),"score")
		tmp1 = tmp2 = tmp3 = tmp4 = "";
		var buf = s.split(",");
		if(buf.length == 2){
			if(buf[1] != "")t_AddText(dom,"/cmi/core/score","raw",buf[1]);
		}else if(buf.length == 3){
			if(buf[1] != "")t_AddText(dom,"/cmi/core/score","raw",buf[1]);
			if(buf[2] != "")t_AddText(dom,"/cmi/core/score","max",buf[2]);
		}else if(buf.length == 4){
			if(buf[1] != "")t_AddText(dom,"/cmi/core/score","raw",buf[1]);
			if(buf[2] != "")t_AddText(dom,"/cmi/core/score","max",buf[2]);
			if(buf[3] != "")t_AddText(dom,"/cmi/core/score","min",buf[3]);
		}else{
			return true;
		}
	}else if(s.indexOf("Time=")==0){
		s = s.replace("Time=","");
		s = chg_str1(s);
		s = ReBTime(s);
		return t_AddText(dom,"/cmi/core","total_time",s);
	}else if(s.indexOf("Lesson_Mode=")==0){
		return t_AddText(dom,"/cmi/core","lesson_mode","normal");
	}else{
		return true;
	}
	return false;
}

function ReBTime(s){
	var buf = s.split(":");
	if(buf[0].length == 2){
		buf[0] = "00" + buf[0];
	}else if(buf[0].length == 3){
		buf[0] = "0" + buf[0];
	}
	return buf.join(":");
}

function makeAdapter(){
	this.DM = new ActiveXObject("Microsoft.XMLDOM");
	this.mrt;
	this.ADPInit = ADPInit;
	this.SCOInit = SCOInit;
	this.SCOFin = SCOFin;
	this.GetLimitTime = GetLimitTime;
	this.sco_GetValue = sco_GetValue;
	this.sco_SetValue = sco_SetValue;
	this.sco_GetNode = sco_GetNode;
	this.sco_Commit = sco_Commit;
	this.SCO = null;
	this.stime = 0;
	this.flgWrite = 0;

	this.dm_CheckModel = dm_CheckModel;
	this.dm_CheckChildren = dm_CheckChildren;
	this.dm_CheckVersion = dm_CheckVersion;
	this.dm_CheckCount = dm_CheckCount;
	this.dm_GetCount = dm_GetCount;
	this.dm_RetDefValue = dm_RetDefValue;
	this.dm_CheckData = dm_CheckData;
	this.dm_CheckValue = dm_CheckValue;

}

function ADPInit(){
	this.DM.async = false;
	var xmlStr = '<?xml version="1.0"?><cmi><core><student_id st="r" dt="CMIIdentifier"/><student_name st="r" dt="CMIString255"/><lesson_location st="rw" dt="CMIString255"/>';
	xmlStr += '<credit st="r" dt="CMIVocabulary"><kw>credit</kw><kw def="t">no-credit</kw></credit><lesson_status st="rw" dt="CMIVocabulary"><kw>passed</kw><kw>completed</kw>';
	xmlStr += '<kw>failed</kw><kw>incomplete</kw><kw>browsed</kw><kw def="t">not attempted</kw></lesson_status><entry st="r" dt="CMIVocabulary"><kw def="t">ab-initio</kw>';
	xmlStr += '<kw>resume</kw><kw/></entry><score><raw st="rw" dt="SCESCORE"/><max st="rw" dt="SCESCORE"/><min st="rw" dt="SCESCORE"/></score><total_time st="r" dt="CMITimespan"/>';
	xmlStr += '<lesson_mode st="r" dt="CMIVocabulary"><kw>browse</kw><kw def="t">normal</kw><kw>review</kw></lesson_mode><exit st="w" dt="CMIVocabulary"><kw>time-out</kw>';
	xmlStr += '<kw>suspend</kw><kw>logout</kw><kw def="t"/></exit><session_time st="w" dt="CMITimespan"/></core><suspend_data st="rw" dt="CMIString4096"/><launch_data st="r" dt="CMIString4096"/><comments st="rw" dt="CMIString4096"/><comments_from_lms st="r" dt="CMIString4096"/><objectives><n><id st="rw" dt="CMIIdentifier"/><score><raw st="rw" dt="SCESCORE"/><max st="rw" dt="SCESCORE"/><min st="rw" dt="SCESCORE"/></score><status st="rw" dt="CMIVocabulary"><kw>passed</kw><kw>completed</kw><kw>failed</kw><kw>incomplete</kw><kw>browsed</kw><kw def="t">not attempted</kw></status></n></objectives><student_data><mastery_score st="r" dt="CMIDecimal"/><max_time_allowed st="r" dt="CMITimespan"/><time_limit_action st="r" dt="CMIVocabulary"><kw>exit,message</kw><kw>exit,no message</kw><kw>continue,message</kw><kw def="t">continue,no message</kw></time_limit_action></student_data><student_preference><audio st="rw" dt="CMISInteger_1_100"/><language st="rw" dt="CMIString255"/><speed st="rw" dt="CMISInteger_100_100"/><text st="rw" dt="CMISInteger_1_1"/></student_preference><interactions><n><id st="w" dt="CMIIdentifier"/><objectives><n><id st="w" dt="CMIIdentifier"/></n></objectives><time st="w" dt="CMITime"/><type st="w" dt="CMIVocabulary"><kw>true-false</kw><kw>choice</kw><kw>fill-in</kw><kw>matching</kw><kw>performance</kw><kw>sequencing</kw><kw>likert</kw><kw>numeric</kw></type><correct_responses><n><pattern st="w" dt="CMIString255"/></n></correct_responses><weighting st="w" dt="CMIDecimal"/><student_response st="w" dt="CMIString255"/><result st="w" dt="SCERESULT"><kw>correct</kw><kw>wrong</kw><kw>unanticipated</kw><kw>neutral</kw></result><latency st="w" dt="CMITimespan"/></n></interactions></cmi>';

	this.DM.loadXML(xmlStr);
	return (this.DM.xml=="")?true:false;
}

var Ajax12 = null;
function SCOInit(sid,trg){

	if(Ajax12 == null){
		Ajax12 = parent.API_1484_11.Ajax;
	}
	Ajax12.setAICC(sid,trg);
	gStr = Ajax12.cmiPost("GetParam", "");

	var mp,buf;
	mp = gStr.indexOf("aicc_data=");
	if(mp == -1) return null;
	var eStr = gStr.substring(0,mp);
	var aStr = gStr.substring(mp + 10,gStr.length);
	var AiccErr = new RetErr(eStr);
	if(AiccErr.error != 0){
		alert("aicc response error!");
		return false;
	}
	this.SCO = new ActiveXObject("Microsoft.XMLDOM");
	if(!RetSco(this.SCO,aStr)){
		alert("Error SCO Init");
		return 0;
	}

	this.stime = t_GetDT("m");
	this.flgWrite = 1;
	return 1;
}

function SCOFin(){
	if(this.stime){
		var etime = t_GetDT("m");
		ADP.sco_SetValue("cmi.core.session_time",t_GetST(etime - this.stime),1);
		ADP.flgWrite = 1;
	}
	ADP.sco_Commit(1);
	return 1;
}

function chkNull(s){
	if(s == null){
		return "";
	}
	return chg_str2(s);
}

function chkNull2(s){
	if(s == null){
		return "";
	}
	return chg_str1(s);
}

function sco_Commit(num){
	var sData = "";
	var eStr;

	if(this.flgWrite){
		var tmp
		sData = "[Core]" + "\r\n";

		sData += "Lesson_Location=" + chkNull(this.sco_GetValue("cmi.core.lesson_location")) + "\r\n";
		tmp = this.sco_GetValue("cmi.core.lesson_status");
		var tmptmp
		if(tmp == "not attempted"){
			tmptmp = "unknown,unknown,"
		}else if(tmp == "browsed"){
			tmptmp = "unknown,incomplete,"
		}else if(tmp == "incomplete"){
			tmptmp = "unknown,incomplete,"
		}else if(tmp == "completed"){
			tmptmp = "unknown,completed,"
		}else if(tmp == "failed"){
			tmptmp = "failed,incomplete,"
		}else if(tmp == "passed"){
			tmptmp = "passed,completed,"
		}

		tmp = this.sco_GetValue("cmi.core.exit");
		if(tmp==null){
			tmp = "";
		}

		sData += "Lesson_Status=" + chkNull(tmptmp + tmp) + "\r\n";

		var tmps1,tmps2,tmps3,tmps4;

		tmps2 = this.sco_GetValue("cmi.core.score.raw");
		tmps1 = "";
		if((tmps2 != "")&&(tmps2 != null)){
			if(!isNaN(tmps2)){
				tmps1 = parseInt(tmps2) / 100;
			}
		}

		tmps3 = this.sco_GetValue("cmi.core.score.max");
		tmps4 = this.sco_GetValue("cmi.core.score.min");

		if(tmps4 != null){
			sData += "Score=" + chkNull(tmps1 + "," + nullToEmp(tmps2) + "," + nullToEmp(tmps3) + "," + nullToEmp(tmps4)) + "\r\n";
		}else if(tmps3 != null){
			sData += "Score=" + chkNull(tmps1 + "," + nullToEmp(tmps2) + "," + nullToEmp(tmps3)) + "\r\n";
		}else if(tmps2 != null){
			sData += "Score=" + chkNull(tmps1 + "," + nullToEmp(tmps2)) + "\r\n";
		}else{
			sData += "Score=" + chkNull(tmps1 + ",") + "\r\n";
		}


		tmp = this.sco_GetValue("cmi.core.session_time");
		if(tmp==null){

		}else{
			sData += "Time=" + chkNull(TStoD(tmp)) + "\r\n";
		}

		sData += "[Core_Lesson]" + "\r\n";
		sData += this.sco_GetValue("cmi.suspend_data") + "\r\n";
		sData += "[Comments]" + "\r\n";
		sData += this.sco_GetValue("cmi.comments") + "\r\n";
		sData += "[Objectives_Status]" + "\r\n";

		sData += "[Student_Data]" + "\r\n";
		sData += "[Student_Preferences]" + "\r\n";

		sData += "Audio=" + chkNull(this.sco_GetValue("cmi.student_preferences.audio")) + "\r\n";
		sData += "Language=" + chkNull(this.sco_GetValue("cmi.student_preferences.language")) + "\r\n";
		sData += "Speed=" + chkNull(this.sco_GetValue("cmi.student_preferences.speed")) + "\r\n";
		sData += "Text=" + chkNull(this.sco_GetValue("cmi.student_preferences.text")) + "\r\n";

		eStr = Ajax12.cmiPost("PutParam",sData);
		var AiccErr = new RetErr(eStr);
		if(AiccErr.error != 0){
			alert("PurParam error!");
			return false;
		}
		this.flgWrite = 0;
	}

	sData = '"Date","Interaction_ID","Objective_ID","Type_Interaction","Correct_Response","Student_Response","Result","Weighting","Latency","Description"' + "\r\n";
	m = dm_RepS("cmi.interactions");
	pn = this.SCO.selectSingleNode(m);

	if(pn != null){
		var iwflg = false;
		var ttn;
		cnl = pn.childNodes;
		pathName = "cmi.interactions.i";
		for(i=0;i<cnl.length;i++){
			tagname = cnl.item(i).tagName;
			if(tagname.match(/^i{1}\d+/) != null){
				iwflg = true;
				if(cnl.item(i).getAttribute("f_chg") == "1"){
					tagname = tagname.replace("i","");

					sData += '"' + chkNull(TStoD2(post_GetValue(pathName + tagname + ".time"))) + '","';
					sData += chkNull(post_GetValue(pathName + tagname + ".id")) + '","';
					var temp = post_GetMultiValue(pathName + tagname + ".objectives","id");
					if(temp != null){
						sData += chkNull(temp) + '","';
					}else{
						sData += '","';
					}

					sData += chkNull(post_GetValue(pathName + tagname + ".type")) + '","';

					temp = post_GetMultiValue(pathName + tagname + ".correct_responses","pattern");
					if(temp != null){
						sData += chkNull(temp) + '","';
					}else{
						sData += '","';
					}

					sData += chkNull(post_GetValue(pathName + tagname + ".student_response")) + '","';
					sData += chkNull(post_GetValue(pathName + tagname + ".result")) + '","';
					sData += chkNull(post_GetValue(pathName + tagname + ".weighting")) + '","';
					sData += chkNull(TStoD(post_GetValue(pathName + tagname + ".latency"))) + '","';
					// 2011.09.02 taku-harada mod >>
					//sData += chkNull(post_GetValue(pathName + tagname + ".discription")) + '"\r\n';
					sData += chkNull(post_GetValue(pathName + tagname + ".description")) + '"\r\n';
					// 2011.09.02 taku-harada mod <<
					post_ResetFlag("cmi.interactions.i" + tagname);
				}
			}
		}

		if(iwflg){
			eStr = Ajax12.cmiPost("PutInteractions",sData);
			var AiccErr = new RetErr(eStr);
			if(AiccErr.error != 0){
				alert("PutInteractions error!");
				return false;
			}
		}
	}

	if(num){
		eStr = Ajax12.cmiPost("ExitAU","");
		var AiccErr = new RetErr(eStr);
		if(AiccErr.error != 0){
			alert("ExitAU error!");
			return false;
		}
	}
	return true;
}


function TStoD(s){
	if(s == ""){
		return "PT0H0M0S";
	}
	var retAry = new Array(0,0,0,0,0,0);
	var buf = s.split(":");
	retAry[4] = eval(buf[1]);

	if(buf[2].charAt(0) == "0"){
		buf[2] = buf[2].substring(1,buf[2].length);
	}

	retAry[5] = eval(buf[2]);
	var tmpNum = eval(buf[0]);
	var HH,DD,MM,YY;
	HH = tmpNum % 24
	tmpNum = (tmpNum - HH) / 24;
	DD = tmpNum % 31
	tmpNum = (tmpNum - DD) / 31;
	MM = tmpNum % 12
	YY = (tmpNum - MM) / 12;
	retAry[0] = YY;
	retAry[1] = MM;
	retAry[2] = DD;
	retAry[3] = HH;
	var retStr = "P"
	if(retAry[0] != 0){
		retStr += retAry[0] + "Y";
	}
	if(retAry[1] != 0){
		retStr += retAry[1] + "M";
	}
	if(retAry[2] != 0){
		retStr += retAry[2] + "D";
	}

	if((retAry[3] != 0)||(retAry[4] != 0)||(retAry[5] != 0)){
		retStr += "T";
		if(retAry[3] != 0){
			retStr += retAry[3] + "H";
		}
		if(retAry[4] != 0){
			retStr += retAry[4] + "M";
		}
		if(retAry[5] != 0){
			retStr += retAry[5] + "S";
		}
	}
	return retStr;

}
function TStoD2(s){
	if((s == "") || (s == null)){
		return "";
	}

	var retVal = "";
	var nowData = new Date();
	var nowM = nowData.getMonth() + 1;
	var nowD = nowData.getDate();

	if(nowM < 10){nowM = "0" + nowM};
	if(nowD < 10){nowD = "0" + nowD};

	retVal = nowData.getFullYear() + "-";
	
	retVal += nowM + "-" + nowD + "T" + s;
	return retVal;
}

function GetLimitTime(){
	var lt,tt;
	lt = this.sco_GetValue("cmi.student_data.max_time_allowed");
	if (lt == null)
		return 0;
	lt = t_GetMS(lt);
	tt = this.sco_GetValue("cmi.core.total_time");
	tt = (tt == null)?0:t_GetMS(tt);
	lt -= tt;
	if(lt <= 0)
		lt = 1;
	return lt;
}

function sco_GetValue(m){
	m = dm_RepS(m);
	var n = this.SCO.selectSingleNode(m);
	return (n==null)?null:n.text;
}

function sco_SetValue(m,s,f){
	if(!f){
		if(m=="cmi.core.session_time"){
			this.stime = 0;
		}
	}
	m = dm_RepS(m);
	var i,tn,nn,cn;
	var ncnt = 0;
	var buf = m.split("/");
	cn = this.SCO;
	for(i=0;i<buf.length;i++){
		tn = cn.selectSingleNode(buf[i]);
		if(tn==null){
			nn = this.SCO.createElement(buf[i]);
			cn.appendChild(nn);
			cn = nn;
		}else{
			cn = tn;
		}

		if(buf[i].match(/^i{1}\d+/) != null){
			ncnt++;
			
			if(ncnt == 1){
				cn.setAttribute("f_chg", "1");
			}
		}
	}
	cn.text = s;
}

function dm_RepG(m){
	var i;
	var buf = m.split(".");
	for(i in buf)
		if(!isNaN(buf[i]))
			buf[i] = "n";
	return "/" + buf.join("/");
}

function dm_RepS(m){
	var i;
	var buf = m.split(".");
	for(i in buf)
		if(!isNaN(buf[i]))
			buf[i] = "i" + buf[i];

	return buf.join("/");
}

function dm_CheckModel(m){return  ADP.mrt.selectSingleNode(m);}

function dm_CheckData(m,f){
	m = dm_RepG(m);
	var ret;
	var n = this.dm_CheckModel(m);
	if(n==null){
		return null;
	}else{
		ret = n.getAttribute("st");
		if(ret==null)
			return null;
		else if((ret=="w")&&(!f))
			return 0;
		else if((ret=="r")&&(f))
			return 0;
		else
			return n.getAttribute("dt");
	}
}

function dm_CheckChildren(m){
	m = dm_RepG(m);
	m = m.replace("/_children","");
	if((m == "/cmi/objectives")||(m == "/cmi/interactions")||(m == "/cmi/interactions/n/objectives")||(m == "/cmi/interactions/n/correct_response"))
		m += "/n";
	var i;
	var ret = "";
	var n = this.dm_CheckModel(m);
	if(n==null){
		return null;
	}else{
		n = n.childNodes;
		for(i=0;i<n.length;i++)
			ret += n.item(i).nodeName + ",";
		return t_DelS(ret,1);
	}
}

function dm_CheckVersion(m){
	m = dm_RepG(m);
	m = m.replace("/_version","");
	var n = this.dm_CheckModel(m);
	return (n==null)?null:1;
}

function dm_CheckCount(m){
	m = dm_RepG(m);
	m = m.replace("/_count","");
	var n = this.dm_CheckModel(m);
	if(n==null){
		return null;
	}else{
		n = n.selectSingleNode("n");
		return (n==null)?0:1;
	}
}

function dm_RetDefValue(v,m){
	if((v=="CMIString255")||(v=="CMIString4096")||(v=="CMIBlank")||(v=="SCESCORE")){
		ret = "";
	}else if((v=="CMIDecimal")||(v=="CMIInteger")||(v.indexOf("CMISInteger")!=-1)){
		ret = 0;
	}else if(v=="CMITimespan"){
		ret = "0000:00:00.00";
	}else if(v=="CMIVocabulary"){
		m = dm_RepG(m)
		ret = this.mrt.selectSingleNode(m + '/kw[@def="t"]').text;
	}else{
		ret = null;
	}
	return ret;
}

function dm_CheckValue(t,s,m){
	var f = false;
	if(t=="CMIIdentifier"){
		f = Check_CMIIdentifier(s);
	}else if(t=="CMIInteger"){
		f = Check_CMIInteger(s);
	}else if(t.indexOf("CMISInteger")!=-1){
		f = Check_CMISInteger(s);
		var buf = t.split("_");
		if((buf.length==3)&&(f))
			f = Check_CMISInteger_Plus(eval(s),eval(buf[1]),eval(buf[2]));
	}else if(t=="CMIString255"){
		f = Check_CMIString255(s);
	}else if(t=="CMIString4096"){
		f = Check_CMIString4096(s);
	}else if(t=="CMIBlank"){
		f = Check_CMIBlank(s);
	}else if(t=="CMIDecimal"){
		f = Check_CMIDecimal(s);
	}else if(t=="CMIVocabulary"){
		f = Check_CMIVocabulary(s,m);
	}else if(t=="CMITimespan"){
		f = Check_CMITimespan(s);
	}else if(t=="CMITime"){
		f = Check_CMITime(s);
	}else if(t=="SCESCORE"){
		f = (Check_CMIBlank(s) || (Check_CMIDecimal(s) && SCE_Check_Score(s)));
	}else if(t=="SCERESULT"){
		f = (Check_CMIVocabulary(s,m) || Check_CMIDecimal(s));
	}
	return f;
}

function Check_CMIVocabulary(s,m){
	var i;
	m = dm_RepG(m) + "/kw";
	var n  = ADP.mrt.selectNodes(m);
	for(i=0;i<n.length;i++){
		if(n.item(i).text == s){
			return true;
		}
	}
	return false;
}

// check_CMIBlank
function Check_CMIBlank(s){return (s=="")?true:false;}

// check_CMIBoolean
function Check_CMIBoolean(s){return ((s == "true") || (s == "false"))?true:false;}

// check_CMIDecimal
function Check_CMIDecimal(s){
	if((s=="")||(s.match(/[^-?\d\.]/) != null))return false;
	return (isNaN(s))?false:true;
}

// check_CMIIdentifier
function Check_CMIIdentifier(s){return ((s.match(/\s/) == null) && (s.length < 256) && (s != ""))?true:false;}


// check_CMIInteger
function check_CMIInteger(s){
	if(s.match(/[^\d]/) != null)return false;
	return (eval(s) < 65536)?true:false;
}

// check_CMISInteger
function Check_CMISInteger(s){
	if(s.match(/[^\d-]/) != null)return false;
	s = Math.abs(eval(s));
	return (s < 32769)?true:false;
}

// check_CMISInteger_Plus
function Check_CMISInteger_Plus(s,i,f){
	return ((-i <= s) && (s <= f))?true:false;
}


// check_CMIString255
function Check_CMIString255(s){return (s.length < 256)?true:false;}

// check_CMIString4096
function Check_CMIString4096(s){return (s.length < 4097)?true:false;}

// Check_CMITimespan
function Check_CMITimespan(s){
	var buf = s.split(".");
	if((buf.length != 1)&&(buf.length != 2))return false;
	if(buf[0].match(/^\d{2,4}:\d{2}:\d{2}$/) == null)return false;
	if((buf.length == 2)&&(buf[1].match(/^\d{1,2}$/) == null))return false;
	return true;
}

// check_CMITime
function Check_CMITime(s){
	var buf = s.split(".");
	if((buf.length != 1)&&(buf.length != 2))return false;

	if(buf[0].match(/^[0-2]\d:[0-5]\d:[0-5]\d$/) == null)return false;

	if((buf.length == 2)&&(buf[1].match(/^\d{1,2}$/) == null))return false;
	return true;
}

//------------------------------------------------------------------------------
// SCORE
// ADD
//------------------------------------------------------------------------------
function SCE_Check_Score(s){
	s = eval(s);
	return ((0 <= s) && (s <= 100))?true:false;
}

//------------------------------------------------------------------------------
// SCORE
// ADD
//------------------------------------------------------------------------------
function SCE_Check_Audio(s){
	s = eval(s);
	return ((-2 < s) && (s < 101))?true:false;
}

//------------------------------------------------------------------------------
// SPEED
// ADD
//------------------------------------------------------------------------------
function SCE_Check_Speed(s){
	s = eval(s);
	return ((-101 < s) && (s < 101))?true:false;
}

//------------------------------------------------------------------------------
// SPEED
// ADD
//------------------------------------------------------------------------------
function SCE_Check_Text(s){
	s = eval(s);
	return ((-2 < s) && (s < 2))?true:false;
}

function post_ResetFlag(m){
	m = dm_RepS(m);
	var n = ADP.SCO.selectSingleNode(m);
	if(n==null) return false;
	n.setAttribute("f_chg","0");
	return true;
}

function post_GetValue(m){
	m = dm_RepS(m);
	var ret = ADP.SCO.selectSingleNode(m);
	return (ret==null)?"":ret.text;
}

function post_GetMultiValue(m,member){
	var pn, cnl, ntag, tname, str, cn, i, buf;

	m = dm_RepS(m);
	pn = ADP.SCO.selectSingleNode(m);
	if(pn != null){
		cnl = pn.childNodes;

		ntag = "";
		//nタグだけを抽出して、タグ名をcsvにする
		for(i=0;i<cnl.length;i++){
			tname = cnl.item(i).tagName;
			if(tname.match(/^i{1}\d+/) != null){
				ntag += tname + ",";
			}
		}
		//nタグ名を昇順にして、その値を;区切で返す
		if(ntag != ""){
			ntag = t_DelS(ntag, 1);
			buf = ntag.split(",");
			buf = buf.sort();
			str = "";
			for(i=0;i<buf.length;i++){
				if(member == ""){
					cn = pn.selectSingleNode(buf[i]);
				}else{
					cn = pn.selectSingleNode(buf[i] + "/" + member);
				}
				if(cn == null){
					str = str + ";";
				}else{
					str = str + cn.text + ";";
				}
			}
			return t_DelS(str, 1);
		}else{
			return null;
		}
	}else{
		return null;
	}
}


////////////////////////////////////////////////////////////////////////////////////////////////////////

var ADP = null;
function myInit(){
	ADP = new makeAdapter()
	if(ADP.ADPInit()){
		alert("データモデルのロードに失敗しました。");
		return false;
	}
	ADP.mrt = ADP.DM.documentElement;
}

var flg_initialize = 0;
var flg_finish = 1;

function LMSInitialize(s){
	ErrorNum = 0;
	var ret = checkArgumanet(s,0);
	if(ret){
		ErrorNum = ret;
		return "false";
	}

	if(!flg_finish){
		ErrorNum = 101;
		return "false";
	}
	if(flg_initialize){
		ErrorNum = 101;
		return "false";
	}

	var sp,ep,loc,tmp,sid,trg;
	// 2011.09.01 taku-harada mod >>
	//loc = _getSCOLocationObject().search;
	var aicc_sid = parent.frames.main.g_AICC_SID;
	var aicc_url = parent.frames.main.g_AICC_URL;
	loc = "AICC_SID=" + aicc_sid + "&AICC_URL=" + aicc_url;
	// 2011.09.01 taku-harada mod <<

	tmp = loc.toUpperCase();

	sp = tmp.indexOf("AICC_SID=");
	if (sp == -1) return "false";

	ep = tmp.indexOf("&",sp);
	sid = loc.substring(sp + 9, ep);
	sid = unescape(sid)

	sp = tmp.indexOf("AICC_URL=")
	if(sp == -1) return "false";

	ep = tmp.indexOf("&",sp);
	if(ep == -1) ep = tmp.length;

	trg = loc.substring(sp + 9, ep);
	trg = unescape(trg.replace("http://",""));

	if(sid == "" || trg == "" ) return "false";

	if(ADP.SCOInit(sid,trg)==null){
		ErrorNum = 101;
		return "false";
	}

	var ts = ADP.GetLimitTime();

	if(ts){
		f_timer = setTimeout("TimerEvent()",ts);
	}else{
		f_timer = null;
	}

	flg_initialize = 1;
	flg_finish = 0;

	if(parent.main.loadBTN == "function"){
		parent.main.loadBTN();
	}

	return "true";
}

function LMSFinish(s){
	ErrorNum = 0;

	var ret = checkArgumanet(s,0);
	if(ret){
		ErrorNum = 201;
		return "false";
	}

	ret = checkInitFin();
	if(ret){
		ErrorNum = ret;
		return "false";
	}


	if(ADP.SCOFin()==null){
		ErrorNum = 101;
		return "false";
	}
	flg_finish = 1;
	flg_initialize = 0
	return "true";
}


function LMSGetValue(m){

	ErrorNum = 0;

	var ret = checkArgumanet(m,1);
	if(ret){
		ErrorNum = ret;
		return "";
	}
	ret = checkInitFin();
	if(ret){
		ErrorNum = ret;
		return "";
	}

	var buf,i,kw,str;
	buf = m.split(".");

	if(buf.length==1){
		ErrorNum = 201;
		return "";
	}else{
		kw = buf[buf.length-1];
		if(kw=="_children"){
			if((buf.length>1)&&(buf[buf.length-2]=="n")){
				ErrorNum = 202;
				return "";
			}

			ret = ADP.dm_CheckChildren(m);
			if(ret==null)
				ErrorNum = 201;
			else if(ret=="")
				ErrorNum = 202;
			else
				return ret;
			return "";
		}else if(kw=="_version"){
			if(m=="cmi._version")
				ErrorNum = 201;
			else
				return "";
			return "false";
		}else if(kw=="_count"){
			ret = ADP.dm_CheckCount(m);
			if(ret==null)
				ErrorNum = 201;
			else if(ret)
				return ADP.dm_GetCount(m);
			else
				ErrorNum = 203;
			return "";
		}else{
			ret = ADP.dm_CheckData(m,0);

			if(ret==null){
				ErrorNum = 201;
				return "";
			}else if(ret){
				str = ADP.sco_GetValue(m);
				if(str==null){
					var reret = ADP.dm_RetDefValue(ret,m)
					if(reret==null){
						return "";
					}else{
						return reret;
					}
				}else{
					return str;
				}
			}else{
				ErrorNum = 404;
				return "";
			}
		}
	}
}

function dm_GetCount(m){
	m = dm_RepS(m);
	m = m.replace("/_count","");
	var n = this.SCO.selectSingleNode(m);
	if(n==null){
		return 0;
	}else{
		var cn = n.childNodes;
		return cn.length;
	}
}


function LMSSetValue(m,s){
	if(m == "cmd.exit"){
		parent.main.Button.LMSUI_NavSuspendAll();
		return "true";
	}

	ErrorNum = 0;
	var ret = checkArgumanet(m,1);
	if(ret){
		ErrorNum = ret;
		return "false";
	}
	ret = checkArgumanet(s,1);
	if(ret){
		ErrorNum = ret;
		return "false";
	}
	ret = checkInitFin();
	if(ret){
		ErrorNum = ret;
		return "false";
	}

	var buf,i,kw,str,cw;
	buf = m.split(".");

// 例外処理
	if((m == "cmi.core.lesson_status")&&(s == "not attempted")){
		ErrorNum = 405;
		return "false";
	}

	if(m == "cmi.comments"){
		if(s.length < 4097){
			var tstr = LMSGetValue("cmi.comments");
			tstr += s;
			ADP.sco_SetValue(m,tstr,0);
			return "true";
		}
	}

	if(buf.length==1){
		ErrorNum = 201;
	}else{
		kw = buf[buf.length-1];
		if((kw=="_children")||(kw=="_version")||(kw=="_count")){
			ErrorNum = 402;
			return "false";
		}else{
			ret = ADP.dm_CheckData(m,1);
			if(ret==null){
				ErrorNum = 201;
			}else if(ret){
				if(ADP.dm_CheckValue(ret,s,m)){

					// indexの調査
					var tStr = dm_RepG(m);
					if(tStr.indexOf("/n/") != -1){
						if((tStr == "/cmi/interactions/n/objectives/n/id")||(tStr == "/cmi/interactions/n/correct_responses/n/pattern")){
							t1 = dm_RepS2(m);
							if(t1 == ""){
							}else{
								if(ADP.sco_GetNode(t1)){
									ErrorNum = 201;
									return "false";
								}
							}

							t1 = dm_RepS3(m);
							if(t1 == ""){
							}else{
								if(ADP.sco_GetNode(t1)){
									ErrorNum = 201;
									return "false";
								}
							}
						}else{
							t1 = dm_RepS2(m);
							if(t1 == ""){
							}else{

								if(ADP.sco_GetNode(t1)){
									ErrorNum = 201;
									return "false";
								}
							}
						}
					}

					ADP.sco_SetValue(m,s,0);
					ADP.flgWrite = 1;
					return "true";
				}else{
					ErrorNum = 405;
				}
			}else{
				ErrorNum = 403;
			}
			return "false";
		}
	}
	return "false";
}

function dm_RepS2(m){
	var i;
	var retstr = "";
	var buf = m.split(".");
	for(i in buf){
		if(!isNaN(buf[i])){
			if(parseInt(buf[i]) == 0){
				return "";
			}else{
				buf[i] = "i" + (parseInt(buf[i]) - 1);
			}
			retstr += buf[i];
			return retstr;
		}else{
			retstr += buf[i] + "/";
		}
	}
	return "";
}


function dm_RepS3(m){
	var flg = false;
	var i;
	var retstr = "";
	var buf = m.split(".");
	for(i in buf){
		if(!isNaN(buf[i])){
			if(flg){
				if(parseInt(buf[i]) == 0){
					return "";
				}else{
					buf[i] = "i" + (parseInt(buf[i]) - 1);
				}
				retstr += buf[i];
				return retstr;
			}else{
				buf[i] = "i" + buf[i];
				retstr += buf[i] + "/";
				flg = true;
			}
		}else{
			retstr += buf[i] + "/";
		}
	}
	return "";
}

function sco_GetNode(m){
	var n = this.SCO.selectSingleNode(m);
	return (n==null)?1:0;
}


function LMSCommit(s){

	ErrorNum = 0;

	var ret = checkArgumanet(s,0);
	if(ret){
		ErrorNum = ret;
		return "false";
	}
	ret = checkInitFin();
	if(ret){
		ErrorNum = ret;
		return "false";
	}

	var ret = ADP.sco_Commit(0);
	return (ret==null)?"false":"true";
}

/////////////////////////////////////////////////
function LMSGetLastError(){

	return String(ErrorNum);
}

function LMSGetErrorString(s){

	if((s == "")||(s == null)){
		return "undefined";
	}
	return EM[String(s)];
}

function LMSGetDiagnostic(){
	return "error";
}

function checkArgumanet(s,f){
	if(typeof(s)!="string"){
		return 201;
	}
	if(f==0){
		if(s!=""){
			return 201;
		}
	}
	return 0;
}

function checkInitFin(){
	if(!flg_initialize){
		return 301;
	}
	if(flg_finish){
		return 101;
	}
	return 0;
}
