function DOMTool(){if(DOMTool._instance==null||DOMTool._instance==undefined){DOMTool._instance=this}}DOMTool._instance=null;DOMTool.getInstance=function(){if(DOMTool._instance==null||DOMTool._instance==undefined){DOMTool._instance=new DOMTool()}return DOMTool._instance};DOMTool.setClass=function(b,a){DOMTool.setAttribute(b,"class",a)};DOMTool.addClass=function(f,d){var b;var e=false;if(f==undefined||d==undefined){throw new JSInvalidArgumentException("addClass needs two String parameters to work")}if(typeof(f)=="string"){b=DOMTool.getElementById(f)}else{b=f}var a=b.className.split(" ");for(var g=0;g<a.length;++g){if(a[g]==d){e=true;break}}if(!e){b.className+=" "+d}};DOMTool.removeClass=function(f,d){var b;var e=false;if(f==undefined||d==undefined){throw new JSInvalidArgumentException("removeClass needs two String parameters to work")}if(typeof(f)=="string"){b=DOMTool.getElementById(f)}else{b=f}var a=b.className.split(" ");var h=0;for(var g=0;g<a.length;++g){if(a[g]==d){e=true;break}h+=a[g].length}if(e){b.className=b.className.substring(0,h+1)+b.className.substring(h+d.length+2,b.className.length)}b.className.replace(/[^\s+|\s+$]/,"")};DOMTool.setStyle=function(d,a){if(d==undefined||a==undefined){throw new JSInvalidArgumentException("setStyle needs two parameters (string and string or obj) to work")}if(typeof(a)=="string"){DOMTool.setAttribute(d,a)}else{if(typeof(a)=="object"){for(var c in a){try{DOMTool.setCSSProperty(d,c,a[c])}catch(b){if(b instanceof JSDoesNotSupportException){}else{throw b}}}}}};DOMTool.setCSSProperty=function(g,h,c){if(g==undefined||h==undefined||c==undefined){throw new JSInvalidArgumentException("setCSSProperty needs three String parameters to work")}var b;if(typeof(g)=="string"){b=DOMTool.getElementById(g)}else{b=g}if(b.style==undefined){throw new JSDoesNotSupportException("element does not support 'style'-attribute")}var a=h.toString().toLowerCase().split("-");if(a.length>1){h=a[0];for(var f=1;f<a.length;++f){h+=a[f].substr(0,1).toUpperCase()+a[f].substr(1,a[f].length)}}if(b.style[h]!=undefined){try{b.style[h]=c}catch(d){}}};DOMTool.setSrc=function(idOrEl,newSrc){var el=null;if(idOrEl==undefined||newSrc==undefined||typeof(newSrc)!="string"){throw new JSInvalidArgumentException("setSrc needs two String parameters to work")}if(typeof(idOrEl)=="string"){try{el=DOMTool.getElementById(idOrEl)}catch(e){if(e instanceof JSNotImplementedException){if(document.images){var images;eval("images = document.images");el=images[idOrEl]}else{throw new JSRuntimeException("the browser does not support some needed functions")}}else{throw e}}}else{el=idOrEl}if(el.src==undefined){throw new JSDoesNotSupportException("the element does not support the 'src'-attribute")}el.src=newSrc};DOMTool.rollOver=function(h){var f=null;if(h==undefined){throw new JSInvalidArgumentException("rollOver needs a string or HTMLElement parameter to work")}if(typeof(h)=="string"){f=DOMTool.getElementById(h)}else{f=h}if(f.src==undefined){throw new JSDoesNotSupportException("element does not support 'src'-attribute")}var b="";var a=f.src;var g=a.substring(0,a.lastIndexOf("/")+1);var e=a.substring(a.lastIndexOf("."),a.length);var c=a.substring(g.length,(a.length-e.length)-1);var d=a.substring(g.length+c.length,a.length-e.length);if(d=="0"){b=g+c+1+e}else{if(d=="1"){b=g+c+0+e}}DOMTool.setSrc(b)};DOMTool.setAttribute=function(d,a,c){var b=null;if(d==undefined||a==undefined||c==undefined){throw new JSInvalidArgumentException("setAttribute needs three String parameters to work")}if(typeof(d)=="string"){b=DOMTool.getElementById(d)}else{b=d}if(b[a.toString()]==undefined){throw new JSDoesNotSupportException("the element does not support the attribute '"+a+"'")}b[a]=c.toString()};DOMTool.findParent=function(b,c){var a=null;if(typeof(b)=="string"){a=DOMTool.getElementById(b)}else{if(typeof(b)=="object"){a=b}else{if(b==undefined||c==undefined||typeof(c)!="object"){throw new JSInvalidArgumentException("findParent needs one string or object and one object parameter")}}}if(c.tagName!=undefined){c.tagName=c.tagName.toUpperCase()}while(a.parentNode!=null&&a.parentNode.tagName.toLowerCase()!="body"){a=a.parentNode;if(DOMTool.__checkCriteria(c,a)){alert("findParent() hit");return a}}return null};DOMTool.findElement=function(g){if(g==undefined||typeof(g)!="object"){throw new JSInvalidArgumentException("findElement needs one object parameter to work")}var a=new Array();if(g.id!=undefined){var d=DOMTool.getElementById(g.id.toString());if(d!=null){a.push(d)}}else{if(g.tagName!=undefined){g.tagName=g.tagName.toUpperCase();var b=document.getElementsByTagName(g.tagName);for(var f=0;f<b.length;++f){a.push(b[f])}}else{throw new JSDoesNotSupportException("sorry, the search for arbitray elements is not implemented yet. Please specify criteria.id or criteria.tagName")}}for(var c=0;c<a.length;++c){if(DOMTool.__checkCriteria(g,a[c])){alert("findElement() hit");return a[c]}}return null};DOMTool.getElementById=function(b){if(document.getElementById==undefined||(typeof(document.getElementById)!="function"&&typeof(document.getElementById)!="object")){throw new JSDoesNotSupportException("browser does not support 'document.getElementById()'")}if(b==undefined){throw new JSInvalidArgumentException("getElementById needs one String parameters to work")}if(b.id!=undefined){b=b.id}var a=document.getElementById(b.toString());if(a==undefined||a==null){throw new JSInvalidElementIdException("could not find an element with id '"+b+"'")}return a};DOMTool.__checkCriteria=function(f,n,i){for(var h in f){var j=f[h];var g=n[h];if(typeof(j)=="function"){continue}if(g==undefined){if(h=="class"&&n.className!=undefined){g=n.className}else{if(i=="style"){var e=h.toString().toLowerCase().split("-");if(e.length>1){h=e[0];for(var a=1;a<prparts.length;++a){h+=e[a].substr(0,1).toUpperCase()+e[a].substr(1,e[a].length)}}if(n[h]!=undefined){g=n[h]}else{alert("1) undefined property "+h+" even after conversion");return false}}else{alert("1) undefined property "+h);return false}}}if(typeof(j)!=typeof(g)){if(typeof(g)=="object"&&g.value!=undefined&&typeof(g.value)==typeof(j)){g=g.value}else{alert("2) differing types for "+h);return false}}if(typeof(j)=="object"){if(!DOMTool.__checkCriteria(j,g,h)){alert("3) recursion for "+h+" failed");return false}}else{if(g!=j){if(j.indexOf("#")==0&&g.indexOf("rgb(")==0){var m=g.substring(g.indexOf("(")+1,g.lastIndexOf(")")).split(", ");var l="0123456789abcdef";g="#";for(var k=0;k<m.length;++k){var d;var b="";while(m[k]>15){d=m[k]-(Math.floor(m[k]/16))*16;b=l.charAt(d)+b;m[k]=Math.floor(m[k]/16)}b=l.charAt(m[k])+b;g+=b}if(g.toLowerCase()!=j.toLowerCase()){alert("4) suspect differs even after conversion for "+h+": |"+g+"| != |"+j+"|");return false}}else{alert("4) suspect differs for "+h+": |"+g+"| != |"+j+"|");return false}}}}return true};DOMTool.prototype.setClass=function(b,a){return DOMTool.setClass(b,a)};DOMTool.prototype.addClass=function(b,a){return DOMTool.addClass(b,a)};DOMTool.prototype.removeClass=function(b,a){return DOMTool.removeClass(b,a)};DOMTool.prototype.setStyle=function(b,a){return DOMTool.setStyle(b,a)};DOMTool.prototype.setCSSProperty=function(c,b,a){return DOMTool.setCSSProperty(c,b,a)};DOMTool.prototype.setSrc=function(b,a){return DOMTool.setSrc(b,a)};DOMTool.prototype.rollOver=function(a){return DOMTool.rollOver(a)};DOMTool.prototype.setAttribute=function(c,a,b){return DOMTool.setAttribute(c,a,b)};DOMTool.prototype.findParent=function(a,b){return DOMTool.findParent(a,b)};DOMTool.prototype.findElement=function(a){return DOMTool.findElement(a)};DOMTool.prototype.getElementById=function(a){return DOMTool.getElementById(a)};
