Utils = { // remove all of the children from a DOM object removeChildren : function( obj ) { for( var kk = obj.childNodes.length; --kk >= 0 ; ) { obj.removeChild( obj.childNodes[kk] ); } }, // copy all options (typically from a dropdown) into an array copyOptionsToArray : function( obj ) { var optArray = new Array(1); var idx = 0; for(idx=0;idx t ) return 1; else return 0; } ); // Note that as we insert existing nodes, they are automatically removed from their current position for(var i = 0; i < children.length; i++) { container.appendChild(children[i]); } }, // find the text content within a node of node tree innerText : function(node) { // is this a text or CDATA node? if (node.nodeType == 3 || node.nodeType == 4) { return node.data; } var i; var returnValue = []; for (i = 0; i < node.childNodes.length; i++) { returnValue.push(this.innerText(node.childNodes[i])); } return returnValue.join(' '); }, Timer : { timers : new Object(), // return current timestamp - dates are ignored getTimestamp : function() { var currentTimestamp = new Date(); return currentTimestamp.getTime(); }, startTimer : function( timerName ) { this.timers[timerName] = new Object(); this.timers[timerName]['startTime'] = this.getTimestamp(); this.timers[timerName]['lapTime'] = this.timers[timerName]['startTime']; this.timers[timerName]['times'] = new Object(); }, lapTime : function( timerName, lapName ) { if( this.timers[timerName] == undefined ) { this.startTimer(timerName); } var timestamp = this.getTimestamp(); this.timers[timerName]['times'] [lapName] = ( timestamp - this.timers[timerName]['lapTime'] ) / 1000; this.timers[timerName]['lapTime'] = timestamp; }, getTimes : function( timerName ) { return this.timers[timerName]['times'] ; }, reportTimings : function( timerName ) { var times = this.getTimes( timerName ); var buffer = ""; var counter = 0; for( lap in times ) { buffer += "\n" + ( ++counter ) + ". " + lap + ": " + times[lap] + "s"; } Logger.debug( "Lap times for '" + timerName + "': " + buffer ); } } } // Add a function to the String class to trip leading and trailing white-space String.prototype.trim = function() { return this.replace(/^\s*|\s*$/g, ""); } // Watch for all links on the page and force external links to open in a new window. Event.observe( window, 'load', Utils.targetExternalLinks, false );