
if(typeof org=="undefined"||org==null){org=new Object();}
if(typeof org.xmlBlaster=="undefined"||org.xmlBlaster==null){org.xmlBlaster=new Object();}
if(typeof org.xmlBlaster.client=="undefined"||org.xmlBlaster.client==null){org.xmlBlaster.client=new Object();}
if(typeof org.xmlBlaster.util=="undefined"||org.xmlBlaster.util==null){org.xmlBlaster.util=new Object();}
org.xmlBlaster.util.uniqueCounter=0;org.xmlBlaster.util.startTimestamp=null;org.xmlBlaster.util.log=log4javascript.getLogger("org.xmlBlaster");log4javascript.setEnabled(false);org.xmlBlaster.util.popUpAppender=new log4javascript.PopUpAppender();org.xmlBlaster.util.popUpLayout=new log4javascript.PatternLayout("%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p - - %c %m%n");org.xmlBlaster.util.popUpAppender.setLayout(org.xmlBlaster.util.popUpLayout);org.xmlBlaster.util.popUpAppender.setThreshold(log4javascript.Level.DEBUG);org.xmlBlaster.util.isIE=false;org.xmlBlaster.util.isIE5=false;org.xmlBlaster.util.isIE6=false;org.xmlBlaster.util.isIE7=false;org.xmlBlaster.util.isIE8=false;org.xmlBlaster.util.isFF=false;org.xmlBlaster.util.isFF1=false;org.xmlBlaster.util.isFF2=false;org.xmlBlaster.util.isFF3=false;org.xmlBlaster.util.isOpera=false;org.xmlBlaster.util.isOpera7=false;org.xmlBlaster.util.isOpera8=false;org.xmlBlaster.util.isOpera9=false;org.xmlBlaster.util.isOpera10=false;org.xmlBlaster.util.isSafari=false;org.xmlBlaster.util.isKonqueror=false;function checkAgent(str)
{var index=navigator.userAgent.indexOf(str);return index>=0;}
if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){org.xmlBlaster.util.isFF=true;var ffversion=new Number(RegExp.$1)
if(navigator.userAgent.indexOf("Firefox/3")>=0)
org.xmlBlaster.util.isFF3=true;else if(navigator.userAgent.indexOf("Firefox/2")>=0)
org.xmlBlaster.util.isFF2=true;else if(ffversion>=1)
org.xmlBlaster.util.isFF1=true;}
else if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)||window.ActiveXObject!=undefined){org.xmlBlaster.util.isIE=true;var ieversion=new Number(RegExp.$1)
if(ieversion>=8)
org.xmlBlaster.util.isIE8=true;else if(ieversion>=7)
org.xmlBlaster.util.isIE7=true;else if(ieversion>=6)
org.xmlBlaster.util.isIE6=true;else if(ieversion>=5)
org.xmlBlaster.util.isIE5=true;}
else if(/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){org.xmlBlaster.util.isOpera=true;var oprversion=new Number(RegExp.$1)
if(oprversion>=10)
org.xmlBlaster.util.isOpera10=true;else if(oprversion>=9)
org.xmlBlaster.util.isOpera9=true;else if(oprversion>=8)
org.xmlBlaster.util.isOpera8=true;else if(oprversion>=7)
org.xmlBlaster.util.isOpera7=true;}
else if(checkAgent("Safari")){org.xmlBlaster.util.isSafari=true;}
else if(checkAgent("konqueror")){org.xmlBlaster.util.isKonqueror=true;}
org.xmlBlaster.util.XmlBlasterException=function(errorCodeStr,location_,rawMessage,isServerSide){this.errorCodeStr=errorCodeStr||"internal.unknown";this.errorCodeStrOrig="";this.location=location_||"";this.rawMessage=rawMessage||"-";this.embeddedMessage="";this.xmlBlasterServerSide=isServerSide||false;this.tomcatServerSide=false;this.getErrorCodeStr=function(){return this.errorCodeStr;}
this.setErrorCodeStr=function(str){var str=str||"user.internal";this.errorCodeStrOrig=this.errorCodeStr;this.errorCodeStr=str;}
this.isJavascriptSide=function(){return(this.tomcatServerSide==false&&this.xmlBlasterServerSide==false);}
this.isServerSide=function(){return(this.tomcatServerSide==true||this.xmlBlasterServerSide==true);}
this.isXmlBlasterServerSide=function(){return this.xmlBlasterServerSide;}
this.isTomcatServerSide=function(){return this.tomcatServerSide;}
this.setTomcatServerSide=function(serverSide){this.tomcatServerSide=org.xmlBlaster.util.toBoolean(serverSide,false);if(this.tomcatServerSide)
this.xmlBlasterServerSide=false;}
this.setXmlBlasterServerSide=function(serverSide){this.xmlBlasterServerSide=org.xmlBlaster.util.toBoolean(serverSide,true);if(this.xmlBlasterServerSide)
this.tomcatServerSide=false;}
this.setLocation=function(location){this.location=location||"";}
this.getLocation=function(){return this.location;}
this.getRawMessage=function(){return this.rawMessage;}
this.getMessage=function(){return this.getRawMessage();}
this.setEmbeddedMessage=function(embeddedMessage){this.embeddedMessage=embeddedMessage||"";var start=this.embeddedMessage.indexOf("errorCode=");if(start>=0&&this.embeddedMessage.length>11){this.errorCodeStr=this.embeddedMessage.substring(start+10);var end=this.errorCodeStr.indexOf(" ");if(end>0)
this.errorCodeStr=this.errorCodeStr.substring(0,end);}}
this.setMessage=function(rawMessage){this.rawMessage=rawMessage||"";var start=this.rawMessage.indexOf("errorCode=");if(start>=0){var tmp=this.rawMessage.substring(start+9);var end=tmp.indexOf(": ");if(end>0&&(end+2)<tmp.length)
this.rawMessage=tmp.substring(end+2);}}
this.toString=function(){var text="errorCode="+this.getErrorCodeStr()+" message="+this.getRawMessage();return text;}}
org.xmlBlaster.util.toHex=function(decimal){var hexChars="0123456789ABCDEFabcdef";return"%"+hexChars.charAt(decimal>>4)+hexChars.charAt(decimal&0xF);}
org.xmlBlaster.util.encodeToUTF8=function(decoded){var unreserved="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~:@&=+$,/?%#";var encoded="";for(var i=0;i<decoded.length;i++){var ch=decoded.charAt(i);if(unreserved.indexOf(ch)!=-1){encoded=encoded+ch;}else{var charcode=decoded.charCodeAt(i);if(charcode<128){encoded=encoded+org.xmlBlaster.util.toHex(charcode);}
if(charcode>127&&charcode<2048){encoded=encoded+org.xmlBlaster.util.toHex((charcode>>6)|0xC0);encoded=encoded+org.xmlBlaster.util.toHex((charcode&0x3F)|0x80);}
if(charcode>2047&&charcode<65536){encoded=encoded+org.xmlBlaster.util.toHex((charcode>>12)|0xE0);encoded=encoded+org.xmlBlaster.util.toHex(((charcode>>6)&0x3F)|0x80);encoded=encoded+org.xmlBlaster.util.toHex((charcode&0x3F)|0x80);}
if(charcode>65535){encoded=encoded+org.xmlBlaster.util.toHex((charcode>>18)|0xF0);encoded=encoded+org.xmlBlaster.util.toHex(((charcode>>12)&0x3F)|0x80);encoded=encoded+org.xmlBlaster.util.toHex(((charcode>>6)&0x3F)|0x80);encoded=encoded+org.xmlBlaster.util.toHex((charcode&0x3F)|0x80);}}}
return encoded;}
org.xmlBlaster.util.setupParameters=function(){var parameters=new Object();if(window.location.search){parameters=org.xmlBlaster.util.splitParameters(window.location.search.substr(1));}
window.location.parameters=parameters;}
org.xmlBlaster.util.splitParameters=function(str){var parameters=new Object();var paramArray=str.split('&');var length=paramArray.length;for(var index=0;index<length;index++){var param=paramArray[index].split('=');var name=param[0];var value=typeof param[1]=="string"?decodeURIComponent(param[1].replace(/\+/g,' ')):true;parameters[name]=value;}
return parameters;}
org.xmlBlaster.util.getParameter=function(name,defaultVal){var defaultVal=org.xmlBlaster.util.isDefined(defaultVal)?defaultVal:null;if(typeof window.location.parameters=="undefined")
org.xmlBlaster.util.setupParameters();var ret=window.location.parameters[name];if(org.xmlBlaster.util.isDefined(ret)){if(org.xmlBlaster.util.isDefined(defaultVal)&&(defaultVal===true||defaultVal===false||defaultVal instanceof Boolean)){return org.xmlBlaster.util.parseBoolean(ret);}
return ret;}
return defaultVal;}
org.xmlBlaster.util.createCookie=function(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";return document.cookie;}
org.xmlBlaster.util.readCookie=function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
org.xmlBlaster.util.eraseCookie=function(name){createCookie(name,"",-1);}
var ME1="xmlBlaster.js: ";org.xmlBlaster.util.isDefined=function(variable){if(variable===undefined)
return false;if(variable===true||variable===false)return true;if(variable==null)
return false;return true;}
org.xmlBlaster.util.getUniqueCounter=function(){return org.xmlBlaster.util.uniqueCounter++;}
org.xmlBlaster.util.getHash=function(obj){if(!org.xmlBlaster.util.isDefined(obj))
return org.xmlBlaster.util.getUniqueCounter();if(org.xmlBlaster.util.isDefined(obj.___hash))
return obj.___hash;obj.___hash=org.xmlBlaster.util.getUniqueCounter();return obj.___hash;}
org.xmlBlaster.util.isFilled=function(variable){if(org.xmlBlaster.util.isDefined(variable)){if(org.xmlBlaster.util.isDefined(variable.length))
return(variable.length>0);else
return true;}}
org.xmlBlaster.util.parseBoolean=function(boolString,defaultVal){return org.xmlBlaster.util.toBoolean(boolString,defaultVal);}
org.xmlBlaster.util.toBoolean=function(variable,defaultVal){if(org.xmlBlaster.util.isFilled(variable)){if(typeof variable=="boolean")
return variable==true;if(variable===true||variable===false)
return variable;if(variable==true)
return true;if((""+variable).toLowerCase()=="true")
return true;return false;}
return org.xmlBlaster.util.isDefined(defaultVal)?defaultVal:false;}
org.xmlBlaster.util.toBooleanRelaxed=function(variable,defaultVal){if(org.xmlBlaster.util.isFilled(variable)){if(typeof variable=="boolean")
return variable==true;if(variable===true||variable===false)
return variable;if(variable==true)
return true;var str=(""+variable).toLowerCase();if(str=="true"||str=="1"||str=="on")
return true;return false;}
return org.xmlBlaster.util.isDefined(defaultVal)?defaultVal:false;}
org.xmlBlaster.util.isBoolean=function(variable){if(variable===undefined||variable==null)
return false;if(typeof variable=="boolean")
return true;if(variable===true||variable===false)
return true;if(variable==true)
return true;return false;}
org.xmlBlaster.util.toNumber=function(variable,defaultVal){if(!org.xmlBlaster.util.isDefined(defaultVal))
defaultVal=0;if(!org.xmlBlaster.util.isDefined(variable))
return defaultVal;if(typeof variable=="Number")
return variable.valueOf();var n=new Number(variable).valueOf();if(isNaN(n))
return defaultVal;return n;}
org.xmlBlaster.util.splitHtml=function(text,maxChars,separator){if(!org.xmlBlaster.util.isFilled(text))return"";var separator=org.xmlBlaster.util.isFilled(separator)?separator:"<br />";var maxChars=org.xmlBlaster.util.toNumber(maxChars,256);if(maxChars<20)maxChars=20;var count=0;for(var i=0;i<text.length;i++){if(count>maxChars&&text[i]==' '){text=text.substring(0,i)+separator+text.substring(i+1);count=0;continue;}
count++;}
return text;}
org.xmlBlaster.util.toNiceDistance=function(meters){var integer=Math.round(meters);if(integer<1000)return""+integer;var ret="";var str=""+integer;var len=str.length;for(i=0;i<len;i++){if((len-i)%3==0)
ret+="' ";ret+=str[i];}
return ret;}
org.xmlBlaster.util.round=function(number,decimals){var decimals=(decimals==undefined)?null:decimals;if(decimals!=null){if(decimals>12)
decimals=12;if(decimals<1){return Math.round(number);}
var P=Math.pow(10,decimals);var result=Math.round(number*P)/P;return result;}
return number;}
org.xmlBlaster.util.fillZero=function(str,width){if(str==null)
str="";var dif=width-str.length;var res="";for(var i=0;i<dif;i++){res+="0";}
res+=str;return res;}
org.xmlBlaster.util.getDOMDocument=function(xmlString){if(window.ActiveXObject){var doc=new ActiveXObject("Microsoft.XMLDOM");doc.async="false";doc.loadXML(xmlString);return doc;}
else{var parser=new DOMParser();var doc=parser.parseFromString(xmlString,"text/xml");return doc;}}
org.xmlBlaster.util.getDateFromIsoDateStr=function(isoDateStr,defaultToCurrentDate){var defaultToCurrentDate=org.xmlBlaster.util.toBoolean(defaultToCurrentDate,true);if(!org.xmlBlaster.util.isFilled(isoDateStr))
return(defaultToCurrentDate?new Date():null);var space=isoDateStr.indexOf(" ");if(space>0)
isoDateStr=isoDateStr.substring(0,space)+"T"+isoDateStr.substring(space+1);var regexp="([0-9]{4})(-([0-9]{2})(-([0-9]{2})"+"(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?"+"(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";var d=isoDateStr.match(new RegExp(regexp));if(!org.xmlBlaster.util.isFilled(d))
return(defaultToCurrentDate?new Date():null);var offset=0;var date=new Date(d[1],0,1);if(d[3]){date.setMonth(d[3]-1);}
if(d[5]){date.setDate(d[5]);}
if(d[7]){date.setHours(d[7]);}
if(d[8]){date.setMinutes(d[8]);}
if(d[10]){date.setSeconds(d[10]);}
if(d[12]){date.setMilliseconds(Number("0."+d[12])*1000);}
if(d[14]){offset=(Number(d[16])*60)+Number(d[17]);offset*=((d[15]=='-')?1:-1);}
offset-=date.getTimezoneOffset();time=(Number(date)+(offset*60*1000));var date=new Date();date.setTime(Number(time));return date;}
org.xmlBlaster.util.getTimeStrFromIsoDateStr=function(isoDateStr){if(!org.xmlBlaster.util.isFilled(isoDateStr))
return"";var index=isoDateStr.indexOf(" ");if(index==-1)
index=isoDateStr.indexOf("T");if(index==-1)
return isoDateStr;var time=isoDateStr.substr(index+1);return time.substr(0,8);}
org.xmlBlaster.util.getDateStrFromIsoDateStr=function(isoDateStr){if(!org.xmlBlaster.util.isFilled(isoDateStr))
return"";var index=isoDateStr.indexOf(" ");if(index==-1)
index=isoDateStr.indexOf("T");if(index==-1)
return isoDateStr;var time=isoDateStr.substr(0,index);return time;}
org.xmlBlaster.util.getLocalDateFromGmt=function(gmt){var da=gmt||new Date();return da;}
org.xmlBlaster.util.getCurrentGmtDate=function(da_){var da=da_||new Date();return da;}
org.xmlBlaster.util.getTimezoneOffsetMinutes=function(da){var d=da||new Date();var localOffset=d.getTimezoneOffset();return localOffset;}
org.xmlBlaster.util.getLocaleId=function(){var id="";if(navigator){if(navigator.language){id=navigator.language;}
else if(navigator.browserLanguage){id=navigator.browserLanguage;}
else if(navigator.systemLanguage){id=navigator.systemLanguage;}
else if(navigator.userLanguage){id=navigator.userLanguage;}}
return id;}
org.xmlBlaster.util.getLocaleIdJava=function(){var id=org.xmlBlaster.util.getLocaleId();id=org.xmlBlaster.util.replaceAllTokens(id,"-","_");return id;}
org.xmlBlaster.util.getDateStr=function(da_){var da=da_||new Date();var dy=da.getFullYear()
var dm=da.getMonth()+1
var dd=da.getDate()
if(dy<1970)dy=dy+100;var ys=new String(dy)
var ms=new String(dm)
var ds=new String(dd)
if(ms.length==1)ms="0"+ms;if(ds.length==1)ds="0"+ds;var iso=ys+"-"+ms+"-"+ds;return iso;}
org.xmlBlaster.util.getTimeStr=function(da_,withSeconds){var da=da_||new Date();var withSeconds=org.xmlBlaster.util.toBoolean(withSeconds,true);var hourS=new String(da.getHours());var minS=new String(da.getMinutes());var secS=new String(da.getSeconds());var iso="";if(hourS.length==1)iso+="0";iso+=da.getHours();iso+=":";if(minS.length==1)iso+="0";iso+=da.getMinutes();if(withSeconds){iso+=":";if(secS.length==1)iso+="0";iso+=da.getSeconds();}
return iso;}
org.xmlBlaster.util.getCurrentIsoGmtTimestampStr=function(da_,withMillis,withT){var withT=org.xmlBlaster.util.toBoolean(withT,true);var da=da_||new Date();var dy=da.getUTCFullYear()
var dm=da.getUTCMonth()+1
var dd=da.getUTCDate()
if(dy<1970)dy=dy+100;var ys=new String(dy)
var ms=new String(dm)
var ds=new String(dd)
if(ms.length==1)ms="0"+ms;if(ds.length==1)ds="0"+ds;var iso=ys+"-"+ms+"-"+ds;var hourS=new String(da.getUTCHours());var minS=new String(da.getUTCMinutes());var secS=new String(da.getUTCSeconds());iso+=(withT?"T":" ");if(hourS.length==1)iso+="0";iso+=da.getUTCHours();iso+=":";if(minS.length==1)iso+="0";iso+=da.getUTCMinutes();iso+=":";if(secS.length==1)iso+="0";iso+=da.getUTCSeconds();if(org.xmlBlaster.util.toBoolean(withMillis,false))
iso+="."+da.getUTCMilliseconds();iso+="Z";return iso;}
org.xmlBlaster.util.getCurrentIsoLocalTimestampStr=function(da_,withMillis,withT){var withT=org.xmlBlaster.util.toBoolean(withT,true);var da=da_||new Date();var millis=Date.valueOf();var dy=da.getFullYear()
var dm=da.getMonth()+1
var dd=da.getDate()
if(dy<1970)dy=dy+100;var ys=new String(dy)
var ms=new String(dm)
var ds=new String(dd)
if(ms.length==1)ms="0"+ms;if(ds.length==1)ds="0"+ds;var iso=ys+"-"+ms+"-"+ds;var hourS=new String(da.getHours());var minS=new String(da.getMinutes());var secS=new String(da.getSeconds());iso+=(withT?"T":" ");if(hourS.length==1)iso+="0";iso+=da.getHours();iso+=":";if(minS.length==1)iso+="0";iso+=da.getMinutes();iso+=":";if(secS.length==1)iso+="0";iso+=da.getSeconds();if(org.xmlBlaster.util.toBoolean(withMillis,false))
iso+="."+da.getUTCMilliseconds();var localOffset=da.getTimezoneOffset();if(localOffset==0){iso+="Z";return iso;}
localOffset*=-1;var minutes=Math.abs(localOffset)%60;if(minutes==0){minutes="00";}
else if(minutes<10){minutes="0"+(""+minutes);}
var hour=Math.abs(localOffset)/60;if(hour==0){hour==(localOffset>0)?"+00":"-00";}
else if(hour<10){hour=((localOffset>0)?"+0":"-0")+hour;}
else{hour=((localOffset>0)?"+":"-")+hour;}
iso+=hour+":"+minutes;return iso;}
org.xmlBlaster.util.equals=function(str1,str2){if(!str1&&str2||str1&&!str2)return false;return""+str1===""+str2;}
org.xmlBlaster.util.replaceAllTokens=function(s,t,u){var i=s.indexOf(t);var r="";if(i==-1)return s;r+=s.substring(0,i)+u;if(i+t.length<s.length)
r+=org.xmlBlaster.util.replaceAllTokens(s.substring(i+t.length,s.length),t,u);return r;}
org.xmlBlaster.util.escapeXmlAttr=function(text){return org.xmlBlaster.util.escapeXml(text);}
org.xmlBlaster.util.escapeXml=function(text){if(!org.xmlBlaster.util.isDefined(text))return"";if(!org.xmlBlaster.util.isDefined(text.length)){return text;}
var length=text.length;var ret="";var i;for(i=0;i<length;i++){var c=text.charAt(i);switch(c){case'\0':ret+="&#x0;";break;case'&':ret+="&amp;";break;case'<':ret+="&lt;";break;case'>':ret+="&gt;";break;case'"':ret+="&quot;";break;case'\'':ret+="&apos;";break;case'\r':ret+="&#x0D;";break;default:ret+=c;}}
return ret;}
org.xmlBlaster.util.EventObject=function(type,data){this.type=type||"";this.data=data||null;this.getType=function(){return this.type;}
this.getData=function(){return this.data;}}
org.xmlBlaster.util.EventManager=function(){this.listeners={};this.addListener=function(type,func,obj){if(typeof type!=="string")
throw"org.xmlBlaster.util.EventManager.addListener("+type+"): '"+type+"' is not a string";if(typeof func!=="function")
throw"org.xmlBlaster.util.EventManager.addListener("+type+"): '"+func+"' is not a function";if(!org.xmlBlaster.util.isDefined(this.listeners[type]))
this.listeners[type]={};this.listeners[type][org.xmlBlaster.util.getHash(func)]={func:func,obj:obj};return func;}
this.removeListener=function(type,func){if(this.listeners[type]===undefined)
return;if(!org.xmlBlaster.util.isDefined(func)){delete this.listeners[type];return;}
if(typeof func!=="function")
throw new Error("org.xmlBlaster.util.EventManager.removeListener("+type+"): '"+func+"' is not a function");delete this.listeners[type][org.xmlBlaster.util.getHash(func)];}
this.hasListeners=function(type){return org.xmlBlaster.util.isDefined(this.listeners[type]);}
this.fireEvent=function(type,data){var ev=new org.xmlBlaster.util.EventObject(type,data);var ll=this.listeners[type];if(ll){for(var hash in ll){var obj=ll[hash].obj||this;ll[hash].func.call(obj,ev);}
return ll.length;}
return 0;}
this.clear=function(){this.listeners=null;this.listeners={};}
this.dispose=function(){this.listeners=null;this.listeners={};}}
theXmlBlasterEventManager=null;org.xmlBlaster.util.EventManager.getInstance=function(){if(theXmlBlasterEventManager==null){theXmlBlasterEventManager=new org.xmlBlaster.util.EventManager();}
return theXmlBlasterEventManager;}
org.xmlBlaster.util.ClientProperty=function(name,value,encoding){this.name=name;this.type="String";this.value=org.xmlBlaster.util.isFilled(value)?value:"";this.encoding=org.xmlBlaster.util.isFilled(encoding)?encoding:null;this.charset=null;this.getName=function(){return this.name;}
this.getEncoding=function(){return this.encoding;}
this.getCharset=function(){return this.charset;}
this.getValueRaw=function(){return this.value;}
this.getValueStr=function(){if(this.value==null||this.value.length==0)return"";if("base64"==this.encoding){var trimmedValue=org.xmlBlaster.util.trim(this.value);var content=org.xmlBlaster.util.Base64.decode(trimmedValue);org.xmlBlaster.util.log.debug(ME1+"Decoded base64");return content;}
return this.value;}
this.getValue=function(){var val=this.getValueStr();switch(this.type){case"boolean":return org.xmlBlaster.util.parseBoolean(val);break;case"double":case"float":case"int":case"short":case"long":return new Number(val).valueOf();break;case"byte":case"String":case"byte[]":return val;break;default:return val;break;}}
this.dump=function(){var str="<clientProperty";if(this.name!=null)str+=" name='"+this.name+"'";if(this.encoding!=null)str+=" encoding='"+this.encoding+"'";if(this.charset!=null)str+=" charset='"+this.charset+"'";str+=">";if(this.value!=null)str+=this.value;str+="</clientProperty>";return str;}}
org.xmlBlaster.util.SessionName=function(name,subjectId_,sessionId_,nodeId_){if(name==null&&org.xmlBlaster.util.isDefined(subjectId_)){this.origName=subjectId_;this.nodeId=nodeId_||"undefined";this.subjectId=subjectId_;this.pubSessionId=sessionId_||1;}
else{this.origName=name||"";var index=name.indexOf("/");if(index==-1){this.nodeId="undefined";if(name.length<1)
this.subjectId="undefined";else
this.subjectId=name;this.pubSessionId=0;}
else if(index==0){var arr=name.substring(1).split("/");this.nodeId=arr[1];this.subjectId=arr[3];if(arr.length>5)
this.pubSessionId=new Number(arr[5]).valueOf();else
this.pubSessionId=new Number(arr[4]).valueOf();}
else{var arr=name.split("/");this.nodeId="undefined";this.subjectId=arr[1];if(arr.length>2)
this.pubSessionId=new Number(arr[3]).valueOf();else
this.pubSessionId=new Number(arr[1]).valueOf();}}
this.getAbsoluteName=function(){return"/node/"+this.nodeId+"/"+this.getRelativeName();}
this.getNodeId=function(){return this.nodeId;}
this.getSubjectId=function(){return this.subjectId;}
this.getPubSessionId=function(){return this.pubSessionId;}
this.getRelativeName=function(){return"client/"+this.subjectId+"/session/"+this.pubSessionId;}
this.toString=function(){return this.getAbsoluteName();}}
org.xmlBlaster.util.parseServiceXml=function(domDocument){}
org.xmlBlaster.client.QosData=function(){this.stateId="OK";this.stateInfo="";this.sender="";this.priority=5;this.subscriptionId="";this.rcvTimestampNanos="";this.lifeTime=-1;this.remainingLife=-1;this.persistent=false;this.queueIndex=0;this.queueSize=1;this.redeliver=0;this.eraseKeyOid="";this.destinationQueryType=null;this.destinationStr=null;this.destinationForceQueuing=false;this.clientProperties=new org.xmlBlaster.util.Hashtable();this.getStateId=function(){return this.stateId;}
this.getStateInfo=function(){return this.stateInfo;}
this.getSender=function(){return new org.xmlBlaster.util.SessionName(this.sender);}
this.isPtp=function(){return(org.xmlBlaster.util.isDefined(this.destinationStr))};this.getDestination=function(){return(org.xmlBlaster.util.isDefined(this.destinationStr))?new org.xmlBlaster.util.SessionName(this.destinationStr):null;}
this.setDestinationStr=function(destination){this.destinationStr=destination;}
this.setDestination=function(sessionName){if(org.xmlBlaster.util.isDefined(sessionName))
this.destinationStr=sessionName.getAbsoluteName();else
this.destinationStr=null;}
this.getPriority=function(){return this.priority;}
this.getSubscriptionId=function(){return this.subscriptionId;}
this.getRcvTimestampNanos=function(){return this.rcvTimestampNanos;}
this.getLifeTime=function(){return this.lifeTime;}
this.getRemainingLife=function(){return this.remainingLife;}
this.isPersistent=function(){return this.persistent;}
this.getQueueIndex=function(){return this.queueIndex;}
this.getQueueSize=function(){return this.queueSize;}
this.getRedeliver=function(){return this.redeliver;}
this.getEraseKeyOid=function(){return this.eraseKeyOid;}
this.hasClientProperty=function(key){var cp=this.clientProperties.get(key);if(!org.xmlBlaster.util.isDefined(cp))return false;return true;}
this.setClientProperty=function(clientProperty){if(!org.xmlBlaster.util.isDefined(clientProperty))return null;return this.clientProperties.put(clientProperty.getName(),clientProperty);}
this.getClientProperties=function(){return this.clientProperties;}
this.getClientProperty=function(key,defaultValue){if(!org.xmlBlaster.util.isDefined(defaultValue))
defaultValue=null;var cp=this.clientProperties.get(key);if(!org.xmlBlaster.util.isDefined(cp))return defaultValue;return cp.getValue();}
this.dump=function(){var str="<qos>"+"<state id='"+this.stateId+"'"+" info='"+this.stateInfo+"'/>";if(org.xmlBlaster.util.isFilled(this.sender))
str+="<sender>"+this.sender+"</sender>";if(this.priority!=5)
str+="<priority>"+this.priority+"</priority>";if(org.xmlBlaster.util.isFilled(this.subscriptionId))
str+="<subscribe id='"+this.subscriptionId+"'/>";if(org.xmlBlaster.util.isFilled(this.rcvTimestampNanos))
str+="<rcvTimestamp nanos='"+this.rcvTimestampNanos+"'/>";if(this.lifeTime!=-1)
str+="<expiration lifeTime='"+this.lifeTime+"' remainingLife='"+this.remainingLife+"'/> ";if(org.xmlBlaster.util.isFilled(this.destinationStr))
str+="<destination forceQueuing='"+this.destinationForceQueuing+"'>"+this.destinationStr+"</destination>";if(this.queueIndex>0)
str+="<queue index='"+this.queueIndex+"' size='"+this.queueSize+"'/>";this.clientProperties.moveFirst();while(this.clientProperties.next()){str+=this.clientProperties.getValue().dump();}
str+="</qos>";return str;}
this.toXml=function(){return this.dump();}}
org.xmlBlaster.client.QosData.parse=function(domDocument,currentNode){var qosData=new org.xmlBlaster.client.QosData();for(var i=0;i<currentNode.childNodes.length;i++){var node=currentNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=org.xmlBlaster.util.isDefined(node.nodeValue)?node.nodeValue:"";var tmp=org.xmlBlaster.util.trim(val);if(tmp.length==0)continue;val=": '"+val+"'";var txt="QosData(): Ignoring xmlBlaster response node "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?org.xmlBlaster.util.log.debug(ME1+txt):org.xmlBlaster.util.log.warn(ME1+txt);continue;}
switch(node.nodeName){case"state":qosData.stateId=node.getAttribute('id');if(qosData.stateId==null)qosData.stateId="";qosData.stateInfo=node.getAttribute('info');if(qosData.stateInfo==null)qosData.stateInfo="";break;case"sender":qosData.sender=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"priority":var val=org.xmlBlaster.util.collectTextFromNodeChilds(node);qosData.priority=org.xmlBlaster.util.toNumber(val,qosData.priority);break;case"subscribe":qosData.subscriptionId=node.getAttribute('id');break;case"rcvTimestamp":qosData.rcvTimestampNanos=node.getAttribute('nanos');break;case"expiration":qosData.lifeTime=new Number(node.getAttribute('lifeTime')).valueOf();qosData.remainingLife=new Number(node.getAttribute('remainingLife')).valueOf();break;case"persistent":qosData.persistent=org.xmlBlaster.util.collectBooleanFromNodeChilds(node,qosData.persistent);break;case"queue":qosData.queueIndex=new Number(node.getAttribute('index')).valueOf();qosData.queueSize=new Number(node.getAttribute('size')).valueOf();break;case"redeliver":var val=org.xmlBlaster.util.collectTextFromNodeChilds(node);qosData.redeliver=org.xmlBlaster.util.toNumber(val,qosData.redeliver);break;case"route":org.xmlBlaster.util.log.debug(ME1+"QoS <route> tag parsing is not implemented");break;case"subscribable":org.xmlBlaster.util.log.error(ME1+"QoS <subscribable> tag parsing is not implemented");break;case"forceUpdate":org.xmlBlaster.util.log.error(ME1+"QoS <forceUpdate> tag parsing is not implemented");break;case"destination":qosData.destinationQueryType=node.getAttribute('queryType');qosData.destinationForceQueuing=org.xmlBlaster.util.parseBoolean(node.getAttribute('forceQueuing'));qosData.destinationStr=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"clientProperty":var cp=new org.xmlBlaster.util.ClientProperty(node.getAttribute('name'));if(node.getAttribute('type')!=null)cp.type=node.getAttribute('type');if(node.getAttribute('encoding')!=null)cp.encoding=node.getAttribute('encoding');if(node.getAttribute('charset')!=null)cp.charset=node.getAttribute('charset');cp.value=org.xmlBlaster.util.collectTextFromNodeChilds(node);qosData.clientProperties.put(cp.name,cp);break;case"key":var keyData=org.xmlBlaster.client.KeyData.parse(domDocument,node);qosData.eraseKeyOid=(keyData==null)?"":keyData.getOid();break;case"isSubscribe":case"isPublish":case"isUpdate":case"isUnSubscribe":case"isErase":case"isConnect":org.xmlBlaster.util.log.debug(ME1+"QosData(): Ignoring xmlBlaster response tag "+org.xmlBlaster.util.getXPathLocation(node,true));break;default:org.xmlBlaster.util.log.warn(ME1+"QosData(): Ignoring xmlBlaster response tag "+org.xmlBlaster.util.getXPathLocation(node,true));break;}}
return qosData;}
org.xmlBlaster.client.SessionQos=function(){this.sessionName=null;this.sessionTimeout=1000*60*60*24;this.maxSessions=10;this.clearSessions=false;this.reconnectSameClientOnly=false;this.sessionId="";this.getSessionName=function(){return this.sessionName;}
this.getSessionTimeout=function(){return this.sessionTimeout;}
this.getMaxSessions=function(){return this.maxSessions;}
this.getClearSessions=function(){return this.clearSessions;}
this.getReconnectSameClientOnly=function(){return this.reconnectSameClientOnly;}
this.getSessionId=function(){return this.sessionId;}
this.dump=function(){var str="<session";if(this.sessionName!=null)str+=" name='"+this.sessionName+"'";if(this.sessionTimeout!=null)str+=" timeout='"+this.sessionTimeout+"'";if(this.maxSessions!=null)str+=" maxSessions='"+this.maxSessions+"'";if(this.clearSessions!=null)str+=" clearSessions='"+this.clearSessions+"'";if(this.sessionId!=null)str+=" sessionId='"+this.sessionId+"'";str+="/>";return str;}}
org.xmlBlaster.client.SecurityService=function(){this.user=null;this.passwd=null;this.type="htpasswd";this.version="1.0";this.getType=function(){return this.type;}
this.getVersion=function(){return this.version;}
this.getUser=function(){return this.user;}
this.getPasswd=function(){return this.passwd;}
this.dump=function(){var str="<securityService type='"+this.type+"' version='"+this.version+"'>";str+="    <user>"+this.user+"</user>";str+="    <passwd>"+this.passwd+"</passwd>";str+="  </securityService>";return str;}}
org.xmlBlaster.util.extractFromTag=function(xml,tag){if(xml==null||tag==null)return null;var startToken="<"+tag+">";var endToken="</"+tag+">";var start=xml.indexOf(startToken);var end=xml.indexOf(endToken);if(start!=-1&&end!=-1){return xml.substring(start+startToken.length,end);}
return null;}
org.xmlBlaster.client.ConnectQosData=function(domDocument,currentNode){this.securityService=null;this.sessionQos=null;this.reconnected=false;this.priority=5;this.persistent=false;this.instanceId="";this.clientProperties=new org.xmlBlaster.util.Hashtable();for(var i=0;i<currentNode.childNodes.length;i++){var node=currentNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=org.xmlBlaster.util.isDefined(node.nodeValue)?node.nodeValue:"";var tmp=org.xmlBlaster.util.trim(val);if(tmp.length==0)continue;val=": '"+val+"'";var txt="ConnectQosData(): Ignoring xmlBlaster response node "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?org.xmlBlaster.util.log.debug(ME1+txt):org.xmlBlaster.util.log.warn(ME1+txt);continue;}
switch(node.nodeName){case"securityService":this.securityService=new org.xmlBlaster.client.SecurityService();if(node.getAttribute('type')!=null)
this.securityService.type=node.getAttribute('type');if(node.getAttribute('version')!=null)
this.securityService.version=node.getAttribute('version');for(var jj=0;jj<node.childNodes.length;jj++){var tmpNode=node.childNodes[jj];if(tmpNode.nodeType==Node.CDATA_SECTION_NODE){var valCdata=tmpNode.nodeValue;org.xmlBlaster.util.log.debug(ME1+"Parsing valCdata="+valCdata);this.securityService.user=org.xmlBlaster.util.extractFromTag(valCdata,"user");this.securityService.passwd=org.xmlBlaster.util.extractFromTag(valCdata,"passwd");break;}
var val=(tmpNode.firstChild)?tmpNode.firstChild.nodeValue:null;if(val!=null){if(tmpNode.nodeName=="user")
this.securityService.user=val;else if(tmpNode.nodeName=="passwd")
this.securityService.passwd=val;}}
break;case"session":this.sessionQos=new org.xmlBlaster.client.SessionQos();this.sessionQos.sessionName=new org.xmlBlaster.util.SessionName(node.getAttribute('name'));if(node.getAttribute('timeout')!=null)
this.sessionQos.sessionTimeout=new Number(node.getAttribute('timeout')).valueOf();if(node.getAttribute('maxSessions')!=null)
this.sessionQos.maxSessions=new Number(node.getAttribute('maxSessions')).valueOf();if(node.getAttribute('clearSessions')!=null)
this.sessionQos.clearSessions=org.xmlBlaster.util.parseBoolean(node.getAttribute('clearSessions'));if(node.getAttribute('reconnectSameClientOnly')!=null)
this.sessionQos.reconnectSameClientOnly=org.xmlBlaster.util.parseBoolean(node.getAttribute('reconnectSameClientOnly'));if(node.getAttribute('sessionId')!=null)
this.sessionQos.sessionId=node.getAttribute('sessionId');break;case"instanceId":this.instanceId=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"queue":org.xmlBlaster.util.log.debug(ME1+"ConnectQosData("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Parsing not implemented");break;case"serverRef":org.xmlBlaster.util.log.debug(ME1+"ConnectQosData("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Parsing not implemented");break;case"reconnected":this.reconnected=org.xmlBlaster.util.collectBooleanFromNodeChilds(node,this.reconnected);break;case"priority":var val=org.xmlBlaster.util.collectTextFromNodeChilds(node);this.priority=org.xmlBlaster.util.toNumber(val,this.priority);break;case"persistent":this.persistent=org.xmlBlaster.util.collectBooleanFromNodeChilds(node,this.persistent);break;case"clientProperty":var cp=new org.xmlBlaster.util.ClientProperty(node.getAttribute('name'));if(node.getAttribute('type')!=null)cp.type=node.getAttribute('type');if(node.getAttribute('encoding')!=null)cp.encoding=node.getAttribute('encoding');if(node.getAttribute('charset')!=null)cp.charset=node.getAttribute('charset');cp.value=org.xmlBlaster.util.collectTextFromNodeChilds(node);this.clientProperties.put(cp.name,cp);break;default:org.xmlBlaster.util.log.warn(ME1+"ConnectQosData(): Ignoring xmlBlaster response tag "+org.xmlBlaster.util.getXPathLocation(node,true));break;}}
this.getSecurityService=function(){return this.securityService;}
this.getSessionQos=function(){return this.sessionQos;}
this.getInstanceId=function(){return this.instanceId;}
this.isReconnected=function(){return this.reconnected;}
this.getPriority=function(){return this.priority;}
this.isPersistent=function(){return this.persistent;}
this.hasClientProperty=function(key){var cp=this.clientProperties.get(key);if(!org.xmlBlaster.util.isDefined(cp))return false;return true;}
this.getClientProperty=function(key,defaultValue){if(defaultValue==undefined)
return this.clientProperties.get(key);var cp=this.clientProperties.get(key);if(cp==undefined||cp==null)return defaultValue;return cp.getValue();}
this.dump=function(){var str="<qos>";if(this.securityService!=null)str+=this.securityService.dump();if(this.sessionQos!=null)str+=this.sessionQos.dump();str+="<persistent>"+this.persistent+"</persistent>";str+="<priority>"+this.priority+"</priority>";this.clientProperties.moveFirst();while(this.clientProperties.next()){str+=this.clientProperties.getValue().dump();}
str+="</qos>";return str;}}
org.xmlBlaster.client.KeyData=function(oid,contentMime,contentMimeExtended,domain){this.oid=org.xmlBlaster.util.isDefined(oid)?oid:null;this.contentMime=org.xmlBlaster.util.isDefined(contentMime)?contentMime:null;this.contentMimeExtended=org.xmlBlaster.util.isDefined(contentMimeExtended)?contentMimeExtended:null;this.queryType=null;this.domain=org.xmlBlaster.util.isDefined(domain)?domain:null;this.queryString="";this.getOid=function(){return this.oid}
this.getContentMime=function(){return this.contentMime;}
this.getContentMimeExtended=function(){return this.contentMimeExtended;}
this.getDomain=function(){return this.domain;}
this.setDomain=function(domain){this.domain=domain;}
this.getQueryType=function(){if(this.queryType==null)this.queryType="EXACT";return this.queryType;}
this.setQueryType=function(queryType){this.queryType=queryType;}
this.getQueryString=function(){return this.queryString;}
this.setQueryString=function(queryString){this.queryString=queryString;}
this.isExact=function(){return"EXACT"==this.queryType;}
this.isQuery=function(){return"XPATH"==this.queryType||"REGEX"==this.queryType;}
this.isXPath=function(){return"XPATH"==this.queryType;}
this.isDomain=function(){return"DOMAIN"==this.queryType;}
this.getUrl=function(){if(this.isExact())
return"exact:"+this.oid;else if(this.isXPath())
return"xpath:"+this.queryString;else if(this.isDomain())
return"domain:"+this.domain;else
return this.oid;};this.dump=function(){var str="<key oid='"+this.oid+"'";if(this.contentMime!=null)str+=" contentMime='"+this.contentMime+"'";if(this.contentMimeExtended!=null)str+=" contentMimeExtended='"+this.contentMimeExtended+"'";if(this.domain!=null)str+=" domain='"+this.domain+"'";if(this.queryType!=null&&this.queryType!="EXACT")str+=" queryType='"+this.queryType+"'";if(this.queryString!=null&&this.queryString!=""){str+=">"+this.queryString+"</key>";}
else{str+="/>";}
return str;}
this.toXml=function(){return this.dump();}}
org.xmlBlaster.client.KeyData.parse=function(domDocument,currentNode){var keyData=new org.xmlBlaster.client.KeyData();keyData.oid=currentNode.getAttribute('oid');keyData.contentMime=currentNode.getAttribute('contentMime');keyData.contentMimeExtended=currentNode.getAttribute('contentMimeExtended');keyData.queryType=currentNode.getAttribute('queryType');keyData.domain=currentNode.getAttribute('domain');keyData.queryString=(currentNode.firstChild==null)?"":currentNode.firstChild.nodeValue;return keyData;}
org.xmlBlaster.util.MsgUnit=function(methodName,qosData,keyData,content){this.sessionId="";this.methodName=methodName||"";this.xmlBlasterException=null;this.qosData=qosData;this.keyData=keyData||null;this.content=content||"";this.isConnect=function(){return("connect"==this.methodName);}
this.isException=function(){return("exception"==this.methodName);}
this.isUpdate=function(){return("update"==this.methodName);}
this.isGet=function(){return("get"==this.methodName);}
this.isSubscribe=function(){return("subscribe"==this.methodName);}
this.isUnSubscribe=function(){return("unSubscribe"==this.methodName);}
this.isPublish=function(){return("publish"==this.methodName);}
this.isErase=function(){return("erase"==this.methodName);}
this.getXmlBlasterException=function(){return this.xmlBlasterException;};this.getSessionId=function(){return this.sessionId;};this.getQosData=function(){return this.qosData;};this.getKeyData=function(){return this.keyData;};this.getContentStr=function(){return this.content;};this.dump=function(){var str="<"+this.methodName+">\n";if(this.qosData!=null)str+=this.qosData.dump();if(this.keyData!=null)str+="\n"+this.keyData.dump();if(this.content.length>0)str+="\n<content>"+this.content+"</content>";str+="\n</"+this.methodName+">";return str;}
this.toXml=function(){return this.dump();}}
org.xmlBlaster.util.collectNumberFromNodeChilds=function(node,defaultVal){var defaultVal=org.xmlBlaster.util.toNumber(defaultVal,0);if(!org.xmlBlaster.util.isDefined(node))
return defaultVal;if(!org.xmlBlaster.util.isDefined(node.childNodes))
return defaultVal;var val=org.xmlBlaster.util.collectTextFromNodeChilds(node);val=org.xmlBlaster.util.trim(val);return org.xmlBlaster.util.toNumber(val,defaultVal);}
org.xmlBlaster.util.collectBooleanFromNodeChilds=function(node,defaultVal){var defaultVal=org.xmlBlaster.util.toBoolean(defaultVal,false);if(!org.xmlBlaster.util.isDefined(node))
return defaultVal;if(!org.xmlBlaster.util.isDefined(node.childNodes))
return defaultVal;var val=org.xmlBlaster.util.collectTextFromNodeChilds(node);val=org.xmlBlaster.util.trim(val);if(val=="")return true;return org.xmlBlaster.util.toBoolean(val,defaultVal);}
org.xmlBlaster.util.collectTextFromNodeChilds=function(node,defaultVal){var text=(org.xmlBlaster.util.isDefined(defaultVal))?defaultVal:"";if(!org.xmlBlaster.util.isDefined(node))
return text;if(!org.xmlBlaster.util.isDefined(node.childNodes))
return text;for(var i=0,l=node.childNodes.length;i<l;i++){var n=node.childNodes[i];var value=n.nodeValue;if(value==null)
value=n.text;if(i==0){var index=org.xmlBlaster.util.trim(value).indexOf("<![CDATA[");if(index==0){return org.xmlBlaster.util.serializeNode(node.childNodes[1]);}}
text+=value;}
return text;}
org.xmlBlaster.util.serializeNode=function(node){if(!org.xmlBlaster.util.isDefined(node))
return"";if(typeof XMLSerializer!='undefined'){return new XMLSerializer().serializeToString(node);}
else if(typeof node.xml!='undefined'){return node.xml;}
else if(typeof printNode!='undefined'){return printNode(node);}
else if(typeof Packages!='undefined'){try{var stringWriter=new java.io.StringWriter();Packages.org.apache.batik.dom.util.DOMUtilities.writeNode(node,stringWriter);return stringWriter.toString();}
catch(e){throw"Browser does not support to serialize xml node";}}
else{throw"Browser does not support to serialize xml node";}}
org.xmlBlaster.util.parseMsgUnit=function(domDocument,currentNode,methodName){var msgUnit=new org.xmlBlaster.util.MsgUnit(methodName);var msgUnits=new Array();for(var i=0;i<currentNode.childNodes.length;i++){var node=currentNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=org.xmlBlaster.util.isDefined(node.nodeValue)?node.nodeValue:"";var tmp=org.xmlBlaster.util.trim(val);if(tmp.length==0)continue;val=": '"+val+"'";var txt="parseMsgUnit(): Ignoring xmlBlaster response node "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?org.xmlBlaster.util.log.debug(ME1+txt):org.xmlBlaster.util.log.warn(ME1+txt);continue;}
switch(node.nodeName){case"sessionId":msgUnit.sessionId=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"qos":var hasParsedQos=org.xmlBlaster.util.isDefined(msgUnit.qosData);if(hasParsedQos){msgUnit=new org.xmlBlaster.util.MsgUnit(methodName);}
if(methodName=="connect")
msgUnit.qosData=new org.xmlBlaster.client.ConnectQosData(domDocument,node);else
msgUnit.qosData=org.xmlBlaster.client.QosData.parse(domDocument,node);msgUnits.push(msgUnit);break;case"key":msgUnit.keyData=org.xmlBlaster.client.KeyData.parse(domDocument,node);break;case"content":var cp=new org.xmlBlaster.util.ClientProperty('content');if(node.getAttribute('type')!=null)cp.type=node.getAttribute('type');if(node.getAttribute('encoding')!=null)cp.encoding=node.getAttribute('encoding');if(node.getAttribute('charset')!=null)cp.charset=node.getAttribute('charset');cp.value=org.xmlBlaster.util.collectTextFromNodeChilds(node);msgUnit.content=cp.getValue();break;default:org.xmlBlaster.util.log.warn(ME1+"parseMsgUnit(): Ignoring xmlBlaster response tag "+org.xmlBlaster.util.getXPathLocation(node,true));break;}}
if(msgUnits.length==0)msgUnits.push(msgUnit);return msgUnits;}
if(!window.Node||!window.Node.ELEMENT_NODE){var Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};}
org.xmlBlaster.util.getNodeTypeName=function(nodeType){switch(nodeType){case Node.ELEMENT_NODE:return"ELEMENT_NODE";break;case Node.ATTRIBUTE_NODE:return"ATTRIBUTE_NODE";break;case Node.TEXT_NODE:return"TEXT_NODE";break;case Node.CDATA_SECTION_NODE:return"CDATA_SECTION_NODE";break;case Node.ENTITY_REFERENCE_NODE:return"ENTITY_REFERENCE_NODE";break;case Node.ENTITY_NODE:return"ENTITY_NODE";break;case Node.PROCESSING_INSTRUCTION_NODE:return"PROCESSING_INSTRUCTION_NODE";break;case Node.COMMENT_NODE:return"COMMENT_NODE";break;case Node.DOCUMENT_NODE:return"DOCUMENT_NODE";break;case Node.DOCUMENT_TYPE_NODE:return"DOCUMENT_TYPE_NODE";break;case Node.DOCUMENT_FRAGMENT_NODE:return"DOCUMENT_FRAGMENT_NODE";break;case Node.NOTATION_NODE:return"NOTATION_NODE";break;default:return nodeType;}}
org.xmlBlaster.util.getXPathLocation=function(node,addTypeInfo){if(node==null)return"";var origNode=node;var text=node.nodeName;while(node.parentNode){node=node.parentNode;if(node.nodeType==Node.DOCUMENT_NODE||node.nodeType==Node.DOCUMENT_TYPE_NODE||node.nodeType==Node.DOCUMENT_FRAGMENT_NODE)break;text=node.nodeName+"/"+text;}
if(addTypeInfo&&addTypeInfo==true)
text+="-"+org.xmlBlaster.util.getNodeTypeName(origNode.nodeType)+":"+origNode.nodeType;text="/"+text;return text;}
org.xmlBlaster.util.parseXmlBlasterResponse=function(domDocument){var rootNode=domDocument.documentElement;var msgUnits=new Array();if(!org.xmlBlaster.util.isDefined(rootNode)){org.xmlBlaster.util.log.error(ME1+" parseXmlBlasterResponse rootNode==null");return msgUnits;}
if(rootNode.nodeName=="parsererror"){var val=org.xmlBlaster.util.isDefined(rootNode.nodeValue)?(": "+rootNode.nodeValue):"";var val2=(rootNode.childNodes.length>0&&org.xmlBlaster.util.isDefined(rootNode.childNodes[0].nodeValue))?(": "+rootNode.childNodes[0].nodeValue):"";var txt="parseXmlBlasterResponse(): Illegal xmlBlaster response ("+rootNode.nodeName+" type="+org.xmlBlaster.util.getNodeTypeName(rootNode.nodeType)+val+val2;org.xmlBlaster.util.log.error(ME1+txt);alert(txt);return msgUnits;}
for(var i=0;i<rootNode.childNodes.length;i++){var node=rootNode.childNodes[i];org.xmlBlaster.util.log.debug(ME1+"parseXmlBlasterResponse("+org.xmlBlaster.util.getXPathLocation(node,true)+"): parsing now ...");if(node.nodeType!=Node.ELEMENT_NODE){var val=org.xmlBlaster.util.isDefined(node.nodeValue)?node.nodeValue:"";var tmp=org.xmlBlaster.util.trim(val);if(tmp.length==0)continue;val=": '"+val+"'";var txt="parseXmlBlasterResponse(): Ignoring xmlBlaster response node "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?org.xmlBlaster.util.log.debug(ME1+txt):org.xmlBlaster.util.log.warn(ME1+txt);continue;}
switch(node.nodeName){case"exception":var msgUnit=new org.xmlBlaster.util.MsgUnit(node.nodeName);msgUnit.xmlBlasterException=new org.xmlBlaster.util.XmlBlasterException();var ex=msgUnit.xmlBlasterException;ex.setTomcatServerSide(true);if(node.getAttribute('errorCode')!=null)ex.errorCodeStr=node.getAttribute('errorCode');var nodeList=node.getElementsByTagName("message");if(nodeList!=null&&nodeList.length>0&&nodeList[0].firstChild)
ex.setMessage(nodeList[0].firstChild.nodeValue);var nodeList=node.getElementsByTagName("embeddedMessage");if(nodeList!=null&&nodeList.length>0&&nodeList[0].firstChild)
ex.setEmbeddedMessage(nodeList[0].firstChild.nodeValue);var nodeList=node.getElementsByTagName("location");if(nodeList!=null&&nodeList.length>0&&nodeList[0].firstChild)
ex.setLocation(nodeList[0].firstChild.nodeValue);var nodeList=node.getElementsByTagName("isServerSide");if(nodeList!=null&&nodeList.length>0&&nodeList[0].firstChild){var isServerSide=org.xmlBlaster.util.parseBoolean(nodeList[0].firstChild.nodeValue,true);if(isServerSide==true)
ex.setXmlBlasterServerSide(true);else
ex.setTomcatServerSide(true);}
msgUnits.push(msgUnit);break;case"update":case"publish":case"subscribe":case"connect":var msgUnitArr=org.xmlBlaster.util.parseMsgUnit(domDocument,node,node.nodeName);if(msgUnitArr.length>0){if(log4javascript.Level.DEBUG==org.xmlBlaster.util.log.getLevel())
org.xmlBlaster.util.log.debug(ME1+"parseXmlBlasterResponse() Parsed: "+msgUnitArr[0].dump());msgUnits.push(msgUnitArr[0]);}
else
org.xmlBlaster.util.log.warn(ME1+"parseXmlBlasterResponse("+org.xmlBlaster.util.getXPathLocation(node,true)+"): has empty MsgUnit");break;case"unSubscribe":case"erase":var msgUnitArr=org.xmlBlaster.util.parseMsgUnit(domDocument,node,node.nodeName);for(var jj=0;jj<msgUnitArr.length;jj++){org.xmlBlaster.util.log.debug(ME1+"Parsed: "+msgUnitArr[jj].dump());msgUnits.push(msgUnitArr[jj]);}
if(msgUnitArr.length==0)
org.xmlBlaster.util.log.warn(ME1+"parseXmlBlasterResponse("+org.xmlBlaster.util.getXPathLocation(node,true)+"): has empty MsgUnit");break;case"get":case"publishArr":for(var j=0;j<node.childNodes.length;j++){if(node.childNodes[j].nodeName!="message"){org.xmlBlaster.util.log.warn(ME1+"parseXmlBlasterResponse("+org.xmlBlaster.util.getXPathLocation(node.childNodes[j],true)+"): Ignoring xmlBlaster response tag");continue;}
var msgUnitArr=org.xmlBlaster.util.parseMsgUnit(domDocument,node.childNodes[j],node.nodeName);if(msgUnitArr.length>0){org.xmlBlaster.util.log.debug("Parsed: "+msgUnitArr[0].dump());msgUnits.push(msgUnitArr[0]);}
else
org.xmlBlaster.util.log.warn(ME1+"parseXmlBlasterResponse("+org.xmlBlaster.util.getXPathLocation(node.childNodes[j])+"): has empty MsgUnit");}
break;default:org.xmlBlaster.util.log.warn(ME1+"parseXmlBlasterResponse("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Ignoring xmlBlaster response tag");break;}}
return msgUnits;}
org.xmlBlaster.util.Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_base64Reverse:null,_createReverseLookup:function(){if(this._base64Reverse!=null){return this._base64Reverse;}
this._base64Reverse=[];for(var i=0,l=this._keyStr.length;i<l;i++){this._base64Reverse[this._keyStr.charAt(i)]=i;}
return this._base64Reverse;},encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=org.xmlBlaster.util.Base64._utf8_encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+
this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+
this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);}
return output;},decode:function(input){if(org.xmlBlaster.util.isIE){var output=[];var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");var reverse=this._createReverseLookup();var l=input.length;while(i<l){var enc1=reverse[input.charAt(i++)];var enc2=reverse[input.charAt(i++)];var enc3=reverse[input.charAt(i++)];var enc4=reverse[input.charAt(i++)];var chr1=(enc1<<2)|(enc2>>4);var chr2=((enc2&15)<<4)|(enc3>>2);var chr3=((enc3&3)<<6)|enc4;output.push(String.fromCharCode(chr1));if(enc3!=64){output.push(String.fromCharCode(chr2));}
if(enc4!=64){output.push(String.fromCharCode(chr3));}}
return org.xmlBlaster.util.Base64._utf8_decode(output.join(""));}else{var output="";var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");var reverse=this._createReverseLookup();var l=input.length;while(i<l){var enc1=reverse[input.charAt(i++)];var enc2=reverse[input.charAt(i++)];var enc3=reverse[input.charAt(i++)];var enc4=reverse[input.charAt(i++)];var chr1=(enc1<<2)|(enc2>>4);var chr2=((enc2&15)<<4)|(enc3>>2);var chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
if(enc4!=64){output=output+String.fromCharCode(chr3);}}
output=org.xmlBlaster.util.Base64._utf8_decode(output);return output;}},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;},_utf8_decode:function(utftext){if(org.xmlBlaster.util.isIE){var buf=[];var i=0;var l=utftext.length;while(i<l){var c=utftext.charCodeAt(i);if(c<128){buf.push(String.fromCharCode(c));i++;}
else
if((c>191)&&(c<224)){var c2=utftext.charCodeAt(i+1);buf.push(String.fromCharCode(((c&31)<<6)|(c2&63)));i+=2;}
else{var c2=utftext.charCodeAt(i+1);var c3=utftext.charCodeAt(i+2);buf.push(String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63)));i+=3;}}
return buf.join("");}else{var string="";var i=0;var l=utftext.length;while(i<l){var c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}
else
if((c>191)&&(c<224)){var c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{var c2=utftext.charCodeAt(i+1);var c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;}}}
org.xmlBlaster.util.trimFront=function(value){if(value==undefined||value==null)return null;var re=/\s*((\S+\s*)*)/;return value.replace(re,"$1");}
org.xmlBlaster.util.trimEnd=function(value){if(value==undefined||value==null)return null;var re=/((\s*\S+)*)\s*/;return value.replace(re,"$1");}
org.xmlBlaster.util.trim=function(value){if(value==undefined||value==null)return null;return org.xmlBlaster.util.trimFront(org.xmlBlaster.util.trimEnd(value));}
org.xmlBlaster.util.Hashtable=function(){this.hash=new Array();this.keys=new Array();this.location=0;}
org.xmlBlaster.util.Hashtable.prototype.hash=null;org.xmlBlaster.util.Hashtable.prototype.keys=null;org.xmlBlaster.util.Hashtable.prototype.location=null;org.xmlBlaster.util.Hashtable.parseCSV=function(csv){var hash=new org.xmlBlaster.util.Hashtable();var csv=csv||null;if(csv==null)return hash;var arr=csv.split(",");for(var i=0,l=arr.length;i<l;i++){var tuple=arr[i];var index=tuple.indexOf("=");if(index>=0){var key=tuple.substring(0,index);var value=tuple.substring(index+1);hash.put(key,org.xmlBlaster.util.replaceAllTokens(value,"&comma;",","));}
else{var key=tuple;var value=true;hash.put(key,value);}}
return hash;}
org.xmlBlaster.util.Hashtable.prototype.toCSV=function(){try{var s=new Array(this.keys.length);for(var i=0;i<this.keys.length;i++){s[s.length]=this.keys[i];var v=this.hash[this.keys[i]];if(v!==undefined&&v!=null){s[s.length]="=";s[s.length]=v.toString();}
if(i!=this.keys.length-1)
s[s.length]=",";}}catch(e){}finally{}
return s.join("");}
org.xmlBlaster.util.Hashtable.prototype.sort=function(){this.keys.sort();}
org.xmlBlaster.util.Hashtable.prototype.sortByKeysIgnoreCase=function(ascending){var ascending=org.xmlBlaster.util.toBoolean(ascending,true);this.keys.sort(function(key1,key2){var obj1=key1.toLowerCase();var obj2=key2.toLowerCase();var returnVal;if(ascending){returnVal=(obj1>obj2)?1:((obj1==obj2)?0:-1);}
else{returnVal=(obj1<obj2)?1:((obj1==obj2)?0:-1);}
return returnVal;});}
org.xmlBlaster.util.Hashtable.prototype.getKeys=function(){return this.keys;}
org.xmlBlaster.util.Hashtable.prototype.getValues=function(){var arr=new Array();for(var i=0,l=this.keys.length;i<l;i++)
arr.push(this.hash[this.keys[i]]);return arr;}
org.xmlBlaster.util.Hashtable.prototype.put=function(key,value){if(typeof value=="undefined"||value==null)
return null;var oldValue=this.hash[key];if(oldValue==null)
this.keys[this.keys.length]=key;this.hash[key]=value;return oldValue;}
org.xmlBlaster.util.Hashtable.prototype.getBoolean=function(key,defaultValue){var value=this.get(key,defaultValue);return org.xmlBlaster.util.toBooleanRelaxed(value,defaultValue);}
org.xmlBlaster.util.Hashtable.prototype.getNumber=function(key,defaultValue){var value=this.get(key,defaultValue);return org.xmlBlaster.util.toNumber(value,defaultValue);}
org.xmlBlaster.util.Hashtable.prototype.get=function(key,defaultValue){var defaultValue=(defaultValue===undefined)?null:defaultValue;var val=this.hash[key];if(typeof val=="undefined"||val==null)
return defaultValue;if(defaultValue!=null){if(defaultValue.constructor==Number&&val.constructor!=Number)
return org.xmlBlaster.util.toNumber(val);else if(defaultValue.constructor==Boolean&&val.constructor!=Boolean)
return org.xmlBlaster.util.toBooleanRelaxed(val);}
return val.valueOf();}
org.xmlBlaster.util.Hashtable.prototype.contains=function(key){var val=this.hash[key];if(typeof val=="undefined")
return false;return true;}
org.xmlBlaster.util.Hashtable.prototype.remove=function(key){for(var i=0;i<this.keys.length;i++){if(key==this.keys[i]){var obj=this.hash[this.keys[i]];this.hash[this.keys[i]]=null;delete this.hash[this.keys[i]];this.keys.splice(i,1);return obj;}}
return null;}
org.xmlBlaster.util.Hashtable.prototype.clear=function(){var count=this.keys.length;this.hash.length=0;this.hash=new Array();this.keys.length=0;this.keys=new Array();this.location=0;return count;}
org.xmlBlaster.util.Hashtable.prototype.size=function(){return this.keys.length;}
org.xmlBlaster.util.Hashtable.prototype.next=function(){if(++this.location<this.keys.length)
return true;else
return false;}
org.xmlBlaster.util.Hashtable.prototype.moveFirst=function(){try{this.location=-1;}catch(e){}}
org.xmlBlaster.util.Hashtable.prototype.moveLast=function(){try{this.location=this.keys.length-1;}catch(e){}}
org.xmlBlaster.util.Hashtable.prototype.getKey=function(){try{return this.keys[this.location];}catch(e){return null;}}
org.xmlBlaster.util.Hashtable.prototype.getValue=function(){try{return this.hash[this.keys[this.location]];}catch(e){return null;}}
org.xmlBlaster.util.Hashtable.prototype.getKeyOfValue=function(value){for(var i=0;i<this.keys.length;i++)
if(this.hash[this.keys[i]]==value)
return this.keys[i]
return null;}
org.xmlBlaster.util.Hashtable.prototype.toString=function(){try{var s=new Array(this.keys.length);s[s.length]="{";for(var i=0;i<this.keys.length;i++){s[s.length]=this.keys[i];s[s.length]="=";var v=this.hash[this.keys[i]];if(v)
s[s.length]=v.toString();else
s[s.length]="null";if(i!=this.keys.length-1)
s[s.length]=", ";}}catch(e){}finally{s[s.length]="}";}
return s.join("");}
org.xmlBlaster.util.Hashtable.prototype.add=function(ht){try{ht.moveFirst();while(ht.next()){var key=ht.getKey();this.hash[key]=ht.getValue();var found=false;for(var i=0;i<this.keys.length;i++){if(this.keys[i]==key){found=true;break;}}
if(!found){this.keys[this.keys.length]=key;}}}catch(e){}finally{return this;}}
org.xmlBlaster.util.arrayToCsv=function(arr,seperator){if(arr===undefined)
return"";if(seperator===undefined||seperator==null||seperator.length<1)
seperator=",";var csv="";for(var i=0,l=arr.length;i<l;i++){if(i>0)
csv+=seperator;csv+=arr[i];}
return csv;}
org.xmlBlaster.util.FifoQueue=function(maxEntries){this.maxEntries=maxEntries;this.fifoQueue=new Array();this.getArray=function(){return this.fifoQueue;}
this.push=function(data){var old=null;if(this.fifoQueue.length>=this.maxEntries){old=this.pop();}
this.fifoQueue[this.fifoQueue.length]=data;return old;}
this.size=function(){return this.fifoQueue.length;}
this.pop=function(){var ret=null;if(this.fifoQueue.length>0){ret=this.fifoQueue[0];for(var i=0;i<this.fifoQueue.length-1;i++){this.fifoQueue[i]=this.fifoQueue[i+1];}
this.fifoQueue.length=this.fifoQueue.length-1;}
return ret;}
this.peekOldest=function(){var ret=null;if(this.fifoQueue.length>0){return this.fifoQueue[0];}
return null;}
this.peekNewest=function(){var ret=null;if(this.fifoQueue.length>0){return this.fifoQueue[this.fifoQueue.length-1];}
return null;}
this.setMaxEntries=function(newMax){if(newMax>this.maxEntries){this.maxEntries=newMax;return;}
var count=this.maxEntries-newMax;for(var i=0;i<count;i++){this.pop();}
this.maxEntries=newMax;}
this.getMaxEntries=function(){return this.maxEntries;}
this.clear=function(){var old=this.fifoQueue.length;this.fifoQueue.length=0;return old;}
this.dump=function(){var buf="Number of queue entries: "+this.fifoQueue.length+" of maxEntries="+this.maxEntries;for(var i=0;i<this.fifoQueue.length;i++){buf+="\n"+i+": "+this.fifoQueue[i];}
return buf;}}