PageRenderTime 152ms CodeModel.GetById 53ms app.highlight 89ms RepoModel.GetById 1ms app.codeStats 0ms

/source/Plug-in/xajax/xajax_js/xajax_core.js

http://prosporous.googlecode.com/
JavaScript | 411 lines | 410 code | 1 blank | 0 comment | 44 complexity | e05f613f0f256be45bc4f6df96ee008a MD5 | raw file
  1
  2if('undefined'==typeof xajax)
  3xajax={};if('undefined'==typeof xajax.config)
  4xajax.config={};xajax.config.setDefault=function(option,defaultValue){if('undefined'==typeof xajax.config[option])
  5xajax.config[option]=defaultValue;}
  6xajax.config.setDefault('commonHeaders',{'If-Modified-Since':'Sat, 1 Jan 2000 00:00:00 GMT'
  7});xajax.config.setDefault('postHeaders',{});xajax.config.setDefault('getHeaders',{});xajax.config.setDefault('waitCursor',false);xajax.config.setDefault('statusMessages',false);xajax.config.setDefault('baseDocument',document);xajax.config.setDefault('requestURI',xajax.config.baseDocument.URL);xajax.config.setDefault('defaultMode','asynchronous');xajax.config.setDefault('defaultHttpVersion','HTTP/1.1');xajax.config.setDefault('defaultContentType','application/x-www-form-urlencoded');xajax.config.setDefault('defaultResponseDelayTime',1000);xajax.config.setDefault('defaultExpirationTime',10000);xajax.config.setDefault('defaultMethod','POST');xajax.config.setDefault('defaultRetry',5);xajax.config.setDefault('defaultReturnValue',false);xajax.config.setDefault('maxObjectDepth',20);xajax.config.setDefault('maxObjectSize',2000);xajax.config.setDefault('responseQueueSize',1000);xajax.config.status={update:function(){return{onRequest:function(){window.status='Sending Request...';},
  8onWaiting:function(){window.status='Waiting for Response...';},
  9onProcessing:function(){window.status='Processing...';},
 10onComplete:function(){window.status='Done.';}
 11}
 12},
 13dontUpdate:function(){return{onRequest:function(){},
 14onWaiting:function(){},
 15onProcessing:function(){},
 16onComplete:function(){}
 17}
 18}
 19}
 20xajax.config.cursor={update:function(){return{onWaiting:function(){if(xajax.config.baseDocument.body)
 21xajax.config.baseDocument.body.style.cursor='wait';},
 22onComplete:function(){xajax.config.baseDocument.body.style.cursor='auto';}
 23}
 24},
 25dontUpdate:function(){return{onWaiting:function(){},
 26onComplete:function(){}
 27}
 28}
 29}
 30xajax.tools={}
 31xajax.tools.$=function(sId){if(!sId)
 32return null;var oDoc=xajax.config.baseDocument;var obj=oDoc.getElementById(sId);if(obj)
 33return obj;if(oDoc.all)
 34return oDoc.all[sId];return obj;}
 35xajax.tools.arrayContainsValue=function(array,valueToCheck){var i=0;var l=array.length;while(i < l){if(array[i]==valueToCheck)
 36return true;++i;}
 37return false;}
 38xajax.tools.doubleQuotes=function(haystack){return haystack.replace(new RegExp("'",'g'),'"');}
 39xajax.tools.singleQuotes=function(haystack){return haystack.replace(new RegExp('"','g'),"'");}
 40xajax.tools._escape=function(data){if('undefined'==typeof data)
 41return data;if('string'!=typeof data)
 42return data;var needCDATA=false;if(encodeURIComponent(data)!=data){needCDATA=true;var segments=data.split('<![CDATA[');var segLen=segments.length;data=[];for(var i=0;i < segLen;++i){var segment=segments[i];var fragments=segment.split(']]>');var fragLen=fragments.length;segment='';for(var j=0;j < fragLen;++j){if(0!=j)
 43segment+=']]]]><![CDATA[>';segment+=fragments[j];}
 44if(0!=i)
 45data.push('<![]]><![CDATA[CDATA[');data.push(segment);}
 46data=data.join('');}
 47if(needCDATA)
 48data='<![CDATA['+data+']]>';return data;}
 49xajax.tools._objectToXML=function(obj,guard){var aXml=[];aXml.push('<xjxobj>');for(var key in obj){++guard.size;if(guard.maxSize < guard.size)
 50return aXml.join('');if('undefined'!=typeof obj[key]){if('constructor'==key)
 51continue;if('function'==typeof obj[key])
 52continue;aXml.push('<e><k>');var val=xajax.tools._escape(key);aXml.push(val);aXml.push('</k><v>');if('object'==typeof obj[key]){++guard.depth;if(guard.maxDepth > guard.depth){try{aXml.push(xajax.tools._objectToXML(obj[key],guard));}catch(e){}
 53}
 54--guard.depth;}else{var val=xajax.tools._escape(obj[key]);if('undefined'==typeof val||null==val){aXml.push('*');}else{var sType=typeof val;if('string'==sType)
 55aXml.push('S');else if('boolean'==sType)
 56aXml.push('B');else if('number'==sType)
 57aXml.push('N');aXml.push(val);}
 58}
 59aXml.push('</v></e>');}
 60}
 61aXml.push('</xjxobj>');return aXml.join('');}
 62xajax.tools._enforceDataType=function(value){value=new String(value);var type=value.substr(0,1);value=value.substr(1);if('*'==type)
 63value=null;else if('N'==type)
 64value=value-0;else if('B'==type)
 65value=!!value;return value;}
 66xajax.tools._nodeToObject=function(node){if(null==node)
 67return '';if('undefined'!=typeof node.nodeName){if('#cdata-section'==node.nodeName||'#text'==node.nodeName){var data='';do if(node.data)data+=node.data;while(node=node.nextSibling);return xajax.tools._enforceDataType(data);}else if('xjxobj'==node.nodeName){var key=null;var value=null;var data=new Array;var child=node.firstChild;while(child){if('e'==child.nodeName){var grandChild=child.firstChild;while(grandChild){if('k'==grandChild.nodeName)
 68key=xajax.tools._enforceDataType(grandChild.firstChild.data);else('v'==grandChild.nodeName)
 69value=xajax.tools._nodeToObject(grandChild.firstChild);grandChild=grandChild.nextSibling;}
 70if(null!=key){data[key]=value;key=value=null;}
 71}
 72child=child.nextSibling;}
 73return data;}
 74}
 75throw{code:10001,data:node.nodeName};}
 76xajax.tools.getRequestObject=function(){if('undefined'!=typeof XMLHttpRequest){xajax.tools.getRequestObject=function(){return new XMLHttpRequest();}
 77}else if('undefined'!=typeof ActiveXObject){xajax.tools.getRequestObject=function(){try{return new ActiveXObject('Msxml2.XMLHTTP.4.0');}catch(e){xajax.tools.getRequestObject=function(){try{return new ActiveXObject('Msxml2.XMLHTTP');}catch(e2){xajax.tools.getRequestObject=function(){return new ActiveXObject('Microsoft.XMLHTTP');}
 78return xajax.tools.getRequestObject();}
 79}
 80return xajax.tools.getRequestObject();}
 81}
 82}else if(window.createRequest){xajax.tools.getRequestObject=function(){return window.createRequest();}
 83}else{xajax.tools.getRequestObject=function(){throw{code:10002};}
 84}
 85return xajax.tools.getRequestObject();}
 86xajax.tools.getBrowserHTML=function(sValue){var oDoc=xajax.config.baseDocument;if(!oDoc.body)
 87return '';var elWorkspace=xajax.$('xajax_temp_workspace');if(!elWorkspace){elWorkspace=oDoc.createElement('div');elWorkspace.setAttribute('id','xajax_temp_workspace');elWorkspace.style.display='none';elWorkspace.style.visibility='hidden';oDoc.body.appendChild(elWorkspace);}
 88elWorkspace.innerHTML=sValue;var browserHTML=elWorkspace.innerHTML;elWorkspace.innerHTML='';return browserHTML;}
 89xajax.tools.willChange=function(element,attribute,newData){if('string'==typeof element)
 90element=xajax.$(element);if(element){var oldData;eval('oldData=element.'+attribute);return(newData!=oldData);}
 91return false;}
 92xajax.tools.getFormValues=function(parent){var submitDisabledElements=false;if(arguments.length > 1&&arguments[1]==true)
 93submitDisabledElements=true;var prefix='';if(arguments.length > 2)
 94prefix=arguments[2];if('string'==typeof parent)
 95parent=xajax.$(parent);var aFormValues={};if(parent)
 96if(parent.childNodes)
 97xajax.tools._getFormValues(aFormValues,parent.childNodes,submitDisabledElements,prefix);return aFormValues;}
 98xajax.tools._getFormValues=function(aFormValues,children,submitDisabledElements,prefix){var iLen=children.length;for(var i=0;i < iLen;++i){var child=children[i];if('undefined'!=typeof child.childNodes)
 99xajax.tools._getFormValues(aFormValues,child.childNodes,submitDisabledElements,prefix);xajax.tools._getFormValue(aFormValues,child,submitDisabledElements,prefix);}
100}
101xajax.tools._getFormValue=function(aFormValues,child,submitDisabledElements,prefix){if(!child.name)
102return;if(child.disabled)
103if(true==child.disabled)
104if(false==submitDisabledElements)
105return;if(prefix!=child.name.substring(0,prefix.length))
106return;if(child.type)
107if(child.type=='radio'||child.type=='checkbox')
108if(false==child.checked)
109return;var name=child.name;var values=[];if('select-multiple'==child.type){var jLen=child.length;for(var j=0;j < jLen;++j){var option=child.options[j];if(true==option.selected)
110values.push(option.value);}
111}else{values=child.value;}
112var keyBegin=name.indexOf('[');if(0 <=keyBegin){var n=name;var k=n.substr(0,n.indexOf('['));var a=n.substr(n.indexOf('['));if(typeof aFormValues[k]=='undefined')
113aFormValues[k]=[];var p=aFormValues;while(a.length!=0){var sa=a.substr(0,a.indexOf(']')+1);var lk=k;var lp=p;a=a.substr(a.indexOf(']')+1);p=p[k];k=sa.substr(1,sa.length-2);if(k==''){if('select-multiple'==child.type){k=lk;p=lp;}else{k=p.length;}
114}
115if(typeof p[k]=='undefined')
116p[k]=[];}
117p[k]=values;}else{aFormValues[name]=values;}
118}
119xajax.tools.stripOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(0==sEventName.indexOf('on'))
120sEventName=sEventName.replace(/on/,'');return sEventName;}
121xajax.tools.addOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(0!=sEventName.indexOf('on'))
122sEventName='on'+sEventName;return sEventName;}
123xajax.tools.xml={};xajax.tools.xml.parseAttributes=function(child,obj){var iLen=child.attributes.length;for(var i=0;i < iLen;++i){var attr=child.attributes[i];obj[attr.name]=attr.value;}
124}
125xajax.tools.xml.parseChildren=function(child,obj){obj.data='';if(0 < child.childNodes.length){if(1 < child.childNodes.length){var grandChild=child.firstChild;do{if('#cdata-section'==grandChild.nodeName||'#text'==grandChild.nodeName){obj.data+=grandChild.data;}
126}while(grandChild=grandChild.nextSibling);}else{var grandChild=child.firstChild;if('xjxobj'==grandChild.nodeName){obj.data=xajax.tools._nodeToObject(grandChild);return;}else if('#cdata-section'==grandChild.nodeName||'#text'==grandChild.nodeName){obj.data=grandChild.data;}
127}
128}else if('undefined'!=typeof child.data){obj.data=child.data;}
129obj.data=xajax.tools._enforceDataType(obj.data);}
130xajax.tools.xml.processFragment=function(xmlNode,seq,oRet,oRequest){var xx=xajax;var xt=xx.tools;while(xmlNode){if('cmd'==xmlNode.nodeName){var obj={};obj.fullName='*unknown*';obj.sequence=seq;obj.request=oRequest;obj.context=oRequest.context;xt.xml.parseAttributes(xmlNode,obj);xt.xml.parseChildren(xmlNode,obj);xt.queue.push(xx.response,obj);}else if('xjxrv'==xmlNode.nodeName){oRet=xt._nodeToObject(xmlNode.firstChild);}else if('debugmsg'==xmlNode.nodeName){}else
131throw{code:10004,data:xmlNode.nodeName}
132++seq;xmlNode=xmlNode.nextSibling;}
133return oRet;}
134xajax.tools.queue={}
135xajax.tools.queue.create=function(size){return{start:0,
136size:size,
137end:0,
138commands:[],
139timeout:null
140}
141}
142xajax.tools.queue.retry=function(obj,count){var retries=obj.retries;if(retries){--retries;if(1 > retries)
143return false;}else retries=count;obj.retries=retries;return true;}
144xajax.tools.queue.rewind=function(theQ){if(0 < theQ.start)
145--theQ.start;else
146theQ.start=theQ.size;}
147xajax.tools.queue.setWakeup=function(theQ,when){if(null!=theQ.timeout){clearTimeout(theQ.timeout);theQ.timeout=null;}
148theQ.timout=setTimeout(function(){xajax.tools.queue.process(theQ);},when);}
149xajax.tools.queue.process=function(theQ){if(null!=theQ.timeout){clearTimeout(theQ.timeout);theQ.timeout=null;}
150var obj=xajax.tools.queue.pop(theQ);while(null!=obj){try{if(false==xajax.executeCommand(obj))
151return false;}catch(e){}
152delete obj;obj=xajax.tools.queue.pop(theQ);}
153return true;}
154xajax.tools.queue.push=function(theQ,obj){var next=theQ.end+1;if(next > theQ.size)
155next=0;if(next!=theQ.start){theQ.commands[theQ.end]=obj;theQ.end=next;}else
156throw{code:10003}
157}
158xajax.tools.queue.pushFront=function(theQ,obj){xajax.tools.queue.rewind(theQ);theQ.commands[theQ.start]=obj;}
159xajax.tools.queue.pop=function(theQ){var next=theQ.start;if(next==theQ.end)
160return null;next++;if(next > theQ.size)
161next=0;var obj=theQ.commands[theQ.start];delete theQ.commands[theQ.start];theQ.start=next;return obj;}
162xajax.responseProcessor={};xajax.responseProcessor.xml=function(oRequest){var xx=xajax;var xt=xx.tools;var xcb=xx.callback;var gcb=xcb.global;var lcb=oRequest.callback;var oRet=oRequest.returnValue;if(xt.arrayContainsValue(xx.responseSuccessCodes,oRequest.request.status)){xcb.execute([gcb,lcb],'onSuccess',oRequest);var seq=0;if(oRequest.request.responseXML){var responseXML=oRequest.request.responseXML;if(responseXML.documentElement){oRequest.status.onProcessing();var child=responseXML.documentElement.firstChild;oRet=xt.xml.processFragment(child,seq,oRet,oRequest);}
163}
164var obj={};obj.fullName='Response Complete';obj.sequence=seq;obj.request=oRequest;obj.context=oRequest.context;obj.cmd='rcmplt';xt.queue.push(xx.response,obj);if(null==xx.response.timeout)
165xt.queue.process(xx.response);}else if(xt.arrayContainsValue(xx.responseRedirectCodes,oRequest.request.status)){xcb.execute([gcb,lcb],'onRedirect',oRequest);window.location=oRequest.request.getResponseHeader('location');xx.completeResponse(oRequest);}else if(xt.arrayContainsValue(xx.responseErrorsForAlert,oRequest.request.status)){xcb.execute([gcb,lcb],'onFailure',oRequest);xx.completeResponse(oRequest);}
166return oRet;}
167xajax.js={}
168xajax.js.includeScriptOnce=function(command){command.fullName='includeScriptOnce';var fileName=command.data;var oDoc=xajax.config.baseDocument;var loadedScripts=oDoc.getElementsByTagName('script');var iLen=loadedScripts.length;for(var i=0;i < iLen;++i){var script=loadedScripts[i];if(script.src){if(0 <=script.src.indexOf(fileName))
169return true;}
170}
171return xajax.js.includeScript(command);}
172xajax.js.includeScript=function(command){command.fullName='includeScript';var oDoc=xajax.config.baseDocument;var objHead=oDoc.getElementsByTagName('head');var objScript=oDoc.createElement('script');objScript.src=command.data;if('undefined'==typeof command.type)objScript.type='text/javascript';else objScript.type=command.type;if('undefined'!=typeof command.type)objScript.setAttribute('id',command.elm_id);objHead[0].appendChild(objScript);return true;}
173xajax.js.removeScript=function(command){command.fullName='removeScript';var fileName=command.data;var unload=command.unld;var oDoc=xajax.config.baseDocument;var loadedScripts=oDoc.getElementsByTagName('script');var iLen=loadedScripts.length;for(var i=0;i < iLen;++i){var script=loadedScripts[i];if(script.src){if(0 <=script.src.indexOf(fileName)){if('undefined'!=typeof unload){var args={};args.data=unload;args.context=window;xajax.js.execute(args);}
174var parent=script.parentNode;parent.removeChild(script);}
175}
176}
177return true;}
178xajax.js.sleep=function(command){command.fullName='sleep';if(xajax.tools.queue.retry(command,command.prop)){xajax.tools.queue.setWakeup(xajax.response,100);return false;}
179return true;}
180xajax.js.confirmCommands=function(command){command.fullName='confirmCommands';var msg=command.data;var numberOfCommands=command.id;if(false==confirm(msg)){while(0 < numberOfCommands){xajax.tools.queue.pop(xajax.response);--numberOfCommands;}
181}
182return true;}
183xajax.js.execute=function(args){args.fullName='execute Javascript';var returnValue=true;args.context.xajaxDelegateCall=function(){eval(args.data);}
184args.context.xajaxDelegateCall();return returnValue;}
185xajax.js.waitFor=function(args){args.fullName='waitFor';var bResult=false;var cmdToEval='bResult = (';cmdToEval+=args.data;cmdToEval+=');';try{args.context.xajaxDelegateCall=function(){eval(cmdToEval);}
186args.context.xajaxDelegateCall();}catch(e){}
187if(false==bResult){if(xajax.tools.queue.retry(args,args.prop)){xajax.tools.queue.setWakeup(xajax.response,100);return false;}
188}
189return true;}
190xajax.js.call=function(args){args.fullName='call js function';var parameters=args.data;var scr=new Array();scr.push(args.func);scr.push('(');if('undefined'!=typeof parameters){if('object'==typeof parameters){var iLen=parameters.length;if(0 < iLen){scr.push('parameters[0]');for(var i=1;i < iLen;++i)
191scr.push(', parameters['+i+']');}
192}
193}
194scr.push(');');args.context.xajaxDelegateCall=function(){eval(scr.join(''));}
195args.context.xajaxDelegateCall();return true;}
196xajax.js.setFunction=function(args){args.fullName='setFunction';var code=new Array();code.push(args.func);code.push(' = function(');if('object'==typeof args.prop){var separator='';for(var m in args.prop){code.push(separator);code.push(args.prop[m]);separator=',';}
197}else code.push(args.prop);code.push(') { ');code.push(args.data);code.push(' }');args.context.xajaxDelegateCall=function(){eval(code.join(''));}
198args.context.xajaxDelegateCall();return true;}
199xajax.js.wrapFunction=function(args){args.fullName='wrapFunction';var code=new Array();code.push(args.func);code.push(' = xajax.js.makeWrapper(');code.push(args.func);code.push(', args.prop, args.data, args.type, args.context);');args.context.xajaxDelegateCall=function(){eval(code.join(''));}
200args.context.xajaxDelegateCall();return true;}
201xajax.js.makeWrapper=function(origFun,args,codeBlocks,returnVariable,context){var originalCall='';if(0 < returnVariable.length){originalCall+=returnVariable;originalCall+=' = ';}
202var originalCall='origFun(';originalCall+=args;originalCall+='); ';var code='wrapper = function(';code+=args;code+=') { ';if(0 < returnVariable.length){code+=' var ';code+=returnVariable;code+=' = null;';}
203var separator='';var bLen=codeBlocks.length;for(var b=0;b < bLen;++b){code+=separator;code+=codeBlocks[b];separator=originalCall;}
204if(0 < returnVariable.length){code+=' return ';code+=returnVariable;code+=';';}
205code+=' } ';var wrapper=null;context.xajaxDelegateCall=function(){eval(code);}
206context.xajaxDelegateCall();return wrapper;}
207xajax.dom={}
208xajax.dom.assign=function(element,property,data){if('string'==typeof element)
209element=xajax.$(element);switch(property){case 'innerHTML':
210element.innerHTML=data;break;case 'outerHTML':
211if('undefined'==typeof element.outerHTML){var r=xajax.config.baseDocument.createRange();r.setStartBefore(element);var df=r.createContextualFragment(data);element.parentNode.replaceChild(df,element);}else element.outerHTML=data;break;default:
212if(xajax.tools.willChange(element,property,data))
213eval('element.'+property+' = data;');break;}
214return true;}
215xajax.dom.append=function(element,property,data){if('string'==typeof element)
216element=xajax.$(element);eval('element.'+property+' += data;');return true;}
217xajax.dom.prepend=function(element,property,data){if('string'==typeof element)
218element=xajax.$(element);eval('element.'+property+' = data + element.'+property);return true;}
219xajax.dom.replace=function(element,sAttribute,aData){var sSearch=aData['s'];var sReplace=aData['r'];if(sAttribute=='innerHTML')
220sSearch=xajax.tools.getBrowserHTML(sSearch);if('string'==typeof element)
221element=xajax.$(element);eval('var txt = element.'+sAttribute);var bFunction=false;if('function'==typeof txt){txt=txt.join('');bFunction=true;}
222var start=txt.indexOf(sSearch);if(start >-1){var newTxt=[];while(start >-1){var end=start+sSearch.length;newTxt.push(txt.substr(0,start));newTxt.push(sReplace);txt=txt.substr(end,txt.length-end);start=txt.indexOf(sSearch);}
223newTxt.push(txt);newTxt=newTxt.join('');if(bFunction){eval('element.'+sAttribute+'=newTxt;');}else if(xajax.tools.willChange(element,sAttribute,newTxt)){eval('element.'+sAttribute+'=newTxt;');}
224}
225return true;}
226xajax.dom.remove=function(element){if('string'==typeof element)
227element=xajax.$(element);if(element&&element.parentNode&&element.parentNode.removeChild)
228element.parentNode.removeChild(element);return true;}
229xajax.dom.create=function(objParent,sTag,sId){if('string'==typeof objParent)
230objParent=xajax.$(objParent);var target=xajax.config.baseDocument.createElement(sTag);target.setAttribute('id',sId);if(objParent)
231objParent.appendChild(target);return true;}
232xajax.dom.insert=function(objSibling,sTag,sId){if('string'==typeof objSibling)
233objSibling=xajax.$(objSibling);var target=xajax.config.baseDocument.createElement(sTag);target.setAttribute('id',sId);objSibling.parentNode.insertBefore(target,objSibling);return true;}
234xajax.dom.insertAfter=function(objSibling,sTag,sId){if('string'==typeof objSibling)
235objSibling=xajax.$(objSibling);var target=xajax.config.baseDocument.createElement(sTag);target.setAttribute('id',sId);objSibling.parentNode.insertBefore(target,objSibling.nextSibling);return true;}
236xajax.dom.contextAssign=function(args){args.fullName='context assign';var code=[];code.push('this.');code.push(args.prop);code.push(' = data;');code=code.join('');args.context.xajaxDelegateCall=function(data){eval(code);}
237args.context.xajaxDelegateCall(args.data);return true;}
238xajax.dom.contextAppend=function(args){args.fullName='context append';var code=[];code.push('this.');code.push(args.prop);code.push(' += data;');code=code.join('');args.context.xajaxDelegateCall=function(data){eval(code);}
239args.context.xajaxDelegateCall(args.data);return true;}
240xajax.dom.contextPrepend=function(args){args.fullName='context prepend';var code=[];code.push('this.');code.push(args.prop);code.push(' = data + this.');code.push(args.prop);code.push(';');code=code.join('');args.context.xajaxDelegateCall=function(data){eval(code);}
241args.context.xajaxDelegateCall(args.data);return true;}
242xajax.css={}
243xajax.css.add=function(fileName,media){var oDoc=xajax.config.baseDocument;var oHeads=oDoc.getElementsByTagName('head');var oHead=oHeads[0];var oLinks=oHead.getElementsByTagName('link');var found=false;var iLen=oLinks.length;for(var i=0;i < iLen&&false==found;++i)
244if(0 <=oLinks[i].href.indexOf(fileName)&&oLinks[i].media==media)
245found=true;if(false==found){var oCSS=oDoc.createElement('link');oCSS.rel='stylesheet';oCSS.type='text/css';oCSS.href=fileName;oCSS.media=media;oHead.appendChild(oCSS);}
246return true;}
247xajax.css.remove=function(fileName,media){var oDoc=xajax.config.baseDocument;var oHeads=oDoc.getElementsByTagName('head');var oHead=oHeads[0];var oLinks=oHead.getElementsByTagName('link');var i=0;while(i < oLinks.length)
248if(0 <=oLinks[i].href.indexOf(fileName)&&oLinks[i].media==media)
249oHead.removeChild(oLinks[i]);else++i;return true;}
250xajax.css.waitForCSS=function(args){var oDocSS=xajax.config.baseDocument.styleSheets;var ssEnabled=[];var iLen=oDocSS.length;for(var i=0;i < iLen;++i){ssEnabled[i]=0;try{ssEnabled[i]=oDocSS[i].cssRules.length;}catch(e){try{ssEnabled[i]=oDocSS[i].rules.length;}catch(e){}
251}
252}
253var ssLoaded=true;var iLen=ssEnabled.length;for(var i=0;i < iLen;++i)
254if(0==ssEnabled[i])
255ssLoaded=false;if(false==ssLoaded){if(xajax.tools.queue.retry(args,args.prop)){xajax.tools.queue.setWakeup(xajax.response,10);return false;}
256}
257return true;}
258xajax.forms={}
259xajax.forms.getInput=function(type,name,id){if('undefined'==typeof window.addEventListener){xajax.forms.getInput=function(type,name,id){return xajax.config.baseDocument.createElement('<input type="'+type+'" name="'+name+'" id="'+id+'">');}
260}else{xajax.forms.getInput=function(type,name,id){var oDoc=xajax.config.baseDocument;var Obj=oDoc.createElement('input');Obj.setAttribute('type',type);Obj.setAttribute('name',name);Obj.setAttribute('id',id);return Obj;}
261}
262return xajax.forms.getInput(type,name,id);}
263xajax.forms.createInput=function(command){command.fullName='createInput';var objParent=command.id;var sType=command.type;var sName=command.data;var sId=command.prop;if('string'==typeof objParent)
264objParent=xajax.$(objParent);var target=xajax.forms.getInput(sType,sName,sId);if(objParent&&target){objParent.appendChild(target);}
265return true;}
266xajax.forms.insertInput=function(command){command.fullName='insertInput';var objSibling=command.id;var sType=command.type;var sName=command.data;var sId=command.prop;if('string'==typeof objSibling)
267objSibling=xajax.$(objSibling);var target=xajax.forms.getInput(sType,sName,sId);if(target&&objSibling&&objSibling.parentNode)
268objSibling.parentNode.insertBefore(target,objSibling);return true;}
269xajax.forms.insertInputAfter=function(command){command.fullName='insertInputAfter';var objSibling=command.id;var sType=command.type;var sName=command.data;var sId=command.prop;if('string'==typeof objSibling)
270objSibling=xajax.$(objSibling);var target=xajax.forms.getInput(sType,sName,sId);if(target&&objSibling&&objSibling.parentNode)
271objSibling.parentNode.insertBefore(target,objSibling.nextSibling);return true;}
272xajax.events={}
273xajax.events.setEvent=function(command){command.fullName='addEvent';var element=command.id;var sEvent=command.prop;var code=command.data;if('string'==typeof element)
274element=xajax.$(element);sEvent=xajax.tools.addOnPrefix(sEvent);code=xajax.tools.doubleQuotes(code);eval('element.'+sEvent+' = function() { '+code+'; }');return true;}
275xajax.events.addHandler=function(element,sEvent,fun){if(window.addEventListener){xajax.events.addHandler=function(command){command.fullName='addHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
276element=xajax.$(element);sEvent=xajax.tools.stripOnPrefix(sEvent);eval('element.addEventListener("'+sEvent+'", '+fun+', false);');return true;}
277}else{xajax.events.addHandler=function(command){command.fullName='addHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
278element=xajax.$(element);sEvent=xajax.tools.addOnPrefix(sEvent);eval('element.attachEvent("'+sEvent+'", '+fun+', false);');return true;}
279}
280return xajax.events.addHandler(element,sEvent,fun);}
281xajax.events.removeHandler=function(element,sEvent,fun){if(window.removeEventListener){xajax.events.removeHandler=function(command){command.fullName='removeHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
282element=xajax.$(element);sEvent=xajax.tools.stripOnPrefix(sEvent);eval('element.removeEventListener("'+sEvent+'", '+fun+', false);');return true;}
283}else{xajax.events.removeHandler=function(command){command.fullName='removeHandler';var element=command.id;var sEvent=command.prop;var fun=command.data;if('string'==typeof element)
284element=xajax.$(element);sEvent=xajax.tools.addOnPrefix(sEvent);eval('element.detachEvent("'+sEvent+'", '+fun+', false);');return true;}
285}
286return xajax.events.removeHandler(element,sEvent,fun);}
287xajax.callback={}
288xajax.callback.create=function(){var xx=xajax;var xc=xx.config;var xcb=xx.callback;var oCB={}
289oCB.timers={};oCB.timers.onResponseDelay=xcb.setupTimer(
290(arguments.length > 0)
291? arguments[0]
292:xc.defaultResponseDelayTime);oCB.timers.onExpiration=xcb.setupTimer(
293(arguments.length > 1)
294? arguments[1]
295:xc.defaultExpirationTime);oCB.onRequest=null;oCB.onResponseDelay=null;oCB.onExpiration=null;oCB.beforeResponseProcessing=null;oCB.onFailure=null;oCB.onRedirect=null;oCB.onSuccess=null;oCB.onComplete=null;return oCB;}
296xajax.callback.setupTimer=function(iDelay){return{timer:null,delay:iDelay};}
297xajax.callback.clearTimer=function(oCallback,sFunction){if('undefined'!=typeof oCallback.timers){if('undefined'!=typeof oCallback.timers[sFunction]){clearTimeout(oCallback.timers[sFunction].timer);}
298}else if('object'==typeof oCallback){var iLen=oCallback.length;for(var i=0;i < iLen;++i)
299xajax.callback.clearTimer(oCallback[i],sFunction);}
300}
301xajax.callback.execute=function(oCallback,sFunction,args){if('undefined'!=typeof oCallback[sFunction]){var func=oCallback[sFunction];if('function'==typeof func){if('undefined'!=typeof oCallback.timers[sFunction]){oCallback.timers[sFunction].timer=setTimeout(function(){func(args);},oCallback.timers[sFunction].delay);}
302else{func(args);}
303}
304}else if('object'==typeof oCallback){var iLen=oCallback.length;for(var i=0;i < iLen;++i)
305xajax.callback.execute(oCallback[i],sFunction,args);}
306}
307xajax.callback.global=xajax.callback.create();xajax.response=xajax.tools.queue.create(xajax.config.responseQueueSize);xajax.responseSuccessCodes=['0','200'];xajax.responseErrorsForAlert=['400','401','402','403','404','500','501','502','503'];xajax.responseRedirectCodes=['301','302','307'];if('undefined'==typeof xajax.command)
308xajax.command={};xajax.command.create=function(sequence,request,context){var newCmd={};newCmd.cmd='*';newCmd.fullName='* unknown command name *';newCmd.sequence=sequence;newCmd.request=request;newCmd.context=context;return newCmd;}
309if('undefined'==typeof xajax.command.handler)
310xajax.command.handler={};if('undefined'==typeof xajax.command.handler.handlers)
311xajax.command.handler.handlers=[];xajax.command.handler.register=function(shortName,func){xajax.command.handler.handlers[shortName]=func;}
312xajax.command.handler.unregister=function(shortName){var func=xajax.command.handler.handlers[shortName];delete xajax.command.handler.handlers[shortName];return func;}
313xajax.command.handler.isRegistered=function(command){var shortName=command.cmd;if(xajax.command.handler.handlers[shortName])
314return true;return false;}
315xajax.command.handler.call=function(command){var shortName=command.cmd;return xajax.command.handler.handlers[shortName](command);}
316xajax.command.handler.register('rcmplt',function(args){xajax.completeResponse(args.request);return true;});xajax.command.handler.register('css',function(args){args.fullName='includeCSS';if('undefined'==typeof args.media)
317args.media='screen';return xajax.css.add(args.data,args.media);});xajax.command.handler.register('rcss',function(args){args.fullName='removeCSS';if('undefined'==typeof args.media)
318args.media='screen';return xajax.css.remove(args.data,args.media);});xajax.command.handler.register('wcss',function(args){args.fullName='waitForCSS';return xajax.css.waitForCSS(args);});xajax.command.handler.register('as',function(args){args.fullName='assign/clear';try{return xajax.dom.assign(args.target,args.prop,args.data);}catch(e){}
319return true;});xajax.command.handler.register('ap',function(args){args.fullName='append';return xajax.dom.append(args.target,args.prop,args.data);});xajax.command.handler.register('pp',function(args){args.fullName='prepend';return xajax.dom.prepend(args.target,args.prop,args.data);});xajax.command.handler.register('rp',function(args){args.fullName='replace';return xajax.dom.replace(args.id,args.prop,args.data);});xajax.command.handler.register('rm',function(args){args.fullName='remove';return xajax.dom.remove(args.id);});xajax.command.handler.register('ce',function(args){args.fullName='create';return xajax.dom.create(args.id,args.data,args.prop);});xajax.command.handler.register('ie',function(args){args.fullName='insert';return xajax.dom.insert(args.id,args.data,args.prop);});xajax.command.handler.register('ia',function(args){args.fullName='insertAfter';return xajax.dom.insertAfter(args.id,args.data,args.prop);});xajax.command.handler.register('c:as',xajax.dom.contextAssign);xajax.command.handler.register('c:ap',xajax.dom.contextAppend);xajax.command.handler.register('c:pp',xajax.dom.contextPrepend);xajax.command.handler.register('s',xajax.js.sleep);xajax.command.handler.register('ino',xajax.js.includeScriptOnce);xajax.command.handler.register('in',xajax.js.includeScript);xajax.command.handler.register('rjs',xajax.js.removeScript);xajax.command.handler.register('wf',xajax.js.waitFor);xajax.command.handler.register('js',xajax.js.execute);xajax.command.handler.register('jc',xajax.js.call);xajax.command.handler.register('sf',xajax.js.setFunction);xajax.command.handler.register('wpf',xajax.js.wrapFunction);xajax.command.handler.register('al',function(args){args.fullName='alert';alert(args.data);return true;});xajax.command.handler.register('cc',xajax.js.confirmCommands);xajax.command.handler.register('ci',xajax.forms.createInput);xajax.command.handler.register('ii',xajax.forms.insertInput);xajax.command.handler.register('iia',xajax.forms.insertInputAfter);xajax.command.handler.register('ev',xajax.events.setEvent);xajax.command.handler.register('ah',xajax.events.addHandler);xajax.command.handler.register('rh',xajax.events.removeHandler);xajax.command.handler.register('dbg',function(args){args.fullName='debug message';return true;});xajax.initializeRequest=function(oRequest){var xx=xajax;var xc=xx.config;oRequest.append=function(opt,def){if('undefined'!=typeof this[opt]){for(var itmName in def)
320if('undefined'==typeof this[opt][itmName])
321this[opt][itmName]=def[itmName];}else this[opt]=def;}
322oRequest.append('commonHeaders',xc.commonHeaders);oRequest.append('postHeaders',xc.postHeaders);oRequest.append('getHeaders',xc.getHeaders);oRequest.set=function(option,defaultValue){if('undefined'==typeof this[option])
323this[option]=defaultValue;}
324oRequest.set('statusMessages',xc.statusMessages);oRequest.set('waitCursor',xc.waitCursor);oRequest.set('mode',xc.defaultMode);oRequest.set('method',xc.defaultMethod);oRequest.set('URI',xc.requestURI);oRequest.set('httpVersion',xc.defaultHttpVersion);oRequest.set('contentType',xc.defaultContentType);oRequest.set('retry',xc.defaultRetry);oRequest.set('returnValue',xc.defaultReturnValue);oRequest.set('maxObjectDepth',xc.maxObjectDepth);oRequest.set('maxObjectSize',xc.maxObjectSize);oRequest.set('context',window);var xcb=xx.callback;var gcb=xcb.global;var lcb=xcb.create();lcb.take=function(frm,opt){if('undefined'!=typeof frm[opt]){lcb[opt]=frm[opt];lcb.hasEvents=true;}
325delete frm[opt];}
326lcb.take(oRequest,'onRequest');lcb.take(oRequest,'onResponseDelay');lcb.take(oRequest,'onExpiration');lcb.take(oRequest,'beforeResponseProcessing');lcb.take(oRequest,'onFailure');lcb.take(oRequest,'onRedirect');lcb.take(oRequest,'onSuccess');lcb.take(oRequest,'onComplete');if('undefined'!=typeof oRequest.callback){if(lcb.hasEvents)
327oRequest.callback=[oRequest.callback,lcb];}else
328oRequest.callback=lcb;oRequest.status=(oRequest.statusMessages)
329? xc.status.update()
330:xc.status.dontUpdate();oRequest.cursor=(oRequest.waitCursor)
331? xc.cursor.update()
332:xc.cursor.dontUpdate();oRequest.method=oRequest.method.toUpperCase();if('GET'!=oRequest.method)
333oRequest.method='POST';oRequest.requestRetry=oRequest.retry;oRequest.append('postHeaders',{'content-type':oRequest.contentType
334});delete oRequest['append'];delete oRequest['set'];delete oRequest['take'];if('undefined'==typeof oRequest.URI)
335throw{code:10005}
336}
337xajax.processParameters=function(oRequest){var xx=xajax;var xt=xx.tools;var rd=[];var separator='';for(var sCommand in oRequest.functionName){if('constructor'!=sCommand){rd.push(separator);rd.push(sCommand);rd.push('=');rd.push(encodeURIComponent(oRequest.functionName[sCommand]));separator='&';}
338}
339var dNow=new Date();rd.push('&xjxr=');rd.push(dNow.getTime());delete dNow;if(oRequest.parameters){var i=0;var iLen=oRequest.parameters.length;while(i < iLen){var oVal=oRequest.parameters[i];if('object'==typeof oVal&&null!=oVal){try{var oGuard={};oGuard.depth=0;oGuard.maxDepth=oRequest.maxObjectDepth;oGuard.size=0;oGuard.maxSize=oRequest.maxObjectSize;oVal=xt._objectToXML(oVal,oGuard);}catch(e){oVal='';}
340rd.push('&xjxargs[]=');oVal=encodeURIComponent(oVal);rd.push(oVal);++i;}else{rd.push('&xjxargs[]=');oVal=xt._escape(oVal);if('undefined'==typeof oVal||null==oVal){rd.push('*');}else{var sType=typeof oVal;if('string'==sType)
341rd.push('S');else if('boolean'==sType)
342rd.push('B');else if('number'==sType)
343rd.push('N');oVal=encodeURIComponent(oVal);rd.push(oVal);}
344++i;}
345}
346}
347oRequest.requestURI=oRequest.URI;if('GET'==oRequest.method){oRequest.requestURI+=oRequest.requestURI.indexOf('?')==-1 ? '?':'&';oRequest.requestURI+=rd.join('');rd=[];}
348oRequest.requestData=rd.join('');}
349xajax.prepareRequest=function(oRequest){var xx=xajax;var xt=xx.tools;oRequest.request=xt.getRequestObject();oRequest.setRequestHeaders=function(headers){if('object'==typeof headers){for(var optionName in headers)
350this.request.setRequestHeader(optionName,headers[optionName]);}
351}
352oRequest.setCommonRequestHeaders=function(){this.setRequestHeaders(this.commonHeaders);}
353oRequest.setPostRequestHeaders=function(){this.setRequestHeaders(this.postHeaders);}
354oRequest.setGetRequestHeaders=function(){this.setRequestHeaders(this.getHeaders);}
355if('asynchronous'==oRequest.mode){oRequest.request.onreadystatechange=function(){if(oRequest.request.readyState!=4)
356return;xajax.responseReceived(oRequest);}
357oRequest.finishRequest=function(){return this.returnValue;}
358}else{oRequest.finishRequest=function(){return xajax.responseReceived(oRequest);}
359}
360if('undefined'!=typeof oRequest.userName&&'undefined'!=typeof oRequest.password){oRequest.open=function(){this.request.open(
361this.method,
362this.requestURI,
363'asynchronous'==this.mode,
364oRequest.userName,
365oRequest.password);}
366}else{oRequest.open=function(){this.request.open(
367this.method,
368this.requestURI,
369'asynchronous'==this.mode);}
370}
371if('POST'==oRequest.method){oRequest.applyRequestHeaders=function(){this.setCommonRequestHeaders();try{this.setPostRequestHeaders();}catch(e){this.method='GET';this.requestURI+=this.requestURI.indexOf('?')==-1 ? '?':'&';this.requestURI+=this.requestData;this.requestData='';if(0==this.requestRetry)this.requestRetry=1;throw e;}
372}
373}else{oRequest.applyRequestHeaders=function(){this.setCommonRequestHeaders();this.setGetRequestHeaders();}
374}
375}
376xajax.request=function(){var numArgs=arguments.length;if(0==numArgs)
377return false;var oRequest={}
378if(1 < numArgs)
379oRequest=arguments[1];oRequest.functionName=arguments[0];var xx=xajax;xx.initializeRequest(oRequest);xx.processParameters(oRequest);while(0 < oRequest.requestRetry){try{--oRequest.requestRetry;xx.prepareRequest(oRequest);return xx.submitRequest(oRequest);}catch(e){xajax.callback.execute(
380[xajax.callback.global,oRequest.callback],
381'onFailure',oRequest);if(0==oRequest.requestRetry)
382throw e;}
383}
384}
385xajax.call=function(){var numArgs=arguments.length;if(0==numArgs)
386return false;var oRequest={}
387if(1 < numArgs)
388oRequest=arguments[1];oRequest.functionName={xjxfun:arguments[0]};var xx=xajax;xx.initializeRequest(oRequest);xx.processParameters(oRequest);while(0 < oRequest.requestRetry){try{--oRequest.requestRetry;xx.prepareRequest(oRequest);return xx.submitRequest(oRequest);}catch(e){xajax.callback.execute(
389[xajax.callback.global,oRequest.callback],
390'onFailure',oRequest);if(0==oRequest.requestRetry)
391throw e;}
392}
393}
394xajax.submitRequest=function(oRequest){oRequest.status.onRequest();var xcb=xajax.callback;var gcb=xcb.global;var lcb=oRequest.callback;xcb.execute([gcb,lcb],'onResponseDelay',oRequest);xcb.execute([gcb,lcb],'onExpiration',oRequest);xcb.execute([gcb,lcb],'onRequest',oRequest);oRequest.open();oRequest.applyRequestHeaders();oRequest.cursor.onWaiting();oRequest.status.onWaiting();xajax._internalSend(oRequest);return oRequest.finishRequest();}
395xajax._internalSend=function(oRequest){oRequest.request.send(oRequest.requestData);}
396xajax.abortRequest=function(oRequest){oRequest.aborted=true;oRequest.request.abort();xajax.completeResponse(oRequest);}
397xajax.responseReceived=function(oRequest){var xx=xajax;var xcb=xx.callback;var gcb=xcb.global;var lcb=oRequest.callback;if(oRequest.aborted)
398return;xcb.clearTimer([gcb,lcb],'onExpiration');xcb.clearTimer([gcb,lcb],'onResponseDelay');xcb.execute([gcb,lcb],'beforeResponseProcessing',oRequest);var fProc=xx.getResponseProcessor(oRequest);if('undefined'==typeof fProc){xcb.execute([gcb,lcb],'onFailure',oRequest);xx.completeResponse(oRequest);return;}
399return fProc(oRequest);}
400xajax.getResponseProcessor=function(oRequest){var fProc;if('undefined'==typeof oRequest.responseProcessor){var cTyp=oRequest.request.getResponseHeader('content-type');if(cTyp){if(0 <=cTyp.indexOf('text/xml')){fProc=xajax.responseProcessor.xml;}
401}
402}else fProc=oRequest.responseProcessor;return fProc;}
403xajax.executeCommand=function(command){if(xajax.command.handler.isRegistered(command)){if(command.id)
404command.target=xajax.$(command.id);if(false==xajax.command.handler.call(command)){xajax.tools.queue.pushFront(xajax.response,command);return false;}
405}
406return true;}
407xajax.completeResponse=function(oRequest){xajax.callback.execute(
408[xajax.callback.global,oRequest.callback],
409'onComplete',oRequest);oRequest.cursor.onComplete();oRequest.status.onComplete();delete oRequest['functionName'];delete oRequest['requestURI'];delete oRequest['requestData'];delete oRequest['requestRetry'];delete oRequest['request'];delete oRequest['set'];delete oRequest['open'];delete oRequest['setRequestHeaders'];delete oRequest['setCommonRequestHeaders'];delete oRequest['setPostRequestHeaders'];delete oRequest['setGetRequestHeaders'];delete oRequest['applyRequestHeaders'];delete oRequest['finishRequest'];delete oRequest['status'];delete oRequest['cursor'];}
410xajax.$=xajax.tools.$;xajax.getFormValues=xajax.tools.getFormValues;xajax.isLoaded=true;xjx={}
411xjx.$=xajax.tools.$;xjx.getFormValues=xajax.tools.getFormValues;xjx.call=xajax.call;xjx.request=xajax.request;