function cpaint(){var e=[];e.debugging=0;e.proxy_url="";e.transfer_mode="GET";e.async=true;e.response_type="OBJECT";e.persistent_connection=false;e.use_cpaint_api=true;var g=0;this.set_debug=function(b){if(typeof b=="boolean")e.debugging=b===true?1:0;else if(typeof b=="number")e.debugging=Math.round(b)};this.set_proxy_url=function(b){if(typeof b=="string")e.proxy_url=b};this.set_transfer_mode=function(b){if(b.toUpperCase()=="GET"||b.toUpperCase()=="POST")e.transfer_mode=b.toUpperCase()};this.set_async=
function(b){if(typeof b=="boolean")e.async=b};this.set_response_type=function(b){if(b.toUpperCase()=="TEXT"||b.toUpperCase()=="XML"||b.toUpperCase()=="OBJECT")e.response_type=b.toUpperCase()};this.set_persistent_connection=function(b){if(typeof b=="boolean")e.persistent_connection=b};this.set_use_cpaint_api=function(b){if(typeof b=="boolean")e.use_cpaint_api=b};this.call=function(){var b=-1;if(e.persistent_connection==true&&typeof __cpaint_stack[0]=="object")switch(__cpaint_stack[0].get_http_state()){case -1:b=
0;a("no XMLHttpObject object to re-use for persistence, creating new one later",2);break;case 4:b=0;a("re-using the persistent connection",2);break;default:a("the persistent connection is in use - skipping this request",2)}else if(e.persistent_connection==true){b=0;__cpaint_stack[b]=new cpaint_call(b);a("no cpaint_call object available for re-use, created new one",2)}else{b=g;__cpaint_stack[b]=new cpaint_call(b);a("no cpaint_call object created new one",2)}if(b!=-1){__cpaint_stack[b].set_debug(e.debugging);
__cpaint_stack[b].set_proxy_url(e.proxy_url);__cpaint_stack[b].set_transfer_mode(e.transfer_mode);__cpaint_stack[b].set_async(e.async);__cpaint_stack[b].set_response_type(e.response_type);__cpaint_stack[b].set_persistent_connection(e.persistent_connection);__cpaint_stack[b].set_use_cpaint_api(e.use_cpaint_api);__cpaint_stack[b].set_client_callback(arguments[2]);e.proxy_url!=""?__cpaint_stack[b].call_proxy(arguments):__cpaint_stack[b].call_direct(arguments);g++;a("stack size: "+__cpaint_stack.length,
2)}};function a(b,d){e.debugging>=d&&alert("[CPAINT Debug] "+b)}}var __cpaint_stack=[],__cpaint_transformer=new cpaint_transformer;
function cpaint_call(e){var g=false,a=false,b="",d="GET",f=true,h="OBJECT",n=false,t=true,r,s=e;this.set_debug=function(c){if(typeof c=="number")g=Math.round(c)};this.set_proxy_url=function(c){if(typeof c=="string")b=c};this.set_transfer_mode=function(c){if(c.toUpperCase()=="GET"||c.toUpperCase()=="POST")d=c.toUpperCase()};this.set_async=function(c){if(typeof c=="boolean")f=c};this.set_response_type=function(c){if(c.toUpperCase()=="TEXT"||c.toUpperCase()=="XML"||c.toUpperCase()=="OBJECT")h=c.toUpperCase()};
this.set_persistent_connection=function(c){if(typeof c=="boolean")n=c};this.set_use_cpaint_api=function(c){if(typeof c=="boolean")t=c};this.set_client_callback=function(c){if(typeof c=="function")r=c};this.get_http_state=function(){var c=-1;if(typeof a=="object")c=a.readyState;return c};this.call_direct=function(c){var k=c[0],o=c[1],l="",i=0;if(k=="SELF")k=document.location.href;if(t==true){for(i=3;i<c.length;i++)l+="&cpaint_argument[]="+encodeURIComponent2(c[i]);l+="&cpaint_response_type="+h;if(d==
"GET")k=k+"?cpaint_function="+o+l;else l="cpaint_function="+o+l}else{for(i=3;i<c.length;i++)l+=i==3?encodeURIComponent2(c[i]):"&"+encodeURIComponent2(c[i]);if(d=="GET")k+=l}u();m('opening connection to "'+k+'"',1);a.open(d,k,f);if(d=="POST")try{a.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(p){alert("ERROR! POST cannot be completed due to incompatible browser.  Use GET as your request method.")}a.onreadystatechange=q;if(d=="GET")a.send(null);else{m("sending query: "+
l,1);a.send(l)}f==false&&q()};this.call_proxy=function(c){var k=b,o=c[0],l=c[1],i="",p=0,v="cpaint_argument[]=";if(l=="")v="";for(p=3;p<c.length;p++)i+=encodeURIComponent2(v+c[p]+"&");i+=encodeURIComponent2("&cpaint_function="+l);i+=encodeURIComponent2("&cpaint_responsetype="+h);if(d=="GET")k+="?cpaint_remote_url="+encodeURIComponent2(o)+"&cpaint_remote_method="+d+"&cpaint_response_type="+h+"&cpaint_remote_query="+i;else i="cpaint_remote_url="+encodeURIComponent2(o)+"&cpaint_remote_method="+d+"&cpaint_response_type="+
h+"&cpaint_remote_query="+i;u();m('opening connection to proxy "'+k+'"',1);a.open(d,k,f);if(d=="POST")try{a.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(x){alert("[CPAINT Error] POST cannot be completed due to incompatible browser.  Use GET as your request method.")}a.onreadystatechange=q;if(d=="GET")a.send(null);else{m("sending query: "+i,1);a.send(i)}f==false&&q()};function u(){var c=false,k=false;if(n==false){m("Using new connection object",1);k=true}else{m("Using shared connection object.",
1);if(typeof a!="object"){m("Getting new persistent connection object.",1);k=true}}if(k==true){try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(o){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(l){a=null}}if(!a&&typeof XMLHttpRequest!="undefined")a=new XMLHttpRequest;if(a)c=true;else alert("[CPAINT Error] Could not create connection object")}a.readyState!=4&&a.abort();return c}function q(){var c=null;if(a.readyState==4){m(a.responseText,1);switch(h){case "XML":c=__cpaint_transformer.xml_conversion(a.responseXML);
break;case "OBJECT":c=__cpaint_transformer.object_conversion(a.responseXML);if(!c.ajaxResponse){OpenWindow=window.open("","foutmelding","width=400,height=400,resizable=yes");OpenWindow.document.write(a.responseText);OpenWindow.document.close();c=null}break;case "TEXT":c=a.responseText;break;default:alert("[CPAINT Error] invalid response type '"+h+"'")}c!=null&&typeof r=="function"&&r(c);w()}}function w(){if(typeof s=="number"&&__cpaint_stack[s]&&n==false)__cpaint_stack[s]=null}function m(c,k){g>=
k&&alert("[CPAINT Debug] "+c)}}
function cpaint_transformer(){this.object_conversion=function(a){var b=new cpaint_result_object,d=0,f="";if(typeof a=="object"&&a!=null){for(d=0;d<a.childNodes.length;d++)if(a.childNodes[d].nodeType==1){f=a.childNodes[d].nodeName;break}a=a.getElementsByTagName(f);b[f]=[];for(d=0;d<a.length;d++){var h=e(a[d]);h.id=a[d].getAttribute("id");b[f].push(h)}}else alert("[CPAINT Error] received invalid XML response");return b};this.xml_conversion=function(a){return a};this.text_conversion=function(a){return g(a)};
function e(a){var b=new cpaint_result_object,d="",f=0,h=0;if(a.hasChildNodes()==true)for(f=0;f<a.childNodes.length;f++){d=g(a.childNodes[f].nodeName);d=d.replace(/[^a-zA-Z0-9]*/g,"");if(typeof b[d]!="object")b[d]=[];if(a.childNodes[f].nodeType==1){var n=e(a.childNodes[f]);for(h=0;h<a.childNodes[f].attributes.length;h++)n.set_attribute(g(a.childNodes[f].attributes[h].nodeName),g(a.childNodes[f].attributes[h].nodeValue));b[d].push(n)}else if(a.childNodes[f].nodeType==3)b.data=g(a.firstChild.data)}return b}
function g(a){var b="",d=0,f=0,h=f=f=f=0;if(a.indexOf("\\u")!=-1)for(;d<a.length;)if(a.charAt(d)=="\\"&&a.charAt(d+1)=="u"){f=0;for(j=2;j<6;j+=1){h=parseInt(a.charAt(d+j),16);if(!isFinite(h))break;f=f*16+h}b+=String.fromCharCode(f);d+=6}else{b+=a.charAt(d);d++}else b=a;if(b!==""&&!isNaN(b)&&isFinite(b))b=Number(b);return b}}
function cpaint_result_object(){this.data=this.id=0;var e=[];this.find_item_by_id=function(g,a){var b=null;g=g;a=a;var d=0;if(this[g])for(d=0;d<this[g].length;d++)if(this[g][d].get_attribute("id")==a){b=this[g][d];break}return b};this.get_attribute=function(g){var a=null;g=g;if(typeof e[g]!="undefined")a=e[g];return a};this.set_attribute=function(g,a){e[g]=a}}function encodeURIComponent2(e){return escape(e).replace(/\+/g,"%2B").replace(/\"/g,"%22").replace(/\'/g,"%27").replace(/\//g,"%2F")};
