﻿
if(window.dynamicReq==null){window.dynamicReq={};};function TUF1_DynamicReq(){this.tThread="ct_"+Math.random()*100;addThread(this);};function addThread(obj){window.dynamicReq[obj.tThread]={_modelObj:obj,_isShowLoadingBox:false,_boxOffsetLeft:0,_boxOffsetTop:0,_drMsg:null,_LoadingDIV:null,_scriptDIV:null,_afterSubmit:null,_ifm:null,_href:null,_parm:null,_call:"no set"};};TUF1_DynamicReq.prototype.getContent=function(sURL,id){var t=window.dynamicReq[this.tThread];if(t._isShowLoadingBox){this.setProgressDIVBox();};var href=null;var parm=null;var is_async=(id==null?false:true);if(sURL.indexOf("?")>0){href=sURL.substring(0,sURL.indexOf("?"));parm=sURL.substring(sURL.indexOf("?")+1);}else{href=sURL;};var xmlhttp=tdr_CreateXHR();var tThread=this.tThread;xmlhttp.open("POST",href,is_async);t._href=href;t._parm=parm;if(is_async){xmlhttp.onreadystatechange=function(){var t=window.dynamicReq[tThread];var obj=t._modelObj;if(xmlhttp.readyState==4){var response=xmlhttp.responseText;if(xmlhttp.status==200){try{obj.setInnerHTML(response,id);}catch(ex){alert(ex.message);return false;}}else if(xmlhttp.status=='12029'||xmlhttp.status=='12030'||xmlhttp.status=='12031'){var tdrMsg="A problem occurred with communication with the server program.\n"+"Please make sure you are connected to the Internet and try again in a few moments.";alert(tdrMsg);}else{tdr_IncludeJs('/tuf1/js/TUF1_DynamicReqErr.js');showError(response,xmlhttp.status,t._href,t._parm);};obj.cHideProgress();if(t._afterSubmit){eval(t._afterSubmit);};if(t._scriptDIV){tdr_GetBody().removeChild(t._scriptDIV);t._scriptDIV=null;}}};};xmlhttp.setRequestHeader("X-Requested-With","XMLHttpRequest");xmlhttp.setRequestHeader("Accept","text/javascript,text/html,application/xml,text/xml,*/*");xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.setRequestHeader("X-Requested-Call",t._call);if(href.indexOf("TUF1_ControllerServlet.do")>0){if((parm==null||parm=="")){xmlhttp.setRequestHeader("X-Requested-sURL",sURL);}else{xmlhttp.setRequestHeader("X-Requested-parm",parm.length>100?parm.substring(0,100):parm);}};xmlhttp.send(parm);if(!is_async){var html=xmlhttp.responseText;this.cHideProgress();if(t._afterSubmit){eval(t._afterSubmit);};return html.replace(/<script([^>]*)>/gi,'<script$1 defer>');}};TUF1_DynamicReq.prototype.setMsgShowType=function(sType,msg,msgId){var t=window.dynamicReq[this.tThread];if(sType=="2"){if(msg==null){alert("Error! Please give me some message.");}else{t._isShowLoadingBox=true;t._drMsg=msg;}}};TUF1_DynamicReq.prototype.setMsgBoxOffset=function(top,left){var t=window.dynamicReq[this.tThread];if(t._isShowLoadingBox){if(top==null){top=0;};if(left==null){left=0;};t._boxOffsetTop=top;t._boxOffsetLeft=left;}else{alert("Please exec cSetMsgShowType(2,Msg) first.");}};TUF1_DynamicReq.prototype.postFormData=function(fID,SpanID){var fObj=tdr_GetId(fID);var target,sUrl;try{target=fObj.action;}catch(exception){alert(exception);};tdr_IncludeJs("/tuf1/js/TUF1_GetFormValue.js");var str=getFormValue(fObj);if(target.indexOf("?")>0){sUrl=target+'&'+str;}else{sUrl=target+'?'+str;};return this.getContent(sUrl,SpanID);};TUF1_DynamicReq.prototype.setInnerHTML=function(code,id){var el=tdr_GetId(id);if(el){el.innerHTML="";var t=window.dynamicReq[this.tThread];if(tdr_isIE()){code='<div style="display:none">for IE</div>'+code;code=code.replace(/<script([^>]*)>/gi,'<script$1 defer>');el.innerHTML=code;el.removeChild(el.firstChild);}else if(tdr_isSafari()){var scriptStart=0;if(code.indexOf("<script>")!=-1){scriptStart=parseInt(code.indexOf("<script>"))+8;}else if(code.indexOf("javascript\">")!=-1){scriptStart=parseInt(code.indexOf("javascript\">"))+20;};var scriptEnd=code.indexOf("</script>");var htmlText=code.substring(0,scriptStart);var scriptText=code.substring(scriptStart,scriptEnd);el.innerHTML=code;if(scriptStart!=0){var script=code.substring(scriptStart,scriptEnd);eval(script);}}else{var el_next=el.nextSibling;var el_parent=el.parentNode;el_parent.removeChild(el);el.innerHTML=code;if(el_next){el_parent.insertBefore(el,el_next)}else{el_parent.appendChild(el);}}}};TUF1_DynamicReq.prototype.getScript=function(url,is_async){if(is_async){is_async=(is_async=="Y"?true:false);}else{is_async=true;};var t=window.dynamicReq[this.tThread];t._scriptDIV=document.createElement('DIV');t._scriptDIV.id="ScriptDIV"+this.tThread;tdr_GetBody().appendChild(t._scriptDIV);if(is_async){this.getContent(url,"ScriptDIV"+this.tThread);}else{var code=this.getContent(url);this.setInnerHTML(code,"ScriptDIV"+this.tThread);tdr_GetBody().removeChild(t._scriptDIV);t._scriptDIV=null;}};TUF1_DynamicReq.prototype.setAfterSubmit=function(n){var t=window.dynamicReq[this.tThread];t._afterSubmit=n;};TUF1_DynamicReq.prototype.setCall=function(n){var t=window.dynamicReq[this.tThread];t._call=n;};TUF1_DynamicReq.prototype.cHideProgress=function(){var t=window.dynamicReq[this.tThread];if(t._isShowLoadingBox){tdr_GetBody().removeChild(t._LoadingDIV);tdr_GetBody().removeChild(t._ifm);t._ifm=null;t._LoadingDIV=null;};tdr_GetBody().onscroll=function(){;};tdr_GetBody().onresize=function(){;}};TUF1_DynamicReq.prototype.setProgressDIVBox=function(){var t=window.dynamicReq[this.tThread];t._LoadingDIV=document.createElement('DIV');tdr_GetBody().appendChild(t._LoadingDIV);var str="<table width='200' border='0' cellspacing='2' cellpadding='2' id='msgTable"+this.tThread+"'>"+"  <tr> "+"    <td align='center' bgcolor='#3068D8'>"+"     <table width='200' border='0' cellspacing='0' cellpadding='0' bgcolor='#EBF2FF'>"+"        <tr> "+"          <td align='center' style='color: #222222; font-weight: bold; font-size:12px; font-family:Verdana,Helvetica'><BR>"+t._drMsg+"<BR><BR></td>"+"        </tr>"+"      </table></td>"+"  </tr>"+"</table>";t._LoadingDIV.innerHTML=str;t._LoadingDIV.style.position='absolute';t._LoadingDIV.style.height='200px';t._LoadingDIV.style.width='300px';t._LoadingDIV.style.zIndex=3;t._LoadingDIV.style.left=document.body.clientWidth/2-100+t._boxOffsetLeft;t._LoadingDIV.style.top=document.body.scrollTop+250+t._boxOffsetTop;if(tdr_isIE()){t._LoadingDIV.style.filter="progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=135,Strength=5)";};t._ifm=document.createElement('IFRAME');t._ifm.src="javascript:false";t._ifm.style.position='absolute';t._ifm.style.visibility='inherit';t._ifm.style.top=0;t._ifm.style.left=0;t._ifm.style.width=0;t._ifm.style.height=0;t._ifm.style.zIndex=2;t._ifm.frameBorder=0;t._ifm.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';t._ifm.id='ifm'+this.tThread;tdr_GetBody().appendChild(t._ifm);t._ifm.style.width=tdr_GetId('msgTable'+this.tThread).offsetWidth-5;t._ifm.style.height=tdr_GetId('msgTable'+this.tThread).offsetHeight-5;var thread=this.tThread;tdr_SetMsgBoxPos(thread);tdr_GetBody().onscroll=function(){tdr_SetMsgBoxPos(thread)};tdr_GetBody().onresize=function(){tdr_SetMsgBoxPos(thread)};};function tdr_isIE(){return(navigator.appName.indexOf("Microsoft")!=-1);};function tdr_isSafari(){return(window.navigator.userAgent.indexOf("Safari")!=-1);};function tdr_SetMsgBoxPos(thread){var t=window.dynamicReq[thread];var top=document.body.scrollTop+250+t._boxOffsetTop;var left=document.body.clientWidth/2-100+t._boxOffsetLeft;t._LoadingDIV.style.top=top;t._LoadingDIV.style.left=left;t._ifm.style.top=top+2;t._ifm.style.left=left+2;};function tdr_CreateXHR(){var xmlhttp;try{xmlhttp=new XMLHttpRequest();}catch(e){try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.4.0");}catch(e){try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp=new ActiveXObject("microsoft.XMLHTTP");}catch(e){alert(e);throw new Error("Unable to get an HTTP request object.");}}}};return xmlhttp;};function tdr_IncludeJs(js){try{var xmlhttp=tdr_CreateXHR();xmlhttp.open('GET',js,false);xmlhttp.setRequestHeader("X-Requested-With","XMLHttpRequest");xmlhttp.send(null);window.execScript(xmlhttp.responseText);}catch(e){alert("tdr_IncludeJs - Exception : "+e);}};function tdr_GetBody(){return document.getElementsByTagName('BODY')[0];};function tdr_GetId(v){return document.getElementById(v);};if(window.execScript==null){try{window.execScript=function(script){window.eval(script);}}catch(e){alert(e);}};


