function getNextElementSibling(n){if(n.nextElementSibling)return n.nextElementSibling;do n=n.nextSibling;while(n&&n.nodeType!==1);return n}function htmlEncode(n){return document.createElement("div").appendChild(document.createTextNode(n)).parentNode.innerHTML}(function(n,t){typeof define=="function"&&define.amd?define(t):typeof exports=="object"?module.exports=t():n.returnExports=t()})(this,function(){function l(){}function et(n){return n=+n,n!==n?n=0:n!==0&&n!==1/0&&n!==-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n))),n}function k(n){var t=typeof n;return n===null||t==="undefined"||t==="boolean"||t==="number"||t==="string"}function ti(n){var i,r,u;if(k(n))return n;if((r=n.valueOf,t(r)&&(i=r.call(n),k(i)))||(u=n.toString,t(u)&&(i=u.call(n),k(i))))return i;throw new TypeError;}var o=Function.prototype.call,ot=Array.prototype,u=Object.prototype,e=ot.slice,c=Array.prototype.splice,st=Array.prototype.push,d=Array.prototype.unshift,t=function(n){return u.toString.call(n)==="[object Function]"},ht=function(n){return u.toString.call(n)==="[object RegExp]"},h,n,ct,lt,at,vt,yt,a,v,y,p,w,b,tt,it,i,rt,ut,ft,r;Function.prototype.bind||(Function.prototype.bind=function(n){var i=this,r,u;if(!t(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);var f=e.call(arguments,1),s=function(){if(this instanceof u){var t=i.apply(this,f.concat(e.call(arguments)));return Object(t)===t?t:this}return i.apply(n,f.concat(e.call(arguments)))},h=Math.max(0,i.length-f.length),o=[];for(r=0;r<h;r++)o.push("$"+r);return u=Function("binder","return function("+o.join(",")+"){return binder.apply(this,arguments)}")(s),i.prototype&&(l.prototype=i.prototype,u.prototype=new l,l.prototype=null),u});h=o.bind(u.hasOwnProperty);n=o.bind(u.toString);(yt=h(u,"__defineGetter__"))&&(ct=o.bind(u.__defineGetter__),lt=o.bind(u.__defineSetter__),at=o.bind(u.__lookupGetter__),vt=o.bind(u.__lookupSetter__));[1,2].splice(0).length!==2&&(Array.prototype.splice=function(){function t(n){for(var t=[];n--;)t.unshift(n);return t}var n=[],i;return n.splice.bind(n,0,0).apply(null,t(20)),n.splice.bind(n,0,0).apply(null,t(26)),i=n.length,n.splice(5,0,"XXX"),i+1===n.length?!0:void 0}()?function(n,t){return arguments.length?c.apply(this,[n===void 0?0:n,t===void 0?this.length-n:t].concat(e.call(arguments,2))):[]}:function(n,t){var r,i=e.call(arguments,2),u=i.length;if(!arguments.length)return[];if(n===void 0&&(n=0),t===void 0&&(t=this.length-n),u>0){if(t<=0){if(n===this.length)return st.apply(this,i),[];if(n===0)return d.apply(this,i),[]}return r=e.call(this,n,n+t),i.push.apply(i,e.call(this,n+t,this.length)),i.unshift.apply(i,e.call(this,0,n)),i.unshift(0,this.length),c.apply(this,i),r}return c.call(this,n,t)});[].unshift(0)!==1&&(Array.prototype.unshift=function(){return d.apply(this,arguments),this.length});Array.isArray||(Array.isArray=function(t){return n(t)==="[object Array]"});var g=Object("a"),f=g[0]!=="a"||!(0 in g),s=function(n){var t=!0,i=!0;return n&&(n.call("foo",function(n,i,r){typeof r!="object"&&(t=!1)}),n.call([1],function(){"use strict";i=typeof this=="string"},"x")),!!n&&t&&i};if(Array.prototype.forEach&&s(Array.prototype.forEach)||(Array.prototype.forEach=function(i){var o=r(this),e=f&&n(this)==="[object String]"?this.split(""):o,s=arguments[1],u=-1,h=e.length>>>0;if(!t(i))throw new TypeError;while(++u<h)u in e&&i.call(s,e[u],u,o)}),Array.prototype.map&&s(Array.prototype.map)||(Array.prototype.map=function(i){var o=r(this),e=f&&n(this)==="[object String]"?this.split(""):o,s=e.length>>>0,h=Array(s),c=arguments[1],u;if(!t(i))throw new TypeError(i+" is not a function");for(u=0;u<s;u++)u in e&&(h[u]=i.call(c,e[u],u,o));return h}),Array.prototype.filter&&s(Array.prototype.filter)||(Array.prototype.filter=function(i){var s=r(this),e=f&&n(this)==="[object String]"?this.split(""):s,c=e.length>>>0,h=[],o,l=arguments[1],u;if(!t(i))throw new TypeError(i+" is not a function");for(u=0;u<c;u++)u in e&&(o=e[u],i.call(l,o,u,s)&&h.push(o));return h}),Array.prototype.every&&s(Array.prototype.every)||(Array.prototype.every=function(i){var o=r(this),e=f&&n(this)==="[object String]"?this.split(""):o,s=e.length>>>0,h=arguments[1],u;if(!t(i))throw new TypeError(i+" is not a function");for(u=0;u<s;u++)if(u in e&&!i.call(h,e[u],u,o))return!1;return!0}),Array.prototype.some&&s(Array.prototype.some)||(Array.prototype.some=function(i){var o=r(this),e=f&&n(this)==="[object String]"?this.split(""):o,s=e.length>>>0,h=arguments[1],u;if(!t(i))throw new TypeError(i+" is not a function");for(u=0;u<s;u++)if(u in e&&i.call(h,e[u],u,o))return!0;return!1}),a=!1,Array.prototype.reduce&&(a=typeof Array.prototype.reduce.call("a",function(n,t,i,r){return r})=="object"),Array.prototype.reduce&&a||(Array.prototype.reduce=function(i){var h=r(this),e=f&&n(this)==="[object String]"?this.split(""):h,s=e.length>>>0,u,o;if(!t(i))throw new TypeError(i+" is not a function");if(!s&&arguments.length===1)throw new TypeError("reduce of empty array with no initial value");if(u=0,arguments.length>=2)o=arguments[1];else do{if(u in e){o=e[u++];break}if(++u>=s)throw new TypeError("reduce of empty array with no initial value");}while(1);for(;u<s;u++)u in e&&(o=i.call(void 0,o,e[u],u,h));return o}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(i){var s=r(this),o=f&&n(this)==="[object String]"?this.split(""):s,h=o.length>>>0,e,u;if(!t(i))throw new TypeError(i+" is not a function");if(!h&&arguments.length===1)throw new TypeError("reduceRight of empty array with no initial value");if(u=h-1,arguments.length>=2)e=arguments[1];else do{if(u in o){e=o[u--];break}if(--u<0)throw new TypeError("reduceRight of empty array with no initial value");}while(1);if(u<0)return e;do u in this&&(e=i.call(void 0,e,o[u],u,s));while(u--);return e}),Array.prototype.indexOf&&[0,1].indexOf(1,2)===-1||(Array.prototype.indexOf=function(t){var u=f&&n(this)==="[object String]"?this.split(""):r(this),e=u.length>>>0,i;if(!e)return-1;for(i=0,arguments.length>1&&(i=et(arguments[1])),i=i>=0?i:Math.max(0,e+i);i<e;i++)if(i in u&&u[i]===t)return i;return-1}),Array.prototype.lastIndexOf&&[0,1].lastIndexOf(0,-3)===-1||(Array.prototype.lastIndexOf=function(t){var u=f&&n(this)==="[object String]"?this.split(""):r(this),e=u.length>>>0,i;if(!e)return-1;for(i=e-1,arguments.length>1&&(i=Math.min(i,et(arguments[1]))),i=i>=0?i:e-Math.abs(i);i>=0;i--)if(i in u&&t===u[i])return i;return-1}),!Object.keys){var pt=!{toString:null}.propertyIsEnumerable("toString"),wt=function(){}.propertyIsEnumerable("prototype"),nt=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],bt=nt.length,kt=function(i){var u=n(i),r=u==="[object Arguments]";return r||(r=!Array.isArray(u)&&i!==null&&typeof i=="object"&&typeof i.length=="number"&&i.length>=0&&t(i.callee)),r};Object.keys=function(i){var c=t(i),l=kt(i),a=i!==null&&typeof i=="object",p=a&&n(i)==="[object String]",r,v,u,f,s,y,e,o;if(!a&&!c&&!l)throw new TypeError("Object.keys called on a non-object");if(r=[],v=wt&&c,p||l)for(u=0;u<i.length;++u)r.push(String(u));else for(f in i)v&&f==="prototype"||!h(i,f)||r.push(String(f));if(pt)for(s=i.constructor,y=s&&s.prototype===i,e=0;e<bt;e++)o=nt[e],y&&o==="constructor"||!h(i,o)||r.push(o);return r}}v=-621987552e5;y="-000001";Date.prototype.toISOString&&new Date(v).toISOString().indexOf(y)!==-1||(Date.prototype.toISOString=function(){var t,r,u,n,i;if(!isFinite(this))throw new RangeError("Date.prototype.toISOString called on non-finite value.");for(n=this.getUTCFullYear(),i=this.getUTCMonth(),n+=Math.floor(i/12),i=(i%12+12)%12,t=[i+1,this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds()],n=(n<0?"-":n>9999?"+":"")+("00000"+Math.abs(n)).slice(0<=n&&n<=9999?-4:-6),r=t.length;r--;)u=t[r],u<10&&(t[r]="0"+u);return n+"-"+t.slice(0,2).join("-")+"T"+t.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+"Z"});p=!1;try{p=Date.prototype.toJSON&&new Date(NaN).toJSON()===null&&new Date(v).toJSON().indexOf(y)!==-1&&Date.prototype.toJSON.call({toISOString:function(){return!0}})}catch(wi){}p||(Date.prototype.toJSON=function(){var n=Object(this),i=ti(n),t;if(typeof i=="number"&&!isFinite(i))return null;if(t=n.toISOString,typeof t!="function")throw new TypeError("toISOString property is not callable");return t.call(n)});var dt=Date.parse("+033658-09-27T01:46:40.000Z")===1e15,gt=!isNaN(Date.parse("2012-04-04T24:00:00.500Z"))||!isNaN(Date.parse("2012-11-31T23:59:59.000Z")),ni=isNaN(Date.parse("2000-01-01T00:00:00.000Z"));(!Date.parse||ni||gt||!dt)&&(Date=function(n){function t(i,r,u,f,e,o,s){var h=arguments.length,c;return this instanceof n?(c=h===1&&String(i)===i?new n(t.parse(i)):h>=7?new n(i,r,u,f,e,o,s):h>=6?new n(i,r,u,f,e,o):h>=5?new n(i,r,u,f,e):h>=4?new n(i,r,u,f):h>=3?new n(i,r,u):h>=2?new n(i,r):h>=1?new n(i):new n,c.constructor=t,c):n.apply(this,arguments)}function i(n,t){var i=t>1?1:0;return f[t]+Math.floor((n-1969+i)/4)-Math.floor((n-1901+i)/100)+Math.floor((n-1601+i)/400)+365*(n-1970)}function e(t){return Number(new n(1970,0,1,0,0,0,t))}var u=new RegExp("^(\\d{4}|[+-]\\d{6})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:(\\.\\d{1,}))?)?(Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$"),f=[0,31,59,90,120,151,181,212,243,273,304,334,365];for(var r in n)t[r]=n[r];return t.now=n.now,t.UTC=n.UTC,t.prototype=n.prototype,t.prototype.constructor=t,t.parse=function(t){var r=u.exec(t);if(r){var s=Number(r[1]),o=Number(r[2]||1)-1,h=Number(r[3]||1)-1,v=Number(r[4]||0),c=Number(r[5]||0),l=Number(r[6]||0),a=Math.floor(Number(r[7]||0)*1e3),b=Boolean(r[4]&&!r[8]),y=r[9]==="-"?1:-1,p=Number(r[10]||0),w=Number(r[11]||0),f;return v<(c>0||l>0||a>0?24:25)&&c<60&&l<60&&a<1e3&&o>-1&&o<12&&p<24&&w<60&&h>-1&&h<i(s,o+1)-i(s,o)&&(f=((i(s,o)+h)*24+v+p*y)*60,f=((f+c+w*y)*60+l)*1e3+a,b&&(f=e(f)),-864e13<=f&&f<=864e13)?f:NaN}return n.parse.apply(this,arguments)},t}(Date));Date.now||(Date.now=function(){return(new Date).getTime()});Number.prototype.toFixed&&8e-5.toFixed(3)==="0.000"&&.9.toFixed(0)!=="0"&&1.255.toFixed(2)==="1.25"&&1000000000000000128..toFixed(0)==="1000000000000000128"||function(){function t(t,i){for(var f=-1;++f<u;)i+=t*n[f],n[f]=i%r,i=Math.floor(i/r)}function f(t){for(var f=u,i=0;--f>=0;)i+=n[f],n[f]=Math.floor(i/t),i=i%t*r}function e(){for(var i=u,t="",r;--i>=0;)(t!==""||i===0||n[i]!==0)&&(r=String(n[i]),t===""?t=r:t+="0000000".slice(0,7-r.length)+r);return t}function i(n,t,r){return t===0?r:t%2==1?i(n,t-1,r*n):i(n*n,t/2,r)}function o(n){for(var t=0;n>=4096;)t+=12,n/=4096;while(n>=2)t+=1,n/=2;return t}var r,u,n;r=1e7;u=6;n=[0,0,0,0,0,0];Number.prototype.toFixed=function(n){var r,u,l,s,h,v,c,a;if(r=Number(n),r=r!==r?0:Math.floor(r),r<0||r>20)throw new RangeError("Number.toFixed called with invalid number of decimals");if(u=Number(this),u!==u)return"NaN";if(u<=-1e21||u>=1e21)return String(u);if(l="",u<0&&(l="-",u=-u),s="0",u>1e-21)if(h=o(u*i(2,69,1))-69,v=h<0?u*i(2,-h,1):u/i(2,h,1),v*=4503599627370496,h=52-h,h>0){for(t(0,v),c=r;c>=7;)t(1e7,0),c-=7;for(t(i(10,c,1),0),c=h-1;c>=23;)f(8388608),c-=23;f(1<<c);t(1,1);f(2);s=e()}else t(0,v),t(1<<-h,0),s=e()+"0.00000000000000000000".slice(2,2+r);return r>0?(a=s.length,s=a<=r?l+"0.0000000000000000000".slice(0,r-a+2)+s:l+s.slice(0,a-r)+"."+s.slice(a-r)):s=l+s,s}}();w=String.prototype.split;"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||"tesst".split(/(s)*/)[1]==="t"||"".split(/.?/).length||".".split(/()()/).length>1?function(){var t=/()??/.exec("")[1]===void 0;String.prototype.split=function(i,r){var e=this;if(i===void 0&&r===0)return[];if(n(i)!=="[object RegExp]")return w.apply(this,arguments);var f=[],h=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.extended?"x":"")+(i.sticky?"y":""),o=0,c,u,s,l;for(i=new RegExp(i.source,h+"g"),e+="",t||(c=new RegExp("^"+i.source+"$(?!\\s)",h)),r=r===void 0?-1>>>0:r>>>0;u=i.exec(e);){if(s=u.index+u[0].length,s>o&&(f.push(e.slice(o,u.index)),!t&&u.length>1&&u[0].replace(c,function(){for(var n=1;n<arguments.length-2;n++)arguments[n]===void 0&&(u[n]=void 0)}),u.length>1&&u.index<e.length&&Array.prototype.push.apply(f,u.slice(1)),l=u[0].length,o=s,f.length>=r))break;i.lastIndex===u.index&&i.lastIndex++}return o===e.length?(l||!i.test(""))&&f.push(""):f.push(e.slice(o)),f.length>r?f.slice(0,r):f}}():"0".split(void 0,0).length&&(String.prototype.split=function(n,t){return n===void 0&&t===0?[]:w.apply(this,arguments)});b=String.prototype.replace;tt=function(){var n=[];return"x".replace(/x(.)?/g,function(t,i){n.push(i)}),n.length===1&&typeof n[0]=="undefined"}();tt||(String.prototype.replace=function(n,i){var u=t(i),f=ht(n)&&/\)[*?]/.test(n.source),r;return u&&f?(r=function(t){var u=arguments.length,f=n.lastIndex,r;return n.lastIndex=0,r=n.exec(t),n.lastIndex=f,r.push(arguments[u-2],arguments[u-1]),i.apply(this,r)},b.call(this,n,r)):b.apply(this,arguments)});"".substr&&"0b".substr(-1)!=="b"&&(it=String.prototype.substr,String.prototype.substr=function(n,t){return it.call(this,n<0?(n=this.length+n)<0?0:n:n,t)});i="\t\n\x0b\f\r   ᠎             　\u2028\u2029﻿";rt="​";String.prototype.trim&&!i.trim()&&rt.trim()||(i="["+i+"]",ut=new RegExp("^"+i+i+"*"),ft=new RegExp(i+i+"*$"),String.prototype.trim=function(){if(this===void 0||this===null)throw new TypeError("can't convert "+this+" to object");return String(this).replace(ut,"").replace(ft,"")});(parseInt(i+"08")!==8||parseInt(i+"0x16")!==22)&&(parseInt=function(n){var t=/^0[xX]/;return function(i,r){return i=String(i).trim(),Number(r)||(r=t.test(i)?16:10),n(i,r)}}(parseInt));r=function(n){if(n==null)throw new TypeError("can't convert "+n+" to object");return Object(n)}});var DataExplorer=function(){function i(i){var r,u;if(typeof i=="object")for(r in i)i.hasOwnProperty(r)&&(i[r]&&typeof i[r]=="object"?typeof n[r]=="object"&&$.extend(n[r],i[r]):r.indexOf(".")!==-1?(u=r.split("."),typeof n[u[0]]=="object"&&(n[u[0]][u[1]]=i[r])):n[r]=i[r]);$(document).ready(function(){t.resolve()})}function r(n){t.done(n)}function u(n,t,i){return(typeof n=="string"&&(n=$(n)),!n.length)?n:n.each(function(){var r="tmpl-"+t,u=$(this),n=u.data(r);if(!n){if(n=t==="text"?this.firstChild.nodeValue:this[t],!n)return;u.data(r,n)}t==="text"?this.firstChild.nodeValue=n.format(i):this[t]=n.format(i)})}function f(n){var t="__RequestVerificationToken",i=$('input[name="'+t+'"]').val();return n?(n[t]=i,n):i}var t=new $.Deferred,n={User:{},Site:{}};return{init:i,ready:r,options:n,template:u,token:f}}(),_textContent="textContent"in document.createElement("span")?"textContent":"innerText";DataExplorer.DeferredRequest=function DeferredRequest(n){function e(n){r=!0;n=!!n;var i=typeof t.data=="function"?t.data():t.data;u?r=!1:$.ajax({async:n,data:i,type:t.type,url:t.url,success:s})}function s(n){t.callback&&t.callback(n);r=!1;f&&f()}if(!(this instanceof DeferredRequest))return new DeferredRequest(n);var t=$.extend({delay:950,type:"post",force:!0},n),i=null,r=!1,u=!1,f=null;t.force&&$(document).bind("unload",function(){e(!0)});this.request=function o(n){i&&clearTimeout(i);u=!1;r?f=function(){o(n)}:(t.data=n,i=setTimeout(e,t.delay))};this.cancel=function(){clearTimeout(i);u=!0}};DataExplorer.Voting=function(){function h(r,o,s,h){var l;(r=$(r),h)||(u=o,i=s,n=r.find("span").click(c),t=r.find(".favoritecount"),f=r.find(".error-notification"),l=parseInt(t.text()),e(i,l))}function e(i,r){t.text(r);i?(t.addClass("favoritecount-selected"),n.removeClass("star-off"),n.addClass("star-on"),n.prop("title",o)):(t.removeClass("favoritecount-selected"),n.removeClass("star-on"),n.addClass("star-off"),n.prop("title",s))}function c(){if(!DataExplorer.options.User.isAuthenticated){f.show();return}r||(r=!0,$.post("/vote/"+u,{voteType:"favorite"},function(n){if(typeof n=="object"&&n.success){var u;i=!i;u=parseInt(t.text())+(i?1:-1);e(i,u)}r=!1}))}var u,f,t,n,i=!1,r=!1,o="This is one of your favorite queries (click to undo)",s="Click to mark as favorite query (click again to undo)";return{init:h}}();DataExplorer.ready(function(){$(document).delegate(".error-notification","click",function(){$(this).hide()})});$.fn.tabs=function(n){return this.delegate("a:not(.youarehere)","click",function(){$(this.hash).show();$(this).addClass("youarehere").siblings().removeClass("youarehere").each(function(){$(this.hash).hide()}).end().trigger("show",[this.hash])}).delegate("a","click",function(){return!n})};$.fn.sortChildren=function(n,t){return this.each(function(){for(var r=[],u=this.children,f=u.length,e,i=0;i<f;++i)e=n(u[i]),e!==!1&&r.push({node:u[i],value:n(u[i])});for(r.sort(function(n,t){return n.value===t.value?0:n.value>t.value?1:-1}),t||(t=function(n,t){n.appendChild(t)}),f=r.length,i=0;i<f;++i)t(this,r[i].node)})};document.create=function(n,t,i){var r,u,f;if(n=document.createElement(n),t)for(t.text!=null&&(n[_textContent]=t.text,delete t.text),t.innerHTML!=null&&(n.innerHTML=t.innerHTML,delete t.innerHTML),u=Object.keys(t),r=0;r<u.length;++r)f=u[r],f.toLowerCase()==="classname"&&(f="class"),n.setAttribute(f,t[u[r]]);return i&&i.appendChild(n),n};String.prototype.format=function(n){var t,i,r;if(!n)return this;t=this;for(i in n)n.hasOwnProperty(i)&&(r=new RegExp(":"+i+";?","g"),t=t.replace(r,function(){var t=n[i];return t||t===0||(t=""),t}));return t};String.prototype.toCamelCase=function(){return this.charAt(0).toLowerCase()+this.substring(1)};String.prototype.from=function(n,t){return(n=this.indexOf(n),typeof t=="undefined"&&(t=!0),n<1)?this:this.substring(n+(t?0:1))};window.location.param=function(){var n=null;return function(t){if(n===null){if(n={},window.location.search.length<4){n=!1;return}for(var i=window.location.search.substring(1),u=i.split("&"),r=0;r<u.length;++r)i=u[r].split("="),i.length===2&&i[0].length&&(n[i[0].toLowerCase()]=window.decodeURIComponent(i[1].replace(/\+/g," ")))}if(n!==!1)return n[t.toLowerCase()]}}();Date.parseTimestamp=function(){var n=function(n){return new Date(n)};try{n("2011-01-01 12:00:00Z")}catch(t){n=function(n){var t=n.split(/[-: Z]/);return typeof t[7]=="undefined"?new Date(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),parseInt(t[4],10),parseInt(t[5],10)):new Date(Date.UTC(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),parseInt(t[4],10),parseInt(t[5],10)))}}return n}();Date.prototype.toUTC=function(){function n(n){return n<10?"0"+n:n}return function(){return this.getUTCFullYear()+"-"+n(this.getUTCMonth()+1)+"-"+n(this.getUTCDate())+" "+n(this.getUTCHours())+":"+n(this.getUTCMinutes())+":"+n(this.getUTCSeconds())}}();Date.prototype.toRelativeTimeMini=function(){return months=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],function(){var n=(Date.now()-this)/1e3,t="",i=60,r=60*i,u=24*r,f=this.getUTCMinutes();return n<5?t="just now":n<i?t=Math.round(n)+"s ago":n<r?t=Math.round(n/i)+"m ago":n<u?t=Math.round(n/r)+"h ago":(n=Math.round(n/u),n<=2?t=n+"d ago":n<=330&&(t=months[this.getUTCMonth()]+" "+this.getUTCDate()+" at "+this.getUTCHours()+":"+(f<10?"0":"")+f)),t}}();Number.prototype.prettify=function(){var n=this,t,i="",r=n<0;if(r&&(n=-n),n<1e3)return(r?"-":"")+(Math.floor(n)==n?n:n.toFixed(2));do t=n/1e3,n=Math.floor(t),t=Math.round((t-n)*1e3),i=t+i,n>0&&(i=(t<100?"0":"")+(t<10?"0":"")+i);while(n>0&&(i=","+i));return(r?"-":"")+i};DataExplorer.initComposeButton=function(n){function v(){return o?l():y(),!1}function y(){c&&(c=!1,i.css({top:r.offset().top+r.outerHeight(),left:h.offset().left+h.outerWidth()-i.outerWidth()}),DataExplorer.options.WhitelistEnabled&&!DataExplorer.options.User.isAuthenticated?u[_textContent]="Please log in first":$.get("/sites",p));r.addClass("youarehere");i.show();o=!0;t&&t.focus()}function l(){f.className!=="youarehere"&&r.removeClass("youarehere");i.hide();o=!1;t&&t.val(null)}function p(n){t=document.create("input",{placeholder:"search by name or url"});var r=document.create("div",{className:"ac_results"});u.parentNode.replaceChild(t,u);t.parentNode.appendChild(r);t=$(t);t.width(i.width()-(t.outerWidth(!0)-t.width()));t.autocomplete(n,{container:$(r),minChars:2,matchContains:"word",autoFill:!1,width:"100%",formatItem:function(n){return'<img src="'+n.IconUrl+'" class="site-icon" /> '+htmlEncode(n.LongName)},formatMatch:function(n){return htmlEncode(n.LongName+" "+n.Url)},formatResult:function(n){return n.LongName}}).result(function(n,t){window.location="/"+t.Name.toLowerCase()+"/query/new"});t.focus()}var f=document.getElementById("compose-button"),e=f.parentNode.parentNode,r=document.create("li",{className:"site-selector-arrow "+f.className,innerHTML:"&#9662;"}),a=document.create("img",{src:n.IconUrl,alt:n.LongName,title:"Switch site from "+n.LongName}),s=document.create("span",{className:"site-icon-wrapper"}),i,u;s.appendChild(a);r.insertBefore(s,r.childNodes[0]);e.appendChild(r);i=document.create("div",{className:"site-selector-popup"});u=document.create("p",{className:"loading",text:"Loading list of sites..."});i.appendChild(u);e.parentNode.appendChild(i);i=$(i).click(function(){return!1});r=$(r).click(v);$(document).click(l);var h=$(e.parentNode),t,o=!1,c=!0},function(n){n.fn.extend({autocomplete:function(t,i){var r=typeof t=="string";return i=n.extend({},n.Autocompleter.defaults,{url:r?t:null,data:r?null:t,delay:r?n.Autocompleter.defaults.delay:10,max:i&&!i.scroll?10:150},i),i.highlight=i.highlight||function(n){return n},i.formatMatch=i.formatMatch||i.formatItem,this.each(function(){new n.Autocompleter(this,i)})},result:function(n){return this.bind("result",n)},search:function(n){return this.trigger("search",[n])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(n){return this.trigger("setOptions",[n])},unautocomplete:function(){return this.trigger("unautocomplete")}});n.Autocompleter=function(t,i){function k(){var h=r.selected(),f,o;if(!h)return!1;if(f=h.result,e=f,i.multiple){if(o=s(u.val()),o.length>1){var a=i.multipleSeparator.length,y=n(t).selection().start,l,c=0;n.each(o,function(n,t){if(c+=t.length,y<=c)return l=n,!1;c+=a});o[l]=f;f=o.join(i.multipleSeparator)}f+=i.multipleSeparator}return u.val(f),v(),u.trigger("result",[h.data,h.value]),!0}function o(n,t){if(y==f.DEL){r.hide();return}var o=u.val();(t||o!=e)&&(e=o,o=a(o),o.length>=i.minChars?(u.addClass(i.loadingClass),i.matchCase||(o=o.toLowerCase()),d(o,tt,v)):(w(),r.hide()))}function s(t){return t?i.multiple?n.map(t.split(i.multipleSeparator),function(i){return n.trim(t).length?n.trim(i):null}):[n.trim(t)]:[""]}function a(r){var u,f;return i.multiple?(u=s(r),u.length==1)?u[0]:(f=n(t).selection().start,u=f==r.length?s(r):s(r.replace(r.substring(f),"")),u[u.length-1]):r}function g(r,o){i.autoFill&&a(u.val()).toLowerCase()==r.toLowerCase()&&y!=f.BACKSPACE&&(u.val(u.val()+o.substring(a(e).length)),n(t).selection(e.length,e.length+o.length))}function nt(){clearTimeout(h);h=setTimeout(v,200)}function v(){var n=r.visible();r.hide();clearTimeout(h);w();i.mustMatch&&u.search(function(n){if(!n)if(i.multiple){var t=s(u.val()).slice(0,-1);u.val(t.join(i.multipleSeparator)+(t.length?i.multipleSeparator:""))}else u.val(""),u.trigger("result",null)})}function tt(n,t){t&&t.length&&c?(w(),r.display(t,n),g(n,t[0].value),r.show()):v()}function d(u,f,e){var o,s;i.matchCase||(u=u.toLowerCase());o=l.load(u);o&&o.length?f(u,o):typeof i.url=="string"&&i.url.length>0?(s={timestamp:+new Date},n.each(i.extraParams,function(n,t){s[n]=typeof t=="function"?t():t}),n.ajax({mode:"abort",port:"autocomplete"+t.name,dataType:i.dataType,url:i.url,data:n.extend({q:a(u),limit:i.max},s),success:function(n){var t=i.parse&&i.parse(n)||it(n);l.add(u,t);f(u,t)}})):(r.emptyList(),e(u))}function it(t){for(var r,u=[],e=t.split("\n"),f=0;f<e.length;f++)r=n.trim(e[f]),r&&(r=r.split("|"),u[u.length]={data:r,value:r[0],result:i.formatResult&&i.formatResult(r,r[0])||r[0]});return u}function w(){u.removeClass(i.loadingClass)}var f={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8},u=n(t).attr("autocomplete","off").addClass(i.inputClass),h,e="",l=n.Autocompleter.Cache(i),c=0,y,b={mouseDownOnSelect:!1},r=n.Autocompleter.Select(i,t,k,b),p;n.browser.opera&&n(t.form).bind("submit.autocomplete",function(){if(p)return p=!1,!1});u.bind((n.browser.opera?"keypress":"keydown")+".autocomplete",function(t){c=1;y=t.keyCode;switch(t.keyCode){case f.UP:t.preventDefault();r.visible()?r.prev():o(0,!0);break;case f.DOWN:t.preventDefault();r.visible()?r.next():o(0,!0);break;case f.PAGEUP:t.preventDefault();r.visible()?r.pageUp():o(0,!0);break;case f.PAGEDOWN:t.preventDefault();r.visible()?r.pageDown():o(0,!0);break;case i.multiple&&n.trim(i.multipleSeparator)==","&&f.COMMA:case f.TAB:case f.RETURN:if(k())return t.preventDefault(),p=!0,!1;break;case f.ESC:r.hide();break;default:clearTimeout(h);h=setTimeout(o,i.delay)}}).focus(function(){c++}).blur(function(){c=0;b.mouseDownOnSelect||nt()}).click(function(){c++>1&&!r.visible()&&o(0,!0)}).bind("search",function(){function i(n,i){var r,f;if(i&&i.length)for(f=0;f<i.length;f++)if(i[f].result.toLowerCase()==n.toLowerCase()){r=i[f];break}typeof t=="function"?t(r):u.trigger("result",r&&[r.data,r.value])}var t=arguments.length>1?arguments[1]:null;n.each(s(u.val()),function(n,t){d(t,i,i)})}).bind("flushCache",function(){l.flush()}).bind("setOptions",function(){n.extend(i,arguments[1]);"data"in arguments[1]&&l.populate()}).bind("unautocomplete",function(){r.unbind();u.unbind();n(t.form).unbind(".autocomplete")})};n.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:!1,matchSubset:!0,matchContains:!1,cacheLength:10,max:100,mustMatch:!1,extraParams:{},selectFirst:!0,formatItem:function(n){return n[0]},formatMatch:null,autoFill:!1,width:0,multiple:!1,multipleSeparator:", ",highlight:function(n,t){return n.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+t.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1<\/strong>")},scroll:!0,scrollHeight:180};n.Autocompleter.Cache=function(t){function u(n,i){t.matchCase||(n=n.toLowerCase());var r=n.indexOf(i);return(t.matchContains=="word"&&(r=n.toLowerCase().search("\\b"+i.toLowerCase())),r==-1)?!1:r==0||t.matchContains}function f(n,u){r>t.cacheLength&&o();i[n]||r++;i[n]=u}function e(){var r,h,u,c,i,e,o,s;if(!t.data)return!1;for(r={},h=0,t.url||(t.cacheLength=1),r[""]=[],u=0,c=t.data.length;u<c;u++)(i=t.data[u],i=typeof i=="string"?[i]:i,e=t.formatMatch(i,u+1,t.data.length),e!==!1)&&(o=e.charAt(0).toLowerCase(),r[o]||(r[o]=[]),s={value:e,data:i,result:t.formatResult&&t.formatResult(i)||e},r[o].push(s),h++<t.max&&r[""].push(s));n.each(r,function(n,i){t.cacheLength++;f(n,i)})}function o(){i={};r=0}var i={},r=0;return setTimeout(e,25),{flush:o,add:f,populate:e,load:function(f){var h,s,o,e;if(!t.cacheLength||!r)return null;if(!t.url&&t.matchContains){e=[];for(h in i)h.length>0&&(o=i[h],n.each(o,function(n,t){u(t.value,f)&&e.push(t)}));return e}if(i[f])return i[f];if(t.matchSubset)for(s=f.length-1;s>=t.minChars;s--)if(o=i[f.substr(0,s)],o)return e=[],n.each(o,function(n,t){u(t.value,f)&&(e[e.length]=t)}),e;return null}}};n.Autocompleter.Select=function(t,i,r,u){function p(){y&&(h=t.container||n("<div/>").hide().addClass(t.resultsClass).css("position","absolute").appendTo(document.body),o=n("<ul/>").appendTo(h).mouseover(function(t){a(t).nodeName&&a(t).nodeName.toUpperCase()=="LI"&&(e=n("li",o).removeClass(s.ACTIVE).index(a(t)),n(a(t)).addClass(s.ACTIVE))}).click(function(t){return n(a(t)).addClass(s.ACTIVE),r(),i.focus(),!1}).mousedown(function(){u.mouseDownOnSelect=!0}).mouseup(function(){u.mouseDownOnSelect=!1}),t.width>0&&h.css("width",t.width),y=!1)}function a(n){for(var t=n.target;t&&t.tagName!="LI";)t=t.parentNode;return t?t:[]}function l(n){var r,i;f.slice(e,e+1).removeClass(s.ACTIVE);w(n);r=f.slice(e,e+1).addClass(s.ACTIVE);t.scroll&&(i=0,f.slice(0,e).each(function(){i+=this.offsetHeight}),i+r[0].offsetHeight-o.scrollTop()>o[0].clientHeight?o.scrollTop(i+r[0].offsetHeight-o.innerHeight()):i<o.scrollTop()&&o.scrollTop(i))}function w(n){e+=n;e<0?e=f.size()-1:e>=f.size()&&(e=0)}function b(n){return t.max&&t.max<n?t.max:n}function k(){var r,i,u,h;for(o.empty(),r=b(c.length),i=0;i<r;i++)c[i]&&(u=t.formatItem(c[i].data,i+1,r,c[i].value,v),u!==!1)&&(h=n("<li/>").html(t.highlight(u,v)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(o)[0],n.data(h,"ac_data",c[i]));f=o.find("li");t.selectFirst&&(f.slice(0,1).addClass(s.ACTIVE),e=0);n.fn.bgiframe&&o.bgiframe()}var s={ACTIVE:"ac_over"},f,e=-1,c,v="",y=!0,h,o;return{display:function(n,t){p();c=n;v=t;k()},next:function(){l(1)},prev:function(){l(-1)},pageUp:function(){e!=0&&e-8<0?l(-e):l(-8)},pageDown:function(){e!=f.size()-1&&e+8>f.size()?l(f.size()-1-e):l(8)},hide:function(){h&&h.hide();f&&f.removeClass(s.ACTIVE);e=-1},visible:function(){return h&&h.is(":visible")},current:function(){return this.visible()&&(f.filter("."+s.ACTIVE)[0]||t.selectFirst&&f[0])},show:function(){var e=n(i).offset(),r,u;h.css({width:typeof t.width=="string"||t.width>0?t.width:n(i).width(),top:e.top+i.offsetHeight,left:e.left}).show();t.scroll&&(o.scrollTop(0),o.css({maxHeight:t.scrollHeight,overflow:"auto"}),n.browser.msie&&typeof document.body.style.maxHeight=="undefined"&&(r=0,f.each(function(){r+=this.offsetHeight}),u=r>t.scrollHeight,o.css("height",u?t.scrollHeight:r),u||f.width(o.width()-parseInt(f.css("padding-left"))-parseInt(f.css("padding-right")))))},selected:function(){var t=f&&f.filter("."+s.ACTIVE).removeClass(s.ACTIVE);return t&&t.length&&n.data(t[0],"ac_data")},emptyList:function(){o&&o.empty()},unbind:function(){h&&h.remove()}}};n.fn.selection=function(n,t){var i,r;if(n!==undefined)return this.each(function(){if(this.createTextRange){var i=this.createTextRange();t===undefined||n==t?(i.move("character",n),i.select()):(i.collapse(!0),i.moveStart("character",n),i.moveEnd("character",t),i.select())}else this.setSelectionRange?this.setSelectionRange(n,t):this.selectionStart&&(this.selectionStart=n,this.selectionEnd=t)});if(i=this[0],i.createTextRange){var u=document.selection.createRange(),o=i.value,f="<->",e=u.text.length;return u.text=f,r=i.value.indexOf(f),i.value=o,this.selection(r,r+e),{start:r,end:r+e}}if(i.selectionStart!==undefined)return{start:i.selectionStart,end:i.selectionEnd}}}(jQuery)