if(typeof (Kumu)=="undefined"){Kumu={}}if(typeof (Kumu.Ajax)=="undefined"){Kumu.Ajax={}}Kumu.Ajax={AJAX_COMPONENT_NAME:"AjaxComponent",HTTP_STATUS_OK:200,HTTP_STATUS_NOT_FOUND:404,XML_HTTP_REQUEST_STATUS_UNINITIALIZED:0,XML_HTTP_REQUEST_STATUS_LOADING:1,XML_HTTP_REQUEST_STATUS_LOADED:2,XML_HTTP_REQUEST_STATUS_INTERACTIVE:3,XML_HTTP_REQUEST_STATUS_COMPLETE:4,RESPONSE_TYPE_XML:1,RESPONSE_TYPE_JSON:2,RESPONSE_TYPE_TEXT:3,RESPONSE_TYPE_HTML:4,READY_STATE:["Uninitialized","Loading","Loaded","Interactive"],axo:new Array("Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP"),URL:"teeda.ajax",ASYNC:true,DEBUG:false,getS2AjaxComponent:function(){return new this.AjaxComponent()},AjaxComponent:function(){var A=Kumu.Ajax;this.name=A.AJAX_COMPONENT_NAME;this.responseType=null;this.url=A.URL;this.async=A.ASYNC;this.params=null;this.doAction=function(B){}},AjaxProcess:function(C,B){var A=Kumu.Ajax;this.xhr=C;this.ajaxComponent=B;this.cancel=A._createCanceler(C,B)},_createXmlHttp:function(){var xmlHttp=false;/*@cc_on
    @if (@_jscript_version >= 5)
    var self = Kumu.Ajax;
    for (var i = 0; !xmlHttp && i < self.axo.length; i++) {
      try {
        xmlHttp = new ActiveXObject(self.axo[i]);
      } catch(e) {
      }
    }
    @else
      xmlHttp = false;
    @end @*/if(!xmlHttp&&typeof XMLHttpRequest!="undefined"){try{xmlHttp=new XMLHttpRequest()}catch(e){xmlHttp=false}}return xmlHttp},debugPrint:function(C,E){if(E){try{var F=document.createElement("div");document.body.appendChild(F);F.setAttribute("id","ajax_msg");C="<font color='red'>"+C+"</font>";document.getElementById("ajax_msg").innerHTML="<br/>"+C}catch(D){}}else{try{var A=document.createElement("br");var B=document.createElement("span");document.body.appendChild(A);document.body.appendChild(B.appendChild(document.createTextNode(C)))}catch(D){}}},_checkComponent:function(C){var A=Kumu.Ajax;var B;try{B=C.name}catch(D){return false}if(A.AJAX_COMPONENT_NAME!=B||!C.doAction||!C.url){return false}return true},executeAjax:function(I){var N=Kumu.Ajax;if(!N._checkComponent(I)){N.debugPrint("IllegalArgument. argument object is not AjaxComponent. implements url or doAction!",true);return }var G=N._createXmlHttp();if(!G||!document.getElementById){N.debugPrint("This browser does not support Ajax.",true);return }var L=new String(new Date());var B=I.url;var D=I.async;var M="";var E=I.params;if(!E){E={}}var A="GET";if(E.method){A=E.method.toUpperCase();if(A!="GET"&&A!="POST"){A="GET"}delete E.method}if(I.timeout){var F=N._setTimeout(G,I,I.timeout,I.onTimeout);I._clearTimeout=function(){clearTimeout(F)}}var C=new Kumu.Ajax.AjaxProcess(G,I);if(A=="GET"){B+="?time="+N.encodeURL(L);if(null!=E){for(var K in E){var J=E[K];if(J instanceof Function){continue}M+="&"+K+"="+N.encodeURL(J)}}B+=M;if(G){N._registAjaxListener(G,I);G.open("GET",B,D);G.setRequestHeader("If-Modified-Since",L);G.send(null)}}else{E["time"]=N.encodeURL(L);if(E){var H=new Array();for(var K in E){var J=E[K];if(J instanceof Function){continue}H.push(K+"="+encodeURIComponent(J))}M=H.join("&")}if(G){N._registAjaxListener(G,I);G.open("POST",B,D);G.setRequestHeader("Content-type","application/x-www-form-urlencoded");G.setRequestHeader("If-Modified-Since",L);G.send(M)}}return C},_setTimeout:function(D,C,F,H){var A;var B=Kumu.Ajax;var E=B._createCanceler(D,C);var G=function(){E();if(H){H(D,C)}clearTimeout(A)};A=setTimeout(G,F*1000);return A},_createCanceler:function(B,A){return function(){var C=Kumu.Ajax;if(B.readyState==0||B.readyState==C.XML_HTTP_REQUEST_STATUS_COMPLETE){return }B.abort();if(A._clearTimeout){A._clearTimeout()}}},_onReadyStateChange:function(D,C){var A=Kumu.Ajax;var B="on"+A.READY_STATE[D.readyState];if(C[B]&&!(C._called)){C[B](D,C);C[B]._called=true}else{if(C.doAction&&C.doAction[B]&&!(C.doAction[B]._called)){C.doAction[B](D,C);C.doAction[B]._called=true}}},_onException:function(A,B){if(B.doAction&&B.doAction.onException){B.doAction.onException(A,B)}if(B._clearTimeout){B._clearTimeout()}},_evalResult:function(req,ajaxComponent){var self=Kumu.Ajax;var status;try{status=req.status}catch(e){}if(status>=self.HTTP_STATUS_OK&&status<300){if(self.DEBUG){self.debugPrint(req.responseText)}if(self.RESPONSE_TYPE_JSON==ajaxComponent.responseType){var resText=req.responseText;ajaxComponent.doAction(eval("("+resText+")"))}else{if(self.RESPONSE_TYPE_XML==ajaxComponent.responseType){var responseText=req.responseXML;ajaxComponent.doAction(responseText)}else{ajaxComponent.doAction(req.responseText)}}if(ajaxComponent._clearTimeout){ajaxComponent._clearTimeout()}}else{if(status>0){if(ajaxComponent.doAction&&ajaxComponent.doAction.onFailure){ajaxComponent.doAction.onFailure(req,ajaxComponent)}else{self.debugPrint("AjaxError! status["+status+"] message["+req.responseText+"]",true)}}if(ajaxComponent._clearTimeout){ajaxComponent._clearTimeout()}}},_registAjaxListener:function(C,B){var A=Kumu.Ajax;C.onreadystatechange=function(){try{if(A.XML_HTTP_REQUEST_STATUS_COMPLETE==C.readyState){A._evalResult(C,B)}else{A._onReadyStateChange(C,B)}}catch(D){A._onException(D,B)}}},encodeURL:function(A){if(encodeURI){return encodeURI(A)}if(encodeURIComponent){return encodeURIComponent(A)}if(escape){return escape(A)}},_getComponentName:function(F){var G=F.toString();var E=G.match(/[0-9A-Za-z_]+\(/).toString();E=E.substring(0,E.length-1);var B=E.lastIndexOf("_");if(B==-1){return[]}var D=E.substring(0,B);var C=E.substring(B+1);var A=new Array(D,C);return A},executeTeedaAjax:function(G,F,B){var A=Kumu.Ajax;var E=A.getS2AjaxComponent();var D=A._getComponentName(G);if(!F){F={}}if("onUninitialized" in F){E.onUninitialized=F["onUninitialized"];delete F["onUninitialized"]}if("onLoading" in F){E.onLoading=F["onLoading"];delete F["onLoading"]}if("onLoaded" in F){E.onLoaded=F["onLoaded"];delete F["onLoaded"]}if("onFailure" in F){E.onFailure=F["onFailure"];delete F["onFailure"]}if("onException" in F){E.onException=F["onException"];delete F["onException"]}if("timeout" in F){E.timeout=F["timeout"];delete F["timeout"]}if("onTimeout" in F){E.onTimeout=F["onTimeout"];delete F["onTimeout"]}E.params=F;if(F instanceof Array){for(var C=0;C<F.length;C++){E.params["AjaxParam"+new String(C)]=F[C]}}if(!("component" in F)&&!("action" in F)&&(D.length==2)){E.params["component"]=D[0];E.params["action"]=D[1]}E.doAction=G;if(!B){B=A.RESPONSE_TYPE_JSON}E.responseType=B;return A.executeAjax(E)},_setJSONData:function(A,B){if(A.style.display=="none"){A.style.display=""}A.innerHTML=B},render:function(N){var O=Kumu.Ajax;for(var L in N){var A=[];var C=document.getElementById(L);while(C){A.push(C);C.id="";C=document.getElementById(L)}for(var H=0;H<A.length;H++){var D=A[H];D.id=L;var B=N[L];if(B&&B instanceof Array){var K=D.parentNode;if(K.nodeType==3){K=K.parentNode}var J=D.cloneNode(true);K.removeChild(D);for(var F=0;F<B.length;F++){var G=B[F];var I=J.cloneNode(true);if(I.style.display&&I.style.display=="none"){I.style.display=""}K.appendChild(I);for(var E in G){var M=document.getElementById(E);if(M){O._setJSONData(M,G[E]);M.id=M.id+":rendered"}}I.id=I.id+":rendered"}K.appendChild(J)}else{O._setJSONData(D,B)}}}},removeRender:function(C){var A=C+":rendered";var B=document.getElementById(A);while(B){B.parentNode.removeChild(B);B=document.getElementById(A)}}}
