// dynamic-lib: JavaScript function library for easy DOM, AJAX and more
// (c) Yves Goergen, http://beta.unclassified.de/code/html-css-js/dynamic-lib/
// See the website for licensing details.

var runtimeConfigStore={};setErrorMessages(true);function setErrorMessages(show){setConfigValue('showErrorMessages',show?true:false);setConfigValue('showErrorMessages.counter',0);}function errorMessage(msg,context){if(getConfigValue('showErrorMessages',false)&&msg!=""){if(getConfigValue('showErrorMessages.counter',0)>=3)return;if(!isSet(context))context="";var AFn="";for(var i=0;i<9+(context.length*0.85);i++)AFn+=String.fromCharCode(0xAF);setConfigValue('showErrorMessages.counter',getConfigValue('showErrorMessages.counter',0)+1);alert((context?"Context: "+context+"\n"+AFn+"\n":"")+msg);setConfigValue('showErrorMessages.counter',getConfigValue('showErrorMessages.counter',0)-1);}}function formatException(ex){try{var nbsp=String.fromCharCode(160);var nbsp8=nbsp+nbsp+nbsp+nbsp+nbsp+nbsp+nbsp+nbsp;var msg="";msg+="Exception: "+ex.name+"\n";msg+="Message: "+ex.message+"\n";if(ex.fileName)msg+="Code: "+ex.fileName+":"+ex.lineNumber+"\n";if(ex.stack)msg+="Stack:\n"+nbsp8+ex.stack.trim().replace(/\r/g,"").replace(/^((?:.*?\n){25}).*$/,"$1").replace(/(^|\n)(.{150}).*?(?=\n|$)/g,"$1$2").replace(/\n/g,"\n"+nbsp8)+"\n";return msg;}catch(ex2){if(ex2.stack)return "Error formatting exception: "+ex2+"\n\nInner exception: "+ex;else return "Error formatting exception:\n"+inspectObject(ex2,false,true)+"\nInner exception:\n"+inspectObject(ex,false,true);}}function isSet(o){return typeof o!="undefined"&&o!=null;}function isString(o){return typeof o=="string";}function isObject(o){return typeof o=="object";}function isArray(o){return typeof o=="object"&&o instanceof Array;}function isFunction(o){return typeof o=="function";}function isNumber(o){return typeof o=="number";}function isBoolean(o){return typeof o=="boolean";}function isNumeric(o){return isNumber(o)||isString(o)&&o.search(/^-?[0-9]+(.[0-9]+)?$/)!=-1;}function isEven(x){return isNumber(x)&&x%2==0;}function isOdd(x){return isNumber(x)&&x%2==1;}function isTrue(x){if(!isSet(x))return false;if(isString(x))return x.trim()!=""&&x.trim()!="0"&&x.trim().toLowerCase()!="false";if(isObject(x))return x!=null;if(isArray(x))return x.length>0;if(isNumber(x))return x!=0;if(isBoolean(x))return x;return false;}function includeSource(url){var script=document.createElement("script");script.setAttribute("type","text/javascript");script.setAttribute("src",url);document.getElementsByTagName("head")[0].appendChild(script);}function evalCode(code){try{eval(code);}catch(ex){errorMessage("Exception caught while eval'ing code:\n"+formatException(ex),"evalCode");}}function defer(f,t,clr){if(!this.memory)this.memory={};var id=this.memory.findValue(f);if(clr&&id){clearTimeout(id);this.memory[id]=undefined;}id=setTimeout(f,t);this.memory[id]=f;}function getLocalTimezone(){var localclock=new Date();return-localclock.getTimezoneOffset();}function getURLDirectoryName(url){return url.replace(/([^/]*)$/,"");}function getURLFileName(url){return url.replace(/^(.*\/)([^/]*)$/,"$2");}function formatNumber(num,dec){if(isNaN(num))return num;if(!isSet(dec))dec=0;var factor=Math.pow(10,dec);num=Math.round(num*factor)/factor;var str=num+"";if(dec>0){if(str.indexOf(".")==-1)str+=".";while(str.length-str.indexOf(".")-1<dec)str+="0";}return str.replace(/\./,",");}function setConfigValue(name,value){runtimeConfigStore[name]=value;}function getConfigValue(name,def){var value=runtimeConfigStore[name];if(!isSet(value))value=def;return value;}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(o,s){if(!isSet(s))s=0;if(s<0)s+=this.length;if(s<0)s=0;for(;s<this.length;s++)if(this[s]===o)return s;return-1;};}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(o,s){var l=this.length;if(!isSet(s))s=l-1;if(s<0)s+=l;if(s>l-1)s=l-1;for(;s>=0;s--)if(this[s]===o)return s;return-1;};}Array.prototype.contains=function(o){for(var i=0;i<this.length;i++)if(this[i]===o)return true;return false;};Array.prototype.each=function(f){for(var i=0;i<this.length;i++)if(i in this)f(this[i],i);};Array.prototype.flatten=function(){var a=[];for(var i=0;i<this.length;i++)if(i in this)a=a.concat(this[i]instanceof Array?this[i].flatten():this[i]);return a;};if(!Array.prototype.map){Array.prototype.map=function(f){var a=new Array(this.length);for(var i=0;i<this.length;i++)if(i in this)a[i]=f(this[i],i);return a;};}Array.prototype.filter=function(f){var out=[];for(var i=0;i<this.length;i++)if(i in this&&f(this[i],i))out.push(this[i]);return out;};Array.prototype.remove=function(o){return this.filter(function(x){return x!=o});};Array.prototype.removeAt=function(n){if(n<0)n+=this.length;return this.filter(function(x,i){return n!=i});};Array.prototype.uniq=function(){var out=[];for(var i=0;i<this.length;i++)if(i in this&&!out.contains(this[i]))out.push(this[i]);return out;};Array.prototype.clone=function(){var out=[];for(var i=0;i<this.length;i++)if(i in this)out[i]=this[i];return out;};Array.prototype.none=function(arg){for(var i=0;i<this.length;i++)if(i in this&&this[i](arg))return false;return true;};Array.prototype.any=function(arg){for(var i=0;i<this.length;i++)if(i in this&&this[i](arg))return true;return false;};Array.prototype.all=function(arg){for(var i=0;i<this.length;i++)if(i in this&&!this[i](arg))return false;return true;};Object.prototype.findValue=function(o){for(var prop in this)if(this[prop]===o)return prop;};Object.prototype.containsValue=function(o){return this.findValue(o)!==false?true:false;};String.prototype.contains=function(str){return this.indexOf(str)!=-1;};String.prototype.trimStart=function(c){if(isSet(c)){for(var i=0;i<this.length&&c.contains(this.charAt(i));i++){}return this.substr(i);}return this.replace(/^\s+/,"");};String.prototype.trimEnd=function(c){if(isSet(c)){for(var i=this.length-1;i>=0&&c.contains(this.charAt(i));i--){}return this.substr(0,i+1);}return this.replace(/\s+$/,"");};String.prototype.trim=function(c){return this.trimStart(c).trimEnd(c);};String.prototype.startsWith=function(str){if(!isString(str))return false;return this.substr(0,str.length)==str;};String.prototype.endsWith=function(str){if(!isString(str))return false;return this.substr(this.length-str.length,str.length)==str;};String.prototype.pad=function(minLength,ch,atBegin){var out=this;if(!isSet(ch))ch=" ";while(out.length<minLength)if(atBegin)out=ch+out;else out+=ch;return out;};String.prototype.repeat=function(n){var a="";while(n--)a+=this;return a;};String.prototype.escapeXml=function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");};String.prototype.escapeRegex=function(){return this.replace(/([$^*+.?\\()/|\[\]{}])/g,"\\$1");};String.prototype.escapeRegexCC=function(){return this.replace(/([-\\^\[\]])/g,"\\$1");};String.prototype.encodeUri=function(){return encodeURIComponent(this).replace(/%20/g,"+").replace(/%2C/g,",");};String.prototype.toCamelCase=function(sep){sep=sep||"-";var parts=this.split(sep);var ret=parts[0];for(var i=1;i<parts.length;i++)ret+=parts[i].charAt(0).toUpperCase()+parts[i].substr(1);return ret;};function getCookie(n){var vars=document.cookie.split(";");for(var i=0;i<vars.length;i++){var parts=vars[i].trim().split("=");if(parts[0]==n&&isString(parts[1]))return decodeURIComponent(parts[1].replace(/\+/," "));}return undefined;}function setCookie(n,v,lifetime,path){var addStr="";if(lifetime){var time=new Date();time.setTime(time.getTime()+lifetime*86400*1000);addStr+="; expires="+time.toGMTString();}if(path){addStr+="; path="+path;}document.cookie=n+"="+encodeURIComponent(v)+addStr;}function openPopupWindow(url,w,h){window.open(url,"","width="+w+", height="+h+", resizable=yes, scrollbars=yes");}var DOM=function(){var scrollTimeout=false;var scrollOffset=0;var prevLocationHash;var historyChangedHandlers=[];var thisModule={top:function(o){o=$(o);if(!isSet(o))return 0;var top=o.offsetTop;while(o=o.offsetParent)top+=o.offsetTop;return top;},left:function(o){o=$(o);if(!isSet(o))return 0;var left=o.offsetLeft;while(o=o.offsetParent)left+=o.offsetLeft;return left;},bottom:function(o){o=$(o);return thisModule.top(o)+thisModule.height(o);},right:function(o){o=$(o);return thisModule.left(o)+thisModule.width(o);},width:function(o){o=$(o);if(!isSet(o))return 0;return o.offsetWidth;},height:function(o){o=$(o);if(!isSet(o))return 0;return o.offsetHeight;},resizeVert:function(o,cy,negative){o=$(o);if(!isSet(o))return;var newCy=o.clientHeight+cy;var minCy=0;var maxCy=1000;if(o.tagName.toLowerCase()=="textarea")minCy=60;if(newCy<minCy)newCy=minCy;if(newCy>maxCy)newCy=maxCy;var diffY=newCy-o.clientHeight;o.style.height=newCy+"px";if(negative==true)window.scrollBy(0,diffY);},moveTo:function(o,x,y){o=$(o);if(!isSet(o))return;o.style.left=x+"px";o.style.top=y+"px";},moveBy:function(o,dx,dy){o=$(o);if(!isSet(o))return;o.style.left=(parseInt(o.style.left)+dx)+"px";o.style.top=(parseInt(o.style.top)+dy)+"px";},resizeTo:function(o,w,h){o=$(o);if(!isSet(o))return;o.style.width=w+"px";o.style.height=h+"px";},resizeBy:function(o,dx,dy){o=$(o);if(!isSet(o))return;o.style.width=(parseInt(o.style.width)+dx)+"px";o.style.height=(parseInt(o.style.height)+dy)+"px";},unsetSize:function(o){o=$(o);if(!isSet(o))return;o.style.width="";o.style.height="";},windowClientWidth:function(){if(isSet(window.innerWidth))return window.innerWidth;if(document.documentElement.clientWidth>0)return document.documentElement.clientWidth;if(isSet(document.body.clientWidth))return document.body.clientWidth;return undefined;},windowClientHeight:function(){if(isSet(window.innerHeight))return window.innerHeight;if(document.documentElement.clientHeight>0)return document.documentElement.clientHeight;if(isSet(document.body.clientHeight))return document.body.clientHeight;return undefined;},toggleVisible:function(o,state){o=$(o);if(!isSet(o))return-1;if(!isSet(state))newstate=(o.style.display=="")?"none":"";else newstate=state?"":"none";o.style.display=newstate;return newstate==""?1:-1;},show:function(o){return thisModule.toggleVisible(o,true);},hide:function(o){return thisModule.toggleVisible(o,false);},visible:function(o){o=$(o);if(!isSet(o))return false;return o.style.display!="none";},toggleEnabled:function(o,state){o=$(o);if(!isSet(o))return false;if(state==null)newstate=!o.disabled;else newstate=!state;o.disabled=newstate;return!newstate;},enable:function(o){return thisModule.toggleEnabled(o,true);},disable:function(o){return thisModule.toggleEnabled(o,false);},enabled:function(o){o=$(o);if(!isSet(o))return false;return!o.disabled;},disableAsync:function(o){o=$(o);window.setTimeout(function(){if(o){o.blur();o.disabled=true;}},50);},toggleSelected:function(o){o=$(o);if(thisModule.hasClass(o,"selected")){thisModule.removeClass(o,"selected");return false;}thisModule.addClass(o,"selected");return true;},scrollX:function(v){if(isSet(window.pageXOffset))if(isSet(v)){window.scrollTo(v,thisModule.scrollY());return v;}else return window.pageXOffset;if(document.compatMode=="CSS1Compat")if(isSet(v))return document.documentElement.scrollLeft=v;else return document.documentElement.scrollLeft;else if(isSet(v))return document.body.scrollLeft=v;else return document.body.scrollLeft;},scrollY:function(v){if(isSet(window.pageYOffset))if(isSet(v)){window.scrollTo(thisModule.scrollX(),v);return v;}else return window.pageYOffset;if(document.compatMode=="CSS1Compat")if(isSet(v))return document.documentElement.scrollTop=v;else return document.documentElement.scrollTop;else if(isSet(v))return document.body.scrollTop=v;else return document.body.scrollTop;},scrollDownBy:function(o){o=$(o);window.scrollBy(0,thisModule.height(o));},scrollUpBy:function(o){o=$(o);window.scrollBy(0,-thisModule.height(o));},setAnchorScrollOffset:function(y){scrollOffset=y;},scrollToAnchor:function(){try{clearTimeout(scrollTimeout);}catch(ex){}var url=window.location.href;var id="";var id_pos=url.lastIndexOf("#");if(id_pos>0)id=url.substring(id_pos+1,url.length);else  if(id!=""){var o=$(id);if(!isSet(o))return;var top=thisModule.top(o)-7+scrollOffset;window.scrollTo(0,top);}},scrollToObject:function(o){o=$(o);if(!isSet(o))return;var top=thisModule.top(o)-7+scrollOffset;window.scrollTo(0,top);},autoScrollToAnchor:function(){DOMEvents.add(window,"load",thisModule.scrollToAnchor);scrollTimeout=setTimeout(thisModule.scrollToAnchor,1000);},toggleVisibleScroll:function(o){o=$(o);if(!isSet(o))return;if(o.style.display==""){window.scrollBy(0,-thisModule.height(o));newstate="none";o.style.display=newstate;}else{newstate="";o.style.display=newstate;window.scrollBy(0,thisModule.height(o));}return(newstate==""?1:-1);},setImageCond:function(o,cond,trueimg,falseimg){$(o).src=cond?trueimg:falseimg;},hasClass:function(o,n){o=$(o);if(!isSet(o)||!isSet(o.className))return false;var cn=o.className.split(" ");var req=n.split(" ");req=req.filter(function(x){return!cn.contains(x);});return req.length==0;},getClasses:function(o){o=$(o);if(!isSet(o)||!isSet(o.className))return "";return o.className.split(" ");},addClass:function(o,n){o=$(o);if(!isSet(o)||!isSet(o.className))return;var cn=o.className.split(" ");var req=n.split(" ");req.each(function(x){if(!cn.contains(x))cn.push(x);});o.className=cn.join(" ");},removeClass:function(o,n){o=$(o);if(!isSet(o)||!isSet(o.className))return;var cn=o.className.split(" ");var req=n.split(" ");cn=cn.filter(function(x){return!req.contains(x);});o.className=cn.join(" ");},toggleClass:function(o,n,state){o=$(o);if(!isSet(o)||!isSet(o.className))return;var req=n.split(" ");req.each(function(n){if(state||!isSet(state)&&!thisModule.hasClass(o,n))thisModule.addClass(o,n);else thisModule.removeClass(o,n);});},addPageStyle:function(css){var style=document.createElement("style");style.setAttribute("type","text/css");try{style.appendChild(document.createTextNode(css));}catch(ex){errorMessage(formatException(ex),"DOM.addPageStyle");}document.getElementsByTagName("head")[0].appendChild(style);},getEffectiveStyle:function(o,n){o=$(o);if(!isSet(o))return undefined;if(document.defaultView&&document.defaultView.getComputedStyle)return document.defaultView.getComputedStyle(o,"").getPropertyValue(n);if(o.currentStyle)return o.currentStyle[n.toCamelCase()];errorMessage("Browser does not support retrieval of effective style","DOM.getEffectiveStyle");},getOpacity:function(o){o=$(o);if(!isSet(o))return undefined;if(o.filters&&o.filters.alpha&&isNumber(o.filters.alpha.opacity))return o.filters.alpha.opacity/100;if(isSet(o.style.opacity)&&o.style.opacity!="")return o.style.opacity;return 1;},setOpacity:function(o,opacity){o=$(o);if(!isSet(o))return;if(isSet(o.style.opacity))o.style.opacity=opacity;else if(isSet(o.style.filter))o.style.filter=(opacity===1)?"":"Alpha(opacity="+(opacity*100)+")";},findParentByName:function(o,n){o=$(o);if(!isSet(o))return undefined;while(o.nodeName.toLowerCase()!=n){if(!o.parentNode)return undefined;o=o.parentNode;}return o;},findParentByClass:function(o,n){o=$(o);if(!isSet(o))return undefined;while(!thisModule.hasClass(o,n)){if(!o.parentNode)return undefined;o=o.parentNode;}return o;},addHistoryChangedHandler:function(h){historyChangedHandlers.push(h);if(historyChangedHandlers.length==1){prevLocationHash=window.location.hash;setInterval(function(){if(window.location.hash!=prevLocationHash){prevLocationHash=window.location.hash;thisModule.onHistoryChanged();}},100);}},onHistoryChanged:function(){historyChangedHandlers.each(function(h){h();});}}; return thisModule;}();$=function(id){if(isString(id))return document.getElementById(id.trimStart("#"));return id;};var DOMEvents=function(){var pageLoaded=false;function findEvent(e){e=e||event;if(!e.target&&e.srcElement)e.target=e.srcElement;if(isSet(e.button)){if (/*@cc_on!@*/false){if(e.button&1)e.mouseButton=0;else if(e.button&2)e.mouseButton=2;else if(e.button&4)e.mouseButton=1;}else e.mouseButton=e.button;}return e;}var thisModule={add:function(o,n,handler){if(n=="textchanged")return[this.add(o,"input",handler),this.add(o,"propertychange",handler)];var wrappedHandler=function(e){e=findEvent(e);var res;try{res=handler(e);}catch(ex){errorMessage(formatException(ex),"Event handler function");}if(res===false){e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();  e.returnValue=false;if(e.preventDefault)e.preventDefault();return false;}return true;};var cn=n;if(n=="domload"){n="DOMContentLoaded";cn="load";}o=$(o);if(!isSet(o))return;if(o.addEventListener)o.addEventListener(n,wrappedHandler,false);else if(o.attachEvent)o.attachEvent("on"+cn,wrappedHandler);else o["on"+cn]=wrappedHandler; return{"o":o,"n":n,"cn":cn,"f":wrappedHandler};},remove:function(h){if(!isArray(h))h=[h];h.flatten().each(function(h){if(h.o.addEventListener)h.o.removeEventListener(h.n,h.f,false);else if(h.o.attachEvent)h.o.detachEvent("on"+h.cn,h.f);else h.o["on"+h.cn]=undefined;});},whenLoaded:function(fn){if(pageLoaded)fn();else this.add(window,"load",fn);},isLoaded:function(){return pageLoaded;}};  thisModule.whenLoaded(function(){pageLoaded=true;});return thisModule;}();var DOMKeyEvents=function(){function findKeyCode(e){if(e.data)return e.data;if(e.which)return e.which;return e.keyCode;}this.keyNames={8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",91:"WinLeft",92:"WinRight",93:"AppMenu",96:"Num0",97:"Num1",98:"Num2",99:"Num3",100:"Num4",101:"Num5",102:"Num6",103:"Num7",104:"Num8",105:"Num9",106:"Multiply",107:"Add",109:"Subtract",111:"Divide",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",170:"Search",172:"Web",180:"Mail"};return{add:function(o,keyName,handler){var my_this=this;return DOMEvents.add(o,"keydown",function(e){try{if(my_this.isKeyName(e,keyName))return handler(e);}catch(ex){errorMessage("Exception caught while processing the key event handler for "+keyName+":\n"+formatException(ex));}});},addGlobal:function(keyName,handler){return this.add(document,keyName,handler);},remove:function(h){DOMEvents.remove(h);},altPressed:function(e){return e.altKey;},ctrlPressed:function(e){return e.ctrlKey;},shiftPressed:function(e){return e.shiftKey;},keyCodeFromName:function(n){for(var c in keyNames)if(keyNames[c]==n)return c;return 0;},keyNameFromCode:function(c){if(keyNames.containsKey(c))return keyNames[c];return "";},isKeyName:function(e,n){var modifier=false;var modAlt=false;var modCtrl=false;var modShift=false;do{modifier=false;if(n.startsWith("Alt+")){modAlt=true;n=n.substr(4);modifier=true;}if(n.startsWith("Ctrl+")){modCtrl=true;n=n.substr(5);modifier=true;}if(n.startsWith("Shift+")){modShift=true;n=n.substr(6);modifier=true;}}while(modifier);if(modAlt ^ this.altPressed(e))return false;if(modCtrl ^ this.ctrlPressed(e))return false;if(modShift ^ this.shiftPressed(e))return false;return findKeyCode(e)==this.keyCodeFromName(n);},getKeyName:function(e){var n="";if(this.ctrlPressed(e))n+="Ctrl+";if(this.shiftPressed(e))n+="Shift+";var keyCode=findKeyCode(e);var singleName=this.keyNameFromCode(keyCode);if(singleName)n+=singleName;else n+="<"+keyCode+">";return n;}}}();$=function(q,o){if(!isString(q))return q;var a=$$(q,o);if(isArray(a)&&a.length>=1)return a[0];};$$=function(q,o){if(!isString(q))return q;if(!isSet(o)&&(m=q.match(/^#([-_0-9A-Za-z]+)$/)))return[document.getElementById(m[1])];if(isArray(o)){var nodes=[];for(var oi=0;oi<o.length;oi++)nodes=nodes.concat(arguments.callee(q,o[oi]));return nodes.uniq();}if(isString(o))o=document.getElementById(o);if(!isSet(o))o=document;q=q.trim();var groups=[];var elements=[];while(q.length>0){if(elements.length>0){var m=q.match(/^\s*,\s*/);if(isSet(m)){groups.push(elements);elements=[];q=q.substr(m[0].length);}}var comb="";if(elements.length>0){var m=q.match(/^(\s*[>+~]\s*|\s+)/);if(isSet(m)){comb=m[1].trim();q=q.substr(m[0].length);}else return false;}var element="";var m=q.match(/^([-_0-9A-Za-z]+|\*)/);if(isSet(m)){element=m[1].toLowerCase();q=q.substr(m[0].length);}var specs=[];do{m=q.match(/^#([-_0-9A-Za-z]+)/);if(isSet(m))q="[id="+m[1]+"]"+q.substr(m[0].length);  m=q.match(/^\.([-_0-9A-Za-z]+)/);if(isSet(m))q="[class~="+m[1]+"]"+q.substr(m[0].length);  m=q.match(/^\[([-_0-9A-Za-z]+)(?:(=|~=|\|=|\^=|\$=|\*=)(?:([^'"][^\]]*)|'((?:[^']|\\')*)'|"((?:[^"]|\\")*)"))?\]/);if(isSet(m)){(function(){var attrName=m[1];var op=m[2];var val="";if(isSet(m[3])&&m[3]!="")val=m[3];else if(isSet(m[4])&&m[4]!="")val=m[4].replace(/\\'/g,"'");else if(isSet(m[5])&&m[5]!="")val=m[5].replace(/\\"/g,'"');q=q.substr(m[0].length);var regex;if(op=="=")regex=new RegExp("^"+val.escapeRegex()+"$");else if(op=="~=")regex=new RegExp("(^|\\s)"+val.escapeRegex()+"(\\s|$)");else if(op=="|=")regex=new RegExp("^"+val.escapeRegex()+"(-|$)");else if(op=="^=")regex=new RegExp("^"+val.escapeRegex());else if(op=="$=")regex=new RegExp(val.escapeRegex()+"$");else if(op=="*=")regex=new RegExp(val.escapeRegex());specs.push(function(node){return node.attributes&&node.attributes[attrName]&&(isSet(regex)&&regex.test(node.attributes[attrName].value)||!isSet(regex)&&node.attributes[attrName].specified);});})();continue;}m=q.match(/^:first-child/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){var pcn=node.parentNode.childNodes;for(var i=0;i<pcn.length;i++)if(pcn[i].nodeType==1)return pcn[i]==node;});continue;}m=q.match(/^:last-child/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){var pcn=node.parentNode.childNodes;for(var i=pcn.length-1;i>=0;i--)if(pcn[i].nodeType==1)return pcn[i]==node;});continue;}m=q.match(/^:first-of-type/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){var pcn=node.parentNode.childNodes;for(var i=0;i<pcn.length;i++)if(pcn[i].nodeType==1&&pcn[i].tagName.toLowerCase()==node.tagName.toLowerCase())return pcn[i]==node;});continue;}m=q.match(/^:last-of-type/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){var pcn=node.parentNode.childNodes;for(var i=pcn.length-1;i>=0;i--)if(pcn[i].nodeType==1&&pcn[i].tagName.toLowerCase()==node.tagName.toLowerCase())return pcn[i]==node;});continue;}m=q.match(/^:only-child/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){var pcn=node.parentNode.childNodes;var c=0;for(var i=0;i<pcn.length;i++)if(pcn[i].nodeType==1)c++;return c==1;});continue;}m=q.match(/^:only-of-type/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){var pcn=node.parentNode.childNodes;var c=0;for(var i=0;i<pcn.length;i++)if(pcn[i].nodeType==1&&pcn[i].tagName.toLowerCase()==node.tagName.toLowerCase())c++;return c==1;});continue;}m=q.match(/^:empty/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){return node.childNodes.length==0;});continue;}m=q.match(/^:enabled/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){return!node.disabled;});continue;}m=q.match(/^:disabled/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){return node.disabled;});continue;}m=q.match(/^:checked/);if(isSet(m)){q=q.substr(m[0].length);specs.push(function(node){return node.checked;});continue;}m=q.match(/^:contains\((?:([^'"][^\]]*)|'((?:[^']|\\')*)'|"((?:[^"]|\\")*)")\)/);if(isSet(m)){(function(){var val="";if(isSet(m[1])&&m[1]!="")val=m[1];else if(isSet(m[2])&&m[2]!="")val=m[2].replace(/\\'/g,"'");else if(isSet(m[3])&&m[3]!="")val=m[3].replace(/\\"/g,'"');q=q.substr(m[0].length);specs.push(function(node){return(isSet(node.innerText)?node.innerText:node.textContent).indexOf(val)!=-1;});})();continue;}}while(isSet(m));if(element==""&&specs.length==0)return false;if(element=="")element="*";elements.push({"comb":comb,"element":element,"specs":specs});} if(elements.length>0)groups.push(elements);var checkNode=function(node,elements){if(elements.length===1)return true;pe=elements[elements.length-1];elements=elements.slice(0,-1);e=elements[elements.length-1];if(pe.comb===""){while(node.parentNode&&!((e.element==="*"||node.parentNode.nodeName.toLowerCase()===e.element)&&e.specs.all(node.parentNode)&&checkNode(node.parentNode,elements)))node=node.parentNode;return!!node.parentNode;}if(pe.comb===">"){return(node.parentNode&&(e.element==="*"||node.parentNode.nodeName.toLowerCase()===e.element)&&e.specs.all(node.parentNode)&&checkNode(node.parentNode,elements));}if(pe.comb==="~"){while(node.previousSibling&&!(node.previousSibling.nodeType===1&&(e.element==="*"||node.previousSibling.nodeName.toLowerCase()===e.element)&&e.specs.all(node.previousSibling)&&checkNode(node.previousSibling,elements)))node=node.previousSibling;return!!node.previousSibling;}if(pe.comb==="+"){while(node.previousSibling&&node.previousSibling.nodeType!==1)node=node.previousSibling;return(node.previousSibling&&node.previousSibling.nodeType===1&&(e.element==="*"||node.previousSibling.nodeName.toLowerCase()===e.element)&&e.specs.all(node.previousSibling)&&checkNode(node.previousSibling,elements));}return false;};var foundNodes=[];for(var gi=0;gi<groups.length;gi++){var elements=groups[gi];var e0=elements[elements.length-1];var nodes=o.getElementsByTagName(e0.element);nodes.filter=Array.prototype.filter;nodes=nodes.filter(function(node){return e0.specs.all(node)&&checkNode(node,elements);});foundNodes=foundNodes.concat(nodes);}return foundNodes.uniq();};var WebRequest=function(){return{asyncRequest:function(url,method,data,eventHandler,errorHandler){function makeRequestHandler(request,eventHandler,url,errorHandler){if(!isFunction(eventHandler)){errorMessage("parameter eventHandler is not a function","asyncRequest, makeRequestHandler");return false;}if(isSet(errorHandler)&&!isFunction(errorHandler)){errorMessage("parameter errorHandler is not a function","asyncRequest, makeRequestHandler");return false;}return function(){if(request.readyState==4){if(request.status==200){try{eventHandler(request);}catch(ex){errorMessage("Exception caught while processing the server response:\n"+formatException(ex));}}else{if(isSet(errorHandler)){try{errorHandler(request);}catch(ex){errorMessage("Exception caught while processing the server error response:\n"+formatException(ex));}}else{errorMessage("Server responded with error code "+request.status+" ("+request.statusText+")\n"+"URL: "+ url);}}}}}method=method.toUpperCase();if(method!="GET"&&method!="POST"){errorMessage("parameter method is invalid: "+method,"asyncRequest");return false;}var dataToSend="";if(isObject(data))for(var property in data)if(isBoolean(data[property])||isNumber(data[property])||isString(data[property]))dataToSend+=(dataToSend!=""?"&":"")+property+"="+encodeURIComponent(data[property]);else if(isString(data))dataToSend=data;else if(!isSet(data))if(method=="POST"){errorMessage("parameter data is unset but POST method was requested","asyncRequest");return false;}else{errorMessage("parameter data is invalid","asyncRequest");return false;}var request=false;if(window.XMLHttpRequest)try{request=new XMLHttpRequest();}catch(ex){}else if(window.ActiveXObject)try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){}}if(!request){errorMessage("Browser does not support any kind of XMLHttpRequest object","asyncRequest");return false;}var handler=makeRequestHandler(request,eventHandler,url,errorHandler);if(handler==false){errorMessage("handler factory did not return a function","asyncRequest");return false;}request.open(method,url,true);request.onreadystatechange=handler;if(dataToSend!="")request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');request.send(dataToSend);return true;},asyncGet:function(url,eventHandler,errorHandler){return this.asyncRequest(url,"GET",null,eventHandler,errorHandler);},asyncPost:function(url,data,eventHandler,errorHandler){return this.asyncRequest(url,"POST",data,eventHandler,errorHandler);},getErrorType:function(xml){if(xml==null)return undefined;var n=xml.getElementsByTagName("error")[0];if(n)return n.getAttribute("type");},getErrorValue:function(xml){return this.getValue(xml,"error");},getResultValue:function(xml){return this.getValue(xml,"result");},getValue:function(xml,name,forceArray,onlyFirst){if(xml==null)return undefined;if(!isSet(forceArray))forceArray=false;if(!isSet(onlyFirst))onlyFirst=false;var n=xml.getElementsByTagName(name);if(n.length==1&&!forceArray||n.length>0&&onlyFirst){return n[0].firstChild?n[0].firstChild.nodeValue:"";}else if(n.length>0||forceArray){var a=new Array();for(var i=0;i<n.length;i++){a.push(n[i].firstChild?n[i].firstChild.nodeValue:"");}return a;}}}}();