Element.removeChildren = function(element){ element = $(element); purge(element.childNodes); while( element.firstChild ) { element.removeChild( element.firstChild ); } } Element.searchByClass = function(node,searchClass) { var classElements = new Array(); var els = $(node).childNodes; var elsLen = els.length; var pattern = new RegExp("\b"+searchClass+"\b"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[classElements.length] = els[i]; j++; } } return classElements; } function $E(data) { var el; if ('string'==typeof data) { el=document.createTextNode(data); } else { //create the element el=document.createElement(data.tag); delete(data.tag); //append the children if ('undefined'!=typeof data.children) { if ('string'==typeof data.children || 'undefined'==typeof data.children.length ) { //strings and single elements el.appendChild($E(data.children)); } else { //arrays of elements for (var i=0, child=null; 'undefined'!=typeof (child=data.children[i]); i++) { el.appendChild($E(child)); } } delete(data.children); } if ('undefined'!=typeof data.style) { for( i in data.style ){ if(typeof(data.style[i]) == 'function'){ //el.style[i] = eval("data.style[i]"); //el.style[i] = eval("data.style["+i+"]"); /* IE Problem */ eval("func = "+data.style[i]); el.style[i] = func; /* eval("el.style.[i] = "+data.style[i]); */ //eval("el.style[i] = "+data.style[i]); //eval('el.style.'+i+' = '+data.style[i]); //eval("func = data.style["+i+"]"); //alert( func ); } else { el.style[i] = data.style[i]; } } delete(data.style); } if (data.classname) { //$(el).setAttribute('class',data.classname); Element.addClassName($(el),data.classname); delete(data.classname); } if (data.events) { for( i in data.events ){ el[i] = data.events[i]; } delete(data.events); } for( i in data ){ /* IE Bug */ el[i] = data[i]; } } return el; } function purge(d) { var a = d.attributes, i, l, n; if (a) { l = a.length; for (i = 0; i < l; i += 1) { n = a[i].name; if (typeof d[n] === 'function') { d[n] = null; } } } a = d.childNodes; if (a) { l = a.length; for (i = 0; i < l; i += 1) { purge(d.childNodes[i]); } } }