jsWS=function(b,a){this.wsUrl=b;this.wsMethod=a;this.argName=[];this.argValue=[];this.running=false;this.response=null;this.responseText=null;this.requestType="FORM";this.isAsync=true;this.method="POST";this.readyStateChangeFired=false;this.onReadyStateChange=null};jsWS.prototype.SetSync=function(){this.isAsync=false};jsWS.prototype.SetAsync=function(){this.isAsync=true};jsWS.prototype.addArg=function(b,a){this.argName[this.argName.length]=b;this.argValue[this.argValue.length]=a;return true};jsWS.prototype.addUserInfoParms=function(){this.addArg("DSN",GetCookie(g_LoginCookieName,"DSN"));this.addArg("UserID",GetCookie(g_SessionCookieName,"UserID"));this.addArg("LanguageID",GetCookie(g_LoginCookieName,"LanguageID"));this.addArg("SecurityToken",GetCookie(g_SessionCookieName,"SecurityToken"))};jsWS.prototype.addArgs=function(b){var d=b.split("&");for(var c=0;c<a.length;c++){var a=d[c].split("=");addArg(a[0],a[1])}};jsWS.prototype.envelopeSoap=function(){var c=new XMLDocument("","");c.appendChild(c.createNode(1,"SOAP:Envelope","http://schemas.xmlsoap.org/soap/envelope/"));c.documentElement.appendChild(c.createElement("SOAP:Header"));var b=c.documentElement.appendChild(c.createElement("SOAP:Body"));var f=b.appendChild(c.createNode(1,"m:"+this.wsMethod,"http://tempuri.org/"));for(var d=0;d<this.argName.length;d++){var a=c.createElement(this.argName[d]);a.appendChild(c.createTextNode(this.argValue[d]));f.appendChild(a)}return c};jsWS.prototype.envelopeForm=function(){var a="";for(var b=0;b<this.argName.length;b++){a+=this.argName[b]+"="+this.argValue[b];if(b<this.argName.length-1){a+="&"}}return a};jsWS.prototype.send=function(j,g,f,d,c,b){var i=new XMLHttpRequest();var h=this;this.xmlhttp=i;var k=new Object();this.onReadyStateChange=function(){if(i.readyState==4){h.readyStateChangeFired=true;h.running=false;try{if(i.status==200){h.responseText=i.responseText;h.responseXML=i.responseXML;if(IsMac()){if(h.responseXML){h.response=i.responseXML.documentElement}else{h.response=null}}else{if(i.responseXML){if(i.responseXML.documentElement==null){i.responseXML.async=false;i.responseXML.load(i.responseStream)}h.response=i.responseXML.documentElement}else{h.response=null}}if(j!=null){j(h,g,f,d,c,b)}}else{if(i.status==404){alert("Error Code: "+i.status+"\nError Detials: "+i.statusText+"\nCheck if the requesting URL is correct.")}else{var l;if(i.responseXML){l=i.responseXML.getElementsByTagName("ProcessError")}if(l&&l.length>0){alert(l[0].firstChild.nodeValue)}else{if(!IsMac()||typeof(i.status)!="undefined"){if(i.responseText&&i.responseText.indexOf("<?xml")!=0){alert("There was a problem the web service call "+h.wsMethod+":\nStatus: "+i.status+"\nDetails: "+i.responseText)}else{alert("There was a problem the web service call "+h.wsMethod+":\nStatus: "+i.status+"\nDetails: "+i.statusText)}}}}}}finally{k.responseText=i.responseText;k.responseXML=i.responseXML}}};i.onreadystatechange=this.onReadyStateChange;if(this.method=="GET"){i.open(this.method,this.wsUrl,false);i.send(null);return}if(this.requestType=="SOAP"){i.open(this.method,this.wsUrl,this.isAsync);i.setRequestHeader("User-Agent","XMLHttpRequest");i.setRequestHeader("Content-Type","text/xml; charset=utf-8");if(this.wsUrl=="WebService/WS.asmx"){i.setRequestHeader("SOAPAction","http://aprimo.com/"+this.wsMethod)}else{i.setRequestHeader("SOAPAction","http://tempuri.org/"+this.wsMethod)}i.send(this.envelopeSoap())}else{var a=this.wsUrl;if(this.wsMethod){a+="/"+this.wsMethod}i.open(this.method,a,this.isAsync);i.setRequestHeader("User-Agent","XMLHttpRequest");i.setRequestHeader("Content-Type","application/x-www-form-urlencoded");i.send(this.envelopeForm())}this.running=true;this.enforceOnReadyStateChangeEvent();return k};jsWS.prototype.enforceOnReadyStateChangeEvent=function(){if(!this.isAsync){if(this.xmlhttp.readyState==4&&!this.readyStateChangeFired){this.onReadyStateChange()}else{if(!this.readyStateChangeFired){this.enforceOnReadyStateChangeEvent()}}}};jsWS.prototype.value=function(a){try{return this.response.childNodes[0].nodeValue}catch(b){return""}};jsWS.prototype.complexValue=function(a){if(IsMac()){return this.response.selectNodeText("/"+a)}else{try{return this.response.getElementsByTagName(a)[0].nodeValue}catch(b){return""}}return""};jsWS.prototype.status=function(){return this.xmlhttp.status};jsWS.prototype.statusDescription=function(){return this.xmlhttp.responseText};jsGet=function(a){var b=new XMLHttpRequest();this.xmlhttp=b;b.open("GET",a,false);b.send(null);return b.responseText};window.XMLHttpRequestSupported=false;window.XMLHttpRequestVersion="Unknown";if(window.XMLHttpRequest){window.XMLHttpRequestVersion="XMLHttpRequest";window.XMLHttpRequestSupported=true}if(window.ActiveXObject&&!window.XMLHttpRequest){var test=null;try{test=new ActiveXObject("Msxml2.XMLHTTP");window.XMLHttpRequestVersion="Msxml2.XMLHTTP";window.XMLHttpRequestSupported=true;window.XMLHttpRequest=function(){return new ActiveXObject("Msxml2.XMLHTTP")}}catch(e){try{test=new ActiveXObject("Microsoft.XMLHTTP");window.XMLHttpRequestVersion="Microsoft.XMLHTTP";window.XMLHttpRequestSupported=true;window.XMLHttpRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}catch(E){}}}if(!window.XMLHttpRequest||typeof(window.XMLHttpRequest)=="undefined"){window.XMLHttpRequestVersion="Not Supported";window.XMLHttpRequestSupported=false}window.XMLDocumentSupported=false;window.XMLDocumentVersion="Unknown";if(navigator.userAgent.toLowerCase().indexOf("safari")>-1&&document.implementation&&document.implementation.createDocument){window.XMLDocumentSupported=true;window.XMLDocumentVersion="document.implementation (Safari)";window.XMLDocument=function(b,c){var a=document.implementation.createDocument(b,c,null);if(a.documentElement==null){a.appendChild(a.createElement(c))}a.loadXML=function(j){var h;if(DOMParser){var k=new DOMParser();h=k.parseFromString(j,"text/xml")}else{var g=new XMLHttpRequest();url="data:text/xml;charset=utf-8,"+encodeURIComponent(j);g.open("GET",url,false);g.send(null);h=g.responseXML}while(this.hasChildNodes()){this.removeChild(this.lastChild)}for(var d=0;d<h.childNodes.length;d++){var f=this.importNode(h.childNodes[d],true);this.appendChild(f)}handleOnLoad(this);return h};a.getXML=function(){if(window.XMLSerializer){s=new window.XMLSerializer();return s.serializeToString(this)}};return a}}else{if(window.ActiveXObject){window.XMLDocumentSupported=true;window.XMLDocumentVersion="Microsoft.XMLDOM";window.XMLDocument=function(b,c){var a=new ActiveXObject("Microsoft.XMLDOM");if(c){if(b){a.loadXML("<a0:"+c+' xmlns:a0="'+b+'" />')}else{a.loadXML("<"+c+"/>")}}return a}}else{if(document.implementation&&document.implementation.createDocument){window.XMLDocumentSupported=true;window.XMLDocumentVersion="document.implementation";window.XMLDocument=function(b,c){var a=document.implementation.createDocument(b,c,null);a.addEventListener("load",_Document_onload,false);a.__defineGetter__("xml",_Node_getXML);a.loadXML=function(h){changeReadyState(this,1);var j=new DOMParser();var g=j.parseFromString(h,"text/xml");while(this.hasChildNodes()){this.removeChild(this.lastChild)}for(var d=0;d<g.childNodes.length;d++){var f=this.importNode(g.childNodes[d],true);this.appendChild(f)}handleOnLoad(this)};return a};Document.prototype.loadXML=function(d){changeReadyState(this,1);var f=new DOMParser();var c=f.parseFromString(d,"text/xml");while(this.hasChildNodes()){this.removeChild(this.lastChild)}for(var a=0;a<c.childNodes.length;a++){var b=this.importNode(c.childNodes[a],true);this.appendChild(b)}handleOnLoad(this)};Document.prototype.readyState="0";Document.prototype.__load__=Document.prototype.load;Document.prototype.load=_Document_load;Document.prototype.onreadystatechange=null;Document.prototype.parseError=0;Document.prototype.__defineGetter__("xml",_Node_getXML);Node.prototype.__defineGetter__("xml",_Node_getXML)}else{window.XMLDocumentSupported=false;window.XMLDocumentVersion="Not Supported"}}}function _Node_getXML(){var a=new XMLSerializer();return a.serializeToString(this)}function _Document_load(a){this.parseError=0;changeReadyState(this,1);try{this.__load__(a)}catch(b){this.parseError=-9999999;changeReadyState(this,4)}}function _Document_onload(){handleOnLoad(this)}function handleOnLoad(a){if(!a.documentElement||a.documentElement.tagName=="parsererror"){a.parseError=-9999999}changeReadyState(a,4)}function changeReadyState(b,a){b.readyState=a;if(b.onreadystatechange!=null&&typeof b.onreadystatechange=="function"){b.onreadystatechange()}}function selectSingleNode(a,b){if(a==null){return null}var d=null;for(var c=0;c<a.childNodes.length;c++){d=a.childNodes[c];if(d.tagName==b){return d}}return null};
