function printStackTrace(c){c=c||{guess:true};var a=c.e||null,b=!!c.guess;var d=new printStackTrace.implementation(),e=d.run(a);return(b)?d.guessFunctions(e):e}printStackTrace.implementation=function(){};printStackTrace.implementation.prototype={run:function(a){a=a||this.createException();var b=this.mode(a);if(b==="other"){return this.other(arguments.callee)}else{return this[b](a)}},createException:function(){try{this.undef();return null}catch(a){return a}},mode:function(a){if(a["arguments"]&&a.stack){return(this._mode="chrome")}else{if(typeof window!=="undefined"&&window.opera){return(this._mode=a.stacktrace?"opera10":"opera")}else{if(a.stack){return(this._mode="firefox")}}}return(this._mode="other")},instrumentFunction:function(b,c,a){b=b||window;b["_old"+c]=b[c];b[c]=function(){a.call(this,printStackTrace());return b["_old"+c].apply(this,arguments)};b[c]._instrumented=true},deinstrumentFunction:function(a,b){if(a[b].constructor===Function&&a[b]._instrumented&&a["_old"+b].constructor===Function){a[b]=a["_old"+b]}},chrome:function(a){return a.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@").split("\n")},firefox:function(a){return a.stack.replace(/(?:\n@:0)?\s+$/m,"").replace(/^\(/gm,"{anonymous}(").split("\n")},opera10:function(b){var m=b.stacktrace;var k=m.split("\n"),a="{anonymous}",h=/.*line (\d+), column (\d+) in ((<anonymous function\:?\s*(\S+))|([^\(]+)\([^\)]*\))(?: in )?(.*)\s*$/i,d,f,g;for(d=2,f=0,g=k.length;d<g-2;d++){if(h.test(k[d])){var l=RegExp.$6+":"+RegExp.$1+":"+RegExp.$2;var c=RegExp.$3;c=c.replace(/<anonymous function\:?\s?(\S+)?>/g,a);k[f++]=c+"@"+l}}k.splice(f,k.length-f);return k},opera:function(b){var h=b.message.split("\n"),a="{anonymous}",g=/Line\s+(\d+).*script\s+(http\S+)(?:.*in\s+function\s+(\S+))?/i,c,d,f;for(c=4,d=0,f=h.length;c<f;c+=2){if(g.test(h[c])){h[d++]=(RegExp.$3?RegExp.$3+"()@"+RegExp.$2+RegExp.$1:a+"()@"+RegExp.$2+":"+RegExp.$1)+" -- "+h[c+1].replace(/^\s+/,"")}}h.splice(d,h.length-d);return h},other:function(c){var a="{anonymous}",e=/function\s*([\w\-$]+)?\s*\(/i,g=[],d,b,f=10;while(c&&g.length<f){d=e.test(c.toString())?RegExp.$1||a:a;b=Array.prototype.slice.call(c["arguments"]||[]);g[g.length]=d+"("+this.stringifyArguments(b)+")";c=c.caller}return g},stringifyArguments:function(b){for(var c=0;c<b.length;++c){var a=b[c];if(a===undefined){b[c]="undefined"}else{if(a===null){b[c]="null"}else{if(a.constructor){if(a.constructor===Array){if(a.length<3){b[c]="["+this.stringifyArguments(a)+"]"}else{b[c]="["+this.stringifyArguments(Array.prototype.slice.call(a,0,1))+"..."+this.stringifyArguments(Array.prototype.slice.call(a,-1))+"]"}}else{if(a.constructor===Object){b[c]="#object"}else{if(a.constructor===Function){b[c]="#function"}else{if(a.constructor===String){b[c]='"'+a+'"'}}}}}}}}return b.join(",")},sourceCache:{},ajax:function(b){var a=this.createXMLHTTPObject();if(!a){return}a.open("GET",b,false);a.setRequestHeader("User-Agent","XMLHTTP/1.0");a.send("");return a.responseText},createXMLHTTPObject:function(){var c,d=[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];for(var b=0;b<d.length;b++){try{c=d[b]();this.createXMLHTTPObject=d[b];return c}catch(a){}}},isSameDomain:function(a){return a.indexOf(location.hostname)!==-1},getSource:function(a){if(!(a in this.sourceCache)){this.sourceCache[a]=this.ajax(a).split("\n")}return this.sourceCache[a]},guessFunctions:function(h){for(var d=0;d<h.length;++d){var g=/\{anonymous\}\(.*\)@(\w+:\/\/([\-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/;var b=h[d],f=g.exec(b);if(f){var a=f[1],e=f[4];if(a&&this.isSameDomain(a)&&e){var c=this.guessFunctionName(a,e);h[d]=b.replace("{anonymous}",c)}}}return h},guessFunctionName:function(d,b){var c;try{c=this.guessFunctionNameFromLines(b,this.getSource(d))}catch(a){c="getSource failed with url: "+d+", exception: "+a.toString()}return c},guessFunctionNameFromLines:function(c,h){var f=/function ([^(]*)\(([^)]*)\)/;var g=/['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/;var b="",e=10;for(var a=0;a<e;++a){b=h[c-a]+b;if(b!==undefined){var d=g.exec(b);if(d&&d[1]){return d[1]}else{d=f.exec(b);if(d&&d[1]){return d[1]}}}}return"(?)"}};
