if(typeof window.time=='undefined'){(function(){window.time={start:function(a){if(!a){error('start: If starting a timer manually a name must be set')}else{f[a]=(new Date()).getTime()}},stop:function(a){if(a in f){var b=(new Date()).getTime();var l=new o(a,f[a],b);g.push(l);if(j)k.call(this,l);delete f[a]}else{error('stop:'+a+' not found')}},event:function(a,b,d){if(typeof a!='string'){d=b;b=a;a=''}if(!b.length){b=[b]}if(d.indexOf('on')==-1){d='on'+d}var i=b.length;var e=null;var c=null;while(i--){e=a;if(!e){e=b[i].id||b[i].getAttribute('class')||b[i].getAttribute('className')||b[i].tagName}mapEvent(b[i],d,e)}},func:function(b,c){if(typeof b=='function'){c=b}if(!c.name&&typeof c=='function'){var m=c.toString().match(/function\s*(.*)\s*\(/);if(m[1]){c.name=m[1]}}if(typeof c=='function'&&!c.name){if(typeof b!='string'){n++;b='anonymous'+n}return function(){time.start(b);var a=c.apply(window,arguments);time.stop(b);return a}}else{var d=c.name||c;if(typeof b!='string'){b=d}eval('var fnCopy = '+d);if(typeof fnCopy=='function'){var e=function(){time.start(b);var a=fnCopy.apply(this,arguments);time.stop(b);return a};e.hooked=true;eval(d+' = wrap;');return eval(d)}else{error('func: Could not hook function (name: '+b+')')}}},report:function(a){if(typeof a=='undefined'){h.call(this,g)}else{var i=g.length;var l=[];while(i--){if(a==g[i].name){l.push(g[i])}}h.call(this,l)}},setReportMethod:function(a){if(a.hooked){error('setReportMethod: Cannot use hooked method '+a.name)}else{h=a}},setLineReportMethod:function(a){if(a.hooked){error('setLineReportMethod: Cannot use hooked method '+a.name)}else{k=a;j=true}},errors:false};var f={};var g=[];var h=defaultReport;var j=false;var k=defaultLineReport;var n=0;var o=function(a,b,c){this.name=a;this.start=b;this.stop=c;this.delta=c-b};o.prototype.toString=function(){return this.name+": "+this.delta+"ms"};function defaultReport(a){alert(a.join("\n"))}function defaultLineReport(a){alert(a)}function error(a){if(time.errors)alert(a)}function mapEvent(b,d,e){var c=b[d];if(typeof c=='function'){b[d]=function(){time.start(e+':'+d);var a=c.apply(this,arguments);time.stop(e+':'+d);return a}}else{error('event: Function must be set on element.'+d+' before hooking (name: '+e+')')}}})()}
