/*
 VisualSearch.js 0.1.0
 (c) 2011 Samuel Clay, @samuelclay, DocumentCloud Inc.
 VisualSearch.js may be freely distributed under the MIT license.
 For all details and documentation:
 http://documentcloud.github.com/visualsearch
*/
(function(){window.dc={};dc.controllers={};dc.model={};dc.app={};dc.ui={}})();
(function(){function a(b,c,f){if(b===c)return b!==0||1/b==1/c;if(b==null||c==null)return b===c;if(b._chain)b=b._wrapped;if(c._chain)c=c._wrapped;if(b.isEqual&&j.isFunction(b.isEqual))return b.isEqual(c);if(c.isEqual&&j.isFunction(c.isEqual))return c.isEqual(b);var e=l.call(b);if(e!=l.call(c))return!1;switch(e){case "[object String]":return b==String(c);case "[object Number]":return b!=+b?c!=+c:b==0?1/b==1/c:b==+c;case "[object Date]":case "[object Boolean]":return+b==+c;case "[object RegExp]":return b.source==
c.source&&b.global==c.global&&b.multiline==c.multiline&&b.ignoreCase==c.ignoreCase}if(typeof b!="object"||typeof c!="object")return!1;for(var d=f.length;d--;)if(f[d]==b)return!0;f.push(b);d=0;var g=!0;if(e=="[object Array]"){if(d=b.length,g=d==c.length)for(;d--;)if(!(g=d in b==d in c&&a(b[d],c[d],f)))break}else{if("constructor"in b!="constructor"in c||b.constructor!=c.constructor)return!1;for(var h in b)if(j.has(b,h)&&(d++,!(g=j.has(c,h)&&a(b[h],c[h],f))))break;if(g){for(h in c)if(j.has(c,h)&&!d--)break;
g=!d}}f.pop();return g}var b=this,c=b._,d={},e=Array.prototype,g=Object.prototype,h=e.slice,k=e.unshift,l=g.toString,s=g.hasOwnProperty,z=e.forEach,q=e.map,x=e.reduce,B=e.reduceRight,K=e.filter,M=e.every,F=e.some,G=e.indexOf,L=e.lastIndexOf;g=Array.isArray;var V=Object.keys,m=Function.prototype.bind,j=function(a){return new R(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=j;exports._=j}else b._=j;j.VERSION="1.3.1";var A=j.each=j.forEach=
function(a,b,c){if(a!=null)if(z&&a.forEach===z)a.forEach(b,c);else if(a.length===+a.length)for(var f=0,e=a.length;f<e;f++){if(f in a&&b.call(c,a[f],f,a)===d)break}else for(f in a)if(j.has(a,f)&&b.call(c,a[f],f,a)===d)break};j.map=j.collect=function(a,b,c){var f=[];if(a==null)return f;if(q&&a.map===q)return a.map(b,c);A(a,function(a,e,d){f[f.length]=b.call(c,a,e,d)});if(a.length===+a.length)f.length=a.length;return f};j.reduce=j.foldl=j.inject=function(a,b,c,f){var e=arguments.length>2;a==null&&(a=
[]);if(x&&a.reduce===x)return f&&(b=j.bind(b,f)),e?a.reduce(b,c):a.reduce(b);A(a,function(a,d,g){e?c=b.call(f,c,a,d,g):(c=a,e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c};j.reduceRight=j.foldr=function(a,b,c,f){var e=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B)return f&&(b=j.bind(b,f)),e?a.reduceRight(b,c):a.reduceRight(b);var d=j.toArray(a).reverse();f&&!e&&(b=j.bind(b,f));return e?j.reduce(d,b,c,f):j.reduce(d,b)};j.find=j.detect=function(a,
b,c){var f;I(a,function(a,e,d){if(b.call(c,a,e,d))return f=a,!0});return f};j.filter=j.select=function(a,b,c){var f=[];if(a==null)return f;if(K&&a.filter===K)return a.filter(b,c);A(a,function(a,e,d){b.call(c,a,e,d)&&(f[f.length]=a)});return f};j.reject=function(a,b,c){var f=[];if(a==null)return f;A(a,function(a,e,d){b.call(c,a,e,d)||(f[f.length]=a)});return f};j.every=j.all=function(a,b,c){var f=!0;if(a==null)return f;if(M&&a.every===M)return a.every(b,c);A(a,function(a,e,g){if(!(f=f&&b.call(c,a,
e,g)))return d});return f};var I=j.some=j.any=function(a,b,c){b||(b=j.identity);var f=!1;if(a==null)return f;if(F&&a.some===F)return a.some(b,c);A(a,function(a,e,g){if(f||(f=b.call(c,a,e,g)))return d});return!!f};j.include=j.contains=function(a,b){var c=!1;if(a==null)return c;if(G&&a.indexOf===G)return a.indexOf(b)!=-1;return c=I(a,function(a){return a===b})};j.invoke=function(a,b){var c=h.call(arguments,2);return j.map(a,function(a){return(j.isFunction(b)?b||a:a[b]).apply(a,c)})};j.pluck=function(a,
b){return j.map(a,function(a){return a[b]})};j.max=function(a,b,c){if(!b&&j.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!b&&j.isEmpty(a))return-Infinity;var f={computed:-Infinity};A(a,function(a,e,d){e=b?b.call(c,a,e,d):a;e>=f.computed&&(f={value:a,computed:e})});return f.value};j.min=function(a,b,c){if(!b&&j.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!b&&j.isEmpty(a))return Infinity;var f={computed:Infinity};A(a,function(a,e,d){e=b?b.call(c,a,e,d):a;e<f.computed&&(f=
{value:a,computed:e})});return f.value};j.shuffle=function(a){var b=[],c;A(a,function(a,f){f==0?b[0]=a:(c=Math.floor(Math.random()*(f+1)),b[f]=b[c],b[c]=a)});return b};j.sortBy=function(a,b,c){return j.pluck(j.map(a,function(a,f,e){return{value:a,criteria:b.call(c,a,f,e)}}).sort(function(a,b){var c=a.criteria,f=b.criteria;return c<f?-1:c>f?1:0}),"value")};j.groupBy=function(a,b){var c={},f=j.isFunction(b)?b:function(a){return a[b]};A(a,function(a,b){var e=f(a,b);(c[e]||(c[e]=[])).push(a)});return c};
j.sortedIndex=function(a,b,c){c||(c=j.identity);for(var f=0,e=a.length;f<e;){var d=f+e>>1;c(a[d])<c(b)?f=d+1:e=d}return f};j.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(j.isArray(a))return h.call(a);if(j.isArguments(a))return h.call(a);return j.values(a)};j.size=function(a){return j.toArray(a).length};j.first=j.head=function(a,b,c){return b!=null&&!c?h.call(a,0,b):a[0]};j.initial=function(a,b,c){return h.call(a,0,a.length-(b==null||c?1:b))};j.last=function(a,b,c){return b!=
null&&!c?h.call(a,Math.max(a.length-b,0)):a[a.length-1]};j.rest=j.tail=function(a,b,c){return h.call(a,b==null||c?1:b)};j.compact=function(a){return j.filter(a,function(a){return!!a})};j.flatten=function(a,b){return j.reduce(a,function(a,c){if(j.isArray(c))return a.concat(b?c:j.flatten(c));a[a.length]=c;return a},[])};j.without=function(a){return j.difference(a,h.call(arguments,1))};j.uniq=j.unique=function(a,b,c){c=c?j.map(a,c):a;var f=[];j.reduce(c,function(c,e,d){if(0==d||(b===!0?j.last(c)!=e:
!j.include(c,e)))c[c.length]=e,f[f.length]=a[d];return c},[]);return f};j.union=function(){return j.uniq(j.flatten(arguments,!0))};j.intersection=j.intersect=function(a){var b=h.call(arguments,1);return j.filter(j.uniq(a),function(a){return j.every(b,function(b){return j.indexOf(b,a)>=0})})};j.difference=function(a){var b=j.flatten(h.call(arguments,1));return j.filter(a,function(a){return!j.include(b,a)})};j.zip=function(){for(var a=h.call(arguments),b=j.max(j.pluck(a,"length")),c=Array(b),f=0;f<
b;f++)c[f]=j.pluck(a,""+f);return c};j.indexOf=function(a,b,c){if(a==null)return-1;var f;if(c)return c=j.sortedIndex(a,b),a[c]===b?c:-1;if(G&&a.indexOf===G)return a.indexOf(b);c=0;for(f=a.length;c<f;c++)if(c in a&&a[c]===b)return c;return-1};j.lastIndexOf=function(a,b){if(a==null)return-1;if(L&&a.lastIndexOf===L)return a.lastIndexOf(b);for(var c=a.length;c--;)if(c in a&&a[c]===b)return c;return-1};j.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0);c=arguments[2]||1;for(var f=Math.max(Math.ceil((b-
a)/c),0),e=0,d=Array(f);e<f;)d[e++]=a,a+=c;return d};var S=function(){};j.bind=function(a,b){var c,f;if(a.bind===m&&m)return m.apply(a,h.call(arguments,1));if(!j.isFunction(a))throw new TypeError;f=h.call(arguments,2);return c=function(){if(!(this instanceof c))return a.apply(b,f.concat(h.call(arguments)));S.prototype=a.prototype;var e=new S,d=a.apply(e,f.concat(h.call(arguments)));if(Object(d)===d)return d;return e}};j.bindAll=function(a){var b=h.call(arguments,1);b.length==0&&(b=j.functions(a));
A(b,function(b){a[b]=j.bind(a[b],a)});return a};j.memoize=function(a,b){var c={};b||(b=j.identity);return function(){var f=b.apply(this,arguments);return j.has(c,f)?c[f]:c[f]=a.apply(this,arguments)}};j.delay=function(a,b){var c=h.call(arguments,2);return setTimeout(function(){return a.apply(a,c)},b)};j.defer=function(a){return j.delay.apply(j,[a,1].concat(h.call(arguments,1)))};j.throttle=function(a,b){var c,f,e,d,g,h=j.debounce(function(){g=d=!1},b);return function(){c=this;f=arguments;var j;e||
(e=setTimeout(function(){e=null;g&&a.apply(c,f);h()},b));d?g=!0:a.apply(c,f);h();d=!0}};j.debounce=function(a,b){var c;return function(){var f=this,e=arguments;clearTimeout(c);c=setTimeout(function(){c=null;a.apply(f,e)},b)}};j.once=function(a){var b=!1,c;return function(){if(b)return c;b=!0;return c=a.apply(this,arguments)}};j.wrap=function(a,b){return function(){var c=[a].concat(h.call(arguments,0));return b.apply(this,c)}};j.compose=function(){var a=arguments;return function(){for(var b=arguments,
c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}};j.after=function(a,b){if(a<=0)return b();return function(){if(--a<1)return b.apply(this,arguments)}};j.keys=V||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[],c;for(c in a)j.has(a,c)&&(b[b.length]=c);return b};j.values=function(a){return j.map(a,j.identity)};j.functions=j.methods=function(a){var b=[],c;for(c in a)j.isFunction(a[c])&&b.push(c);return b.sort()};j.extend=function(a){A(h.call(arguments,1),function(b){for(var c in b)a[c]=
b[c]});return a};j.defaults=function(a){A(h.call(arguments,1),function(b){for(var c in b)a[c]==null&&(a[c]=b[c])});return a};j.clone=function(a){if(!j.isObject(a))return a;return j.isArray(a)?a.slice():j.extend({},a)};j.tap=function(a,b){b(a);return a};j.isEqual=function(b,c){return a(b,c,[])};j.isEmpty=function(a){if(j.isArray(a)||j.isString(a))return a.length===0;for(var b in a)if(j.has(a,b))return!1;return!0};j.isElement=function(a){return!!(a&&a.nodeType==1)};j.isArray=g||function(a){return l.call(a)==
"[object Array]"};j.isObject=function(a){return a===Object(a)};j.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!j.isArguments(arguments))j.isArguments=function(a){return!(!a||!j.has(a,"callee"))};j.isFunction=function(a){return l.call(a)=="[object Function]"};j.isString=function(a){return l.call(a)=="[object String]"};j.isNumber=function(a){return l.call(a)=="[object Number]"};j.isNaN=function(a){return a!==a};j.isBoolean=function(a){return a===!0||a===!1||l.call(a)=="[object Boolean]"};
j.isDate=function(a){return l.call(a)=="[object Date]"};j.isRegExp=function(a){return l.call(a)=="[object RegExp]"};j.isNull=function(a){return a===null};j.isUndefined=function(a){return a===void 0};j.has=function(a,b){return s.call(a,b)};j.noConflict=function(){b._=c;return this};j.identity=function(a){return a};j.times=function(a,b,c){for(var f=0;f<a;f++)b.call(c,f)};j.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,
"&#x27;").replace(/\//g,"&#x2F;")};j.mixin=function(a){A(j.functions(a),function(b){f(b,j[b]=a[b])})};var oa=0;j.uniqueId=function(a){var b=oa++;return a?a+b:b};j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var ca=/.^/,v=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};j.template=function(a,b){var c=j.templateSettings;c="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,
"\\'").replace(c.escape||ca,function(a,b){return"',_.escape("+v(b)+"),'"}).replace(c.interpolate||ca,function(a,b){return"',"+v(b)+",'"}).replace(c.evaluate||ca,function(a,b){return"');"+v(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";var f=new Function("obj","_",c);if(b)return f(b,j);return function(a){return f.call(this,a,j)}};j.chain=function(a){return j(a).chain()};var R=function(a){this._wrapped=a};j.prototype=
R.prototype;var ja=function(a,b){return b?j(a).chain():a},f=function(a,b){R.prototype[a]=function(){var a=h.call(arguments);k.call(a,this._wrapped);return ja(b.apply(j,a),this._chain)}};j.mixin(j);A(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=e[a];R.prototype[a]=function(){var c=this._wrapped;b.apply(c,arguments);var f=c.length;(a=="shift"||a=="splice")&&f===0&&delete c[0];return ja(c,this._chain)}});A(["concat","join","slice"],function(a){var b=e[a];R.prototype[a]=
function(){return ja(b.apply(this._wrapped,arguments),this._chain)}});R.prototype.chain=function(){this._chain=!0;return this};R.prototype.value=function(){return this._wrapped}}).call(this);
(function(a,b){function c(a){var b=ka[a]={},c,f;a=a.split(/\s+/);c=0;for(f=a.length;c<f;c++)b[a[c]]=!0;return b}function d(a,c,e){if(e===b&&a.nodeType===1)if(e="data-"+c.replace(ma,"-$1").toLowerCase(),e=a.getAttribute(e),typeof e==="string"){try{e=e==="true"?!0:e==="false"?!1:e==="null"?null:f.isNumeric(e)?parseFloat(e):ra.test(e)?f.parseJSON(e):e}catch(d){}f.data(a,c,e)}else e=b;return e}function e(a){for(var b in a)if(!(b==="data"&&f.isEmptyObject(a[b]))&&b!=="toJSON")return!1;return!0}function g(a,
b,c){var e=b+"defer",d=b+"queue",g=b+"mark",j=f._data(a,e);j&&(c==="queue"||!f._data(a,d))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,d)&&!f._data(a,g)&&(f.removeData(a,e,!0),j.fire())},0)}function h(){return!1}function k(){return!0}function l(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,r){return!!b.call(a,r,a)===c});else if(b.nodeType)return f.grep(a,function(a){return a===b===c});else if(typeof b==="string"){var e=f.grep(a,function(a){return a.nodeType===1});
if(Aa.test(b))return f.filter(b,e,!c);else b=f.filter(b,e)}return f.grep(a,function(a){return f.inArray(a,b)>=0===c})}function s(a){var b=Ca.split("|");a=a.createDocumentFragment();if(a.createElement)for(;b.length;)a.createElement(b.pop());return a}function z(a,b){if(b.nodeType===1&&f.hasData(a)){var c,e,d;e=f._data(a);var g=f._data(b,e),j=e.events;if(j)for(c in delete g.handle,g.events={},j){e=0;for(d=j[c].length;e<d;e++)f.event.add(b,c+(j[c][e].namespace?".":"")+j[c][e].namespace,j[c][e],j[c][e].data)}if(g.data)g.data=
f.extend({},g.data)}}function q(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes();b.mergeAttributes&&b.mergeAttributes(a);c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c==="input"&&(a.type==="checkbox"||a.type==="radio")){if(a.checked)b.defaultChecked=b.checked=a.checked;if(b.value!==a.value)b.value=a.value}else if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue;b.removeAttribute(f.expando)}}
function x(a){return typeof a.getElementsByTagName!=="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!=="undefined"?a.querySelectorAll("*"):[]}function B(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function K(a){var b=(a.nodeName||"").toLowerCase();b==="input"?B(a):b!=="script"&&typeof a.getElementsByTagName!=="undefined"&&f.grep(a.getElementsByTagName("input"),B)}function M(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||
b.textContent||b.innerHTML||"").replace(db,"/*$0*/"));b.parentNode&&b.parentNode.removeChild(b)}function F(a,b,c){var e=b==="width"?a.offsetWidth:a.offsetHeight,d=b==="width"?eb:fb,g=0,j=d.length;if(e>0){if(c!=="border")for(;g<j;g++)c||(e-=parseFloat(f.css(a,"padding"+d[g]))||0),c==="margin"?e+=parseFloat(f.css(a,c+d[g]))||0:e-=parseFloat(f.css(a,"border"+d[g]+"Width"))||0;return e+"px"}e=sa(a,b,b);if(e<0||e==null)e=a.style[b]||0;e=parseFloat(e)||0;if(c)for(;g<j;g++)e+=parseFloat(f.css(a,"padding"+
d[g]))||0,c!=="padding"&&(e+=parseFloat(f.css(a,"border"+d[g]+"Width"))||0),c==="margin"&&(e+=parseFloat(f.css(a,c+d[g]))||0);return e+"px"}function G(a){return function(b,c){typeof b!=="string"&&(c=b,b="*");if(f.isFunction(c))for(var e=b.toLowerCase().split(Pa),d=0,g=e.length,j,h;d<g;d++)j=e[d],(h=/^\+/.test(j))&&(j=j.substr(1)||"*"),j=a[j]=a[j]||[],j[h?"unshift":"push"](c)}}function L(a,c,f,e,d,g){d=d||c.dataTypes[0];g=g||{};g[d]=!0;d=a[d];for(var j=0,h=d?d.length:0,m=a===Ia,n;j<h&&(m||!n);j++)n=
d[j](c,f,e),typeof n==="string"&&(!m||g[n]?n=b:(c.dataTypes.unshift(n),n=L(a,c,f,e,n,g)));if((m||!n)&&!g["*"])n=L(a,c,f,e,"*",g);return n}function V(a,c){var e,d,g=f.ajaxSettings.flatOptions||{};for(e in c)c[e]!==b&&((g[e]?a:d||(d={}))[e]=c[e]);d&&f.extend(!0,a,d)}function m(a,b,c,e){if(f.isArray(b))f.each(b,function(b,p){c||gb.test(a)?e(a,p):m(a+"["+(typeof p==="object"||f.isArray(p)?b:"")+"]",p,c,e)});else if(!c&&b!=null&&typeof b==="object")for(var d in b)m(a+"["+d+"]",b[d],c,e);else e(a,b)}function j(){try{return new a.XMLHttpRequest}catch(b){}}
function A(){setTimeout(I,0);return Da=f.now()}function I(){Da=b}function S(a,b){var c={};f.each(Qa.concat.apply([],Qa.slice(0,b)),function(){c[this]=a});return c}function oa(a){if(!Ja[a]){var b=v.body,c=f("<"+a+">").appendTo(b),e=c.css("display");c.remove();if(e==="none"||e===""){if(!ga)ga=v.createElement("iframe"),ga.frameBorder=ga.width=ga.height=0;b.appendChild(ga);if(!ta||!ga.createElement)ta=(ga.contentWindow||ga.contentDocument).document,ta.write((v.compatMode==="CSS1Compat"?"<!doctype html>":
"")+"<html><body>"),ta.close();c=ta.createElement(a);ta.body.appendChild(c);e=f.css(c,"display");b.removeChild(ga)}Ja[a]=e}return Ja[a]}function ca(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}var v=a.document,R=a.navigator,ja=a.location,f=function(){function c(){if(!p.isReady){try{v.documentElement.doScroll("left")}catch(a){setTimeout(c,1);return}p.ready()}}var p=function(a,b){return new p.fn.init(a,b,d)},f=a.jQuery,e=a.$,d,g=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
j=/\S/,h=/^\s+/,m=/\s+$/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,w=/^[\],:{}\s]*$/,u=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,E=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,P=/(?:^|:|,)(?:\s*\[)+/g,k=/(webkit)[ \/]([\w.]+)/,l=/(opera)(?:.*version)?[ \/]([\w.]+)/,A=/(msie) ([\w.]+)/,o=/(mozilla)(?:.*? rv:([\w.]+))?/,y=/-([a-z]|[0-9])/ig,q=/^-ms-/,H=function(a,b){return(b+"").toUpperCase()},B=R.userAgent,Ea,ua,hb=Object.prototype.toString,Ka=Object.prototype.hasOwnProperty,La=Array.prototype.push,
Ba=Array.prototype.slice,I=String.prototype.trim,t=Array.prototype.indexOf,s={};p.fn=p.prototype={constructor:p,init:function(a,c,r){var f;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(a==="body"&&!c&&v.body)return this.context=v,this[0]=v.body,this.selector=a,this.length=1,this;if(typeof a==="string")if((f=a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?[null,a,null]:g.exec(a))&&(f[1]||!c))if(f[1])return r=(c=c instanceof p?c[0]:c)?c.ownerDocument||
c:v,(a=n.exec(a))?p.isPlainObject(c)?(a=[v.createElement(a[1])],p.fn.attr.call(a,c,!0)):a=[r.createElement(a[1])]:(a=p.buildFragment([f[1]],[r]),a=(a.cacheable?p.clone(a.fragment):a.fragment).childNodes),p.merge(this,a);else{if((c=v.getElementById(f[2]))&&c.parentNode){if(c.id!==f[2])return r.find(a);this.length=1;this[0]=c}this.context=v;this.selector=a;return this}else return!c||c.jquery?(c||r).find(a):this.constructor(c).find(a);else if(p.isFunction(a))return r.ready(a);if(a.selector!==b)this.selector=
a.selector,this.context=a.context;return p.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return Ba.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var r=this.constructor();p.isArray(a)?La.apply(r,a):p.merge(r,a);r.prevObject=this;r.context=this.context;if(b==="find")r.selector=this.selector+(this.selector?" ":"")+c;else if(b)r.selector=this.selector+"."+b+"("+c+")";
return r},each:function(a,b){return p.each(this,a,b)},ready:function(a){p.bindReady();Ea.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(Ba.apply(this,arguments),"slice",Ba.call(arguments).join(","))},map:function(a){return this.pushStack(p.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},
push:La,sort:[].sort,splice:[].splice};p.fn.init.prototype=p.fn;p.extend=p.fn.extend=function(){var a,c,r,f,e,d=arguments[0]||{},g=1,J=arguments.length,fa=!1;typeof d==="boolean"&&(fa=d,d=arguments[1]||{},g=2);typeof d!=="object"&&!p.isFunction(d)&&(d={});J===g&&(d=this,--g);for(;g<J;g++)if((a=arguments[g])!=null)for(c in a)r=d[c],f=a[c],d!==f&&(fa&&f&&(p.isPlainObject(f)||(e=p.isArray(f)))?(e?(e=!1,r=r&&p.isArray(r)?r:[]):r=r&&p.isPlainObject(r)?r:{},d[c]=p.extend(fa,r,f)):f!==b&&(d[c]=f));return d};
p.extend({noConflict:function(b){if(a.$===p)a.$=e;if(b&&a.jQuery===p)a.jQuery=f;return p},isReady:!1,readyWait:1,holdReady:function(a){a?p.readyWait++:p.ready(!0)},ready:function(a){if(a===!0&&!--p.readyWait||a!==!0&&!p.isReady){if(!v.body)return setTimeout(p.ready,1);p.isReady=!0;a!==!0&&--p.readyWait>0||(Ea.fireWith(v,[p]),p.fn.trigger&&p(v).trigger("ready").off("ready"))}},bindReady:function(){if(!Ea){Ea=p.Callbacks("once memory");if(v.readyState==="complete")return setTimeout(p.ready,1);if(v.addEventListener)v.addEventListener("DOMContentLoaded",
ua,!1),a.addEventListener("load",p.ready,!1);else if(v.attachEvent){v.attachEvent("onreadystatechange",ua);a.attachEvent("onload",p.ready);var b=!1;try{b=a.frameElement==null}catch(f){}v.documentElement.doScroll&&b&&c()}}},isFunction:function(a){return p.type(a)==="function"},isArray:Array.isArray||function(a){return p.type(a)==="array"},isWindow:function(a){return a&&typeof a==="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==
null?String(a):s[hb.call(a)]||"object"},isPlainObject:function(a){if(!a||p.type(a)!=="object"||a.nodeType||p.isWindow(a))return!1;try{if(a.constructor&&!Ka.call(a,"constructor")&&!Ka.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}for(var r in a);return r===b||Ka.call(a,r)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw Error(a);},parseJSON:function(b){if(typeof b!=="string"||!b)return null;b=p.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);
if(w.test(b.replace(u,"@").replace(E,"]").replace(P,"")))return(new Function("return "+b))();p.error("Invalid JSON: "+b)},parseXML:function(c){var r,f;try{a.DOMParser?(f=new DOMParser,r=f.parseFromString(c,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(c))}catch(e){r=b}(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&p.error("Invalid XML: "+c);return r},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,
b)})(b)},camelCase:function(a){return a.replace(q,"ms-").replace(y,H)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,r){var f,e=0,d=a.length,g=d===b||p.isFunction(a);if(r)if(g)for(f in a){if(c.apply(a[f],r)===!1)break}else for(;e<d;){if(c.apply(a[e++],r)===!1)break}else if(g)for(f in a){if(c.call(a[f],f,a[f])===!1)break}else for(;e<d;)if(c.call(a[e],e,a[e++])===!1)break;return a},trim:I?function(a){return a==null?"":I.call(a)}:function(a){return a==
null?"":a.toString().replace(h,"").replace(m,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var r=p.type(a);a.length==null||r==="string"||r==="function"||r==="regexp"||p.isWindow(a)?La.call(c,a):p.merge(c,a)}return c},inArray:function(a,b,c){var r;if(b){if(t)return t.call(b,a,c);r=b.length;for(c=c?c<0?Math.max(0,r+c):c:0;c<r;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var r=a.length,f=0;if(typeof c.length==="number")for(var p=c.length;f<p;f++)a[r++]=c[f];else for(;c[f]!==
b;)a[r++]=c[f++];a.length=r;return a},grep:function(a,b,c){var r=[],f;c=!!c;for(var p=0,e=a.length;p<e;p++)f=!!b(a[p],p),c!==f&&r.push(a[p]);return r},map:function(a,c,r){var f,e,d=[],g=0,J=a.length;if(a instanceof p||J!==b&&typeof J==="number"&&(J>0&&a[0]&&a[J-1]||J===0||p.isArray(a)))for(;g<J;g++)f=c(a[g],g,r),f!=null&&(d[d.length]=f);else for(e in a)f=c(a[e],e,r),f!=null&&(d[d.length]=f);return d.concat.apply([],d)},guid:1,proxy:function(a,c){if(typeof c==="string"){var r=a[c];c=a;a=r}if(!p.isFunction(a))return b;
var f=Ba.call(arguments,2);r=function(){return a.apply(c,f.concat(Ba.call(arguments)))};r.guid=a.guid=a.guid||r.guid||p.guid++;return r},access:function(a,c,r,f,e,d){var g=a.length;if(typeof c==="object"){for(var J in c)p.access(a,J,c[J],f,e,r);return a}if(r!==b){f=!d&&f&&p.isFunction(r);for(J=0;J<g;J++)e(a[J],c,f?r.call(a[J],J,e(a[J],c)):r,d);return a}return g?e(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();a=k.exec(a)||l.exec(a)||A.exec(a)||a.indexOf("compatible")<
0&&o.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}p.extend(!0,a,this);a.superclass=this;a.fn=a.prototype=this();a.fn.constructor=a;a.sub=this.sub;a.fn.init=function(c,r){r&&r instanceof p&&!(r instanceof a)&&(r=a(r));return p.fn.init.call(this,c,r,b)};a.fn.init.prototype=a.fn;var b=a(v);return a},browser:{}});p.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){s["[object "+b+"]"]=b.toLowerCase()});
B=p.uaMatch(B);if(B.browser)p.browser[B.browser]=!0,p.browser.version=B.version;if(p.browser.webkit)p.browser.safari=!0;j.test("\u00a0")&&(h=/^[\s\xA0]+/,m=/[\s\xA0]+$/);d=p(v);v.addEventListener?ua=function(){v.removeEventListener("DOMContentLoaded",ua,!1);p.ready()}:v.attachEvent&&(ua=function(){v.readyState==="complete"&&(v.detachEvent("onreadystatechange",ua),p.ready())});return p}(),ka={};f.Callbacks=function(a){a=a?ka[a]||c(a):{};var p=[],e=[],d,g,j,h,m,n=function(b){var c,e,d,g;c=0;for(e=b.length;c<
e;c++)d=b[c],g=f.type(d),g==="array"?n(d):g==="function"&&(!a.unique||!u.has(d))&&p.push(d)},w=function(b,c){c=c||[];d=!a.memory||[b,c];g=!0;m=j||0;j=0;for(h=p.length;p&&m<h;m++)if(p[m].apply(b,c)===!1&&a.stopOnFalse){d=!0;break}g=!1;p&&(a.once?d===!0?u.disable():p=[]:e&&e.length&&(d=e.shift(),u.fireWith(d[0],d[1])))},u={add:function(){if(p){var a=p.length;n(arguments);g?h=p.length:d&&d!==!0&&(j=a,w(d[0],d[1]))}return this},remove:function(){if(p)for(var b=arguments,c=0,f=b.length;c<f;c++)for(var e=
0;e<p.length;e++)if(b[c]===p[e]&&(g&&e<=h&&(h--,e<=m&&m--),p.splice(e--,1),a.unique))break;return this},has:function(a){if(p)for(var b=0,c=p.length;b<c;b++)if(a===p[b])return!0;return!1},empty:function(){p=[];return this},disable:function(){p=e=d=b;return this},disabled:function(){return!p},lock:function(){e=b;(!d||d===!0)&&u.disable();return this},locked:function(){return!e},fireWith:function(b,c){e&&(g?a.once||e.push([b,c]):(!a.once||!d)&&w(b,c));return this},fire:function(){u.fireWith(this,arguments);
return this},fired:function(){return!!d}};return u};var la=[].slice;f.extend({Deferred:function(a){var b=f.Callbacks("once memory"),c=f.Callbacks("once memory"),e=f.Callbacks("memory"),d="pending",g={resolve:b,reject:c,notify:e},j={done:b.add,fail:c.add,progress:e.add,state:function(){return d},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){h.done(a).fail(b).progress(c);return this},always:function(){h.done.apply(h,arguments).fail.apply(h,arguments);return this},pipe:function(a,b,c){return f.Deferred(function(r){f.each({done:[a,
"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],p=b[1],e;if(f.isFunction(c))h[a](function(){if((e=c.apply(this,arguments))&&f.isFunction(e.promise))e.promise().then(r.resolve,r.reject,r.notify);else r[p+"With"](this===h?r:this,[e])});else h[a](r[p])})}).promise()},promise:function(a){if(a==null)a=j;else for(var b in j)a[b]=j[b];return a}},h=j.promise({}),m;for(m in g)h[m]=g[m].fire,h[m+"With"]=g[m].fireWith;h.done(function(){d="resolved"},c.disable,e.lock).fail(function(){d=
"rejected"},b.disable,e.lock);a&&a.call(h,h);return h},when:function(a){function b(a){return function(b){e[a]=arguments.length>1?la.call(arguments,0):b;--h||m.resolveWith(m,e)}}function c(a){return function(b){j[a]=arguments.length>1?la.call(arguments,0):b;m.notifyWith(n,j)}}var e=la.call(arguments,0),d=0,g=e.length,j=Array(g),h=g,m=g<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),n=m.promise();if(g>1){for(;d<g;d++)e[d]&&e[d].promise&&f.isFunction(e[d].promise)?e[d].promise().then(b(d),m.reject,c(d)):
--h;h||m.resolveWith(m,e)}else m!==a&&m.resolveWith(m,g?[a]:[]);return n}});f.support=function(){var b,c,e,d,g,j,h,m,n=v.createElement("div");n.setAttribute("className","t");n.innerHTML="   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";c=n.getElementsByTagName("*");e=n.getElementsByTagName("a")[0];if(!c||!c.length||!e)return{};d=v.createElement("select");g=d.appendChild(v.createElement("option"));c=n.getElementsByTagName("input")[0];b={leadingWhitespace:n.firstChild.nodeType===
3,tbody:!n.getElementsByTagName("tbody").length,htmlSerialize:!!n.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:c.value==="on",optSelected:g.selected,getSetAttribute:n.className!=="t",enctype:!!v.createElement("form").enctype,html5Clone:v.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,
deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0};c.checked=!0;b.noCloneChecked=c.cloneNode(!0).checked;d.disabled=!0;b.optDisabled=!g.disabled;try{delete n.test}catch(u){b.deleteExpando=!1}!n.addEventListener&&n.attachEvent&&n.fireEvent&&(n.attachEvent("onclick",function(){b.noCloneEvent=!1}),n.cloneNode(!0).fireEvent("onclick"));c=v.createElement("input");c.value="t";c.setAttribute("type","radio");b.radioValue=c.value==="t";c.setAttribute("checked",
"checked");n.appendChild(c);e=v.createDocumentFragment();e.appendChild(n.lastChild);b.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked;b.appendChecked=c.checked;e.removeChild(c);e.appendChild(n);n.innerHTML="";if(a.getComputedStyle)c=v.createElement("div"),c.style.width="0",c.style.marginRight="0",n.style.width="2px",n.appendChild(c),b.reliableMarginRight=(parseInt((a.getComputedStyle(c,null)||{marginRight:0}).marginRight,10)||0)===0;if(n.attachEvent)for(h in{submit:1,change:1,focusin:1})c=
"on"+h,m=c in n,m||(n.setAttribute(c,"return;"),m=typeof n[c]==="function"),b[h+"Bubbles"]=m;e.removeChild(n);e=d=g=c=n=c=null;f(function(){var a,c,e,p,d=v.getElementsByTagName("body")[0];if(d){a=v.createElement("div");a.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";d.insertBefore(a,d.firstChild);n=v.createElement("div");a.appendChild(n);n.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";j=n.getElementsByTagName("td");
m=j[0].offsetHeight===0;j[0].style.display="";j[1].style.display="none";b.reliableHiddenOffsets=m&&j[0].offsetHeight===0;n.innerHTML="";n.style.width=n.style.paddingLeft="1px";f.boxModel=b.boxModel=n.offsetWidth===2;if(typeof n.style.zoom!=="undefined")n.style.display="inline",n.style.zoom=1,b.inlineBlockNeedsLayout=n.offsetWidth===2,n.style.display="",n.innerHTML="<div style='width:4px;'></div>",b.shrinkWrapBlocks=n.offsetWidth!==2;n.style.cssText="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;visibility:hidden;border:0;";
n.innerHTML="<div style='position:absolute;top:0;left:0;width:1px;height:1px;margin:0;border:5px solid #000;padding:0;'><div></div></div><table style='position:absolute;top:0;left:0;width:1px;height:1px;margin:0;border:5px solid #000;padding:0;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";c=n.firstChild;e=c.firstChild;p={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:c.nextSibling.firstChild.firstChild.offsetTop===5};e.style.position="fixed";e.style.top="20px";p.fixedPosition=
e.offsetTop===20||e.offsetTop===15;e.style.position=e.style.top="";c.style.overflow="hidden";c.style.position="relative";p.subtractsBorderForOverflowNotVisible=e.offsetTop===-5;p.doesNotIncludeMarginInBodyOffset=d.offsetTop!==1;d.removeChild(a);n=null;f.extend(b,p)}});return b}();var ra=/^(?:\{.*\}|\[.*\])$/,ma=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=
a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!e(a)},data:function(a,c,e,d){if(f.acceptData(a)){var g;g=f.expando;var j=typeof c==="string",h=a.nodeType,m=h?f.cache:a,n=h?a[g]:a[g]&&g,u=c==="events";if(n&&m[n]&&(u||d||m[n].data)||!(j&&e===b)){n||(h?a[g]=n=++f.uuid:n=g);if(!m[n]&&(m[n]={},!h))m[n].toJSON=f.noop;if(typeof c==="object"||typeof c==="function")d?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=a=m[n];if(!d){if(!a.data)a.data={};a=a.data}e!==b&&(a[f.camelCase(c)]=e);if(u&&
!a[c])return g.events;j?(e=a[c],e==null&&(e=a[f.camelCase(c)])):e=a;return e}}},removeData:function(a,b,c){if(f.acceptData(a)){var d,g,j,h=f.expando,m=a.nodeType,n=m?f.cache:a,u=m?a[h]:h;if(n[u]){if(b&&(d=c?n[u]:n[u].data)){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b=b in d?[b]:b.split(" ")));g=0;for(j=b.length;g<j;g++)delete d[b[g]];if(!(c?e:f.isEmptyObject)(d))return}if(!c&&(delete n[u].data,!e(n[u])))return;f.support.deleteExpando||!n.setInterval?delete n[u]:n[u]=null;m&&(f.support.deleteExpando?
delete a[h]:a.removeAttribute?a.removeAttribute(h):a[h]=null)}}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return!(b===!0||a.getAttribute("classid")!==b)}return!0}});f.fn.extend({data:function(a,c){var e,g,j,h=null;if(typeof a==="undefined"){if(this.length&&(h=f.data(this[0]),this[0].nodeType===1&&!f._data(this[0],"parsedAttrs"))){g=this[0].attributes;for(var m=0,n=g.length;m<n;m++)j=g[m].name,j.indexOf("data-")===
0&&(j=f.camelCase(j.substring(5)),d(this[0],j,h[j]));f._data(this[0],"parsedAttrs",!0)}return h}else if(typeof a==="object")return this.each(function(){f.data(this,a)});e=a.split(".");e[1]=e[1]?"."+e[1]:"";return c===b?(h=this.triggerHandler("getData"+e[1]+"!",[e[0]]),h===b&&this.length&&(h=f.data(this[0],a),h=d(this[0],a,h)),h===b&&e[1]?this.data(e[0]):h):this.each(function(){var b=f(this),d=[e[0],c];b.triggerHandler("setData"+e[1]+"!",d);f.data(this,a,c);b.triggerHandler("changeData"+e[1]+"!",d)})},
removeData:function(a){return this.each(function(){f.removeData(this,a)})}});f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var e=c+"mark";(a=a?0:(f._data(b,e)||1)-1)?f._data(b,e,a):(f.removeData(b,e,!0),g(b,c,"mark"))}},queue:function(a,b,c){var e;if(a)return b=(b||"fx")+"queue",e=f._data(a,b),c&&(!e||f.isArray(c)?e=f._data(a,b,f.makeArray(c)):e.push(c)),e||[]},dequeue:function(a,b){b=b||"fx";
var c=f.queue(a,b),e=c.shift(),d={};e==="inprogress"&&(e=c.shift());e&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",d),e.call(a,function(){f.dequeue(a,b)},d));c.length||(f.removeData(a,b+"queue "+b+".run",!0),g(a,b,"queue"))}});f.fn.extend({queue:function(a,c){typeof a!=="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,
a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a;return this.queue(b||"fx",function(b,c){var e=setTimeout(b,a);c.stop=function(){clearTimeout(e)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a){function c(){--j||e.resolveWith(d,[d])}typeof a!=="string"&&(a=b);a=a||"fx";var e=f.Deferred(),d=this,g=d.length,j=1,h=a+"defer",m=a+"queue";a+="mark";for(var n;g--;)if(n=f.data(d[g],h,b,!0)||(f.data(d[g],m,b,!0)||f.data(d[g],a,b,!0))&&f.data(d[g],h,f.Callbacks("once memory"),
!0))j++,n.add(c);c();return e.promise()}});var y=/[\n\t\r]/g,o=/\s+/,O=/\r/g,ba=/^(?:button|input)$/i,na=/^(?:button|input|object|select|textarea)$/i,t=/^a(?:rea)?$/i,U=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,C=f.support.getSetAttribute,D,X,Z;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,
a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,e,d,g,j,h;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a==="string"){b=a.split(o);c=0;for(e=this.length;c<e;c++)if(d=this[c],d.nodeType===1)if(!d.className&&b.length===1)d.className=a;else{g=" "+d.className+" ";j=0;for(h=b.length;j<h;j++)~g.indexOf(" "+b[j]+" ")||(g+=b[j]+" ");
d.className=f.trim(g)}}return this},removeClass:function(a){var c,e,d,g,j,h,m;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a==="string"||a===b){c=(a||"").split(o);e=0;for(d=this.length;e<d;e++)if(g=this[e],g.nodeType===1&&g.className)if(a){j=(" "+g.className+" ").replace(y," ");h=0;for(m=c.length;h<m;h++)j=j.replace(" "+c[h]+" "," ");g.className=f.trim(j)}else g.className=""}return this},toggleClass:function(a,b){var c=typeof a,
e=typeof b==="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string")for(var d,g=0,j=f(this),h=b,m=a.split(o);d=m[g++];)h=e?h:!j.hasClass(d),j[h?"addClass":"removeClass"](d);else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){a=" "+a+" ";for(var b=0,c=
this.length;b<c;b++)if(this[b].nodeType===1&&(" "+this[b].className+" ").replace(y," ").indexOf(a)>-1)return!0;return!1},val:function(a){var c,e,d,g=this[0];if(arguments.length)return d=f.isFunction(a),this.each(function(e){var g=f(this);if(this.nodeType===1&&(e=d?a.call(this,e,g.val()):a,e==null?e="":typeof e==="number"?e+="":f.isArray(e)&&(e=f.map(e,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type],!c||!("set"in c)||c.set(this,e,"value")===b))this.value=
e});else if(g){if((c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type])&&"get"in c&&(e=c.get(g,"value"))!==b)return e;e=g.value;return typeof e==="string"?e.replace(O,""):e==null?"":e}}});f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,e=a.selectedIndex,d=[],g=a.options,j=a.type==="select-one";if(e<0)return null;a=j?e:0;for(c=j?e+1:g.length;a<c;a++)if(b=g[a],b.selected&&(f.support.optDisabled?!b.disabled:
b.getAttribute("disabled")===null)&&(!b.parentNode.disabled||!f.nodeName(b.parentNode,"optgroup"))){b=f(b).val();if(j)return b;d.push(b)}if(j&&!d.length&&g.length)return f(g[e]).val();return d},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0});if(!c.length)a.selectedIndex=-1;return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,e,d){var g,j,h=a.nodeType;if(a&&!(h===3||h===8||
h===2)){if(d&&c in f.attrFn)return f(a)[c](e);if(typeof a.getAttribute==="undefined")return f.prop(a,c,e);if(d=h!==1||!f.isXMLDoc(a))c=c.toLowerCase(),j=f.attrHooks[c]||(U.test(c)?X:D);if(e!==b)if(e===null)f.removeAttr(a,c);else return j&&"set"in j&&d&&(g=j.set(a,e,c))!==b?g:(a.setAttribute(c,""+e),e);else return j&&"get"in j&&d&&(g=j.get(a,c))!==null?g:(g=a.getAttribute(c),g===null?b:g)}},removeAttr:function(a,b){var c,e,d,g,j=0;if(b&&a.nodeType===1){e=b.toLowerCase().split(o);for(g=e.length;j<g;j++)if(d=
e[j])c=f.propFix[d]||d,f.attr(a,d,""),a.removeAttribute(C?d:c),U.test(d)&&c in a&&(a[c]=!1)}},attrHooks:{type:{set:function(a,b){if(ba.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b);if(c)a.value=c;return b}}},value:{get:function(a,b){if(D&&f.nodeName(a,"button"))return D.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(D&&f.nodeName(a,"button"))return D.set(a,
b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,e){var d,g,j=a.nodeType;if(a&&!(j===3||j===8||j===2)){if(j!==1||!f.isXMLDoc(a))c=f.propFix[c]||c,g=f.propHooks[c];return e!==b?g&&"set"in g&&(d=g.set(a,e,c))!==b?d:a[c]=e:g&&"get"in g&&(d=g.get(a,
c))!==null?d:a[c]}},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):na.test(a.nodeName)||t.test(a.nodeName)&&a.href?0:b}}}});f.attrHooks.tabindex=f.propHooks.tabIndex;X={get:function(a,c){var e,d=f.prop(a,c);return d===!0||typeof d!=="boolean"&&(e=a.getAttributeNode(c))&&e.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){b===!1?f.removeAttr(a,c):(b=f.propFix[c]||c,b in a&&(a[b]=!0),a.setAttribute(c,c.toLowerCase()));return c}};
if(!C)Z={name:!0,id:!0},D=f.valHooks.button={get:function(a,c){var e;return(e=a.getAttributeNode(c))&&(Z[c]?e.nodeValue!=="":e.specified)?e.nodeValue:b},set:function(a,b,c){var e=a.getAttributeNode(c);e||(e=v.createAttribute(c),a.setAttributeNode(e));return e.nodeValue=b+""}},f.attrHooks.tabindex.set=D.set,f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c==="")return a.setAttribute(b,"auto"),c}})}),f.attrHooks.contenteditable={get:D.get,set:function(a,
b,c){b===""&&(b="false");D.set(a,b,c)}};f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){a=a.getAttribute(c,2);return a===null?b:a}})});if(!f.support.style)f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}};if(!f.support.optSelected)f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(){return null}});if(!f.support.enctype)f.propFix.enctype=
"encoding";f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}});f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var W=/^(?:textarea|input|select)$/i,Y=/^([^\.]*)?(?:\.(.+))?$/,da=/\bhover(\.\S+)?\b/,N=/^key/,ea=/^(?:mouse|contextmenu)|click/,va=/^(?:focusinfocus|focusoutblur)$/,n=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
P=function(a){if(a=n.exec(a))a[1]=(a[1]||"").toLowerCase(),a[3]=a[3]&&RegExp("(?:^|\\s)"+a[3]+"(?:\\s|$)");return a},w=function(a){return f.event.special.hover?a:a.replace(da,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,e,d,g){var j,h,m,n,u,E,k,l,A;if(!(a.nodeType===3||a.nodeType===8||!c||!e||!(j=f._data(a)))){if(e.handler)k=e,e=k.handler;if(!e.guid)e.guid=f.guid++;m=j.events;if(!m)j.events=m={};h=j.handle;if(!h)j.handle=h=function(a){return typeof f!=="undefined"&&(!a||f.event.triggered!==
a.type)?f.event.dispatch.apply(h.elem,arguments):b},h.elem=a;c=f.trim(w(c)).split(" ");for(j=0;j<c.length;j++){n=Y.exec(c[j])||[];u=n[1];E=(n[2]||"").split(".").sort();A=f.event.special[u]||{};u=(g?A.delegateType:A.bindType)||u;A=f.event.special[u]||{};n=f.extend({type:u,origType:n[1],data:d,handler:e,guid:e.guid,selector:g,quick:P(g),namespace:E.join(".")},k);l=m[u];if(!l&&(l=m[u]=[],l.delegateCount=0,!A.setup||A.setup.call(a,d,E,h)===!1))a.addEventListener?a.addEventListener(u,h,!1):a.attachEvent&&
a.attachEvent("on"+u,h);if(A.add&&(A.add.call(a,n),!n.handler.guid))n.handler.guid=e.guid;g?l.splice(l.delegateCount++,0,n):l.push(n);f.event.global[u]=!0}a=null}},global:{},remove:function(a,b,c,e,d){var g=f.hasData(a)&&f._data(a),j,h,m,n,u,E,k,P,l,A;if(g&&(k=g.events)){b=f.trim(w(b||"")).split(" ");for(j=0;j<b.length;j++)if(h=Y.exec(b[j])||[],m=n=h[1],h=h[2],m){P=f.event.special[m]||{};m=(e?P.delegateType:P.bindType)||m;l=k[m]||[];u=l.length;h=h?RegExp("(^|\\.)"+h.split(".").sort().join("\\.(?:.*\\.)?")+
"(\\.|$)"):null;for(E=0;E<l.length;E++)if(A=l[E],(d||n===A.origType)&&(!c||c.guid===A.guid)&&(!h||h.test(A.namespace))&&(!e||e===A.selector||e==="**"&&A.selector))l.splice(E--,1),A.selector&&l.delegateCount--,P.remove&&P.remove.call(a,A);l.length===0&&u!==l.length&&((!P.teardown||P.teardown.call(a,h)===!1)&&f.removeEvent(a,m,g.handle),delete k[m])}else for(m in k)f.event.remove(a,m+b[j],c,e,!0);if(f.isEmptyObject(k)){if(b=g.handle)b.elem=null;f.removeData(a,["events","handle"],!0)}}},customEvent:{getData:!0,
setData:!0,changeData:!0},trigger:function(c,e,d,g){if(!d||!(d.nodeType===3||d.nodeType===8)){var j=c.type||c,h=[],m,n,u,E,w;if(!va.test(j+f.event.triggered)&&(j.indexOf("!")>=0&&(j=j.slice(0,-1),m=!0),j.indexOf(".")>=0&&(h=j.split("."),j=h.shift(),h.sort()),d&&!f.event.customEvent[j]||f.event.global[j]))if(c=typeof c==="object"?c[f.expando]?c:new f.Event(j,c):new f.Event(j),c.type=j,c.isTrigger=!0,c.exclusive=m,c.namespace=h.join("."),c.namespace_re=c.namespace?RegExp("(^|\\.)"+h.join("\\.(?:.*\\.)?")+
"(\\.|$)"):null,m=j.indexOf(":")<0?"on"+j:"",d){c.result=b;if(!c.target)c.target=d;e=e!=null?f.makeArray(e):[];e.unshift(c);u=f.event.special[j]||{};if(!(u.trigger&&u.trigger.apply(d,e)===!1)){w=[[d,u.bindType||j]];if(!g&&!u.noBubble&&!f.isWindow(d)){E=u.delegateType||j;h=va.test(E+j)?d:d.parentNode;for(n=null;h;h=h.parentNode)w.push([h,E]),n=h;n&&n===d.ownerDocument&&w.push([n.defaultView||n.parentWindow||a,E])}for(n=0;n<w.length&&!c.isPropagationStopped();n++)h=w[n][0],c.type=w[n][1],(E=(f._data(h,
"events")||{})[c.type]&&f._data(h,"handle"))&&E.apply(h,e),(E=m&&h[m])&&f.acceptData(h)&&E.apply(h,e)===!1&&c.preventDefault();c.type=j;if(!g&&!c.isDefaultPrevented()&&(!u._default||u._default.apply(d.ownerDocument,e)===!1)&&!(j==="click"&&f.nodeName(d,"a"))&&f.acceptData(d))if(m&&d[j]&&(j!=="focus"&&j!=="blur"||c.target.offsetWidth!==0)&&!f.isWindow(d))(n=d[m])&&(d[m]=null),f.event.triggered=j,d[j](),f.event.triggered=b,n&&(d[m]=n);return c.result}}else for(n in d=f.cache,d)d[n].events&&d[n].events[j]&&
f.event.trigger(c,e,d[n].handle.elem,!0)}},dispatch:function(c){c=f.event.fix(c||a.event);var e=(f._data(this,"events")||{})[c.type]||[],d=e.delegateCount,g=[].slice.call(arguments,0),j=!c.exclusive&&!c.namespace,h=[],m,n,u,E,w,k,l;g[0]=c;c.delegateTarget=this;if(d&&!c.target.disabled&&!(c.button&&c.type==="click")){u=f(this);u.context=this.ownerDocument||this;for(n=c.target;n!=this;n=n.parentNode||this){w={};k=[];u[0]=n;for(m=0;m<d;m++){E=e[m];l=E.selector;if(w[l]===b){var P=w,A=l,o;if(E.quick){o=
E.quick;var y=n.attributes||{};o=(!o[1]||n.nodeName.toLowerCase()===o[1])&&(!o[2]||(y.id||{}).value===o[2])&&(!o[3]||o[3].test((y["class"]||{}).value))}else o=u.is(l);P[A]=o}w[l]&&k.push(E)}k.length&&h.push({elem:n,matches:k})}}e.length>d&&h.push({elem:this,matches:e.slice(d)});for(m=0;m<h.length&&!c.isPropagationStopped();m++){d=h[m];c.currentTarget=d.elem;for(e=0;e<d.matches.length&&!c.isImmediatePropagationStopped();e++)if(E=d.matches[e],j||!c.namespace&&!E.namespace||c.namespace_re&&c.namespace_re.test(E.namespace))if(c.data=
E.data,c.handleObj=E,E=((f.event.special[E.origType]||{}).handle||E.handler).apply(d.elem,g),E!==b)c.result=E,E===!1&&(c.preventDefault(),c.stopPropagation())}return c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){if(a.which==null)a.which=b.charCode!=null?b.charCode:b.keyCode;
return a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,c){var e,d,f=c.button,g=c.fromElement;if(a.pageX==null&&c.clientX!=null)e=a.target.ownerDocument||v,d=e.documentElement,e=e.body,a.pageX=c.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=c.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0);if(!a.relatedTarget&&g)a.relatedTarget=
g===a.target?c.toElement:g;if(!a.which&&f!==b)a.which=f&1?1:f&2?3:f&4?2:0;return a}},fix:function(a){if(a[f.expando])return a;var c,e,d=a,g=f.event.fixHooks[a.type]||{},j=g.props?this.props.concat(g.props):this.props;a=f.Event(d);for(c=j.length;c;)e=j[--c],a[e]=d[e];if(!a.target)a.target=d.srcElement||v;if(a.target.nodeType===3)a.target=a.target.parentNode;if(a.metaKey===b)a.metaKey=a.ctrlKey;return g.filter?g.filter(a,d):a},special:{ready:{setup:f.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},
blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){if(f.isWindow(this))this.onbeforeunload=c},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}},simulate:function(a,b,c,e){a=f.extend(new f.Event,c,{type:a,isSimulated:!0,originalEvent:{}});e?f.event.trigger(a,null,b):f.event.dispatch.call(b,a);a.isDefaultPrevented()&&c.preventDefault()}};f.event.handle=f.event.dispatch;f.removeEvent=v.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,
c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)};f.Event=function(a,b){if(!(this instanceof f.Event))return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?k:h):this.type=a;b&&f.extend(this,b);this.timeStamp=a&&a.timeStamp||f.now();this[f.expando]=!0};f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=k;var a=this.originalEvent;if(a)a.preventDefault?
a.preventDefault():a.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=k;var a=this.originalEvent;if(a)a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=k;this.stopPropagation()},isDefaultPrevented:h,isPropagationStopped:h,isImmediatePropagationStopped:h};f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c=a.relatedTarget,
e=a.handleObj,d;if(!c||c!==this&&!f.contains(this,c))a.type=e.origType,d=e.handler.apply(this,arguments),a.type=b;return d}}});if(!f.support.submitBubbles)f.event.special.submit={setup:function(){if(f.nodeName(this,"form"))return!1;f.event.add(this,"click._submit keypress._submit",function(a){a=a.target;if((a=f.nodeName(a,"input")||f.nodeName(a,"button")?a.form:b)&&!a._submit_attached)f.event.add(a,"submit._submit",function(a){this.parentNode&&!a.isTrigger&&f.event.simulate("submit",this.parentNode,
a,!0)}),a._submit_attached=!0})},teardown:function(){if(f.nodeName(this,"form"))return!1;f.event.remove(this,"._submit")}};if(!f.support.changeBubbles)f.event.special.change={setup:function(){if(W.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")f.event.add(this,"propertychange._change",function(a){if(a.originalEvent.propertyName==="checked")this._just_changed=!0}),f.event.add(this,"click._change",function(a){if(this._just_changed&&!a.isTrigger)this._just_changed=!1,f.event.simulate("change",
this,a,!0)});return!1}f.event.add(this,"beforeactivate._change",function(a){a=a.target;if(W.test(a.nodeName)&&!a._change_attached)f.event.add(a,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&f.event.simulate("change",this.parentNode,a,!0)}),a._change_attached=!0})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){f.event.remove(this,"._change");
return W.test(this.nodeName)}};f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){var c=0,e=function(a){f.event.simulate(b,a.target,f.event.fix(a),!0)};f.event.special[b]={setup:function(){c++===0&&v.addEventListener(a,e,!0)},teardown:function(){--c===0&&v.removeEventListener(a,e,!0)}}});f.fn.extend({on:function(a,c,e,d,g){var j,m;if(typeof a==="object"){typeof c!=="string"&&(e=c,c=b);for(m in a)this.on(m,c,e,a[m],g);return this}e==null&&d==null?(d=c,e=c=b):d==null&&
(typeof c==="string"?(d=e,e=b):(d=e,e=c,c=b));if(d===!1)d=h;else if(!d)return this;if(g===1)j=d,d=function(a){f().off(a);return j.apply(this,arguments)},d.guid=j.guid||(j.guid=f.guid++);return this.each(function(){f.event.add(this,a,d,e,c)})},one:function(a,b,c,e){return this.on.call(this,a,b,c,e,1)},off:function(a,c,e){if(a&&a.preventDefault&&a.handleObj){var d=a.handleObj;f(a.delegateTarget).off(d.namespace?d.type+"."+d.namespace:d.type,d.selector,d.handler);return this}if(typeof a==="object"){for(d in a)this.off(d,
c,a[d]);return this}if(c===!1||typeof c==="function")e=c,c=b;e===!1&&(e=h);return this.each(function(){f.event.remove(this,a,e,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){f(this.context).on(a,this.selector,b,c);return this},die:function(a,b){f(this.context).off(a,this.selector||"**",b);return this},delegate:function(a,b,c,e){return this.on(b,a,c,e)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):
this.off(b,a,c)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,e=0,d=function(c){var d=(f._data(this,"lastToggle"+a.guid)||0)%e;f._data(this,"lastToggle"+a.guid,d+1);c.preventDefault();return b[d].apply(this,arguments)||!1};for(d.guid=c;e<b.length;)b[e++].guid=c;return this.click(d)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||
a)}});f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.on(b,null,a,c):this.trigger(b)};f.attrFn&&(f.attrFn[b]=!0);if(N.test(b))f.event.fixHooks[b]=f.event.keyHooks;if(ea.test(b))f.event.fixHooks[b]=f.event.mouseHooks});(function(){function a(b,
c,e,f,g,r){g=0;for(var j=f.length;g<j;g++){var h=f[g];if(h){var p=!1;for(h=h[b];h;){if(h[d]===e){p=f[h.sizset];break}if(h.nodeType===1&&!r)h[d]=e,h.sizset=g;if(h.nodeName.toLowerCase()===c){p=h;break}h=h[b]}f[g]=p}}}function c(a,b,e,f,g,r){g=0;for(var j=f.length;g<j;g++){var h=f[g];if(h){var p=!1;for(h=h[a];h;){if(h[d]===e){p=f[h.sizset];break}if(h.nodeType===1){if(!r)h[d]=e,h.sizset=g;if(typeof b!=="string"){if(h===b){p=!0;break}}else if(w.filter(b,[h]).length>0){p=h;break}}h=h[a]}f[g]=p}}}var e=
/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),g=0,j=Object.prototype.toString,h=!1,m=!0,n=/\\/g,u=/\r\n/g,E=/\W/;[0,0].sort(function(){m=!1;return 0});var w=function(a,b,c,d){c=c||[];var f=b=b||v;if(b.nodeType!==1&&b.nodeType!==9)return[];if(!a||typeof a!=="string")return c;var g,r,h,p,m,n=!0,fa=w.isXML(b),u=[],E=a;do if(e.exec(""),g=e.exec(E))if(E=g[3],u.push(g[1]),
g[2]){p=g[3];break}while(g);if(u.length>1&&P.exec(a))if(u.length===2&&k.relative[u[0]])r=I(u[0]+u[1],b,d);else for(r=k.relative[u[0]]?[b]:w(u.shift(),b);u.length;)a=u.shift(),k.relative[a]&&(a+=u.shift()),r=I(a,r,d);else if(!d&&u.length>1&&b.nodeType===9&&!fa&&k.match.ID.test(u[0])&&!k.match.ID.test(u[u.length-1])&&(g=w.find(u.shift(),b,fa),b=g.expr?w.filter(g.expr,g.set)[0]:g.set[0]),b){g=d?{expr:u.pop(),set:y(d)}:w.find(u.pop(),u.length===1&&(u[0]==="~"||u[0]==="+")&&b.parentNode?b.parentNode:b,
fa);r=g.expr?w.filter(g.expr,g.set):g.set;for(u.length>0?h=y(r):n=!1;u.length;)g=m=u.pop(),k.relative[m]?g=u.pop():m="",g==null&&(g=b),k.relative[m](h,g,fa)}else h=[];h||(h=r);h||w.error(m||a);if(j.call(h)==="[object Array]")if(n)if(b&&b.nodeType===1)for(a=0;h[a]!=null;a++)h[a]&&(h[a]===!0||h[a].nodeType===1&&w.contains(b,h[a]))&&c.push(r[a]);else for(a=0;h[a]!=null;a++)h[a]&&h[a].nodeType===1&&c.push(r[a]);else c.push.apply(c,h);else y(h,c);p&&(w(p,f,c,d),w.uniqueSort(c));return c};w.uniqueSort=
function(a){if(B&&(h=m,a.sort(B),h))for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1);return a};w.matches=function(a,b){return w(a,null,null,b)};w.matchesSelector=function(a,b){return w(b,null,null,[a]).length>0};w.find=function(a,b,c){var e,d,f,g,r,j;if(!a)return[];d=0;for(f=k.order.length;d<f;d++)if(r=k.order[d],g=k.leftMatch[r].exec(a))if(j=g[1],g.splice(1,1),j.substr(j.length-1)!=="\\"&&(g[1]=(g[1]||"").replace(n,""),e=k.find[r](g,b,c),e!=null)){a=a.replace(k.match[r],"");break}e||(e=
typeof b.getElementsByTagName!=="undefined"?b.getElementsByTagName("*"):[]);return{set:e,expr:a}};w.filter=function(a,c,e,d){for(var f,g,r,j,h,p,m,n,fa=a,J=[],u=c,E=c&&c[0]&&w.isXML(c[0]);a&&c.length;){for(r in k.filter)if((f=k.leftMatch[r].exec(a))!=null&&f[2])if(p=k.filter[r],h=f[1],g=!1,f.splice(1,1),h.substr(h.length-1)!=="\\"){u===J&&(J=[]);if(k.preFilter[r])if(f=k.preFilter[r](f,u,e,J,d,E)){if(f===!0)continue}else g=j=!0;if(f)for(m=0;(h=u[m])!=null;m++)h&&(j=p(h,f,m,u),n=d^j,e&&j!=null?n?g=
!0:u[m]=!1:n&&(J.push(h),g=!0));if(j!==b){e||(u=J);a=a.replace(k.match[r],"");if(!g)return[];break}}if(a===fa)if(g==null)w.error(a);else break;fa=a}return u};w.error=function(a){throw Error("Syntax error, unrecognized expression: "+a);};var l=w.getText=function(a){var b,c;b=a.nodeType;var e="";if(b)if(b===1||b===9)if(typeof a.textContent==="string")return a.textContent;else if(typeof a.innerText==="string")return a.innerText.replace(u,"");else for(a=a.firstChild;a;a=a.nextSibling)e+=l(a);else{if(b===
3||b===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=l(c));return e},k=w.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b==="string",e=c&&!E.test(b);c=c&&!e;e&&(b=b.toLowerCase());e=0;for(var d=a.length,f;e<d;e++)if(f=a[e]){for(;(f=f.previousSibling)&&f.nodeType!==
1;);a[e]=c||f&&f.nodeName.toLowerCase()===b?f||!1:f===b}c&&w.filter(b,a,!0)},">":function(a,b){var c,e=typeof b==="string",d=0,f=a.length;if(e&&!E.test(b))for(b=b.toLowerCase();d<f;d++){if(c=a[d])c=c.parentNode,a[d]=c.nodeName.toLowerCase()===b?c:!1}else{for(;d<f;d++)(c=a[d])&&(a[d]=e?c.parentNode:c.parentNode===b);e&&w.filter(b,a,!0)}},"":function(b,e,d){var f,j=g++,h=c;typeof e==="string"&&!E.test(e)&&(f=e=e.toLowerCase(),h=a);h("parentNode",e,j,b,f,d)},"~":function(b,e,d){var f,j=g++,h=c;typeof e===
"string"&&!E.test(e)&&(f=e=e.toLowerCase(),h=a);h("previousSibling",e,j,b,f,d)}},find:{ID:function(a,b,c){if(typeof b.getElementById!=="undefined"&&!c)return(a=b.getElementById(a[1]))&&a.parentNode?[a]:[]},NAME:function(a,b){if(typeof b.getElementsByName!=="undefined"){for(var c=[],e=b.getElementsByName(a[1]),d=0,f=e.length;d<f;d++)e[d].getAttribute("name")===a[1]&&c.push(e[d]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!=="undefined")return b.getElementsByTagName(a[1])}},
preFilter:{CLASS:function(a,b,c,e,d,f){a=" "+a[1].replace(n,"")+" ";if(f)return a;f=0;for(var g;(g=b[f])!=null;f++)g&&(d^(g.className&&(" "+g.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||e.push(g):c&&(b[f]=!1));return!1},ID:function(a){return a[1].replace(n,"")},TAG:function(a){return a[1].replace(n,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||w.error(a[0]);a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||
!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0;a[3]=b[3]-0}else a[2]&&w.error(a[0]);a[0]=g++;return a},ATTR:function(a,b,c,e,d,f){b=a[1]=a[1].replace(n,"");!f&&k.attrMap[b]&&(a[1]=k.attrMap[b]);a[4]=(a[4]||a[5]||"").replace(n,"");a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(a,b,c,d,f){if(a[1]==="not")if((e.exec(a[3])||"").length>1||/^\w/.test(a[3]))a[3]=w(a[3],null,null,b);else return a=w.filter(a[3],b,c,1^f),c||d.push.apply(d,a),!1;else if(k.match.POS.test(a[0])||k.match.CHILD.test(a[0]))return!0;
return a},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!w(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()===
"input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()===
"input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,e){return b===e.length-1},even:function(a,b){return b%2===0},odd:function(a,
b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,e){var d=b[1],f=k.filters[d];if(f)return f(a,c,b,e);else if(d==="contains")return(a.textContent||a.innerText||l([a])||"").indexOf(b[3])>=0;else if(d==="not"){b=b[3];c=0;for(e=b.length;c<e;c++)if(b[c]===a)return!1;return!0}else w.error(d)},CHILD:function(a,b){var c,e,f,g,r,j;c=b[1];j=a;switch(c){case "only":case "first":for(;j=
j.previousSibling;)if(j.nodeType===1)return!1;if(c==="first")return!0;j=a;case "last":for(;j=j.nextSibling;)if(j.nodeType===1)return!1;return!0;case "nth":c=b[2];e=b[3];if(c===1&&e===0)return!0;f=b[0];if((g=a.parentNode)&&(g[d]!==f||!a.nodeIndex)){r=0;for(j=g.firstChild;j;j=j.nextSibling)if(j.nodeType===1)j.nodeIndex=++r;g[d]=f}j=a.nodeIndex-e;return c===0?j===0:j%c===0&&j/c>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&
a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1];c=w.attr?w.attr(a,c):k.attrHandle[c]?k.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c);var e=c+"",d=b[2],f=b[4];return c==null?d==="!=":!d&&w.attr?c!=null:d==="="?e===f:d==="*="?e.indexOf(f)>=0:d==="~="?(" "+e+" ").indexOf(f)>=0:!f?e&&c!==!1:d==="!="?e!==f:d==="^="?e.indexOf(f)===0:d==="$="?e.substr(e.length-f.length)===f:d==="|="?e===f||e.substr(0,
f.length+1)===f+"-":!1},POS:function(a,b,c,e){var d=k.setFilters[b[2]];if(d)return d(a,c,b,e)}}},P=k.match.POS,A=function(a,b){return"\\"+(b-0+1)},o;for(o in k.match)k.match[o]=RegExp(k.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),k.leftMatch[o]=RegExp(/(^(?:.|\r|\n)*?)/.source+k.match[o].source.replace(/\\(\d+)/g,A));var y=function(a,b){a=Array.prototype.slice.call(a,0);if(b)return b.push.apply(b,a),b;return a};try{Array.prototype.slice.call(v.documentElement.childNodes,0)}catch(q){y=function(a,
b){var c=0,e=b||[];if(j.call(a)==="[object Array]")Array.prototype.push.apply(e,a);else if(typeof a.length==="number")for(var d=a.length;c<d;c++)e.push(a[c]);else for(;a[c];c++)e.push(a[c]);return e}}var B,H;v.documentElement.compareDocumentPosition?B=function(a,b){if(a===b)return h=!0,0;if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(B=function(a,b){if(a===b)return h=!0,0;else if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-
b.sourceIndex;var c,e,d=[],f=[];c=a.parentNode;e=b.parentNode;var g=c;if(c===e)return H(a,b);else if(c){if(!e)return 1}else return-1;for(;g;)d.unshift(g),g=g.parentNode;for(g=e;g;)f.unshift(g),g=g.parentNode;c=d.length;e=f.length;for(g=0;g<c&&g<e;g++)if(d[g]!==f[g])return H(d[g],f[g]);return g===c?H(a,f[g],-1):H(d[g],b,1)},H=function(a,b,c){if(a===b)return c;for(a=a.nextSibling;a;){if(a===b)return-1;a=a.nextSibling}return 1});(function(){var a=v.createElement("div"),c="script"+(new Date).getTime(),
e=v.documentElement;a.innerHTML="<a name='"+c+"'/>";e.insertBefore(a,e.firstChild);if(v.getElementById(c))k.find.ID=function(a,c,e){if(typeof c.getElementById!=="undefined"&&!e)return(c=c.getElementById(a[1]))?c.id===a[1]||typeof c.getAttributeNode!=="undefined"&&c.getAttributeNode("id").nodeValue===a[1]?[c]:b:[]},k.filter.ID=function(a,b){var c=typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b};e.removeChild(a);e=a=null})();(function(){var a=
v.createElement("div");a.appendChild(v.createComment(""));if(a.getElementsByTagName("*").length>0)k.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){for(var e=[],d=0;c[d];d++)c[d].nodeType===1&&e.push(c[d]);c=e}return c};a.innerHTML="<a href='#'></a>";if(a.firstChild&&typeof a.firstChild.getAttribute!=="undefined"&&a.firstChild.getAttribute("href")!=="#")k.attrHandle.href=function(a){return a.getAttribute("href",2)};a=null})();v.querySelectorAll&&function(){var a=w,b=v.createElement("div");
b.innerHTML="<p class='TEST'></p>";if(!(b.querySelectorAll&&b.querySelectorAll(".TEST").length===0)){w=function(b,c,e,d){c=c||v;if(!d&&!w.isXML(c)){var f=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(f&&(c.nodeType===1||c.nodeType===9))if(f[1])return y(c.getElementsByTagName(b),e);else if(f[2]&&k.find.CLASS&&c.getElementsByClassName)return y(c.getElementsByClassName(f[2]),e);if(c.nodeType===9){if(b==="body"&&c.body)return y([c.body],e);else if(f&&f[3]){var g=c.getElementById(f[3]);if(g&&g.parentNode){if(g.id===
f[3])return y([g],e)}else return y([],e)}try{return y(c.querySelectorAll(b),e)}catch(r){}}else if(c.nodeType===1&&c.nodeName.toLowerCase()!=="object"){f=c;var j=(g=c.getAttribute("id"))||"__sizzle__",h=c.parentNode,p=/^\s*[+~]/.test(b);g?j=j.replace(/'/g,"\\$&"):c.setAttribute("id",j);if(p&&h)c=c.parentNode;try{if(!p||h)return y(c.querySelectorAll("[id='"+j+"'] "+b),e)}catch(m){}finally{g||f.removeAttribute("id")}}}return a(b,c,e,d)};for(var c in a)w[c]=a[c];b=null}}();(function(){var a=v.documentElement,
b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var c=!b.call(v.createElement("div"),"div"),e=!1;try{b.call(v.documentElement,"[test!='']:sizzle")}catch(d){e=!0}w.matchesSelector=function(a,d){d=d.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!w.isXML(a))try{if(e||!k.match.PSEUDO.test(d)&&!/!=/.test(d)){var f=b.call(a,d);if(f||!c||a.document&&a.document.nodeType!==11)return f}}catch(g){}return w(d,null,null,[a]).length>0}}})();(function(){var a=v.createElement("div");
a.innerHTML="<div class='test e'></div><div class='test'></div>";if(a.getElementsByClassName&&a.getElementsByClassName("e").length!==0&&(a.lastChild.className="e",a.getElementsByClassName("e").length!==1))k.order.splice(1,0,"CLASS"),k.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!=="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null})();w.contains=v.documentElement.contains?function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:v.documentElement.compareDocumentPosition?
function(a,b){return!!(a.compareDocumentPosition(b)&16)}:function(){return!1};w.isXML=function(a){return(a=(a?a.ownerDocument||a:0).documentElement)?a.nodeName!=="HTML":!1};var I=function(a,b,c){var e,d=[],f="";for(b=b.nodeType?[b]:b;e=k.match.PSEUDO.exec(a);)f+=e[0],a=a.replace(k.match.PSEUDO,"");a=k.relative[a]?a+"*":a;e=0;for(var g=b.length;e<g;e++)w(a,b[e],d,c);return w.filter(f,d)};w.attr=f.attr;w.selectors.attrMap={};f.find=w;f.expr=w.selectors;f.expr[":"]=f.expr.filters;f.unique=w.uniqueSort;
f.text=w.getText;f.isXMLDoc=w.isXML;f.contains=w.contains})();var u=/Until$/,E=/^(?:parents|prevUntil|prevAll)/,H=/,/,Aa=/^.[^:#\[\.,]*$/,Q=Array.prototype.slice,wa=f.expr.match.POS,ha={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,e;if(typeof a!=="string")return f(a).filter(function(){c=0;for(e=b.length;c<e;c++)if(f.contains(b[c],this))return!0});var d=this.pushStack("","find",a),g,j,h;c=0;for(e=this.length;c<e;c++)if(g=d.length,f.find(a,this[c],d),c>0)for(j=
g;j<d.length;j++)for(h=0;h<g;h++)if(d[h]===d[j]){d.splice(j--,1);break}return d},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(l(this,a,!1),"not",a)},filter:function(a){return this.pushStack(l(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a==="string"?wa.test(a)?f(a,this.context).index(this[0])>=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=
[],e,d,g=this[0];if(f.isArray(a)){for(d=1;g&&g.ownerDocument&&g!==b;){for(e=0;e<a.length;e++)f(g).is(a[e])&&c.push({selector:a[e],elem:g,level:d});g=g.parentNode;d++}return c}var j=wa.test(a)||typeof a!=="string"?f(a,b||this.context):0;e=0;for(d=this.length;e<d;e++)for(g=this[e];g;)if(j?j.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}else if(g=g.parentNode,!g||!g.ownerDocument||g===b||g.nodeType===11)break;c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&
this[0].parentNode?this.prevAll().length:-1;if(typeof a==="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a==="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),e=f.merge(this.get(),c);return this.pushStack(!c[0]||!c[0].parentNode||c[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:f.unique(e))},andSelf:function(){return this.add(this.prevObject)}});f.each({parent:function(a){return(a=a.parentNode)&&
a.nodeType!==11?a:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,
a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,e){var d=f.map(this,b,c);u.test(a)||(e=c);e&&typeof e==="string"&&(d=f.filter(e,d));d=this.length>1&&!ha[a]?f.unique(d):d;if((this.length>1||H.test(e))&&E.test(a))d=d.reverse();return this.pushStack(d,a,Q.call(arguments).join(","))}});f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");
return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,e){var d=[];for(a=a[c];a&&a.nodeType!==9&&(e===b||a.nodeType!==1||!f(a).is(e));)a.nodeType===1&&d.push(a),a=a[c];return d},nth:function(a,b,c){b=b||1;for(var e=0;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var Ca="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
xa=/ jQuery\d+="(?:\d+|null)"/g,Ma=/^\s+/,Fa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,ya=/<([\w:]+)/,ia=/<tbody/i,T=/<|&#?\w+;/,ib=/<(?:script|style)/i,jb=/<(?:script|object|embed|option|style)/i,Ra=RegExp("<(?:"+Ca+")","i"),Sa=/checked\s*(?:[^=]|=\s*.checked.)/i,kb=/\/(java|ecma)script/i,db=/^\s*<!(?:\[CDATA\[|\-\-)/,aa={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>",
"</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},Ta=s(v);aa.optgroup=aa.option;aa.tbody=aa.tfoot=aa.colgroup=aa.caption=aa.thead;aa.th=aa.td;if(!f.support.htmlSerialize)aa._default=[1,"div<div>","</div>"];f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!=="object"&&a!==b)return this.empty().append((this[0]&&
this[0].ownerDocument||v).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var a=this;a.firstChild&&a.firstChild.nodeType===1;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});
return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===
1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});else if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,
"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,e;(e=this[c])!=null;c++)if(!a||f.filter(a,[e]).length)!b&&e.nodeType===1&&(f.cleanData(e.getElementsByTagName("*")),f.cleanData([e])),e.parentNode&&e.parentNode.removeChild(e);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);return this},clone:function(a,b){a=a==null?!1:a;b=b==null?
a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(xa,""):null;else if(typeof a==="string"&&!ib.test(a)&&(f.support.leadingWhitespace||!Ma.test(a))&&!aa[(ya.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Fa,"<$1></$2>");try{for(var c=0,e=this.length;c<e;c++)if(this[c].nodeType===1)f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a}catch(d){this.empty().append(a)}}else f.isFunction(a)?
this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),e=c.html();c.replaceWith(a.call(this,b,e))});typeof a!=="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove();b?f(b).before(a):f(c).append(a)})}else return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",
a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,e){var d,g,j,h=a[0],m=[];if(!f.support.checkClone&&arguments.length===3&&typeof h==="string"&&Sa.test(h))return this.each(function(){f(this).domManip(a,c,e,!0)});if(f.isFunction(h))return this.each(function(d){var g=f(this);a[0]=h.call(this,d,c?g.html():b);g.domManip(a,c,e)});if(this[0]){d=h&&h.parentNode;d=f.support.parentNode&&d&&d.nodeType===11&&d.childNodes.length===this.length?{fragment:d}:f.buildFragment(a,this,m);j=
d.fragment;if(g=j.childNodes.length===1?j=j.firstChild:j.firstChild){c=c&&f.nodeName(g,"tr");g=0;for(var n=this.length,u=n-1;g<n;g++)e.call(c?f.nodeName(this[g],"table")?this[g].getElementsByTagName("tbody")[0]||this[g].appendChild(this[g].ownerDocument.createElement("tbody")):this[g]:this[g],d.cacheable||n>1&&g<u?f.clone(j,!0,!0):j)}m.length&&f.each(m,M)}return this}});f.buildFragment=function(a,b,c){var e,d,g,j,h=a[0];b&&b[0]&&(j=b[0].ownerDocument||b[0]);j.createDocumentFragment||(j=v);if(a.length===
1&&typeof h==="string"&&h.length<512&&j===v&&h.charAt(0)==="<"&&!jb.test(h)&&(f.support.checkClone||!Sa.test(h))&&(f.support.html5Clone||!Ra.test(h)))d=!0,(g=f.fragments[h])&&g!==1&&(e=g);e||(e=j.createDocumentFragment(),f.clean(a,j,e,c));d&&(f.fragments[h]=g?e:1);return{fragment:e,cacheable:d}};f.fragments={};f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var e=[];c=f(c);var d=this.length===1&&this[0].parentNode;
if(d&&d.nodeType===11&&d.childNodes.length===1&&c.length===1)return c[b](this[0]),this;else{d=0;for(var g=c.length;d<g;d++){var j=(d>0?this.clone(!0):this).get();f(c[d])[b](j);e=e.concat(j)}return this.pushStack(e,a,c.selector)}}});f.extend({clone:function(a,b,c){var e,d,g;f.support.html5Clone||!Ra.test("<"+a.nodeName)?e=a.cloneNode(!0):(e=v.createElement("div"),Ta.appendChild(e),e.innerHTML=a.outerHTML,e=e.firstChild);var j=e;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===
1||a.nodeType===11)&&!f.isXMLDoc(a)){q(a,j);e=x(a);d=x(j);for(g=0;e[g];++g)d[g]&&q(e[g],d[g])}if(b&&(z(a,j),c)){e=x(a);d=x(j);for(g=0;e[g];++g)z(e[g],d[g])}return j},clean:function(a,b,c,e){b=b||v;typeof b.createElement==="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||v);for(var d=[],g,j=0,h;(h=a[j])!=null;j++)if(typeof h==="number"&&(h+=""),h){if(typeof h==="string")if(T.test(h)){h=h.replace(Fa,"<$1></$2>");g=(ya.exec(h)||["",""])[1].toLowerCase();var m=aa[g]||aa._default,n=m[0],u=b.createElement("div");
b===v?Ta.appendChild(u):s(b).appendChild(u);for(u.innerHTML=m[1]+h+m[2];n--;)u=u.lastChild;if(!f.support.tbody){n=ia.test(h);m=g==="table"&&!n?u.firstChild&&u.firstChild.childNodes:m[1]==="<table>"&&!n?u.childNodes:[];for(g=m.length-1;g>=0;--g)f.nodeName(m[g],"tbody")&&!m[g].childNodes.length&&m[g].parentNode.removeChild(m[g])}!f.support.leadingWhitespace&&Ma.test(h)&&u.insertBefore(b.createTextNode(Ma.exec(h)[0]),u.firstChild);h=u.childNodes}else h=b.createTextNode(h);var w;if(!f.support.appendChecked)if(h[0]&&
typeof(w=h.length)==="number")for(g=0;g<w;g++)K(h[g]);else K(h);h.nodeType?d.push(h):d=f.merge(d,h)}if(c){a=function(a){return!a.type||kb.test(a.type)};for(j=0;d[j];j++)e&&f.nodeName(d[j],"script")&&(!d[j].type||d[j].type.toLowerCase()==="text/javascript")?e.push(d[j].parentNode?d[j].parentNode.removeChild(d[j]):d[j]):(d[j].nodeType===1&&(b=f.grep(d[j].getElementsByTagName("script"),a),d.splice.apply(d,[j+1,0].concat(b))),c.appendChild(d[j]))}return d},cleanData:function(a){for(var b,c,e=f.cache,
d=f.event.special,g=f.support.deleteExpando,j=0,h;(h=a[j])!=null;j++)if(!h.nodeName||!f.noData[h.nodeName.toLowerCase()])if(c=h[f.expando]){if((b=e[c])&&b.events){for(var m in b.events)d[m]?f.event.remove(h,m):f.removeEvent(h,m,b.handle);if(b.handle)b.handle.elem=null}g?delete h[f.expando]:h.removeAttribute&&h.removeAttribute(f.expando);delete e[c]}}});var Na=/alpha\([^)]*\)/i,lb=/opacity=([^)]*)/,mb=/([A-Z]|^ms)/g,Ua=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob=/^([\-+])=([\-+.\de]+)/,pb={position:"absolute",
visibility:"hidden",display:"block"},eb=["Left","Right"],fb=["Top","Bottom"],sa,Va,Wa;f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,e){return e!==b?f.style(a,c,e):f.css(a,c)})};f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=sa(a,"opacity","opacity");return c===""?"1":c}else return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?
"cssFloat":"styleFloat"},style:function(a,c,e,d){if(a&&!(a.nodeType===3||a.nodeType===8||!a.style)){var g,j=f.camelCase(c),h=a.style,m=f.cssHooks[j];c=f.cssProps[j]||j;if(e!==b){d=typeof e;if(d==="string"&&(g=ob.exec(e)))e=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),d="number";if(!(e==null||d==="number"&&isNaN(e)))if(d==="number"&&!f.cssNumber[j]&&(e+="px"),!m||!("set"in m)||(e=m.set(a,e))!==b)try{h[c]=e}catch(n){}}else{if(m&&"get"in m&&(g=m.get(a,!1,d))!==b)return g;return h[c]}}},css:function(a,c,e){var d,
g;c=f.camelCase(c);g=f.cssHooks[c];c=f.cssProps[c]||c;c==="cssFloat"&&(c="float");if(g&&"get"in g&&(d=g.get(a,!0,e))!==b)return d;else if(sa)return sa(a,c)},swap:function(a,b,c){var e={},d;for(d in b)e[d]=a.style[d],a.style[d]=b[d];c.call(a);for(d in b)a.style[d]=e[d]}});f.curCSS=f.css;f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,e){var d;if(c){if(a.offsetWidth!==0)return F(a,b,e);else f.swap(a,pb,function(){d=F(a,b,e)});return d}},set:function(a,b){if(Ua.test(b)){if(b=
parseFloat(b),b>=0)return b+"px"}else return b}}});if(!f.support.opacity)f.cssHooks.opacity={get:function(a,b){return lb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,e=a.currentStyle,d=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=e&&e.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(Na,""))===""&&(c.removeAttribute("filter"),e&&!e.filter))return;c.filter=Na.test(g)?g.replace(Na,d):g+" "+d}};f(function(){if(!f.support.reliableMarginRight)f.cssHooks.marginRight=
{get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){c=b?sa(a,"margin-right","marginRight"):a.style.marginRight});return c}}});v.defaultView&&v.defaultView.getComputedStyle&&(Va=function(a,b){var c,e,d;b=b.replace(mb,"-$1").toLowerCase();if((e=a.ownerDocument.defaultView)&&(d=e.getComputedStyle(a,null)))c=d.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b));return c});v.documentElement.currentStyle&&(Wa=function(a,b){var c,e,d=a.currentStyle&&
a.currentStyle[b],g=a.style;if(d===null&&g&&(c=g[b]))d=c;if(!Ua.test(d)&&nb.test(d)){c=g.left;if(e=a.runtimeStyle&&a.runtimeStyle.left)a.runtimeStyle.left=a.currentStyle.left;g.left=b==="fontSize"?"1em":d||0;d=g.pixelLeft+"px";g.left=c;if(e)a.runtimeStyle.left=e}return d===""?"auto":d});sa=Va||Wa;if(f.expr&&f.expr.filters)f.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},
f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)};var qb=/%20/g,gb=/\[\]$/,Xa=/\r?\n/g,rb=/#.*$/,sb=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,tb=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,ub=/^(?:GET|HEAD)$/,vb=/^\/\//,Ya=/\?/,wb=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,xb=/^(?:select|textarea)/i,Pa=/\s+/,yb=/([?&])_=[^&]*/,Za=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,$a=f.fn.load,Ia={},ab={},pa,qa,
bb=["*/"]+["*"];try{pa=ja.href}catch(Eb){pa=v.createElement("a"),pa.href="",pa=pa.href}qa=Za.exec(pa.toLowerCase())||[];f.fn.extend({load:function(a,c,e){if(typeof a!=="string"&&$a)return $a.apply(this,arguments);else if(!this.length)return this;var d=a.indexOf(" ");if(d>=0){var g=a.slice(d,a.length);a=a.slice(0,d)}d="GET";c&&(f.isFunction(c)?(e=c,c=b):typeof c==="object"&&(c=f.param(c,f.ajaxSettings.traditional),d="POST"));var j=this;f.ajax({url:a,type:d,dataType:"html",data:c,complete:function(a,
b,c){c=a.responseText;a.isResolved()&&(a.done(function(a){c=a}),j.html(g?f("<div>").append(c.replace(wb,"")).find(g):c));e&&j.each(e,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||xb.test(this.nodeName)||tb.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?
f.map(c,function(a){return{name:b.name,value:a.replace(Xa,"\r\n")}}):{name:b.name,value:c.replace(Xa,"\r\n")}}).get()}});f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}});f.each(["get","post"],function(a,c){f[c]=function(a,e,d,g){f.isFunction(e)&&(g=g||d,d=e,e=b);return f.ajax({type:c,url:a,data:e,success:d,dataType:g})}});f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,
b,c,"json")},ajaxSetup:function(a,b){b?V(a,f.ajaxSettings):(b=a,a=f.ajaxSettings);V(a,b);return a},ajaxSettings:{url:pa,isLocal:/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/.test(qa[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bb},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},
converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:G(Ia),ajaxTransport:G(ab),ajax:function(a,c){function e(a,c,r,p){if(y!==2){y=2;A&&clearTimeout(A);P=b;E=p||"";H.readyState=a>0?4:0;var w,k,l;p=c;if(r){var o=d,J=H,q=o.contents,I=o.dataTypes,t=o.responseFields,s,Q,ha,wa;for(Q in t)Q in r&&(J[t[Q]]=r[Q]);for(;I[0]==="*";)I.shift(),s===b&&(s=o.mimeType||J.getResponseHeader("content-type"));if(s)for(Q in q)if(q[Q]&&
q[Q].test(s)){I.unshift(Q);break}if(I[0]in r)ha=I[0];else{for(Q in r){if(!I[0]||o.converters[Q+" "+I[0]]){ha=Q;break}wa||(wa=Q)}ha=ha||wa}ha?(ha!==I[0]&&I.unshift(ha),r=r[ha]):r=void 0}else r=b;if(a>=200&&a<300||a===304){if(d.ifModified){if(s=H.getResponseHeader("Last-Modified"))f.lastModified[u]=s;if(s=H.getResponseHeader("Etag"))f.etag[u]=s}if(a===304)p="notmodified",w=!0;else try{s=d;s.dataFilter&&(r=s.dataFilter(r,s.dataType));var Aa=s.dataTypes;Q={};var S,xa,Ca=Aa.length,v,ia=Aa[0],z,ya,T,x,
O;for(S=1;S<Ca;S++){if(S===1)for(xa in s.converters)typeof xa==="string"&&(Q[xa.toLowerCase()]=s.converters[xa]);z=ia;ia=Aa[S];if(ia==="*")ia=z;else if(z!=="*"&&z!==ia){ya=z+" "+ia;T=Q[ya]||Q["* "+ia];if(!T)for(x in O=b,Q)if(v=x.split(" "),v[0]===z||v[0]==="*")if(O=Q[v[1]+" "+ia]){x=Q[x];x===!0?T=O:O===!0&&(T=x);break}!T&&!O&&f.error("No conversion from "+ya.replace(" "," to "));T!==!0&&(r=T?T(r):O(x(r)))}}k=r;p="success";w=!0}catch(Fa){p="parsererror",l=Fa}}else if(l=p,!p||a)p="error",a<0&&(a=0);
H.status=a;H.statusText=""+(c||p);w?h.resolveWith(g,[k,p,H]):h.rejectWith(g,[H,p,l]);H.statusCode(n);n=b;B&&j.trigger("ajax"+(w?"Success":"Error"),[H,d,w?k:l]);m.fireWith(g,[H,p]);B&&(j.trigger("ajaxComplete",[H,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a==="object"&&(c=a,a=b);c=c||{};var d=f.ajaxSetup({},c),g=d.context||d,j=g!==d&&(g.nodeType||g instanceof f)?f(g):f.event,h=f.Deferred(),m=f.Callbacks("once memory"),n=d.statusCode||{},u,w={},k={},E,l,P,A,o,y=0,B,q,H={readyState:0,setRequestHeader:function(a,
b){if(!y){var c=a.toLowerCase();a=k[c]=k[c]||a;w[a]=b}return this},getAllResponseHeaders:function(){return y===2?E:null},getResponseHeader:function(a){var c;if(y===2){if(!l)for(l={};c=sb.exec(E);)l[c[1].toLowerCase()]=c[2];c=l[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){if(!y)d.mimeType=a;return this},abort:function(a){a=a||"abort";P&&P.abort(a);e(0,a);return this}};h.promise(H);H.success=H.done;H.error=H.fail;H.complete=m.add;H.statusCode=function(a){if(a){var b;if(y<2)for(b in a)n[b]=
[n[b],a[b]];else b=a[H.status],H.then(b,b)}return this};d.url=((a||d.url)+"").replace(rb,"").replace(vb,qa[1]+"//");d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(Pa);if(d.crossDomain==null)o=Za.exec(d.url.toLowerCase()),d.crossDomain=!(!o||!(o[1]!=qa[1]||o[2]!=qa[2]||(o[3]||(o[1]==="http:"?80:443))!=(qa[3]||(qa[1]==="http:"?80:443))));if(d.data&&d.processData&&typeof d.data!=="string")d.data=f.param(d.data,d.traditional);L(Ia,d,c,H);if(y===2)return!1;B=d.global;d.type=d.type.toUpperCase();
d.hasContent=!ub.test(d.type);B&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent&&(d.data&&(d.url+=(Ya.test(d.url)?"&":"?")+d.data,delete d.data),u=d.url,d.cache===!1)){o=f.now();var I=d.url.replace(yb,"$1_="+o);d.url=I+(I===d.url?(Ya.test(d.url)?"&":"?")+"_="+o:"")}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&H.setRequestHeader("Content-Type",d.contentType);d.ifModified&&(u=u||d.url,f.lastModified[u]&&H.setRequestHeader("If-Modified-Since",f.lastModified[u]),f.etag[u]&&
H.setRequestHeader("If-None-Match",f.etag[u]));H.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bb+"; q=0.01":""):d.accepts["*"]);for(q in d.headers)H.setRequestHeader(q,d.headers[q]);if(d.beforeSend&&(d.beforeSend.call(g,H,d)===!1||y===2))return H.abort(),!1;for(q in{success:1,error:1,complete:1})H[q](d[q]);if(P=L(ab,d,c,H)){H.readyState=1;B&&j.trigger("ajaxSend",[H,d]);d.async&&d.timeout>0&&(A=setTimeout(function(){H.abort("timeout")},
d.timeout));try{y=1,P.send(w,e)}catch(t){if(y<2)e(-1,t);else throw t;}}else e(-1,"No Transport");return H},param:function(a,c){var e=[],d=function(a,b){b=f.isFunction(b)?b():b;e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(c===b)c=f.ajaxSettings.traditional;if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){d(this.name,this.value)});else for(var g in a)m(g,a[g],c,d);return e.join("&").replace(qb,"+")}});f.extend({active:0,lastModified:{},etag:{}});var zb=f.now(),Ga=
/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+zb++}});f.ajaxPrefilter("json jsonp",function(b,c,e){c=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data==="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(Ga.test(b.url)||c&&Ga.test(b.data))){var d,g=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,j=a[g],h=b.url,m=b.data,n="$1"+g+"$2";b.jsonp!==!1&&(h=h.replace(Ga,n),b.url===h&&(c&&(m=m.replace(Ga,n)),
b.data===m&&(h+=(/\?/.test(h)?"&":"?")+b.jsonp+"="+g)));b.url=h;b.data=m;a[g]=function(a){d=[a]};e.always(function(){a[g]=j;if(d&&f.isFunction(j))a[g](d[0])});b.converters["script json"]=function(){d||f.error(g+" was not called");return d[0]};b.dataTypes[0]="json";return"script"}});f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);
return a}}});f.ajaxPrefilter("script",function(a){if(a.cache===b)a.cache=!1;if(a.crossDomain)a.type="GET",a.global=!1});f.ajaxTransport("script",function(a){if(a.crossDomain){var c,e=v.head||v.getElementsByTagName("head")[0]||v.documentElement;return{send:function(d,g){c=v.createElement("script");c.async="async";if(a.scriptCharset)c.charset=a.scriptCharset;c.src=a.url;c.onload=c.onreadystatechange=function(a,d){if(d||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=
null,e&&c.parentNode&&e.removeChild(c),c=b,d||g(200,"success")};e.insertBefore(c,e.firstChild)},abort:function(){if(c)c.onload(0,1)}}}});var Oa=a.ActiveXObject?function(){for(var a in za)za[a](0,1)}:!1,Ab=0,za;f.ajaxSettings.xhr=a.ActiveXObject?function(){var b;if(!(b=!this.isLocal&&j()))a:{try{b=new a.ActiveXObject("Microsoft.XMLHTTP");break a}catch(c){}b=void 0}return b}:j;(function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})})(f.ajaxSettings.xhr());f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||
f.support.cors){var e;return{send:function(d,g){var j=c.xhr(),h,m;c.username?j.open(c.type,c.url,c.async,c.username,c.password):j.open(c.type,c.url,c.async);if(c.xhrFields)for(m in c.xhrFields)j[m]=c.xhrFields[m];c.mimeType&&j.overrideMimeType&&j.overrideMimeType(c.mimeType);!c.crossDomain&&!d["X-Requested-With"]&&(d["X-Requested-With"]="XMLHttpRequest");try{for(m in d)j.setRequestHeader(m,d[m])}catch(n){}j.send(c.hasContent&&c.data||null);e=function(a,d){var m,n,u,w,k;try{if(e&&(d||j.readyState===
4)){e=b;if(h)j.onreadystatechange=f.noop,Oa&&delete za[h];if(d)j.readyState!==4&&j.abort();else{m=j.status;u=j.getAllResponseHeaders();w={};if((k=j.responseXML)&&k.documentElement)w.xml=k;w.text=j.responseText;try{n=j.statusText}catch(E){n=""}!m&&c.isLocal&&!c.crossDomain?m=w.text?200:404:m===1223&&(m=204)}}}catch(l){d||g(-1,l)}w&&g(m,n,w,u)};!c.async||j.readyState===4?e():(h=++Ab,Oa&&(za||(za={},f(a).unload(Oa)),za[h]=e),j.onreadystatechange=e)},abort:function(){e&&e(0,1)}}}});var Ja={},ga,ta,Bb=
/^(?:toggle|show|hide)$/,Cb=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,Ha,Qa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],Da;f.fn.extend({show:function(a,b,c){if(a||a===0)return this.animate(S("show",3),a,b,c);else{c=0;for(var e=this.length;c<e;c++)if(a=this[c],a.style){b=a.style.display;if(!f._data(a,"olddisplay")&&b==="none")b=a.style.display="";b===""&&f.css(a,"display")==="none"&&f._data(a,"olddisplay",
oa(a.nodeName))}for(c=0;c<e;c++)if(a=this[c],a.style&&(b=a.style.display,b===""||b==="none"))a.style.display=f._data(a,"olddisplay")||"";return this}},hide:function(a,b,c){if(a||a===0)return this.animate(S("hide",3),a,b,c);else{c=0;for(var e=this.length;c<e;c++)a=this[c],a.style&&(b=f.css(a,"display"),b!=="none"&&!f._data(a,"olddisplay")&&f._data(a,"olddisplay",b));for(c=0;c<e;c++)if(this[c].style)this[c].style.display="none";return this}},_toggle:f.fn.toggle,toggle:function(a,b,c){var e=typeof a===
"boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||e?this.each(function(){var b=e?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(S("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,e){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,e)},animate:function(a,b,c,e){function d(){g.queue===!1&&f._mark(this);var b=f.extend({},g),c=this.nodeType===1,e=c&&f(this).is(":hidden"),j,h,m,n,u;b.animatedProperties={};for(m in a){j=
f.camelCase(m);m!==j&&(a[j]=a[m],delete a[m]);h=a[j];f.isArray(h)?(b.animatedProperties[j]=h[1],h=a[j]=h[0]):b.animatedProperties[j]=b.specialEasing&&b.specialEasing[j]||b.easing||"swing";if(h==="hide"&&e||h==="show"&&!e)return b.complete.call(this);if(c&&(j==="height"||j==="width"))if(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none")!f.support.inlineBlockNeedsLayout||oa(this.nodeName)==="inline"?this.style.display=
"inline-block":this.style.zoom=1}if(b.overflow!=null)this.style.overflow="hidden";for(m in a)if(c=new f.fx(this,b,m),h=a[m],Bb.test(h))if(j=f._data(this,"toggle"+m)||(h==="toggle"?e?"show":"hide":0))f._data(this,"toggle"+m,j==="show"?"hide":"show"),c[j]();else c[h]();else j=Cb.exec(h),n=c.cur(),j?(h=parseFloat(j[2]),u=j[3]||(f.cssNumber[m]?"":"px"),u!=="px"&&(f.style(this,m,(h||1)+u),n*=(h||1)/c.cur(),f.style(this,m,n+u)),j[1]&&(h=(j[1]==="-="?-1:1)*h+n),c.custom(n,h,u)):c.custom(n,h,"");return!0}
var g=f.speed(b,c,e);if(f.isEmptyObject(a))return this.each(g.complete,[!1]);a=f.extend({},a);return g.queue===!1?this.each(d):this.queue(g.queue,d)},stop:function(a,c,e){typeof a!=="string"&&(e=c,c=a,a=b);c&&a!==!1&&this.queue(a||"fx",[]);return this.each(function(){function b(a,c,d){c=c[d];f.removeData(a,d,!0);c.stop(e)}var c,d=!1,g=f.timers,j=f._data(this);e||f._unmark(!0,this);if(a==null)for(c in j)j[c]&&j[c].stop&&c.indexOf(".run")===c.length-4&&b(this,j,c);else j[c=a+".run"]&&j[c].stop&&b(this,
j,c);for(c=g.length;c--;)if(g[c].elem===this&&(a==null||g[c].queue===a)){if(e)g[c](!0);else g[c].saveState();d=!0;g.splice(c,1)}(!e||!d)&&f.dequeue(this,a)})}});f.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,e){return this.animate(b,a,c,e)}});f.extend({speed:function(a,b,c){var e=a&&typeof a==="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,
duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};e.duration=f.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in f.fx.speeds?f.fx.speeds[e.duration]:f.fx.speeds._default;if(e.queue==null||e.queue===!0)e.queue="fx";e.old=e.complete;e.complete=function(a){f.isFunction(e.old)&&e.old.call(this);e.queue?f.dequeue(this,e.queue):a!==!1&&f._unmark(this)};return e},easing:{linear:function(a,b,c,e){return c+e*a},swing:function(a,b,c,e){return(-Math.cos(a*Math.PI)/2+0.5)*e+c}},timers:[],fx:function(a,
b,c){this.options=b;this.elem=a;this.prop=c;b.orig=b.orig||{}}});f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,c,e){function d(a){return g.step(a)}var g=this,j=f.fx;
this.startTime=Da||A();this.end=c;this.now=this.start=a;this.pos=this.state=0;this.unit=e||this.unit||(f.cssNumber[this.prop]?"":"px");d.queue=this.options.queue;d.elem=this.elem;d.saveState=function(){g.options.hide&&f._data(g.elem,"fxshow"+g.prop)===b&&f._data(g.elem,"fxshow"+g.prop,g.start)};d()&&f.timers.push(d)&&!Ha&&(Ha=setInterval(j.tick,j.interval))},show:function(){var a=f._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||f.style(this.elem,this.prop);this.options.show=!0;
a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f._data(this.elem,"fxshow"+this.prop)||f.style(this.elem,this.prop);this.options.hide=!0;this.custom(this.cur(),0)},step:function(a){var b,c=Da||A(),e=!0,d=this.elem,g=this.options;if(a||c>=g.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();g.animatedProperties[this.prop]=!0;for(b in g.animatedProperties)g.animatedProperties[b]!==
!0&&(e=!1);if(e){g.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=g.overflow[a]});g.hide&&f(d).hide();if(g.hide||g.show)for(b in g.animatedProperties)f.style(d,b,g.orig[b]),f.removeData(d,"fxshow"+b,!0),f.removeData(d,"toggle"+b,!0);if(a=g.complete)g.complete=!1,a.call(d)}return!1}else g.duration==Infinity?this.now=c:(a=c-this.startTime,this.state=a/g.duration,this.pos=f.easing[g.animatedProperties[this.prop]](this.state,a,0,1,g.duration),this.now=
this.start+(this.end-this.start)*this.pos),this.update();return!0}};f.extend(f.fx,{tick:function(){for(var a,b=f.timers,c=0;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||f.fx.stop()},interval:13,stop:function(){clearInterval(Ha);Ha=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=a.now+a.unit:a.elem[a.prop]=a.now}}});f.each(["width","height"],
function(a,b){f.fx.step[b]=function(a){f.style(a.elem,b,Math.max(0,a.now)+a.unit)}});if(f.expr&&f.expr.filters)f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length};var Db=/^t(?:able|d|h)$/i,cb=/^(?:body|html)$/i;f.fn.offset="getBoundingClientRect"in v.documentElement?function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);
try{c=b.getBoundingClientRect()}catch(e){}var d=b.ownerDocument,g=d.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};b=d.body;d=ca(d);return{top:c.top+(d.pageYOffset||f.support.boxModel&&g.scrollTop||b.scrollTop)-(g.clientTop||b.clientTop||0),left:c.left+(d.pageXOffset||f.support.boxModel&&g.scrollLeft||b.scrollLeft)-(g.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;
if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);var c,e=b.offsetParent,d=b.ownerDocument,g=d.documentElement,j=d.body;c=(d=d.defaultView)?d.getComputedStyle(b,null):b.currentStyle;for(var h=b.offsetTop,m=b.offsetLeft;(b=b.parentNode)&&b!==j&&b!==g;){if(f.support.fixedPosition&&c.position==="fixed")break;c=d?d.getComputedStyle(b,null):b.currentStyle;h-=b.scrollTop;m-=b.scrollLeft;if(b===e){h+=b.offsetTop;m+=b.offsetLeft;if(f.support.doesNotAddBorder&&(!f.support.doesAddBorderForTableAndCells||
!Db.test(b.nodeName)))h+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0;e=b.offsetParent}f.support.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(h+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0)}if(c.position==="relative"||c.position==="static")h+=j.offsetTop,m+=j.offsetLeft;f.support.fixedPosition&&c.position==="fixed"&&(h+=Math.max(g.scrollTop,j.scrollTop),m+=Math.max(g.scrollLeft,j.scrollLeft));return{top:h,left:m}};f.offset={bodyOffset:function(a){var b=
a.offsetTop,c=a.offsetLeft;f.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var e=f.css(a,"position");if(e==="static")a.style.position="relative";var d=f(a),g=d.offset(),j=f.css(a,"top"),h=f.css(a,"left"),m={},n={};(e==="absolute"||e==="fixed")&&f.inArray("auto",[j,h])>-1?(n=d.position(),e=n.top,h=n.left):(e=parseFloat(j)||0,h=parseFloat(h)||0);f.isFunction(b)&&(b=b.call(a,c,
g));if(b.top!=null)m.top=b.top-g.top+e;if(b.left!=null)m.left=b.left-g.left+h;"using"in b?b.using.call(a,m):d.css(m)}};f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),e=cb.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0;c.left-=parseFloat(f.css(a,"marginLeft"))||0;e.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-e.top,left:c.left-
e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||v.body;a&&!cb.test(a.nodeName)&&f.css(a,"position")==="static";)a=a.offsetParent;return a})}});f.each(["Left","Top"],function(a,c){var e="scroll"+c;f.fn[e]=function(c){var d,g;if(c===b){d=this[0];if(!d)return null;return(g=ca(d))?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[e]||g.document.body[e]:d[e]}return this.each(function(){(g=ca(this))?g.scrollTo(!a?c:
f(g).scrollLeft(),a?c:f(g).scrollTop()):this[e]=c})}});f.each(["Height","Width"],function(a,c){var e=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,e,"padding")):this[e]():null};f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,e,a?"margin":"border")):this[e]():null};f.fn[e]=function(a){var d=this[0];if(!d)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[e](a.call(this,b,c[e]()))});if(f.isWindow(d)){var g=
d.document.documentElement["client"+c],j=d.document.body;return d.document.compatMode==="CSS1Compat"&&g||j&&j["client"+c]||g}else return d.nodeType===9?Math.max(d.documentElement["client"+c],d.body["scroll"+c],d.documentElement["scroll"+c],d.body["offset"+c],d.documentElement["offset"+c]):a===b?(d=f.css(d,e),g=parseFloat(d),f.isNumeric(g)?g:d):this.css(e,typeof a==="string"?a:a+"px")}});a.jQuery=a.$=f;typeof define==="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window);
(function(a,b){function c(b,c){var h=b.nodeName.toLowerCase();if("area"===h){h=b.parentNode;var k=h.name;if(!b.href||!k||h.nodeName.toLowerCase()!=="map")return!1;h=a("img[usemap=#"+k+"]")[0];return!!h&&d(h)}return(/input|select|textarea|button|object/.test(h)?!b.disabled:"a"==h?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.13",
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({_focus:a.fn.focus,focus:function(b,c){return typeof b==="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus();
c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;b=a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,
"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){c=a(this[0]);for(var d;c.length&&c[0]!==document;){d=c.css("position");if(d==="absolute"||d==="relative"||d==="fixed")if(d=parseInt(c.css("zIndex"),10),!isNaN(d)&&d!==0)return d;c=c.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",
function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){function h(b,c,e,d){a.each(k,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0;e&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0);d&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)});return c}var k=d==="Width"?["Left","Right"]:["Top","Bottom"],l=d.toLowerCase(),s={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,
outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){if(c===b)return s["inner"+d].call(this);return this.each(function(){a(this).css(l,h(this,c)+"px")})};a.fn["outer"+d]=function(b,c){if(typeof b!=="number")return s["outer"+d].call(this,b);return this.each(function(){a(this).css(l,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),h=isNaN(d);
return(h||d>=0)&&c(b,!h)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=c.offsetHeight===100;a.support.selectstart="onselectstart"in c;b.removeChild(c).style.display="none"}),a.extend(a.ui,{plugin:{add:function(b,c,d){b=a.ui[b].prototype;for(var k in d)b.plugins[k]=b.plugins[k]||[],b.plugins[k].push([c,d[k]])},call:function(a,b,c){if((b=a.plugins[b])&&a.element[0].parentNode)for(var d=
0;d<b.length;d++)a.options[b[d][0]]&&b[d][1].apply(a.element,c)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(b,c){if(a(b).css("overflow")==="hidden")return!1;var d=c&&c==="left"?"scrollLeft":"scrollTop",k=!1;if(b[d]>0)return!0;b[d]=1;k=b[d]>0;b[d]=0;return k},isOverAxis:function(a,b,c){return a>b&&a<b+c},isOver:function(b,c,d,k,l,s){return a.ui.isOverAxis(b,d,l)&&a.ui.isOverAxis(c,k,s)}}))})(jQuery);
(function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b){for(var d=0,h;(h=b[d])!=null;d++)a(h).triggerHandler("remove");c(b)}}else{var d=a.fn.remove;a.fn.remove=function(b,c){return this.each(function(){c||(!b||a.filter(b,[this]).length)&&a("*",this).add([this]).each(function(){a(this).triggerHandler("remove")});return d.call(a(this),b,c)})}}a.widget=function(b,c,d){var k=b.split(".")[0],l;b=b.split(".")[1];l=k+"-"+b;if(!d)d=c,c=a.Widget;a.expr[":"][l]=function(c){return!!a.data(c,
b)};a[k]=a[k]||{};a[k][b]=function(a,b){arguments.length&&this._createWidget(a,b)};c=new c;c.options=a.extend(!0,{},c.options);a[k][b].prototype=a.extend(!0,c,{namespace:k,widgetName:b,widgetEventPrefix:a[k][b].prototype.widgetEventPrefix||b,widgetBaseClass:l},d);a.widget.bridge(b,a[k][b])};a.widget.bridge=function(c,d){a.fn[c]=function(h){var k=typeof h==="string",l=Array.prototype.slice.call(arguments,1),s=this;h=!k&&l.length?a.extend.apply(null,[!0,h].concat(l)):h;if(k&&h.charAt(0)==="_")return s;
k?this.each(function(){var d=a.data(this,c),g=d&&a.isFunction(d[h])?d[h].apply(d,l):d;if(g!==d&&g!==b)return s=g,!1}):this.each(function(){var b=a.data(this,c);b?b.option(h||{})._init():a.data(this,c,new d(h,this))});return s}};a.Widget=function(a,b){arguments.length&&this._createWidget(a,b)};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(b,c){a.data(c,this.widgetName,this);this.element=a(c);this.options=a.extend(!0,{},this.options,this._getCreateOptions(),
b);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},
option:function(c,d){var h=c;if(arguments.length===0)return a.extend({},this.options);if(typeof c==="string"){if(d===b)return this.options[c];h={};h[c]=d}this._setOptions(h);return this},_setOptions:function(b){var c=this;a.each(b,function(a,b){c._setOption(a,b)});return this},_setOption:function(a,b){this.options[a]=b;a==="disabled"&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",b);return this},enable:function(){return this._setOption("disabled",
!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(b,c,d){var k=this.options[b];c=a.Event(c);c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase();d=d||{};if(c.originalEvent){b=a.event.props.length;for(var l;b;)l=a.event.props[--b],c[l]=c.originalEvent[l]}this.element.trigger(c,d);return!(a.isFunction(k)&&k.call(this.element[0],c,d)===!1||c.isDefaultPrevented())}}})(jQuery);
(function(a){a.ui=a.ui||{};var b=/left|center|right/,c=/top|center|bottom/,d=a.fn.position,e=a.fn.offset;a.fn.position=function(e){if(!e||!e.of)return d.apply(this,arguments);e=a.extend({},e);var h=a(e.of),k=h[0],l=(e.collision||"flip").split(" "),s=e.offset?e.offset.split(" "):[0,0],z,q,x;k.nodeType===9?(z=h.width(),q=h.height(),x={top:0,left:0}):k.setTimeout?(z=h.width(),q=h.height(),x={top:h.scrollTop(),left:h.scrollLeft()}):k.preventDefault?(e.at="left top",z=q=0,x={top:e.of.pageY,left:e.of.pageX}):
(z=h.outerWidth(),q=h.outerHeight(),x=h.offset());a.each(["my","at"],function(){var a=(e[this]||"").split(" ");a.length===1&&(a=b.test(a[0])?a.concat(["center"]):c.test(a[0])?["center"].concat(a):["center","center"]);a[0]=b.test(a[0])?a[0]:"center";a[1]=c.test(a[1])?a[1]:"center";e[this]=a});l.length===1&&(l[1]=l[0]);s[0]=parseInt(s[0],10)||0;s.length===1&&(s[1]=s[0]);s[1]=parseInt(s[1],10)||0;e.at[0]==="right"?x.left+=z:e.at[0]==="center"&&(x.left+=z/2);e.at[1]==="bottom"?x.top+=q:e.at[1]==="center"&&
(x.top+=q/2);x.left+=s[0];x.top+=s[1];return this.each(function(){var b=a(this),c=b.outerWidth(),d=b.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,k=parseInt(a.curCSS(this,"marginTop",!0))||0,L=c+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),V=d+k+(parseInt(a.curCSS(this,"marginBottom",!0))||0),m=a.extend({},x),j;e.my[0]==="right"?m.left-=c:e.my[0]==="center"&&(m.left-=c/2);e.my[1]==="bottom"?m.top-=d:e.my[1]==="center"&&(m.top-=d/2);m.left=Math.round(m.left);m.top=Math.round(m.top);
j={left:m.left-h,top:m.top-k};a.each(["left","top"],function(b,h){if(a.ui.position[l[b]])a.ui.position[l[b]][h](m,{targetWidth:z,targetHeight:q,elemWidth:c,elemHeight:d,collisionPosition:j,collisionWidth:L,collisionHeight:V,offset:s,my:e.my,at:e.at})});a.fn.bgiframe&&b.bgiframe();b.offset(a.extend(m,{using:e.using}))})};a.ui.position={fit:{left:function(b,c){var d=a(window);d=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=d>0?b.left-d:Math.max(b.left-c.collisionPosition.left,
b.left)},top:function(b,c){var d=a(window);d=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]!=="center"){var d=a(window);d=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();var e=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,s=c.at[0]==="left"?c.targetWidth:-c.targetWidth,z=-2*c.offset[0];b.left+=c.collisionPosition.left<0?e+s+z:d>0?e+s+z:0}},top:function(b,
c){if(c.at[1]!=="center"){var d=a(window);d=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();var e=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,s=c.at[1]==="top"?c.targetHeight:-c.targetHeight,z=-2*c.offset[1];b.top+=c.collisionPosition.top<0?e+s+z:d>0?e+s+z:0}}}};if(!a.offset.setOffset)a.offset.setOffset=function(b,c){if(/static/.test(a.curCSS(b,"position")))b.style.position="relative";var d=a(b),e=d.offset(),s=parseInt(a.curCSS(b,"top",!0),10)||0,z=parseInt(a.curCSS(b,
"left",!0),10)||0;e={top:c.top-e.top+s,left:c.left-e.left+z};"using"in c?c.using.call(b,e):d.css(e)},a.fn.offset=function(b){var c=this[0];if(!c||!c.ownerDocument)return null;if(b)return this.each(function(){a.offset.setOffset(this,b)});return e.call(this)}})(jQuery);
(function(a){var b=!1;a(document).mousedown(function(){b=!1});a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(a){return b._mouseDown(a)}).bind("click."+this.widgetName,function(d){if(!0===a.data(d.target,b.widgetName+".preventClickEvent"))return a.removeData(d.target,b.widgetName+".preventClickEvent"),d.stopImmediatePropagation(),!1});this.started=!1},_mouseDestroy:function(){this.element.unbind("."+
this.widgetName)},_mouseDown:function(c){if(!b){this._mouseStarted&&this._mouseUp(c);this._mouseDownEvent=c;var d=this,e=c.which==1,g=typeof this.options.cancel=="string"?a(c.target).parents().add(c.target).filter(this.options.cancel).length:!1;if(!e||g||!this._mouseCapture(c))return!0;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){d.mouseDelayMet=!0},this.options.delay);if(this._mouseDistanceMet(c)&&this._mouseDelayMet(c)&&(this._mouseStarted=
this._mouseStart(c)!==!1,!this._mouseStarted))return c.preventDefault(),!0;!0===a.data(c.target,this.widgetName+".preventClickEvent")&&a.removeData(c.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(a){return d._mouseMove(a)};this._mouseUpDelegate=function(a){return d._mouseUp(a)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);c.preventDefault();return b=!0}},_mouseMove:function(b){if(a.browser.msie&&
!(document.documentMode>=9)&&!b.button)return this._mouseUp(b);if(this._mouseStarted)return this._mouseDrag(b),b.preventDefault();if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1)?this._mouseDrag(b):this._mouseUp(b);return!this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted)this._mouseStarted=
!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b);return!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})})(jQuery);
(function(a){a.widget("ui.sortable",a.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var a=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh();
this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(b,c){b==="disabled"?(this.options[b]=
c,this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(b);var d=null,e=this;a(b.target).parents().each(function(){if(a.data(this,"sortable-item")==e)return d=a(this),!1});a.data(b.target,"sortable-item")==e&&(d=a(b.target));if(!d)return!1;if(this.options.handle&&!c){var g=!1;a(this.options.handle,
d).find("*").andSelf().each(function(){this==b.target&&(g=!0)});if(!g)return!1}this.currentItem=d;this._removeCurrentsFromItems();return!0},_mouseStart:function(b,c,d){c=this.options;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(b);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position",
"absolute");this.cssPosition=this.helper.css("position");a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(b);this.originalPageX=b.pageX;this.originalPageY=b.pageY;c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();
this._createPlaceholder();c.containment&&this._setContainment();if(c.cursor){if(a("body").css("cursor"))this._storedCursor=a("body").css("cursor");a("body").css("cursor",c.cursor)}if(c.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",c.opacity)}if(c.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",c.zIndex)}if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=
this.scrollParent.offset();this._trigger("start",b,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!d)for(d=this.containers.length-1;d>=0;d--)this.containers[d]._trigger("activate",b,this._uiHash(this));if(a.ui.ddmanager)a.ui.ddmanager.current=this;a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b);this.dragging=!0;this.helper.addClass("ui-sortable-helper");this._mouseDrag(b);return!0},_mouseDrag:function(b){this.position=this._generatePosition(b);
this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var c=this.options,d=!1;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY<c.scrollSensitivity)this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop+c.scrollSpeed;else if(b.pageY-this.overflowOffset.top<c.scrollSensitivity)this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop-
c.scrollSpeed;if(this.overflowOffset.left+this.scrollParent[0].offsetWidth-b.pageX<c.scrollSensitivity)this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft+c.scrollSpeed;else if(b.pageX-this.overflowOffset.left<c.scrollSensitivity)this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft-c.scrollSpeed}else b.pageY-a(document).scrollTop()<c.scrollSensitivity?d=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<c.scrollSensitivity&&
(d=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed)),b.pageX-a(document).scrollLeft()<c.scrollSensitivity?d=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(d=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed));d!==!1&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=
this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(c=this.items.length-1;c>=0;c--){d=this.items[c];var e=d.item[0],g=this._intersectsWithPointer(d);if(g&&e!=this.currentItem[0]&&this.placeholder[g==1?"next":"prev"]()[0]!=e&&!a.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!a.ui.contains(this.element[0],e):1)){this.direction=g==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(d))this._rearrange(b,
d);else break;this._trigger("change",b,this._uiHash());break}}this._contactContainers(b);a.ui.ddmanager&&a.ui.ddmanager.drag(this,b);this._trigger("sort",b,this._uiHash());this.lastPositionAbs=this.positionAbs;return!1},_mouseStop:function(b,c){if(b){a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b);if(this.options.revert){var d=this,e=d.placeholder.offset();d.reverting=!0;a(this.helper).animate({left:e.left-this.offset.parent.left-d.margins.left+(this.offsetParent[0]==document.body?
0:this.offsetParent[0].scrollLeft),top:e.top-this.offset.parent.top-d.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--)if(this.containers[b]._trigger("deactivate",
null,this._uiHash(this)),this.containers[b].containerCache.over)this.containers[b]._trigger("out",null,this._uiHash(this)),this.containers[b].containerCache.over=0}this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):
a(this.domPosition.parent).prepend(this.currentItem));return this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];b=b||{};a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))});!d.length&&b.key&&d.push(b.key+"=");return d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];b=b||{};c.each(function(){d.push(a(b.item||this).attr(b.attribute||
"id")||"")});return d},_intersectsWith:function(a){var c=this.positionAbs.left,d=c+this.helperProportions.width,e=this.positionAbs.top,g=e+this.helperProportions.height,h=a.left,k=h+a.width,l=a.top,s=l+a.height,z=this.offset.click.top,q=this.offset.click.left;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?e+z>l&&e+z<s&&c+q>h&&c+q<k:h<c+this.helperProportions.width/
2&&d-this.helperProportions.width/2<k&&l<e+this.helperProportions.height/2&&g-this.helperProportions.height/2<s},_intersectsWithPointer:function(b){var c=a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top,b.height);b=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left,b.width);c=c&&b;b=this._getDragVerticalDirection();var d=this._getDragHorizontalDirection();if(!c)return!1;return this.floating?d&&d=="right"||b=="down"?2:1:b&&(b=="down"?2:1)},_intersectsWithSides:function(b){var c=
a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top+b.height/2,b.height);b=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left+b.width/2,b.width);var d=this._getDragVerticalDirection(),e=this._getDragHorizontalDirection();return this.floating&&e?e=="right"&&b||e=="left"&&!b:d&&(d=="down"&&c||d=="up"&&!c)},_getDragVerticalDirection:function(){var a=this.positionAbs.top-this.lastPositionAbs.top;return a!=0&&(a>0?"down":"up")},_getDragHorizontalDirection:function(){var a=
this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a);this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c=[],d=[],e=this._connectWith();if(e&&b)for(b=e.length-1;b>=0;b--)for(var g=a(e[b]),h=g.length-1;h>=0;h--){var k=a.data(g[h],"sortable");k&&k!=this&&!k.options.disabled&&d.push([a.isFunction(k.options.items)?
k.options.items.call(k.element):a(k.options.items,k.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),k])}d.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(b=d.length-1;b>=0;b--)d[b][0].each(function(){c.push(this)});return a(c)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),
c=0;c<this.items.length;c++)for(var d=0;d<a.length;d++)a[d]==this.items[c].item[0]&&this.items.splice(c,1)},_refreshItems:function(b){this.items=[];this.containers=[this];var c=this.items,d=[[a.isFunction(this.options.items)?this.options.items.call(this.element[0],b,{item:this.currentItem}):a(this.options.items,this.element),this]],e=this._connectWith();if(e)for(var g=e.length-1;g>=0;g--)for(var h=a(e[g]),k=h.length-1;k>=0;k--){var l=a.data(h[k],"sortable");l&&l!=this&&!l.options.disabled&&(d.push([a.isFunction(l.options.items)?
l.options.items.call(l.element[0],b,{item:this.currentItem}):a(l.options.items,l.element),l]),this.containers.push(l))}for(g=d.length-1;g>=0;g--){b=d[g][1];e=d[g][0];k=0;for(h=e.length;k<h;k++)l=a(e[k]),l.data("sortable-item",b),c.push({item:l,instance:b,width:0,height:0,left:0,top:0})}},refreshPositions:function(b){if(this.offsetParent&&this.helper)this.offset.parent=this._getParentOffset();for(var c=this.items.length-1;c>=0;c--){var d=this.items[c];if(!(d.instance!=this.currentContainer&&this.currentContainer&&
d.item[0]!=this.currentItem[0])){var e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item;if(!b)d.width=e.outerWidth(),d.height=e.outerHeight();e=e.offset();d.left=e.left;d.top=e.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(c=this.containers.length-1;c>=0;c--)e=this.containers[c].element.offset(),this.containers[c].containerCache.left=e.left,this.containers[c].containerCache.top=e.top,this.containers[c].containerCache.width=
this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight();return this},_createPlaceholder:function(b){var c=b||this,d=c.options;if(!d.placeholder||d.placeholder.constructor==String){var e=d.placeholder;d.placeholder={element:function(){var b=a(document.createElement(c.currentItem[0].nodeName)).addClass(e||c.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!e)b.style.visibility="hidden";return b},
update:function(a,b){if(!e||d.forcePlaceholderSize)b.height()||b.height(c.currentItem.innerHeight()-parseInt(c.currentItem.css("paddingTop")||0,10)-parseInt(c.currentItem.css("paddingBottom")||0,10)),b.width()||b.width(c.currentItem.innerWidth()-parseInt(c.currentItem.css("paddingLeft")||0,10)-parseInt(c.currentItem.css("paddingRight")||0,10))}}}c.placeholder=a(d.placeholder.element.call(c.element,c.currentItem));c.currentItem.after(c.placeholder);d.placeholder.update(c,c.placeholder)},_contactContainers:function(b){for(var c=
null,d=null,e=this.containers.length-1;e>=0;e--)if(!a.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!c||!a.ui.contains(this.containers[e].element[0],c.element[0]))c=this.containers[e],d=e}else if(this.containers[e].containerCache.over)this.containers[e]._trigger("out",b,this._uiHash(this)),this.containers[e].containerCache.over=0;if(c)if(this.containers.length===1)this.containers[d]._trigger("over",b,this._uiHash(this)),
this.containers[d].containerCache.over=1;else if(this.currentContainer!=this.containers[d]){c=1E4;e=null;for(var g=this.positionAbs[this.containers[d].floating?"left":"top"],h=this.items.length-1;h>=0;h--)if(a.ui.contains(this.containers[d].element[0],this.items[h].item[0])){var k=this.items[h][this.containers[d].floating?"left":"top"];Math.abs(k-g)<c&&(c=Math.abs(k-g),e=this.items[h])}if(e||this.options.dropOnEmpty)this.currentContainer=this.containers[d],e?this._rearrange(b,e,null,!0):this._rearrange(b,
null,this.containers[d].element,!0),this._trigger("change",b,this._uiHash()),this.containers[d]._trigger("change",b,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1}},_createHelper:function(b){var c=this.options;b=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b,this.currentItem])):c.helper=="clone"?this.currentItem.clone():this.currentItem;b.parents("body").length||
a(c.appendTo!="parent"?c.appendTo:this.currentItem[0].parentNode)[0].appendChild(b[0]);if(b[0]==this.currentItem[0])this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")};(b[0].style.width==""||c.forceHelperSize)&&b.width(this.currentItem.width());(b[0].style.height==""||c.forceHelperSize)&&b.height(this.currentItem.height());return b},_adjustOffsetFromHelper:function(b){typeof b==
"string"&&(b=b.split(" "));a.isArray(b)&&(b={left:+b[0],top:+b[1]||0});if("left"in b)this.offset.click.left=b.left+this.margins.left;if("right"in b)this.offset.click.left=this.helperProportions.width-b.right+this.margins.left;if("top"in b)this.offset.click.top=b.top+this.margins.top;if("bottom"in b)this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition==
"absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition==
"relative"){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},
_setContainment:function(){var b=this.options;if(b.containment=="parent")b.containment=this.helper[0].parentNode;if(b.containment=="document"||b.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-
this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)){var c=a(b.containment)[0];b=a(b.containment).offset();var d=a(c).css("overflow")!="hidden";this.containment=[b.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,b.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,b.left+(d?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),
10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,b.top+(d?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(b,c){if(!c)c=this.position;var d=b=="absolute"?1:-1,e=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?
this.offsetParent:this.scrollParent,g=/(html|body)/i.test(e[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:e.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:e.scrollLeft())*d)}},_generatePosition:function(b){var c=
this.options,d=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName);if(this.cssPosition=="relative"&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0]))this.offset.relative=this._getRelativeOffset();var g=b.pageX,h=b.pageY;this.originalPosition&&(this.containment&&(b.pageX-this.offset.click.left<this.containment[0]&&(g=this.containment[0]+
this.offset.click.left),b.pageY-this.offset.click.top<this.containment[1]&&(h=this.containment[1]+this.offset.click.top),b.pageX-this.offset.click.left>this.containment[2]&&(g=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(h=this.containment[3]+this.offset.click.top)),c.grid&&(h=this.originalPageY+Math.round((h-this.originalPageY)/c.grid[1])*c.grid[1],h=this.containment?!(h-this.offset.click.top<this.containment[1]||h-this.offset.click.top>this.containment[3])?
h:!(h-this.offset.click.top<this.containment[1])?h-c.grid[1]:h+c.grid[1]:h,g=this.originalPageX+Math.round((g-this.originalPageX)/c.grid[0])*c.grid[0],g=this.containment?!(g-this.offset.click.left<this.containment[0]||g-this.offset.click.left>this.containment[2])?g:!(g-this.offset.click.left<this.containment[0])?g-c.grid[0]:g+c.grid[0]:g));return{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():
e?0:d.scrollTop()),left:g-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:d.scrollLeft())}},_rearrange:function(a,c,d,e){d?d[0].appendChild(this.placeholder[0]):c.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?c.item[0]:c.item[0].nextSibling);this.counter=this.counter?++this.counter:1;var g=this,h=this.counter;window.setTimeout(function(){h==
g.counter&&g.refreshPositions(!e)},0)},_clear:function(b,c){this.reverting=!1;var d=[];!this._noFinalSort&&this.currentItem[0].parentNode&&this.placeholder.before(this.currentItem);this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var e in this._storedCSS)if(this._storedCSS[e]=="auto"||this._storedCSS[e]=="static")this._storedCSS[e]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!c&&d.push(function(a){this._trigger("receive",
a,this._uiHash(this.fromOutside))});(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!c&&d.push(function(a){this._trigger("update",a,this._uiHash())});if(!a.ui.contains(this.element[0],this.currentItem[0])){c||d.push(function(a){this._trigger("remove",a,this._uiHash())});for(e=this.containers.length-1;e>=0;e--)a.ui.contains(this.containers[e].element[0],this.currentItem[0])&&!c&&(d.push(function(a){return function(b){a._trigger("receive",
b,this._uiHash(this))}}.call(this,this.containers[e])),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.containers[e])))}for(e=this.containers.length-1;e>=0;e--)if(c||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[e])),this.containers[e].containerCache.over)d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this))}}.call(this,this.containers[e])),this.containers[e].containerCache.over=
0;this._storedCursor&&a("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=!1;if(this.cancelHelperRemoval){if(!c){this._trigger("beforeStop",b,this._uiHash());for(e=0;e<d.length;e++)d[e].call(this,b);this._trigger("stop",b,this._uiHash())}return!1}c||this._trigger("beforeStop",b,this._uiHash());this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
this.helper[0]!=this.currentItem[0]&&this.helper.remove();this.helper=null;if(!c){for(e=0;e<d.length;e++)d[e].call(this,b);this._trigger("stop",b,this._uiHash())}this.fromOutside=!1;return!0},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(b){var c=b||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:b?b.element:null}}});a.extend(a.ui.sortable,
{version:"1.8.13"})})(jQuery);
(function(a){var b=0;a.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var b=this,d=this.element[0].ownerDocument,e;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(d){if(!b.options.disabled&&!b.element.attr("readonly")){e=!1;var h=
a.ui.keyCode;switch(d.keyCode){case h.PAGE_UP:b._move("previousPage",d);break;case h.PAGE_DOWN:b._move("nextPage",d);break;case h.UP:b._move("previous",d);d.preventDefault();break;case h.DOWN:b._move("next",d);d.preventDefault();break;case h.ENTER:case h.NUMPAD_ENTER:b.menu.active&&(e=!0,d.preventDefault());case h.TAB:if(!b.menu.active)break;b.menu.select(d);break;case h.ESCAPE:b.element.val(b.term);b.close(d);break;default:clearTimeout(b.searching),b.searching=setTimeout(function(){if(b.term!=b.element.val())b.selectedItem=
null,b.search(null,d)},b.options.delay)}}}).bind("keypress.autocomplete",function(a){e&&(e=!1,a.preventDefault())}).bind("focus.autocomplete",function(){if(!b.options.disabled)b.selectedItem=null,b.previous=b.element.val()}).bind("blur.autocomplete",function(a){if(!b.options.disabled)clearTimeout(b.searching),b.closing=setTimeout(function(){b.close(a);b._change(a)},150)});this._initSource();this.response=function(){return b._response.apply(b,arguments)};this.menu=a("<ul></ul>").addClass("ui-autocomplete").appendTo(a(this.options.appendTo||
"body",d)[0]).mousedown(function(d){var e=b.menu.element[0];a(d.target).closest(".ui-menu-item").length||setTimeout(function(){a(document).one("mousedown",function(d){d.target!==b.element[0]&&d.target!==e&&!a.ui.contains(e,d.target)&&b.close()})},1);setTimeout(function(){clearTimeout(b.closing)},13)}).menu({focus:function(a,d){var e=d.item.data("item.autocomplete");!1!==b._trigger("focus",a,{item:e})&&/^key/.test(a.originalEvent.type)&&b.element.val(e.value)},selected:function(a,e){var k=e.item.data("item.autocomplete"),
l=b.previous;if(b.element[0]!==d.activeElement)b.element.focus(),b.previous=l,setTimeout(function(){b.previous=l;b.selectedItem=k},1);!1!==b._trigger("select",a,{item:k})&&b.element.val(k.value);b.term=b.element.val();b.close(a);b.selectedItem=k},blur:function(){b.menu.element.is(":visible")&&b.element.val()!==b.term&&b.element.val(b.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");a.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");
this.menu.element.remove();a.Widget.prototype.destroy.call(this)},_setOption:function(b,d){a.Widget.prototype._setOption.apply(this,arguments);b==="source"&&this._initSource();b==="appendTo"&&this.menu.element.appendTo(a(d||"body",this.element[0].ownerDocument)[0]);b==="disabled"&&d&&this.xhr&&this.xhr.abort()},_initSource:function(){var c=this,d,e;a.isArray(this.options.source)?(d=this.options.source,this.source=function(b,c){c(a.ui.autocomplete.filter(d,b.term))}):typeof this.options.source==="string"?
(e=this.options.source,this.source=function(d,h){c.xhr&&c.xhr.abort();c.xhr=a.ajax({url:e,data:d,dataType:"json",autocompleteRequest:++b,success:function(a){this.autocompleteRequest===b&&h(a)},error:function(){this.autocompleteRequest===b&&h([])}})}):this.source=this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)!==!1)return this._search(a)},
_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)},_response:function(a){!this.options.disabled&&a&&a.length?(a=this._normalize(a),this._suggest(a),this._trigger("open")):this.close();this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},close:function(a){clearTimeout(this.closing);this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.deactivate(),this._trigger("close",a))},_change:function(a){this.previous!==
this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(b){if(b.length&&b[0].label&&b[0].value)return b;return a.map(b,function(b){if(typeof b==="string")return{label:b,value:b};return a.extend({label:b.label||b.value,value:b.value||b.label},b)})},_suggest:function(b){var d=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(d,b);this.menu.deactivate();this.menu.refresh();d.show();this._resizeMenu();d.position(a.extend({of:this.element},this.options.position));
this.options.autoFocus&&this.menu.next(new a.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(b,d){var e=this;a.each(d,function(a,d){e._renderItem(b,d)})},_renderItem:function(b,d){return a("<li></li>").data("item.autocomplete",d).append(a("<a></a>").text(d.label)).appendTo(b)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&
/^next/.test(a))this.element.val(this.term),this.menu.deactivate();else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});a.extend(a.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(b,d){var e=RegExp(a.ui.autocomplete.escapeRegex(d),"i");return a.grep(b,function(a){return e.test(a.label||a.value||a)})}})})(jQuery);
(function(a){a.widget("ui.menu",{_create:function(){var b=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){a(c.target).closest(".ui-menu-item a").length&&(c.preventDefault(),b.select(c))});this.refresh()},refresh:function(){var b=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
-1).mouseenter(function(c){b.activate(c,a(this).parent())}).mouseleave(function(){b.deactivate()})},activate:function(a,c){this.deactivate();if(this.hasScroll()){var d=c.offset().top-this.element.offset().top,e=this.element.scrollTop(),g=this.element.height();d<0?this.element.scrollTop(e+d):d>=g&&this.element.scrollTop(e+d-g+c.height())}this.active=c.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",a,{item:c})},deactivate:function(){if(this.active)this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),
this._trigger("blur"),this.active=null},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(a,c,d){this.active?(a=this.active[a+"All"](".ui-menu-item").eq(0),a.length?this.activate(d,a):this.activate(d,this.element.children(c))):this.activate(d,this.element.children(c))},
nextPage:function(b){if(this.hasScroll())if(!this.active||this.last())this.activate(b,this.element.children(".ui-menu-item:first"));else{var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c-d+a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:last"));this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},
previousPage:function(b){if(this.hasScroll())if(!this.active||this.first())this.activate(b,this.element.children(".ui-menu-item:last"));else{var c=this.active.offset().top,d=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c+d-a(this).height();return b<10&&b>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(b,result)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||
this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[a.fn.prop?"prop":"attr"]("scrollHeight")},select:function(a){this._trigger("selected",a,{item:this.active})}})})(jQuery);
(function(){var a=this,b=a.Backbone,c=Array.prototype.slice,d=Array.prototype.splice,e;e=typeof exports!=="undefined"?exports:a.Backbone={};e.VERSION="0.9.1";var g=a._;!g&&typeof require!=="undefined"&&(g=require("underscore"));var h=a.jQuery||a.Zepto||a.ender;e.setDomLibrary=function(a){h=a};e.noConflict=function(){a.Backbone=b;return this};e.emulateHTTP=!1;e.emulateJSON=!1;e.Events={on:function(a,b,c){var d;a=a.split(/\s+/);for(var e=this._callbacks||(this._callbacks={});d=a.shift();){d=e[d]||(e[d]=
{});var g=d.tail||(d.tail=d.next={});g.callback=b;g.context=c;d.tail=g.next={}}return this},off:function(a,b,c){var d,e,g;if(a){if(e=this._callbacks)for(a=a.split(/\s+/);d=a.shift();)if(g=e[d],delete e[d],b&&g)for(;(g=g.next)&&g.next;)if(!(g.callback===b&&(!c||g.context===c)))this.on(d,g.callback,g.context)}else delete this._callbacks;return this},trigger:function(a){var b,d,e,g;if(!(e=this._callbacks))return this;g=e.all;for((a=a.split(/\s+/)).push(null);b=a.shift();)g&&a.push({next:g.next,tail:g.tail,
event:b}),(d=e[b])&&a.push({next:d.next,tail:d.tail});for(g=c.call(arguments,1);d=a.pop();){b=d.tail;for(e=d.event?[d.event].concat(g):g;(d=d.next)!==b;)d.callback.apply(d.context||this,e)}return this}};e.Events.bind=e.Events.on;e.Events.unbind=e.Events.off;e.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=L(this,"defaults"))a=g.extend({},c,a);if(b&&b.collection)this.collection=b.collection;this.attributes={};this._escapedAttributes={};this.cid=g.uniqueId("c");this.set(a,{silent:!0});
delete this._changed;this._previousAttributes=g.clone(this.attributes);this.initialize.apply(this,arguments)};g.extend(e.Model.prototype,e.Events,{idAttribute:"id",initialize:function(){},toJSON:function(){return g.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.attributes[a];return this._escapedAttributes[a]=g.escape(b==null?"":""+b)},has:function(a){return this.attributes[a]!=null},set:function(a,b,c){var d,
h;g.isObject(a)||a==null?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;if(d instanceof e.Model)d=d.attributes;if(c.unset)for(h in d)d[h]=void 0;if(!this._validate(d,c))return!1;if(this.idAttribute in d)this.id=d[this.idAttribute];b=this.attributes;var k=this._escapedAttributes,l=this._previousAttributes||{},q=this._setting;this._changed||(this._changed={});this._setting=!0;for(h in d){a=d[h];g.isEqual(b[h],a)||delete k[h];c.unset?delete b[h]:b[h]=a;if(this._changing&&!g.isEqual(this._changed[h],
a))this.trigger("change:"+h,this,a,c),this._moreChanges=!0;delete this._changed[h];if(!g.isEqual(l[h],a)||g.has(b,h)!=g.has(l,h))this._changed[h]=a}if(!q)!c.silent&&this.hasChanged()&&this.change(c),this._setting=!1;return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(g.clone(this.attributes),a)},fetch:function(a){a=a?g.clone(a):{};var b=this,c=a.success;a.success=function(d,e,g){if(!b.set(b.parse(d,g),a))return!1;
c&&c(b,d)};a.error=e.wrapError(a.error,b,a);return(this.sync||e.sync).call(this,"read",this,a)},save:function(a,b,c){var d,h;g.isObject(a)||a==null?(d=a,c=b):(d={},d[a]=b);c=c?g.clone(c):{};c.wait&&(h=g.clone(this.attributes));a=g.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var k=this,l=c.success;c.success=function(a,b,e){b=k.parse(a,e);c.wait&&(b=g.extend(d||{},b));if(!k.set(b,c))return!1;l?l(k,a):k.trigger("sync",k,a,c)};c.error=e.wrapError(c.error,k,c);b=this.isNew()?"create":
"update";b=(this.sync||e.sync).call(this,b,this,c);c.wait&&this.set(h,a);return b},destroy:function(a){a=a?g.clone(a):{};var b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d();a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=e.wrapError(a.error,b,a);var h=(this.sync||e.sync).call(this,"delete",this,a);a.wait||d();return h},url:function(){var a=L(this.collection,"url")||L(this,"urlRoot")||V();if(this.isNew())return a;return a+
(a.charAt(a.length-1)=="/"?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return this.id==null},change:function(a){if(this._changing||!this.hasChanged())return this;this._moreChanges=this._changing=!0;for(var b in this._changed)this.trigger("change:"+b,this,this._changed[b],a);for(;this._moreChanges;)this._moreChanges=!1,this.trigger("change",this,a);this._previousAttributes=g.clone(this.attributes);
delete this._changed;this._changing=!1;return this},hasChanged:function(a){if(!arguments.length)return!g.isEmpty(this._changed);return this._changed&&g.has(this._changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?g.clone(this._changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!g.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){if(!arguments.length||!this._previousAttributes)return null;return this._previousAttributes[a]},previousAttributes:function(){return g.clone(this._previousAttributes)},
isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;a=g.extend({},this.attributes,a);var c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});e.Collection=function(a,b){b||(b={});if(b.comparator)this.comparator=b.comparator;this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};g.extend(e.Collection.prototype,e.Events,{model:e.Model,initialize:function(){},
toJSON:function(){return this.map(function(a){return a.toJSON()})},add:function(a,b){var c,e,h,k,l,q={},s={},B=[];b||(b={});a=g.isArray(a)?a.slice():[a];c=0;for(e=a.length;c<e;c++){if(!(h=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");k=h.cid;l=h.id;q[k]||this._byCid[k]||l!=null&&(s[l]||this._byId[l])?B.push(c):q[k]=s[l]=h}for(c=B.length;c--;)a.splice(B[c],1);c=0;for(e=a.length;c<e;c++)(h=a[c]).on("all",this._onModelEvent,this),this._byCid[h.cid]=h,h.id!=
null&&(this._byId[h.id]=h);this.length+=e;d.apply(this.models,[b.at!=null?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(e=this.models.length;c<e;c++)if(q[(h=this.models[c]).cid])b.index=c,h.trigger("add",h,this,b);return this},remove:function(a,b){var c,d,e,h;b||(b={});a=g.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++)if(h=this.getByCid(a[c])||this.get(a[c])){delete this._byId[h.id];delete this._byCid[h.cid];e=this.indexOf(h);this.models.splice(e,
1);this.length--;if(!b.silent)b.index=e,h.trigger("remove",h,this,b);this._removeReference(h)}return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,g.extend({at:0},b));return a},shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){if(a!=null)return this._byId[a.id!=null?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||
a]},at:function(a){return this.models[a]},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=g.bind(this.comparator,this);this.comparator.length==1?this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return g.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();
this.add(a,{silent:!0,parse:b.parse});b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?g.clone(a):{};if(a.parse===void 0)a.parse=!0;var b=this,c=a.success;a.success=function(d,e,g){b[a.add?"add":"reset"](b.parse(d,g),a);c&&c(b,d)};a.error=e.wrapError(a.error,b,a);return(this.sync||e.sync).call(this,"read",this,a)},create:function(a,b){var c=this;b=b?g.clone(b):{};a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,g){b.wait&&c.add(e,
b);d?d(e,g):e.trigger("sync",a,g,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return g(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId={};this._byCid={}},_prepareModel:function(a,b){b||(b={});if(a instanceof e.Model){if(!a.collection)a.collection=this}else{var c;b.collection=this;a=new this.model(a,b);a._validate(a.attributes,b)||(a=!1)}return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,
this)},_onModelEvent:function(a,b,c,d){(a=="add"||a=="remove")&&c!=this||(a=="destroy"&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,arguments))}});g.each(["forEach","each","map","reduce","reduceRight","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","sortBy","sortedIndex","toArray","size","first","initial","rest","last","without","indexOf","shuffle",
"lastIndexOf","isEmpty","groupBy"],function(a){e.Collection.prototype[a]=function(){return g[a].apply(g,[this.models].concat(g.toArray(arguments)))}});e.Router=function(a){a||(a={});if(a.routes)this.routes=a.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var k=/:\w+/g,l=/\*\w+/g,s=/[-[\]{}()+?.,\\^$|#\s]/g;g.extend(e.Router.prototype,e.Events,{initialize:function(){},route:function(a,b,c){e.history||(e.history=new e.History);g.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);
e.history.route(a,g.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));e.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){e.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(s,"\\$&").replace(k,"([^/]+)").replace(l,"(.*?)");
return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});e.History=function(){this.handlers=[];g.bindAll(this,"checkUrl")};var z=/^[#\/]/,q=/msie [\w.]+/,x=!1;g.extend(e.History.prototype,e.Events,{interval:50,getFragment:function(a,b){if(a==null)if(this._hasPushState||b){a=window.location.pathname;var c=window.location.search;c&&(a+=c)}else a=window.location.hash;a=decodeURIComponent(a);a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(z,
"")},start:function(a){if(x)throw Error("Backbone.history has already been started");this.options=g.extend({},{root:"/"},this.options,a);this._wantsHashChange=this.options.hashChange!==!1;this._wantsPushState=!!this.options.pushState;this._hasPushState=!(!this.options.pushState||!window.history||!window.history.pushState);a=this.getFragment();var b=document.documentMode;if(b=q.exec(navigator.userAgent.toLowerCase())&&(!b||b<=7))this.iframe=h('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,
this.navigate(a);if(this._hasPushState)h(window).bind("popstate",this.checkUrl);else if(this._wantsHashChange&&"onhashchange"in window&&!b)h(window).bind("hashchange",this.checkUrl);else if(this._wantsHashChange)this._checkUrlInterval=setInterval(this.checkUrl,this.interval);this.fragment=a;x=!0;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+
"#"+this.fragment),!0;else if(this._wantsPushState&&this._hasPushState&&b&&a.hash)this.fragment=a.hash.replace(z,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment);if(!this.options.silent)return this.loadUrl()},stop:function(){h(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);x=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();
a==this.fragment&&this.iframe&&(a=this.getFragment(this.iframe.location.hash));if(a==this.fragment||a==decodeURIComponent(this.fragment))return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return g.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!x)return!1;if(!b||b===!0)b={trigger:b};var c=(a||"").replace(z,"");if(!(this.fragment==c||this.fragment==
decodeURIComponent(c)))this._hasPushState?(c.indexOf(this.options.root)!=0&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.iframe.location.hash)&&(b.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a)},
_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});e.View=function(a){this.cid=g.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()};var B=/^(\S+)\s*(.*)$/,K=["model","collection","el","id","attributes","className","tagName"];g.extend(e.View.prototype,e.Events,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();
return this},make:function(a,b,c){a=document.createElement(a);b&&h(a).attr(b);c&&h(a).html(c);return a},setElement:function(a,b){this.$el=h(a);this.el=this.$el[0];b!==!1&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=L(this,"events")))for(var b in this.undelegateEvents(),a){var c=a[b];g.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Event "'+a[b]+'" does not exist');var d=b.match(B),e=d[1];d=d[2];c=g.bind(c,this);e+=".delegateEvents"+this.cid;d===""?this.$el.bind(e,c):this.$el.delegate(d,
e,c)}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=g.extend({},this.options,a));for(var b=0,c=K.length;b<c;b++){var d=K[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,!1);else{var a=L(this,"attributes")||{};if(this.id)a.id=this.id;if(this.className)a["class"]=this.className;this.setElement(this.make(this.tagName,a),!1)}}});e.Model.extend=e.Collection.extend=e.Router.extend=e.View.extend=
function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var M={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};e.sync=function(a,b,c){var d=M[a],k={type:d,dataType:"json"};if(!c.url)k.url=L(b,"url")||V();if(!c.data&&b&&(a=="create"||a=="update"))k.contentType="application/json",k.data=JSON.stringify(b.toJSON());if(e.emulateJSON)k.contentType="application/x-www-form-urlencoded",k.data=k.data?{model:k.data}:{};if(e.emulateHTTP&&(d==="PUT"||d==="DELETE")){if(e.emulateJSON)k.data._method=
d;k.type="POST";k.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)}}if(k.type!=="GET"&&!e.emulateJSON)k.processData=!1;return h.ajax(g.extend(k,c))};e.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var F=function(){},G=function(a,b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};g.extend(d,a);F.prototype=a.prototype;d.prototype=new F;b&&g.extend(d.prototype,b);c&&g.extend(d,c);d.prototype.constructor=
d;d.__super__=a.prototype;return d},L=function(a,b){if(!a||!a[b])return null;return g.isFunction(a[b])?a[b]():a[b]},V=function(){throw Error('A "url" property or function must be specified');}}).call(this);
(function(){jQuery.color={};jQuery.color.make=function(a,c,d,e){var g={};g.r=a||0;g.g=c||0;g.b=d||0;g.a=e!=null?e:1;g.add=function(a,b){for(var c=0;c<a.length;++c)g[a.charAt(c)]+=b;return g.normalize()};g.scale=function(a,b){for(var c=0;c<a.length;++c)g[a.charAt(c)]*=b;return g.normalize()};g.toString=function(){return g.a>=1?"rgb("+[g.r,g.g,g.b].join(",")+")":"rgba("+[g.r,g.g,g.b,g.a].join(",")+")"};g.normalize=function(){function a(b,c,d){return c<b?b:c>d?d:c}g.r=a(0,parseInt(g.r),255);g.g=a(0,
parseInt(g.g),255);g.b=a(0,parseInt(g.b),255);g.a=a(0,g.a,1);return g};g.clone=function(){return jQuery.color.make(g.r,g.b,g.g,g.a)};return g.normalize()};jQuery.color.extract=function(a,c){var d;do{d=a.css(c).toLowerCase();if(d!=""&&d!="transparent")break;a=a.parent()}while(!jQuery.nodeName(a.get(0),"body"));d=="rgba(0, 0, 0, 0)"&&(d="transparent");return jQuery.color.parse(d)};jQuery.color.parse=function(b){var c,d=jQuery.color.make;if(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))return d(parseInt(c[1],
10),parseInt(c[2],10),parseInt(c[3],10));if(c=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(b))return d(parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10),parseFloat(c[4]));if(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))return d(parseFloat(c[1])*2.55,parseFloat(c[2])*2.55,parseFloat(c[3])*2.55);if(c=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(b))return d(parseFloat(c[1])*
2.55,parseFloat(c[2])*2.55,parseFloat(c[3])*2.55,parseFloat(c[4]));if(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))return d(parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16));if(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))return d(parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16));b=jQuery.trim(b).toLowerCase();return b=="transparent"?d(255,255,255,0):(c=a[b],d(c[0],c[1],c[2]))};var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,
0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,
211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})();
(function(a){function b(b,e,g,h){function k(a,b){b=[N].concat(b);for(var c=0;c<a.length;++c)a[c].apply(this,b)}function l(b){for(var c=[],d=0;d<b.length;++d){var e=a.extend(!0,{},o.series);b[d].data?(e.data=b[d].data,delete b[d].data,a.extend(!0,e,b[d]),b[d].data=e.data):e.data=b[d];c.push(e)}y=c;c=y.length;d=[];e=[];for(b=0;b<y.length;++b){var f=y[b].color;f!=null&&(--c,typeof f=="number"?e.push(f):d.push(a.color.parse(y[b].color)))}for(b=0;b<e.length;++b)c=Math.max(c,e[b]+1);d=[];for(b=e=0;d.length<
c;)f=o.colors.length==b?a.color.make(100,100,100):a.color.parse(o.colors[b]),f.scale("rgb",1+(e%2==1?-1:1)*Math.ceil(e/2)*0.2),d.push(f),++b,b>=o.colors.length&&(b=0,++e);for(b=c=0;b<y.length;++b){e=y[b];if(e.color==null)e.color=d[c].toString(),++c;else if(typeof e.color=="number")e.color=d[e.color].toString();if(e.lines.show==null){var g;f=!0;for(g in e)if(e[g].show){f=!1;break}if(f)e.lines.show=!0}e.xaxis=s(e,"xaxis");e.yaxis=s(e,"yaxis")}z()}function s(a,b){var c=a[b];if(!c||c==1)return C[b];if(typeof c==
"number")return C[b.charAt(0)+c+b.slice(1)];return c}function z(){function a(b,c,d){if(c<b.datamin)b.datamin=c;if(d>b.datamax)b.datamax=d}var b=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,d,e,f,g,h,j,l,m,o,q,s;for(m in C)C[m].datamin=b,C[m].datamax=c,C[m].used=!1;for(d=0;d<y.length;++d)h=y[d],h.datapoints={points:[]},k(da.processRawData,[h,h.data,h.datapoints]);for(d=0;d<y.length;++d){h=y[d];var t=h.data,B=h.datapoints.format;if(!B)B=[],B.push({x:!0,number:!0,required:!0}),B.push({y:!0,number:!0,
required:!0}),h.bars.show&&B.push({y:!0,number:!0,required:!1,defaultValue:0}),h.datapoints.format=B;if(h.datapoints.pointsize==null){if(h.datapoints.pointsize==null)h.datapoints.pointsize=B.length;l=h.datapoints.pointsize;j=h.datapoints.points;insertSteps=h.lines.show&&h.lines.steps;h.xaxis.used=h.yaxis.used=!0;for(e=f=0;e<t.length;++e,f+=l){s=t[e];var T=s==null;if(!T)for(g=0;g<l;++g){o=s[g];if(q=B[g])if(q.number&&o!=null&&(o=+o,isNaN(o)&&(o=null)),o==null&&(q.required&&(T=!0),q.defaultValue!=null))o=
q.defaultValue;j[f+g]=o}if(T)for(g=0;g<l;++g)o=j[f+g],o!=null&&(q=B[g],q.x&&a(h.xaxis,o,o),q.y&&a(h.yaxis,o,o)),j[f+g]=null;else if(insertSteps&&f>0&&j[f-l]!=null&&j[f-l]!=j[f]&&j[f-l+1]!=j[f+1]){for(g=0;g<l;++g)j[f+l+g]=j[f+g];j[f+1]=j[f-l+1];f+=l}}}}for(d=0;d<y.length;++d)h=y[d],k(da.processDatapoints,[h,h.datapoints]);for(d=0;d<y.length;++d){h=y[d];j=h.datapoints.points;l=h.datapoints.pointsize;s=f=b;T=t=c;for(e=0;e<j.length;e+=l)if(j[e]!=null)for(g=0;g<l;++g)if(o=j[e+g],q=B[g])q.x&&(o<f&&(f=o),
o>t&&(t=o)),q.y&&(o<s&&(s=o),o>T&&(T=o));h.bars.show&&(e=h.bars.align=="left"?0:-h.bars.barWidth/2,h.bars.horizontal?(s+=e,T+=e+h.bars.barWidth):(f+=e,t+=e+h.bars.barWidth));a(h.xaxis,f,t);a(h.yaxis,s,T)}for(m in C){if(C[m].datamin==b)C[m].datamin=null;if(C[m].datamax==c)C[m].datamax=null}}function q(){function c(a,b){function d(a){return a}var e,f,g=b.transform||d,h=b.inverseTransform;a==C.xaxis||a==C.x2axis?(e=a.scale=W/(g(a.max)-g(a.min)),f=g(a.min),a.p2c=g==d?function(a){return(a-f)*e}:function(a){return(g(a)-
f)*e},a.c2p=h?function(a){return h(f+a/e)}:function(a){return f+a/e}):(e=a.scale=Y/(g(a.max)-g(a.min)),f=g(a.max),a.p2c=g==d?function(a){return(f-a)*e}:function(a){return(f-g(a))*e},a.c2p=h?function(a){return h(f-a/e)}:function(a){return f-a/e})}function e(c,f){var g,h=[],j;c.labelWidth=f.labelWidth;c.labelHeight=f.labelHeight;if(c==C.xaxis||c==C.x2axis){if(c.labelWidth==null)c.labelWidth=X/(c.ticks.length>0?c.ticks.length:1);if(c.labelHeight==null){h=[];for(g=0;g<c.ticks.length;++g)(j=c.ticks[g].label)&&
h.push('<div class="tickLabel" style="float:left;width:'+c.labelWidth+'px">'+j+"</div>");if(h.length>0)g=a('<div style="position:absolute;top:-10000px;width:10000px;font-size:smaller">'+h.join("")+'<div style="clear:left"></div></div>').appendTo(b),c.labelHeight=g.height(),g.remove()}}else if(c.labelWidth==null||c.labelHeight==null){for(g=0;g<c.ticks.length;++g)(j=c.ticks[g].label)&&h.push('<div class="tickLabel">'+j+"</div>");if(h.length>0){g=a('<div style="position:absolute;top:-10000px;font-size:smaller">'+
h.join("")+"</div>").appendTo(b);if(c.labelWidth==null)c.labelWidth=g.width();if(c.labelHeight==null)c.labelHeight=g.find("div").height();g.remove()}}if(c.labelWidth==null)c.labelWidth=0;if(c.labelHeight==null)c.labelHeight=0}function f(){var a=o.grid.borderWidth;for(i=0;i<y.length;++i)a=Math.max(a,2*(y[i].points.radius+y[i].points.lineWidth/2));D.left=D.right=D.top=D.bottom=a;var b=o.grid.labelMargin+o.grid.borderWidth;if(C.xaxis.labelHeight>0)D.bottom=Math.max(a,C.xaxis.labelHeight+b);if(C.yaxis.labelWidth>
0)D.left=Math.max(a,C.yaxis.labelWidth+b);if(C.x2axis.labelHeight>0)D.top=Math.max(a,C.x2axis.labelHeight+b);if(C.y2axis.labelWidth>0)D.right=Math.max(a,C.y2axis.labelWidth+b);W=X-D.left-D.right;Y=Z-D.bottom-D.top}for(var g in C)x(C[g],o[g]);if(o.grid.show){for(g in C)B(C[g],o[g]),K(C[g],o[g]),e(C[g],o[g]);f()}else D.left=D.right=D.top=D.bottom=0,W=X,Y=Z;for(g in C)c(C[g],o[g]);o.grid.show&&L();S()}function x(a,b){var c=+(b.min!=null?b.min:a.datamin),d=+(b.max!=null?b.max:a.datamax),e=d-c;if(e==0){if(e=
d==0?1:0.01,b.min==null&&(c-=e),b.max==null||b.min!=null)d+=e}else{var f=b.autoscaleMargin;f!=null&&(b.min==null&&(c-=e*f,c<0&&a.datamin!=null&&a.datamin>=0&&(c=0)),b.max==null&&(d+=e*f,d>0&&a.datamax!=null&&a.datamax<=0&&(d=0)))}a.min=c;a.max=d}function B(b,d){var e=(b.max-b.min)/(typeof d.ticks=="number"&&d.ticks>0?d.ticks:b==C.xaxis||b==C.x2axis?0.3*Math.sqrt(X):0.3*Math.sqrt(Z)),f,g,h;if(d.mode=="time"){var j={second:1E3,minute:6E4,hour:36E5,day:864E5,month:2592E6,year:525949.2*6E4};h=[[1,"second"],
[2,"second"],[5,"second"],[10,"second"],[30,"second"],[1,"minute"],[2,"minute"],[5,"minute"],[10,"minute"],[30,"minute"],[1,"hour"],[2,"hour"],[4,"hour"],[8,"hour"],[12,"hour"],[1,"day"],[2,"day"],[3,"day"],[0.25,"month"],[0.5,"month"],[1,"month"],[2,"month"],[3,"month"],[6,"month"],[1,"year"]];f=0;d.minTickSize!=null&&(f=typeof d.tickSize=="number"?d.tickSize:d.minTickSize[0]*j[d.minTickSize[1]]);for(g=0;g<h.length-1;++g)if(e<(h[g][0]*j[h[g][1]]+h[g+1][0]*j[h[g+1][1]])/2&&h[g][0]*j[h[g][1]]>=f)break;
f=h[g][0];g=h[g][1];g=="year"&&(h=Math.pow(10,Math.floor(Math.log(e/j.year)/Math.LN10)),e=e/j.year/h,f=e<1.5?1:e<3?2:e<7.5?5:10,f*=h);d.tickSize&&(f=d.tickSize[0],g=d.tickSize[1]);e=function(a){var b=[],d=a.tickSize[0],e=a.tickSize[1],f=new Date(a.min),g=d*j[e];e=="second"&&f.setUTCSeconds(c(f.getUTCSeconds(),d));e=="minute"&&f.setUTCMinutes(c(f.getUTCMinutes(),d));e=="hour"&&f.setUTCHours(c(f.getUTCHours(),d));e=="month"&&f.setUTCMonth(c(f.getUTCMonth(),d));e=="year"&&f.setUTCFullYear(c(f.getUTCFullYear(),
d));f.setUTCMilliseconds(0);g>=j.minute&&f.setUTCSeconds(0);g>=j.hour&&f.setUTCMinutes(0);g>=j.day&&f.setUTCHours(0);g>=j.day*4&&f.setUTCDate(1);g>=j.year&&f.setUTCMonth(0);var h=0,n=Number.NaN,k;do if(k=n,n=f.getTime(),b.push({v:n,label:a.tickFormatter(n,a)}),e=="month")if(d<1){f.setUTCDate(1);var w=f.getTime();f.setUTCMonth(f.getUTCMonth()+1);var u=f.getTime();f.setTime(n+h*j.hour+(u-w)*d);h=f.getUTCHours();f.setUTCHours(0)}else f.setUTCMonth(f.getUTCMonth()+d);else e=="year"?f.setUTCFullYear(f.getUTCFullYear()+
d):f.setTime(n+g);while(n<a.max&&n!=k);return b};h=function(b,c){var e=new Date(b);if(d.timeformat!=null)return a.plot.formatDate(e,d.timeformat,d.monthNames);var f=c.tickSize[0]*j[c.tickSize[1]],g=c.max-c.min,h=d.twelveHourClock?" %p":"";fmt=f<j.minute?"%h:%M:%S"+h:f<j.day?g<2*j.day?"%h:%M"+h:"%b %d %h:%M"+h:f<j.month?"%b %d":f<j.year?g<j.year?"%b":"%b %y":"%y";return a.plot.formatDate(e,fmt,d.monthNames)}}else{var k=d.tickDecimals,l=-Math.floor(Math.log(e)/Math.LN10);k!=null&&l>k&&(l=k);h=Math.pow(10,
-l);e/=h;if(e<1.5)f=1;else if(e<3){if(f=2,e>2.25&&(k==null||l+1<=k))f=2.5,++l}else f=e<7.5?5:10;f*=h;if(d.minTickSize!=null&&f<d.minTickSize)f=d.minTickSize;if(d.tickSize!=null)f=d.tickSize;b.tickDecimals=Math.max(0,k!=null?k:l);e=function(a){var b=[],d=c(a.min,a.tickSize),e=0,f=Number.NaN,g;do g=f,f=d+e*a.tickSize,b.push({v:f,label:a.tickFormatter(f,a)}),++e;while(f<a.max&&f!=g);return b};h=function(a,b){return a.toFixed(b.tickDecimals)}}b.tickSize=g?[f,g]:f;b.tickGenerator=e;b.tickFormatter=a.isFunction(d.tickFormatter)?
function(a,b){return""+d.tickFormatter(a,b)}:h}function K(b,c){b.ticks=[];if(b.used){if(c.ticks==null)b.ticks=b.tickGenerator(b);else if(typeof c.ticks=="number"){if(c.ticks>0)b.ticks=b.tickGenerator(b)}else if(c.ticks){var d=c.ticks;a.isFunction(d)&&(d=d({min:b.min,max:b.max}));var e,f;for(e=0;e<d.length;++e){var g=null,h=d[e];typeof h=="object"?(f=h[0],h.length>1&&(g=h[1])):f=h;g==null&&(g=b.tickFormatter(f,b));b.ticks[e]={v:f,label:g}}}if(c.autoscaleMargin!=null&&b.ticks.length>0){if(c.min==null)b.min=
Math.min(b.min,b.ticks[0].v);if(c.max==null&&b.ticks.length>1)b.max=Math.max(b.max,b.ticks[b.ticks.length-1].v)}}}function M(){t.clearRect(0,0,X,Z);var a=o.grid;a.show&&!a.aboveData&&G();for(var b=0;b<y.length;++b){var c=y[b];c.lines.show&&V(c);c.bars.show&&A(c);c.points.show&&m(c)}k(da.draw,[t]);a.show&&a.aboveData&&G()}function F(a,b){var c=b+"axis",d=b+"2axis",e,f;a[c]?(e=C[c],f=a[c].from,c=a[c].to):a[d]?(e=C[d],f=a[d].from,c=a[d].to):(e=C[c],f=a[b+"1"],c=a[b+"2"]);if(f!=null&&c!=null&&f>c)return{from:c,
to:f,axis:e};return{from:f,to:c,axis:e}}function G(){var b;t.save();t.translate(D.left,D.top);if(o.grid.backgroundColor)t.fillStyle=ma(o.grid.backgroundColor,Y,0,"rgba(255, 255, 255, 0)"),t.fillRect(0,0,W,Y);var c=o.grid.markings;if(c){a.isFunction(c)&&(c=c({xmin:C.xaxis.min,xmax:C.xaxis.max,ymin:C.yaxis.min,ymax:C.yaxis.max,xaxis:C.xaxis,yaxis:C.yaxis,x2axis:C.x2axis,y2axis:C.y2axis}));for(b=0;b<c.length;++b){var d=c[b],e=F(d,"x"),f=F(d,"y");if(e.from==null)e.from=e.axis.min;if(e.to==null)e.to=e.axis.max;
if(f.from==null)f.from=f.axis.min;if(f.to==null)f.to=f.axis.max;if(!(e.to<e.axis.min||e.from>e.axis.max||f.to<f.axis.min||f.from>f.axis.max))if(e.from=Math.max(e.from,e.axis.min),e.to=Math.min(e.to,e.axis.max),f.from=Math.max(f.from,f.axis.min),f.to=Math.min(f.to,f.axis.max),!(e.from==e.to&&f.from==f.to))e.from=e.axis.p2c(e.from),e.to=e.axis.p2c(e.to),f.from=f.axis.p2c(f.from),f.to=f.axis.p2c(f.to),e.from==e.to||f.from==f.to?(t.beginPath(),t.strokeStyle=d.color||o.grid.markingsColor,t.lineWidth=d.lineWidth||
o.grid.markingsLineWidth,t.moveTo(e.from,f.from),t.lineTo(e.to,f.to),t.stroke()):(t.fillStyle=d.color||o.grid.markingsColor,t.fillRect(e.from,f.to,e.to-e.from,f.from-f.to))}}t.lineWidth=1;t.strokeStyle=o.grid.tickColor;t.beginPath();d=C.xaxis;for(b=0;b<d.ticks.length;++b)c=d.ticks[b].v,c<=d.min||c>=C.xaxis.max||(t.moveTo(Math.floor(d.p2c(c))+t.lineWidth/2,0),t.lineTo(Math.floor(d.p2c(c))+t.lineWidth/2,Y));d=C.yaxis;for(b=0;b<d.ticks.length;++b)c=d.ticks[b].v,c<=d.min||c>=d.max||(t.moveTo(0,Math.floor(d.p2c(c))+
t.lineWidth/2),t.lineTo(W,Math.floor(d.p2c(c))+t.lineWidth/2));d=C.x2axis;for(b=0;b<d.ticks.length;++b)c=d.ticks[b].v,c<=d.min||c>=d.max||(t.moveTo(Math.floor(d.p2c(c))+t.lineWidth/2,-5),t.lineTo(Math.floor(d.p2c(c))+t.lineWidth/2,5));d=C.y2axis;for(b=0;b<d.ticks.length;++b)c=d.ticks[b].v,c<=d.min||c>=d.max||(t.moveTo(W-5,Math.floor(d.p2c(c))+t.lineWidth/2),t.lineTo(W+5,Math.floor(d.p2c(c))+t.lineWidth/2));t.stroke();if(o.grid.borderWidth)b=o.grid.borderWidth,t.lineWidth=b,t.strokeStyle=o.grid.borderColor,
t.strokeRect(-b/2,-b/2,W+b,Y+b);t.restore()}function L(){function a(b,d){for(var e=0;e<b.ticks.length;++e){var f=b.ticks[e];f.label&&!(f.v<b.min||f.v>b.max)&&c.push(d(f,b))}}b.find(".tickLabels").remove();var c=['<div class="tickLabels" style="font-size:smaller;color:'+o.grid.color+'">'],e=o.grid.labelMargin+o.grid.borderWidth;a(C.xaxis,function(a,b){return'<div style="position:absolute;top:'+(D.top+Y+e)+"px;left:"+Math.round(D.left+b.p2c(a.v)-b.labelWidth/2)+"px;width:"+b.labelWidth+'px;text-align:center" class="tickLabel">'+
a.label+"</div>"});a(C.yaxis,function(a,b){return'<div style="position:absolute;top:'+Math.round(D.top+b.p2c(a.v)-b.labelHeight/2)+"px;right:"+(D.right+W+e)+"px;width:"+b.labelWidth+'px;text-align:right" class="tickLabel">'+a.label+"</div>"});a(C.x2axis,function(a,b){return'<div style="position:absolute;bottom:'+(D.bottom+Y+e)+"px;left:"+Math.round(D.left+b.p2c(a.v)-b.labelWidth/2)+"px;width:"+b.labelWidth+'px;text-align:center" class="tickLabel">'+a.label+"</div>"});a(C.y2axis,function(a,b){return'<div style="position:absolute;top:'+
Math.round(D.top+b.p2c(a.v)-b.labelHeight/2)+"px;left:"+(D.left+W+e)+"px;width:"+b.labelWidth+'px;text-align:left" class="tickLabel">'+a.label+"</div>"});c.push("</div>");b.append(c.join(""))}function V(a){function b(a,c,d,e,f){var g=a.points;a=a.pointsize;var h=null,j=null;t.beginPath();for(var n=a;n<g.length;n+=a){var k=g[n-a],l=g[n-a+1],o=g[n],m=g[n+1];if(!(k==null||o==null)){if(l<=m&&l<f.min){if(m<f.min)continue;k=(f.min-l)/(m-l)*(o-k)+k;l=f.min}else if(m<=l&&m<f.min){if(l<f.min)continue;o=(f.min-
l)/(m-l)*(o-k)+k;m=f.min}if(l>=m&&l>f.max){if(m>f.max)continue;k=(f.max-l)/(m-l)*(o-k)+k;l=f.max}else if(m>=l&&m>f.max){if(l>f.max)continue;o=(f.max-l)/(m-l)*(o-k)+k;m=f.max}if(k<=o&&k<e.min){if(o<e.min)continue;l=(e.min-k)/(o-k)*(m-l)+l;k=e.min}else if(o<=k&&o<e.min){if(k<e.min)continue;m=(e.min-k)/(o-k)*(m-l)+l;o=e.min}if(k>=o&&k>e.max){if(o>e.max)continue;l=(e.max-k)/(o-k)*(m-l)+l;k=e.max}else if(o>=k&&o>e.max){if(k>e.max)continue;m=(e.max-k)/(o-k)*(m-l)+l;o=e.max}(k!=h||l!=j)&&t.moveTo(e.p2c(k)+
c,f.p2c(l)+d);h=o;j=m;t.lineTo(e.p2c(o)+c,f.p2c(m)+d)}}t.stroke()}function c(a,b,d){var e=a.points;a=a.pointsize;var f=Math.min(Math.max(0,d.min),d.max),g;g=0;for(var h=!1,j=a;j<e.length;j+=a){var n=e[j-a],k=e[j-a+1],l=e[j],o=e[j+1];if(h&&n!=null&&l==null)t.lineTo(b.p2c(g),d.p2c(f)),t.fill(),h=!1;else if(!(n==null||l==null)){if(n<=l&&n<b.min){if(l<b.min)continue;k=(b.min-n)/(l-n)*(o-k)+k;n=b.min}else if(l<=n&&l<b.min){if(n<b.min)continue;o=(b.min-n)/(l-n)*(o-k)+k;l=b.min}if(n>=l&&n>b.max){if(l>b.max)continue;
k=(b.max-n)/(l-n)*(o-k)+k;n=b.max}else if(l>=n&&l>b.max){if(n>b.max)continue;o=(b.max-n)/(l-n)*(o-k)+k;l=b.max}h||(t.beginPath(),t.moveTo(b.p2c(n),d.p2c(f)),h=!0);if(k>=d.max&&o>=d.max)t.lineTo(b.p2c(n),d.p2c(d.max)),t.lineTo(b.p2c(l),d.p2c(d.max)),g=l;else if(k<=d.min&&o<=d.min)t.lineTo(b.p2c(n),d.p2c(d.min)),t.lineTo(b.p2c(l),d.p2c(d.min)),g=l;else{var m=n,w=l;if(k<=o&&k<d.min&&o>=d.min)n=(d.min-k)/(o-k)*(l-n)+n,k=d.min;else if(o<=k&&o<d.min&&k>=d.min)l=(d.min-k)/(o-k)*(l-n)+n,o=d.min;if(k>=o&&
k>d.max&&o<=d.max)n=(d.max-k)/(o-k)*(l-n)+n,k=d.max;else if(o>=k&&o>d.max&&k<=d.max)l=(d.max-k)/(o-k)*(l-n)+n,o=d.max;n!=m&&(g=k<=d.min?d.min:d.max,t.lineTo(b.p2c(m),d.p2c(g)),t.lineTo(b.p2c(n),d.p2c(g)));t.lineTo(b.p2c(n),d.p2c(k));t.lineTo(b.p2c(l),d.p2c(o));l!=w&&(g=o<=d.min?d.min:d.max,t.lineTo(b.p2c(l),d.p2c(g)),t.lineTo(b.p2c(w),d.p2c(g)));g=Math.max(l,w)}}}h&&(t.lineTo(b.p2c(g),d.p2c(f)),t.fill())}t.save();t.translate(D.left,D.top);t.lineJoin="round";var d=a.lines.lineWidth,e=a.shadowSize;
if(d>0&&e>0){t.lineWidth=e;t.strokeStyle="rgba(0,0,0,0.1)";var f=Math.PI/18;b(a.datapoints,Math.sin(f)*(d/2+e/2),Math.cos(f)*(d/2+e/2),a.xaxis,a.yaxis);t.lineWidth=e/2;b(a.datapoints,Math.sin(f)*(d/2+e/4),Math.cos(f)*(d/2+e/4),a.xaxis,a.yaxis)}t.lineWidth=d;t.strokeStyle=a.color;if(e=I(a.lines,a.color,0,Y))t.fillStyle=e,c(a.datapoints,a.xaxis,a.yaxis);d>0&&b(a.datapoints,0,0,a.xaxis,a.yaxis);t.restore()}function m(a){function b(a,c,d,e,f,g,h){var j=a.points;a=a.pointsize;for(var n=0;n<j.length;n+=
a){var k=j[n],l=j[n+1];if(!(k==null||k<g.min||k>g.max||l<h.min||l>h.max)){t.beginPath();t.arc(g.p2c(k),h.p2c(l)+e,c,0,f,!1);if(d)t.fillStyle=d,t.fill();t.stroke()}}}t.save();t.translate(D.left,D.top);var c=a.lines.lineWidth,d=a.shadowSize,e=a.points.radius;if(c>0&&d>0)d/=2,t.lineWidth=d,t.strokeStyle="rgba(0,0,0,0.1)",b(a.datapoints,e,null,d+d/2,Math.PI,a.xaxis,a.yaxis),t.strokeStyle="rgba(0,0,0,0.2)",b(a.datapoints,e,null,d/2,Math.PI,a.xaxis,a.yaxis);t.lineWidth=c;t.strokeStyle=a.color;b(a.datapoints,
e,I(a.points,a.color),0,2*Math.PI,a.xaxis,a.yaxis);t.restore()}function j(a,b,c,d,e,f,g,h,j,k,l){var o,m,y,q;l?(q=m=y=!0,o=!1,l=c,c=b+d,e=b+e,a<l&&(b=a,a=l,l=b,o=!0,m=!1)):(o=m=y=!0,q=!1,l=a+d,a+=e,e=c,c=b,c<e&&(b=c,c=e,e=b,q=!0,y=!1));if(!(a<h.min||l>h.max||c<j.min||e>j.max)){if(l<h.min)l=h.min,o=!1;if(a>h.max)a=h.max,m=!1;if(e<j.min)e=j.min,q=!1;if(c>j.max)c=j.max,y=!1;l=h.p2c(l);e=j.p2c(e);a=h.p2c(a);c=j.p2c(c);if(g)k.beginPath(),k.moveTo(l,e),k.lineTo(l,c),k.lineTo(a,c),k.lineTo(a,e),k.fillStyle=
g(e,c),k.fill();if(o||m||y||q)k.beginPath(),k.moveTo(l,e+f),o?k.lineTo(l,c+f):k.moveTo(l,c+f),y?k.lineTo(a,c+f):k.moveTo(a,c+f),m?k.lineTo(a,e+f):k.moveTo(a,e+f),q?k.lineTo(l,e+f):k.moveTo(l,e+f),k.stroke()}}function A(a){t.save();t.translate(D.left,D.top);t.lineWidth=a.bars.lineWidth;t.strokeStyle=a.color;var b=a.bars.align=="left"?0:-a.bars.barWidth/2;(function(b,c,d,e,f,g,h){var k=b.points;b=b.pointsize;for(var l=0;l<k.length;l+=b)k[l]!=null&&j(k[l],k[l+1],k[l+2],c,d,e,f,g,h,t,a.bars.horizontal)})(a.datapoints,
b,b+a.bars.barWidth,0,a.bars.fill?function(b,c){return I(a.bars,a.color,b,c)}:null,a.xaxis,a.yaxis);t.restore()}function I(b,c,d,e){var f=b.fill;if(!f)return null;if(b.fillColor)return ma(b.fillColor,d,e,c);b=a.color.parse(c);b.a=typeof f=="number"?f:0.4;b.normalize();return b.toString()}function S(){b.find(".legend").remove();if(o.legend.show){var c=[],e=!1,f=o.legend.labelFormatter,g,h;for(i=0;i<y.length;++i)if(g=y[i],h=g.label)i%o.legend.noColumns==0&&(e&&c.push("</tr>"),c.push("<tr>"),e=!0),f&&
(h=f(h,g)),c.push('<td class="legendColorBox"><div style="border:1px solid '+o.legend.labelBoxBorderColor+';padding:1px"><div style="width:4px;height:0;border:5px solid '+g.color+';overflow:hidden"></div></div></td><td class="legendLabel">'+h+"</td>");e&&c.push("</tr>");if(c.length!=0)if(e='<table style="font-size:smaller;color:'+o.grid.color+'">'+c.join("")+"</table>",o.legend.container!=null)a(o.legend.container).html(e);else if(c="",f=o.legend.position,g=o.legend.margin,g[0]==null&&(g=[g,g]),f.charAt(0)==
"n"?c+="top:"+(g[1]+D.top)+"px;":f.charAt(0)=="s"&&(c+="bottom:"+(g[1]+D.bottom)+"px;"),f.charAt(1)=="e"?c+="right:"+(g[0]+D.right)+"px;":f.charAt(1)=="w"&&(c+="left:"+(g[0]+D.left)+"px;"),e=a('<div class="legend">'+e.replace('style="','style="position:absolute;'+c+";")+"</div>").appendTo(b),o.legend.backgroundOpacity!=0){f=o.legend.backgroundColor;if(f==null)f=(f=o.grid.backgroundColor)&&typeof f=="string"?a.color.parse(f):a.color.extract(e,"background-color"),f.a=1,f=f.toString();g=e.children();
a('<div style="position:absolute;width:'+g.width()+"px;height:"+g.height()+"px;"+c+"background-color:"+f+';"> </div>').prependTo(e).css("opacity",o.legend.backgroundOpacity)}}}function oa(a){o.grid.hoverable&&v("plothover",a,function(a){return a.hoverable!=!1})}function ca(a){v("plotclick",a,function(a){return a.clickable!=!1})}function v(a,c,e){var g=na.offset(),h={pageX:c.pageX,pageY:c.pageY},j=c.pageX-g.left-D.left;c=c.pageY-g.top-D.top;if(C.xaxis.used)h.x=C.xaxis.c2p(j);if(C.yaxis.used)h.y=C.yaxis.c2p(c);
if(C.x2axis.used)h.x2=C.x2axis.c2p(j);if(C.y2axis.used)h.y2=C.y2axis.c2p(c);var k=o.grid.mouseActiveRadius,l=k*k+1,m=null,q,s;for(q=0;q<y.length;++q)if(e(y[q])){var t=y[q],B=t.xaxis,v=t.yaxis,x=t.datapoints.points,O=t.datapoints.pointsize,ba=B.c2p(j),z=v.c2p(c),G=k/B.scale,L=k/v.scale;if(t.lines.show||t.points.show)for(s=0;s<x.length;s+=O){var F=x[s],A=x[s+1];if(F!=null&&!(F-ba>G||F-ba<-G||A-z>L||A-z<-L))F=Math.abs(B.p2c(F)-j),A=Math.abs(v.p2c(A)-c),A=F*F+A*A,A<=l&&(l=A,m=[q,s/O])}if(t.bars.show&&
!m){B=t.bars.align=="left"?0:-t.bars.barWidth/2;t=B+t.bars.barWidth;for(s=0;s<x.length;s+=O)if(F=x[s],A=x[s+1],v=x[s+2],F!=null&&(y[q].bars.horizontal?ba<=Math.max(v,F)&&ba>=Math.min(v,F)&&z>=A+B&&z<=A+t:ba>=F+B&&ba<=F+t&&z>=Math.min(v,A)&&z<=Math.max(v,A)))m=[q,s/O]}}m?(q=m[0],s=m[1],O=y[q].datapoints.pointsize,e={datapoint:y[q].datapoints.points.slice(s*O,(s+1)*O),dataIndex:s,series:y[q],seriesIndex:q}):e=null;if(e)e.pageX=parseInt(e.series.xaxis.p2c(e.datapoint[0])+g.left+D.left),e.pageY=parseInt(e.series.yaxis.p2c(e.datapoint[1])+
g.top+D.top);if(o.grid.autoHighlight){for(g=0;g<ea.length;++g)j=ea[g],j.auto==a&&(!e||!(j.series==e.series&&j.point==e.datapoint))&&ka(j.series,j.point);e&&f(e.series,e.datapoint,a)}b.trigger(a,[h,e])}function R(){va||(va=setTimeout(ja,30))}function ja(){va=null;U.save();U.clearRect(0,0,X,Z);U.translate(D.left,D.top);var b,c;for(b=0;b<ea.length;++b)if(c=ea[b],c.series.bars.show)ra(c.series,c.point);else{var d=c.series,e=c.point;c=e[0];e=e[1];var f=d.xaxis,g=d.yaxis;if(!(c<f.min||c>f.max||e<g.min||
e>g.max)){var h=d.points.radius+d.points.lineWidth/2;U.lineWidth=h;U.strokeStyle=a.color.parse(d.color).scale("a",0.5).toString();d=1.5*h;U.beginPath();U.arc(f.p2c(c),g.p2c(e),d,0,2*Math.PI,!1);U.stroke()}}U.restore();k(da.drawOverlay,[U])}function f(a,b,c){typeof a=="number"&&(a=y[a]);typeof b=="number"&&(b=a.data[b]);var d=la(a,b);if(d==-1)ea.push({series:a,point:b,auto:c}),R();else if(!c)ea[d].auto=!1}function ka(a,b){a==null&&b==null&&(ea=[],R());typeof a=="number"&&(a=y[a]);typeof b=="number"&&
(b=a.data[b]);var c=la(a,b);c!=-1&&(ea.splice(c,1),R())}function la(a,b){for(var c=0;c<ea.length;++c){var d=ea[c];if(d.series==a&&d.point[0]==b[0]&&d.point[1]==b[1])return c}return-1}function ra(b,c){U.lineWidth=b.bars.lineWidth;U.strokeStyle=a.color.parse(b.color).scale("a",0.5).toString();var d=a.color.parse(b.color).scale("a",0.5).toString(),e=b.bars.align=="left"?0:-b.bars.barWidth/2;j(c[0],c[1],c[2]||0,e,e+b.bars.barWidth,0,function(){return d},b.xaxis,b.yaxis,U,b.bars.horizontal)}function ma(b,
c,d,e){if(typeof b=="string")return b;else{c=t.createLinearGradient(0,d,0,c);d=0;for(var f=b.colors.length;d<f;++d){var g=b.colors[d];typeof g!="string"&&(g=a.color.parse(e).scale("rgb",g.brightness),g.a*=g.opacity,g=g.toString());c.addColorStop(d/(f-1),g)}return c}}var y=[],o={colors:["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"],legend:{show:!0,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{mode:null,
transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,tickDecimals:null,tickSize:null,minTickSize:null,monthNames:null,timeformat:null,twelveHourClock:!1},yaxis:{autoscaleMargin:0.02},x2axis:{autoscaleMargin:null},y2axis:{autoscaleMargin:0.02},series:{points:{show:!1,radius:3,lineWidth:2,fill:!0,fillColor:"#ffffff"},lines:{lineWidth:2,fill:!1,fillColor:null,steps:!1},bars:{show:!1,lineWidth:2,barWidth:1,fill:!0,fillColor:null,
align:"left",horizontal:!1},shadowSize:3},grid:{show:!0,aboveData:!1,color:"#545454",backgroundColor:null,tickColor:"rgba(0,0,0,0.15)",labelMargin:5,borderWidth:2,borderColor:null,markings:null,markingsColor:"#f4f4f4",markingsLineWidth:2,clickable:!1,hoverable:!1,autoHighlight:!0,mouseActiveRadius:10},hooks:{}},O=null,ba=null,na=null,t=null,U=null,C={xaxis:{},yaxis:{},x2axis:{},y2axis:{}},D={left:0,right:0,top:0,bottom:0},X=0,Z=0,W=0,Y=0,da={processOptions:[],processRawData:[],processDatapoints:[],
draw:[],bindEvents:[],drawOverlay:[]},N=this;N.setData=l;N.setupGrid=q;N.draw=M;N.getPlaceholder=function(){return b};N.getCanvas=function(){return O};N.getPlotOffset=function(){return D};N.width=function(){return W};N.height=function(){return Y};N.offset=function(){var a=na.offset();a.left+=D.left;a.top+=D.top;return a};N.getData=function(){return y};N.getAxes=function(){return C};N.getOptions=function(){return o};N.highlight=f;N.unhighlight=ka;N.triggerRedrawOverlay=R;N.pointOffset=function(a){return{left:parseInt(s(a,
"xaxis").p2c(+a.x)+D.left),top:parseInt(s(a,"yaxis").p2c(+a.y)+D.top)}};N.hooks=da;(function(){for(var b=0;b<h.length;++b){var c=h[b];c.init(N);c.options&&a.extend(!0,o,c.options)}})(N);(function(b){a.extend(!0,o,b);if(o.grid.borderColor==null)o.grid.borderColor=o.grid.color;if(o.xaxis.noTicks&&o.xaxis.ticks==null)o.xaxis.ticks=o.xaxis.noTicks;if(o.yaxis.noTicks&&o.yaxis.ticks==null)o.yaxis.ticks=o.yaxis.noTicks;if(o.grid.coloredAreas)o.grid.markings=o.grid.coloredAreas;if(o.grid.coloredAreasColor)o.grid.markingsColor=
o.grid.coloredAreasColor;o.lines&&a.extend(!0,o.series.lines,o.lines);o.points&&a.extend(!0,o.series.points,o.points);o.bars&&a.extend(!0,o.series.bars,o.bars);if(o.shadowSize)o.series.shadowSize=o.shadowSize;for(var c in da)o.hooks[c]&&o.hooks[c].length&&(da[c]=da[c].concat(o.hooks[c]));k(da.processOptions,[o])})(g);(function(){function c(b,d){var e=document.createElement("canvas");e.width=b;e.height=d;a.browser.msie&&(e=window.G_vmlCanvasManager.initElement(e));return e}X=b.width();Z=b.height();
b.html("");b.css("position")=="static"&&b.css("position","relative");if(X<=0||Z<=0)throw"Invalid dimensions for plot, width = "+X+", height = "+Z;a.browser.msie&&window.G_vmlCanvasManager.init_(document);O=a(c(X,Z)).appendTo(b).get(0);t=O.getContext("2d");ba=a(c(X,Z)).css({position:"absolute",left:0,top:0}).appendTo(b).get(0);U=ba.getContext("2d");U.stroke()})();l(e);q();M();na=a([ba,O]);o.grid.hoverable&&na.mousemove(oa);o.grid.clickable&&na.click(ca);k(da.bindEvents,[na]);var ea=[],va=null}function c(a,
b){return b*Math.floor(a/b)}a.plot=function(c,e,g){return new b(a(c),e,g,a.plot.plugins)};a.plot.plugins=[];a.plot.formatDate=function(a,b,c){var h=function(a){a=""+a;return a.length==1?"0"+a:a},k=[],l=!1,s=a.getUTCHours(),z=s<12;c==null&&(c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]);b.search(/%p|%P/)!=-1&&(s>12?s-=12:s==0&&(s=12));for(var q=0;q<b.length;++q){var x=b.charAt(q);if(l){switch(x){case "h":x=""+s;break;case "H":x=h(s);break;case "M":x=h(a.getUTCMinutes());
break;case "S":x=h(a.getUTCSeconds());break;case "d":x=""+a.getUTCDate();break;case "m":x=""+(a.getUTCMonth()+1);break;case "y":x=""+a.getUTCFullYear();break;case "b":x=""+c[a.getUTCMonth()];break;case "p":x=z?"am":"pm";break;case "P":x=z?"AM":"PM"}k.push(x);l=!1}else x=="%"?l=!0:k.push(x)}return k.join("")}})(jQuery);
(function(a){a.plot.plugins.push({init:function(b){function c(a){q.active&&(b.getPlaceholder().trigger("plotselecting",[g()]),l(a))}function d(b){if(b.which==1){document.body.focus();if(document.onselectstart!==void 0&&x.onselectstart==null)x.onselectstart=document.onselectstart,document.onselectstart=function(){return!1};if(document.ondrag!==void 0&&x.ondrag==null)x.ondrag=document.ondrag,document.ondrag=function(){return!1};k(q.first,b);q.active=!0;a(document).one("mouseup",e)}}function e(a){if(document.onselectstart!==
void 0)document.onselectstart=x.onselectstart;if(document.ondrag!==void 0)document.ondrag=x.ondrag;q.active=!1;l(a);z()?h():(b.getPlaceholder().trigger("plotunselected",[]),b.getPlaceholder().trigger("plotselecting",[null]));return!1}function g(){if(!z())return null;var a=Math.min(q.first.x,q.second.x),c=Math.max(q.first.x,q.second.x),d=Math.max(q.first.y,q.second.y),e=Math.min(q.first.y,q.second.y),g={},h=b.getAxes();if(h.xaxis.used)g.xaxis={from:h.xaxis.c2p(a),to:h.xaxis.c2p(c)};if(h.x2axis.used)g.x2axis=
{from:h.x2axis.c2p(a),to:h.x2axis.c2p(c)};if(h.yaxis.used)g.yaxis={from:h.yaxis.c2p(d),to:h.yaxis.c2p(e)};if(h.y2axis.used)g.y2axis={from:h.y2axis.c2p(d),to:h.y2axis.c2p(e)};return g}function h(){var a=g();b.getPlaceholder().trigger("plotselected",[a]);var c=b.getAxes();c.xaxis.used&&c.yaxis.used&&b.getPlaceholder().trigger("selected",[{x1:a.xaxis.from,y1:a.yaxis.from,x2:a.xaxis.to,y2:a.yaxis.to}])}function k(a,c){var d=b.getOptions(),e=b.getPlaceholder().offset(),g=b.getPlotOffset(),h=c.pageX-e.left-
g.left,k=b.width();a.x=h<0?0:h>k?k:h;e=c.pageY-e.top-g.top;g=b.height();a.y=e<0?0:e>g?g:e;if(d.selection.mode=="y")a.x=a==q.first?0:b.width();if(d.selection.mode=="x")a.y=a==q.first?0:b.height()}function l(a){if(a.pageX!=null)k(q.second,a),z()?(q.show=!0,b.triggerRedrawOverlay()):s(!0)}function s(a){if(q.show)q.show=!1,b.triggerRedrawOverlay(),a||b.getPlaceholder().trigger("plotunselected",[])}function z(){return Math.abs(q.second.x-q.first.x)>=5&&Math.abs(q.second.y-q.first.y)>=5}var q={first:{x:-1,
y:-1},second:{x:-1,y:-1},show:!1,active:!1},x={};b.clearSelection=s;b.setSelection=function(a,c){var d,e,g=b.getAxes(),k=b.getOptions();k.selection.mode=="y"?(q.first.x=0,q.second.x=b.width()):(d=a.xaxis?g.xaxis:a.x2axis?g.x2axis:g.xaxis,e=a.xaxis||a.x2axis||{from:a.x1,to:a.x2},q.first.x=d.p2c(Math.min(e.from,e.to)),q.second.x=d.p2c(Math.max(e.from,e.to)));k.selection.mode=="x"?(q.first.y=0,q.second.y=b.height()):(d=a.yaxis?g.yaxis:a.y2axis?g.y2axis:g.yaxis,e=a.yaxis||a.y2axis||{from:a.y1,to:a.y2},
q.first.y=d.p2c(Math.min(e.from,e.to)),q.second.y=d.p2c(Math.max(e.from,e.to)));q.show=!0;b.triggerRedrawOverlay();c||h()};b.getSelection=g;b.hooks.bindEvents.push(function(a,b){var e=a.getOptions();e.selection.mode!=null&&b.mousemove(c);e.selection.mode!=null&&b.mousedown(d)});b.hooks.drawOverlay.push(function(b,c){if(q.show&&z()){var d=b.getPlotOffset(),e=b.getOptions();c.save();c.translate(d.left,d.top);d=a.color.parse(e.selection.color);c.strokeStyle=d.scale("a",0.8).toString();c.lineWidth=1;
c.lineJoin="round";c.fillStyle=d.scale("a",0.4).toString();d=Math.min(q.first.x,q.second.x);e=Math.min(q.first.y,q.second.y);var g=Math.abs(q.second.x-q.first.x),h=Math.abs(q.second.y-q.first.y);c.fillRect(d,e,g,h);c.strokeRect(d,e,g,h);c.restore()}})},options:{selection:{mode:null,color:"#e8cfac"}},name:"selection",version:"1.0"})})(jQuery);
(function(a){var b,c,d=function(a,b){var c=0;this.complete=function(){c+=1;c===b&&a()}};b=function(b){var c=this,h,k,l={namespace:"file_upload",uploadFormFilter:function(){return!0},fileInputFilter:function(){return!0},cssClass:"file_upload",dragDropSupport:!0,dropZone:b,url:function(a){return a.attr("action")},method:function(a){return a.attr("method")},fieldName:function(a){return a.attr("name")},formData:function(a){return a.serializeArray()},multipart:!0,multiFileRequest:!1,withCredentials:!1,
forceIframeUpload:!1},s={},z={},q=/^http(s)?:\/\//,x,B=function(){return typeof XMLHttpRequest!=="undefined"&&typeof File!=="undefined"&&(!l.multipart||typeof FormData!=="undefined"||typeof FileReader!=="undefined")},K=function(){if(l.dragDropSupport)typeof l.onDocumentDragEnter==="function"&&(s["dragenter."+l.namespace]=function(a){l.onDocumentDragEnter(a)}),typeof l.onDocumentDragLeave==="function"&&(s["dragleave."+l.namespace]=function(a){l.onDocumentDragLeave(a)}),s["dragover."+l.namespace]=c.onDocumentDragOver,
s["drop."+l.namespace]=c.onDocumentDrop,a(document).bind(s),typeof l.onDragEnter==="function"&&(z["dragenter."+l.namespace]=function(a){l.onDragEnter(a)}),typeof l.onDragLeave==="function"&&(z["dragleave."+l.namespace]=function(a){l.onDragLeave(a)}),z["dragover."+l.namespace]=c.onDragOver,z["drop."+l.namespace]=c.onDrop,l.dropZone.bind(z);k.bind("change."+l.namespace,c.onChange)},M=function(){a.each(s,function(b,c){a(document).unbind(b,c)});a.each(z,function(a,b){l.dropZone.unbind(a,b)});k.unbind("change."+
l.namespace)},F=function(a,b,c,d){if(typeof d.onProgress==="function")c.upload.onprogress=function(e){d.onProgress(e,a,b,c,d)};if(typeof d.onLoad==="function")c.onload=function(e){d.onLoad(e,a,b,c,d)};if(typeof d.onAbort==="function")c.onabort=function(e){d.onAbort(e,a,b,c,d)};if(typeof d.onError==="function")c.onerror=function(e){d.onError(e,a,b,c,d)}},G=function(a){if(typeof a.url==="function")return a.url(a.uploadForm||h);return a.url},L=function(a){if(typeof a.method==="function")return a.method(a.uploadForm||
h);return a.method},V=function(a){if(typeof a.fieldName==="function")return a.fieldName(a.fileInput||k);return a.fieldName},m=function(b){var c;if(typeof b.formData==="function")return b.formData(b.uploadForm||h);else if(a.isArray(b.formData))return b.formData;else if(b.formData)return c=[],a.each(b.formData,function(a,b){c.push({name:a,value:b})}),c;return[]},j=function(b,c,d){if(d)b.setRequestHeader("X-Requested-With","XMLHttpRequest");else if(c.withCredentials)b.withCredentials=!0;a.isArray(c.requestHeaders)?
a.each(c.requestHeaders,function(a,c){b.setRequestHeader(c[0],c[1])}):c.requestHeaders&&a.each(c.requestHeaders,function(a,c){b.setRequestHeader(a,c)})},A=function(b,c,d){var e=new FormData,f;a.each(m(d),function(a,b){e.append(b.name,b.value)});for(f=0;f<b.length;f+=1)e.append(V(d),b[f]);c.send(e)},I=function(a,b){var c=new FileReader;c.onload=function(c){a.content=c.target.result;b()};c.readAsBinaryString(a)},S=function(b,c,d,e){var f="";a.each(e,function(a,c){f+="--"+b+'\r\nContent-Disposition: form-data; name="'+
unescape(encodeURIComponent(c.name))+'"\r\n\r\n'+unescape(encodeURIComponent(c.value))+"\r\n"});a.each(c,function(a,c){f+="--"+b+'\r\nContent-Disposition: form-data; name="'+unescape(encodeURIComponent(d))+'"; filename="'+unescape(encodeURIComponent(c.name))+'"\r\nContent-Type: '+c.type+"\r\n\r\n"+c.content+"\r\n"});f+="--"+b+"--\r\n";return f},oa=function(a,b,c){var e="----MultiPartFormBoundary"+(new Date).getTime(),f,g;b.setRequestHeader("Content-Type","multipart/form-data; boundary="+e);f=new d(function(){b.sendAsBinary(S(e,
a,V(c),m(c)))},a.length);for(g=0;g<a.length;g+=1)I(a[g],f.complete)},ca=function(b,c,d,e){var f=G(e),g;if(q.test(f)){var h=location.host;g=location.protocol.length+2;var k=f.indexOf(h,g);h=k+h.length;g=(k===g||k===f.indexOf("@",g)+1)&&(f.length===h||a.inArray(f.charAt(h),["/","?","#"])!==-1)?!0:!1}else g=!0;F(b,c,d,e);d.open(L(e),f,!0);j(d,e,g);e.multipart?(b=typeof c==="number"?[b[c]]:b,typeof FormData!=="undefined"?A(b,d,e):typeof FileReader!=="undefined"?oa(b,d,e):a.error("Browser does neither support FormData nor FileReader interface")):
(e=b[c],g&&d.setRequestHeader("X-File-Name",unescape(encodeURIComponent(e.name))),d.setRequestHeader("Content-Type",e.type),d.send(e))},v=function(b,c,d,e,f){var g=new XMLHttpRequest,h=a.extend({},l);h.fileInput=d;h.uploadForm=e;typeof h.initUpload==="function"?h.initUpload(b,c,f,g,h,function(){ca(c,f,g,h)}):ca(c,f,g,h)},R=function(a,b,c,d){var e;if(l.multiFileRequest)v(a,b,c,d);else for(e=0;e<b.length;e+=1)v(a,b,c,d,e)},ja=function(b,c,d){var e=m(d);c.find(":input").not(":disabled").attr("disabled",
!0).addClass(d.namespace+"_disabled");a.each(e,function(b,e){a('<input type="hidden"/>').attr("name",e.name).val(e.value).addClass(d.namespace+"_form_data").appendTo(c)});b.attr("name",V(d)).appendTo(c)},f=function(a,b,c){a.detach();b.find("."+c.namespace+"_disabled").removeAttr("disabled").removeClass(c.namespace+"_disabled");b.find("."+c.namespace+"_form_data").remove()},ka=function(b,c,d,e){var g=c.attr("action"),h=c.attr("method"),j=c.attr("target");d.unbind("abort").bind("abort",function(a){d.readyState=
0;d.unbind("load").attr("src","javascript".concat(":false;"));if(typeof e.onAbort==="function")e.onAbort(a,[{name:b.val(),type:null,size:null}],0,d,e)}).unbind("load").bind("load",function(f){d.readyState=4;if(typeof e.onLoad==="function")e.onLoad(f,[{name:b.val(),type:null,size:null}],0,d,e);a('<iframe src="javascript:false;" style="display:none"></iframe>').appendTo(c).remove()});c.attr("action",G(e)).attr("method",L(e)).attr("target",d.attr("name"));ja(b,c,e);d.readyState=2;c.get(0).submit();f(b,
c,e);c.attr("action",g).attr("method",h).attr("target",j)},la=function(b,c,d){var e=a('<iframe src="javascript:false;" style="display:none" name="iframe_'+l.namespace+"_"+(new Date).getTime()+'"></iframe>'),f=a.extend({},l);f.fileInput=c;f.uploadForm=d;e.readyState=0;e.abort=function(){e.trigger("abort")};e.bind("load",function(){e.unbind("load");typeof f.initUpload==="function"?f.initUpload(b,[{name:c.val(),type:null,size:null}],0,e,f,function(){ka(c,d,e,f)}):ka(c,d,e,f)}).appendTo(d)},ra=function(){h=
(b.is("form")?b:b.find("form")).filter(l.uploadFormFilter)},ma=function(){k=h.find("input:file").filter(l.fileInputFilter)};this.onDocumentDragOver=function(a){if(typeof l.onDocumentDragOver==="function"&&l.onDocumentDragOver(a)===!1)return!1;a.preventDefault()};this.onDocumentDrop=function(a){if(typeof l.onDocumentDrop==="function"&&l.onDocumentDrop(a)===!1)return!1;a.preventDefault()};this.onDragOver=function(a){if(typeof l.onDragOver==="function"&&l.onDragOver(a)===!1)return!1;var b=a.originalEvent.dataTransfer;
if(b&&b.files)b.dropEffect=b.effectAllowed="copy",a.preventDefault()};this.onDrop=function(a){if(typeof l.onDrop==="function"&&l.onDrop(a)===!1)return!1;var b=a.originalEvent.dataTransfer;b&&b.files&&B()&&R(a,b.files);a.preventDefault()};this.onChange=function(b){if(typeof l.onChange==="function"&&l.onChange(b)===!1)return!1;var c=a(b.target),d=a(b.target.form);if(d.length===1){c.data("file_upload_form",d);var e=c.clone(!0);a("<form/>").append(e).get(0).reset();c.after(e).detach();ma()}else d=c.data("file_upload_form");
!l.forceIframeUpload&&b.target.files&&B()?R(b,b.target.files,c,d):la(b,c,d)};this.init=function(d){d&&(a.extend(l,d),x=d);ra();ma();b.data(l.namespace)?a.error('FileUpload with namespace "'+l.namespace+'" already assigned to this element'):(b.data(l.namespace,c).addClass(l.cssClass),l.dropZone.not(b).addClass(l.cssClass),K())};this.options=function(c){var d,f,g,h;if(typeof c==="undefined")return a.extend({},l);x&&a.extend(x,c);M();a.each(c,function(b,c){switch(b){case "namespace":a.error("The FileUpload namespace cannot be updated.");
return;case "uploadFormFilter":h=g=!0;break;case "fileInputFilter":h=!0;break;case "cssClass":d=l.cssClass;break;case "dropZone":f=l.dropZone}l[b]=c});g&&ra();h&&ma();typeof d!=="undefined"?(b.removeClass(d).addClass(l.cssClass),(f?f:l.dropZone).not(b).removeClass(d),l.dropZone.not(b).addClass(l.cssClass)):f&&(f.not(b).removeClass(l.cssClass),l.dropZone.not(b).addClass(l.cssClass));K()};this.option=function(a,b){var d;if(typeof b==="undefined")return l[a];d={};d[a]=b;c.options(d)};this.destroy=function(){M();
b.removeData(l.namespace).removeClass(l.cssClass);l.dropZone.not(b).removeClass(l.cssClass)}};c={init:function(c){return this.each(function(){(new b(a(this))).init(c)})},option:function(b,c,d){d=d?d:"file_upload";var k=a(this).data(d);if(k){if(typeof b==="string")return k.option(b,c);return k.options(b)}else a.error('No FileUpload with namespace "'+d+'" assigned to this element')},destroy:function(b){b=b?b:"file_upload";return this.each(function(){var c=a(this).data(b);c?c.destroy():a.error('No FileUpload with namespace "'+
b+'" assigned to this element')})}};a.fn.fileUpload=function(b){if(c[b])return c[b].apply(this,Array.prototype.slice.call(arguments,1));else if(typeof b==="object"||!b)return c.init.apply(this,arguments);else a.error("Method "+b+" does not exist on jQuery.fileUpload")}})(jQuery);if(!this.JSON)this.JSON={};
(function(){function a(a){return a<10?"0"+a:a}function b(a){e.lastIndex=0;return e.test(a)?'"'+a.replace(e,function(a){var b=k[a];return typeof b==="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(a,d){var e,k,B,K,M=g,F,G=d[a];G&&typeof G==="object"&&typeof G.toJSON==="function"&&(G=G.toJSON(a));typeof l==="function"&&(G=l.call(d,a,G));switch(typeof G){case "string":return b(G);case "number":return isFinite(G)?String(G):"null";case "boolean":case "null":return String(G);
case "object":if(!G)return"null";g+=h;F=[];if(Object.prototype.toString.apply(G)==="[object Array]"){K=G.length;for(e=0;e<K;e+=1)F[e]=c(e,G)||"null";B=F.length===0?"[]":g?"[\n"+g+F.join(",\n"+g)+"\n"+M+"]":"["+F.join(",")+"]";g=M;return B}if(l&&typeof l==="object"){K=l.length;for(e=0;e<K;e+=1)k=l[e],typeof k==="string"&&(B=c(k,G))&&F.push(b(k)+(g?": ":":")+B)}else for(k in G)Object.hasOwnProperty.call(G,k)&&(B=c(k,G))&&F.push(b(k)+(g?": ":":")+B);B=F.length===0?"{}":g?"{\n"+g+F.join(",\n"+g)+"\n"+
M+"}":"{"+F.join(",")+"}";g=M;return B}}if(typeof Date.prototype.toJSON!=="function")Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var d=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g,h,k={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},l;if(typeof JSON.stringify!=="function")JSON.stringify=function(a,b,d){var e;h=g="";if(typeof d==="number")for(e=0;e<d;e+=1)h+=" ";else typeof d==="string"&&(h=d);if((l=b)&&typeof b!=="function"&&(typeof b!=="object"||typeof b.length!=="number"))throw Error("JSON.stringify");return c("",
{"":a})};if(typeof JSON.parse!=="function")JSON.parse=function(a,b){function c(a,d){var e,g,h=a[d];if(h&&typeof h==="object")for(e in h)Object.hasOwnProperty.call(h,e)&&(g=c(h,e),g!==void 0?h[e]=g:delete h[e]);return b.call(a,d,h)}var e;d.lastIndex=0;d.test(a)&&(a=a.replace(d,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return e=eval("("+a+")"),typeof b==="function"?c({"":e},""):e;throw new SyntaxError("JSON.parse");}})();
(function(){var a=jQuery;if(!window.VS)window.VS={};if(!VS.app)VS.app={};if(!VS.ui)VS.ui={};if(!VS.model)VS.model={};if(!VS.utils)VS.utils={};VS.VERSION="0.1.0";VS.init=function(b){var c={container:"",query:"",unquotable:[],callbacks:{search:a.noop,focus:a.noop,facetMatches:a.noop,valueMatches:a.noop}};VS.options=_.extend({},c,b);VS.options.callbacks=_.extend({},c.callbacks,b.callbacks);VS.app.hotkeys.initialize();VS.app.searchQuery=new VS.model.SearchQuery;VS.app.searchBox=new VS.ui.SearchBox(b);
if(b.container)c=VS.app.searchBox.render().el,a(b.container).html(c);VS.app.searchBox.value(b.query||"");a(window).bind("unload",function(){});return VS.app.searchBox}})();
(function(){var a=jQuery;VS.ui.SearchBox=Backbone.View.extend({id:"search",events:{"click .VS-cancel-search-box":"clearSearch","mousedown .VS-search-box":"maybeFocusSearch","dblclick .VS-search-box":"highlightSearch","click .VS-search-box":"maybeTripleClick"},initialize:function(){this.flags={allSelected:!1};this.facetViews=[];this.inputViews=[];_.bindAll(this,"renderFacets","_maybeDisableFacets","disableFacets","deselectAllFacets");VS.app.searchQuery.bind("reset",this.renderFacets);a(document).bind("keydown",
this._maybeDisableFacets)},render:function(){a(this.el).append(JST.search_box({}));a(document.body).setMode("no","search");return this},value:function(a){if(a==null)return this.getQuery();return this.setQuery(a)},getQuery:function(){var a=[],c=this.inputViews.length;VS.app.searchQuery.each(_.bind(function(c,e){a.push(this.inputViews[e].value());a.push(c.serialize())},this));c&&a.push(this.inputViews[c-1].value());return _.compact(a).join(" ")},setQuery:function(a){this.currentQuery=a;VS.app.SearchParser.parse(a)},
viewPosition:function(a){a=_.indexOf(a.type=="facet"?this.facetViews:this.inputViews,a);a==-1&&(a=0);return a},searchEvent:function(a){var c=this.value();this.focusSearch(a);VS.options.callbacks.search(c)!==!1&&this.value(c)},addFacet:function(a,c,d){a=VS.utils.inflector.trim(a);c=VS.utils.inflector.trim(c||"");if(a){var e=new VS.model.SearchFacet({category:a,value:c||""});VS.app.searchQuery.add(e,{at:d});this.renderFacets();var g=_.detect(this.facetViews,function(a){if(a.model==e)return!0});_.defer(function(){g.enableEdit()})}},
renderFacets:function(){this.facetViews=[];this.inputViews=[];this.$(".VS-search-inner").empty();VS.app.searchQuery.each(_.bind(function(a,c){this.renderFacet(a,c)},this));this.renderSearchInput()},renderFacet:function(a,c){var d=new VS.ui.SearchFacet({model:a,order:c});this.renderSearchInput();this.facetViews.push(d);this.$(".VS-search-inner").children().eq(c*2).after(d.render().el);d.calculateSize();_.defer(_.bind(d.calculateSize,d));return d},renderSearchInput:function(){var a=new VS.ui.SearchInput({position:this.inputViews.length});
this.$(".VS-search-inner").append(a.render().el);this.inputViews.push(a)},clearSearch:function(a){this.disableFacets();this.value("");this.flags.allSelected=!1;this.focusSearch(a)},selectAllFacets:function(){this.flags.allSelected=!0;a(document).one("click.selectAllFacets",this.deselectAllFacets);_.each(this.facetViews,function(a){a.selectFacet()});_.each(this.inputViews,function(a){a.selectText()})},allSelected:function(a){if(a)this.flags.allSelected=!1;return this.flags.allSelected},deselectAllFacets:function(b){this.disableFacets();
if(this.$(b.target).is(".category,input")){var c=a(b.target).closest(".search_facet,.search_input"),d=_.detect(this.facetViews.concat(this.inputViews),function(a){return a.setElement(c[0])});d.type=="facet"?d.selectFacet():d.type=="input"&&_.defer(function(){d.enableEdit(!0)})}},disableFacets:function(b){_.each(this.inputViews,function(a){a&&a!=b&&(a.modes.editing=="is"||a.modes.selected=="is")&&a.disableEdit()});_.each(this.facetViews,function(a){if(a&&a!=b&&(a.modes.editing=="is"||a.modes.selected==
"is"))a.disableEdit(),a.deselectFacet()});this.flags.allSelected=!1;this.removeFocus();a(document).unbind("click.selectAllFacets")},resizeFacets:function(a){_.each(this.facetViews,function(c){(!a||c==a)&&c.resize()})},_maybeDisableFacets:function(a){if(this.flags.allSelected&&VS.app.hotkeys.key(a)=="backspace")return a.preventDefault(),this.clearSearch(a),!1;else this.flags.allSelected&&VS.app.hotkeys.printable(a)&&this.clearSearch(a)},focusNextFacet:function(a,c,d){d=d||{};var e=this.facetViews.length,
g=d.viewPosition||this.viewPosition(a);d.skipToFacet?d.skipToFacet&&a.type=="text"&&e==g&&c>=0&&(c=g=0):(a.type=="text"&&c>0&&(c-=1),a.type=="facet"&&c<0&&(c+=1));var h;g=Math.min(e,g+c);a.type=="text"?(g>=0&&g<e?h=this.facetViews[g]:g==e&&(h=this.inputViews[this.inputViews.length-1]),h&&d.selectFacet&&h.type=="facet"?h.selectFacet():h&&(h.enableEdit(),h.setCursorAtEnd(c||d.startAtEnd))):a.type=="facet"&&(d.skipToFacet?g>=e||g<0?(h=_.last(this.inputViews),h.enableEdit()):(h=this.facetViews[g],h.enableEdit(),
h.setCursorAtEnd(c||d.startAtEnd)):(h=this.inputViews[g],h.enableEdit()));d.selectText&&h.selectText();this.resizeFacets()},maybeFocusSearch:function(b){(a(b.target).is(".VS-search-box")||a(b.target).is(".VS-search-inner")||b.type=="keydown")&&this.focusSearch(b)},focusSearch:function(a,c){var d=this.inputViews[this.inputViews.length-1];d.enableEdit(c);c||d.setCursorAtEnd(-1);a.type=="keydown"&&(d.keydown(a),d.box.trigger("keydown"));_.defer(_.bind(function(){this.$("input:focus").length||d.enableEdit(c)},
this))},highlightSearch:function(b){if(a(b.target).is(".VS-search-box")||a(b.target).is(".VS-search-inner")||b.type=="keydown")this.inputViews[this.inputViews.length-1].startTripleClickTimer(),this.focusSearch(b,!0)},maybeTripleClick:function(a){return this.inputViews[this.inputViews.length-1].maybeTripleClick(a)},addFocus:function(){VS.options.callbacks.focus();this.$(".VS-search-box").addClass("VS-focus")},removeFocus:function(){_.any(this.facetViews.concat(this.inputViews),function(a){return a.isFocused()})||
this.$(".VS-search-box").removeClass("VS-focus")},showFacetCategoryMenu:function(a){a.preventDefault();a.stopPropagation();if(this.facetCategoryMenu&&this.facetCategoryMenu.modes.open=="is")return this.facetCategoryMenu.close();a=[{title:"Account",onClick:_.bind(this.addFacet,this,"account","")},{title:"Project",onClick:_.bind(this.addFacet,this,"project","")},{title:"Filter",onClick:_.bind(this.addFacet,this,"filter","")},{title:"Access",onClick:_.bind(this.addFacet,this,"access","")}];a=this.facetCategoryMenu||
(this.facetCategoryMenu=new dc.ui.Menu({items:a,standalone:!0}));this.$(".VS-icon-search").after(a.render().open().content);return!1}})})();
(function(){var a=jQuery;VS.ui.SearchFacet=Backbone.View.extend({type:"facet",className:"search_facet",events:{"click .category":"selectFacet","keydown input":"keydown","mousedown input":"enableEdit","mouseover .VS-icon-cancel":"showDelete","mouseout .VS-icon-cancel":"hideDelete","click .VS-icon-cancel":"remove"},initialize:function(){this.flags={canClose:!1};_.bindAll(this,"set","keydown","deselectFacet","deferDisableEdit")},render:function(){a(this.el).html(JST.search_facet({model:this.model}));
this.setMode("not","editing");this.setMode("not","selected");this.box=this.$("input");this.box.val(this.model.get("value"));this.box.bind("blur",this.deferDisableEdit);this.setupAutocomplete();return this},calculateSize:function(){this.box.autoGrowInput();this.box.unbind("updated.autogrow");this.box.bind("updated.autogrow",_.bind(this.moveAutocomplete,this))},resize:function(a){this.box.trigger("resize.autogrow",a)},setupAutocomplete:function(){this.box.autocomplete({source:_.bind(this.autocompleteValues,
this),minLength:0,delay:0,autoFocus:!0,position:{offset:"0 5"},select:_.bind(function(a,c){a.preventDefault();var d=this.model.get("value");this.set(c.item.value);(d!=c.item.value||this.box.val()!=c.item.value)&&this.search(a);return!1},this)});this.box.autocomplete("widget").addClass("VS-interface")},moveAutocomplete:function(){var a=this.box.data("autocomplete");a&&a.menu.element.position({my:"left top",at:"left bottom",of:this.box.data("autocomplete").element,collision:"flip",offset:"0 5"})},searchAutocomplete:function(){var a=
this.box.data("autocomplete");if(a){var c=a.menu.element;a.search();c.outerWidth(Math.max(c.width("").outerWidth(),a.element.outerWidth()))}},closeAutocomplete:function(){var a=this.box.data("autocomplete");a&&a.close()},autocompleteValues:function(b,c){var d=this.model.get("category"),e=this.model.get("value"),g=b.term;VS.options.callbacks.valueMatches(d,g,function(b){b=b||[];if(g&&e!=g){var d=VS.utils.inflector.escapeRegExp(g||""),l=RegExp("\\b"+d,"i");b=a.grep(b,function(a){return l.test(a)||l.test(a.value)||
l.test(a.label)})}c(_.sortBy(b,function(a){return a==e||a.value==e?"":a}))})},set:function(a){a&&this.model.set({value:a})},search:function(a,c){c||(c=1);this.closeAutocomplete();VS.app.searchBox.searchEvent(a);_.defer(_.bind(function(){VS.app.searchBox.focusNextFacet(this,c,{viewPosition:this.options.order})},this))},enableEdit:function(){this.modes.editing!="is"&&(this.setMode("is","editing"),this.deselectFacet(),this.box.val()==""&&this.box.val(this.model.get("value")));this.flags.canClose=!1;
VS.app.searchBox.disableFacets(this);VS.app.searchBox.addFocus();_.defer(function(){VS.app.searchBox.addFocus()});this.resize();this.searchAutocomplete();this.box.focus()},deferDisableEdit:function(){this.flags.canClose=!0;_.delay(_.bind(function(){this.flags.canClose&&!this.box.is(":focus")&&this.modes.editing=="is"&&this.modes.selected!="is"&&this.disableEdit()},this),250)},disableEdit:function(){var a=VS.utils.inflector.trim(this.box.val());a!=this.model.get("value")&&this.set(a);this.flags.canClose=
!1;this.box.selectRange(0,0);this.box.blur();this.setMode("not","editing");this.closeAutocomplete();VS.app.searchBox.removeFocus()},selectFacet:function(b){b&&b.preventDefault();var c=VS.app.searchBox.allSelected();if(this.modes.selected!="is"){this.box.is(":focus")&&(this.box.setCursorPosition(0),this.box.blur());this.flags.canClose=!1;this.closeAutocomplete();this.setMode("is","selected");this.setMode("not","editing");if(!c||b)a(document).unbind("keydown.facet",this.keydown),a(document).unbind("click.facet",
this.deselectFacet),_.defer(_.bind(function(){a(document).unbind("keydown.facet").bind("keydown.facet",this.keydown);a(document).unbind("click.facet").one("click.facet",this.deselectFacet)},this)),VS.app.searchBox.disableFacets(this),VS.app.searchBox.addFocus();return!1}},deselectFacet:function(b){b&&b.preventDefault();this.modes.selected=="is"&&(this.setMode("not","selected"),this.closeAutocomplete(),VS.app.searchBox.removeFocus());a(document).unbind("keydown.facet",this.keydown);a(document).unbind("click.facet",
this.deselectFacet);return!1},isFocused:function(){return this.box.is(":focus")},showDelete:function(){a(this.el).addClass("search_facet_maybe_delete")},hideDelete:function(){a(this.el).removeClass("search_facet_maybe_delete")},setCursorAtEnd:function(a){a==-1?this.box.setCursorPosition(this.box.val().length):this.box.setCursorPosition(0)},remove:function(a){var c=this.model.get("value");this.deselectFacet();this.disableEdit();VS.app.searchQuery.remove(this.model);c?this.search(a,-1):(VS.app.searchBox.renderFacets(),
VS.app.searchBox.focusNextFacet(this,-1,{viewPosition:this.options.order}))},selectText:function(){this.box.selectRange(0,this.box.val().length)},keydown:function(a){var c=VS.app.hotkeys.key(a);if(c=="enter"&&this.box.val())this.disableEdit(),this.search(a);else if(c=="left")this.modes.selected=="is"?(this.deselectFacet(),VS.app.searchBox.focusNextFacet(this,-1,{startAtEnd:-1})):this.box.getCursorPosition()==0&&!this.box.getSelection().length&&this.selectFacet();else if(c=="right")this.modes.selected==
"is"?(a.preventDefault(),this.deselectFacet(),this.setCursorAtEnd(0),this.enableEdit()):this.box.getCursorPosition()==this.box.val().length&&(a.preventDefault(),this.disableEdit(),VS.app.searchBox.focusNextFacet(this,1));else if(VS.app.hotkeys.shift&&c=="tab")a.preventDefault(),VS.app.searchBox.focusNextFacet(this,-1,{startAtEnd:-1,skipToFacet:!0,selectText:!0});else if(c=="tab")a.preventDefault(),VS.app.searchBox.focusNextFacet(this,1,{skipToFacet:!0,selectText:!0});else if(VS.app.hotkeys.command&&
(a.which==97||a.which==65))return a.preventDefault(),VS.app.searchBox.selectAllFacets(),!1;else VS.app.hotkeys.printable(a)&&this.modes.selected=="is"?(VS.app.searchBox.focusNextFacet(this,-1,{startAtEnd:-1}),this.remove(a)):c=="backspace"&&(this.modes.selected=="is"?(a.preventDefault(),this.remove(a)):this.box.getCursorPosition()==0&&!this.box.getSelection().length&&(a.preventDefault(),this.selectFacet()));this.resize(a)}})})();
(function(){var a=jQuery;VS.ui.SearchInput=Backbone.View.extend({type:"text",className:"search_input",events:{"keypress input":"keypress","keydown input":"keydown","click input":"maybeTripleClick","dblclick input":"startTripleClickTimer"},initialize:function(){this.flags={canClose:!1};_.bindAll(this,"removeFocus","addFocus","moveAutocomplete","deferDisableEdit")},render:function(){a(this.el).html(JST.search_input({}));this.setMode("not","editing");this.setMode("not","selected");this.box=this.$("input");
this.box.autoGrowInput();this.box.bind("updated.autogrow",this.moveAutocomplete);this.box.bind("blur",this.deferDisableEdit);this.box.bind("focus",this.addFocus);this.setupAutocomplete();return this},setupAutocomplete:function(){this.box.autocomplete({minLength:1,delay:50,autoFocus:!0,position:{offset:"0 -1"},source:_.bind(this.autocompleteValues,this),select:_.bind(function(a,c){a.preventDefault();a.stopPropagation();var d=this.options.position+(this.addTextFacetRemainder(c.item.value)?1:0);VS.app.searchBox.addFacet(c.item.value,
"",d);return!1},this)});this.box.data("autocomplete")._renderMenu=function(a,c){var d="";_.each(c,_.bind(function(c){if(c.category&&c.category!=d)a.append('<li class="ui-autocomplete-category">'+c.category+"</li>"),d=c.category;this._renderItem(a,c)},this))};this.box.autocomplete("widget").addClass("VS-interface")},autocompleteValues:function(b,c){var d=b.term.match(/\w+$/),e=VS.utils.inflector.escapeRegExp(d&&d[0]||" ");VS.options.callbacks.facetMatches(function(b){b=b||[];var d=RegExp("^"+e,"i");
b=a.grep(b,function(a){return a&&d.test(a.label||a)});c(_.sortBy(b,function(a){return a.label?a.category+"-"+a.label:a}))})},closeAutocomplete:function(){var a=this.box.data("autocomplete");a&&a.close()},moveAutocomplete:function(){var a=this.box.data("autocomplete");a&&a.menu.element.position({my:"left top",at:"left bottom",of:this.box.data("autocomplete").element,collision:"none",offset:"0 -1"})},searchAutocomplete:function(){var a=this.box.data("autocomplete");if(a){var c=a.menu.element;a.search();
c.outerWidth(Math.max(c.width("").outerWidth(),a.element.outerWidth()))}},addTextFacetRemainder:function(a){var c=this.box.val(),d=c.match(/\b(\w+)$/),e=RegExp(d[0],"i");d&&a.search(e)==0&&(c=c.replace(/\b(\w+)$/,""));(c=c.replace("^s+|s+$",""))&&VS.app.searchBox.addFacet("text",c,this.options.position);return c},enableEdit:function(a){this.addFocus();a&&this.selectText();this.box.focus()},addFocus:function(){this.flags.canClose=!1;VS.app.searchBox.allSelected()||VS.app.searchBox.disableFacets(this);
VS.app.searchBox.addFocus();this.setMode("is","editing");this.setMode("not","selected");this.searchAutocomplete()},disableEdit:function(){this.box.blur();this.removeFocus()},removeFocus:function(){this.flags.canClose=!1;VS.app.searchBox.removeFocus();this.setMode("not","editing");this.setMode("not","selected");this.closeAutocomplete()},deferDisableEdit:function(){this.flags.canClose=!0;_.delay(_.bind(function(){this.flags.canClose&&!this.box.is(":focus")&&this.modes.editing=="is"&&this.disableEdit()},
this),250)},startTripleClickTimer:function(){this.tripleClickTimer=setTimeout(_.bind(function(){this.tripleClickTimer=null},this),500)},maybeTripleClick:function(a){if(this.tripleClickTimer)return a.preventDefault(),VS.app.searchBox.selectAllFacets(),!1},isFocused:function(){return this.box.is(":focus")},value:function(){return this.box.val()},setCursorAtEnd:function(a){a==-1?this.box.setCursorPosition(this.box.val().length):this.box.setCursorPosition(0)},selectText:function(){this.box.selectRange(0,
this.box.val().length);VS.app.searchBox.allSelected()?this.setMode("is","selected"):this.box.focus()},search:function(a,c){c||(c=0);this.closeAutocomplete();VS.app.searchBox.searchEvent(a);_.defer(_.bind(function(){VS.app.searchBox.focusNextFacet(this,c)},this))},keypress:function(a){var c=VS.app.hotkeys.key(a);if(c=="enter")return this.search(a,100);else if(VS.app.hotkeys.colon(a)){this.box.trigger("resize.autogrow",a);c=this.box.val();var d=VS.options.callbacks.facetMatches()||[];d=_.map(d,function(a){return a.label?
a.label:a});if(_.contains(d,c))return a.preventDefault(),a=this.options.position+(this.addTextFacetRemainder(c)?1:0),VS.app.searchBox.addFacet(c,"",a),!1}else if(c=="backspace"&&this.box.getCursorPosition()==0&&!this.box.getSelection().length)return a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),VS.app.searchBox.resizeFacets(),!1},keydown:function(a){var c=VS.app.hotkeys.key(a);if(c=="left")this.box.getCursorPosition()==0&&(a.preventDefault(),VS.app.searchBox.focusNextFacet(this,
-1,{startAtEnd:-1}));else if(c=="right")this.box.getCursorPosition()==this.box.val().length&&(a.preventDefault(),VS.app.searchBox.focusNextFacet(this,1,{selectFacet:!0}));else if(VS.app.hotkeys.shift&&c=="tab")a.preventDefault(),VS.app.searchBox.focusNextFacet(this,-1,{selectText:!0});else if(c=="tab")if(a.preventDefault(),c=this.box.val(),c.length){var d=this.options.position+(this.addTextFacetRemainder(c)?1:0);VS.app.searchBox.addFacet(c,"",d)}else VS.app.searchBox.focusNextFacet(this,0,{skipToFacet:!0,
selectText:!0});else if(VS.app.hotkeys.command&&String.fromCharCode(a.which).toLowerCase()=="a")return a.preventDefault(),VS.app.searchBox.selectAllFacets(),!1;else if(c=="backspace"&&!VS.app.searchBox.allSelected()&&this.box.getCursorPosition()==0&&!this.box.getSelection().length)return a.preventDefault(),VS.app.searchBox.focusNextFacet(this,-1,{backspace:!0}),!1;this.box.trigger("resize.autogrow",a)}})})();
(function(){var a=jQuery;Backbone.View.prototype.setMode=function(b,c){this.modes||(this.modes={});this.modes[c]!==b&&(a(this.el).setMode(b,c),this.modes[c]=b)}})();
(function(){var a=jQuery;VS.app.hotkeys={KEYS:{"16":"shift","17":"command","91":"command","93":"command","224":"command","13":"enter","37":"left","38":"upArrow","39":"right","40":"downArrow","46":"delete","8":"backspace","9":"tab","188":"comma"},initialize:function(){_.bindAll(this,"down","up","blur");a(document).bind("keydown",this.down);a(document).bind("keyup",this.up);a(window).bind("blur",this.blur)},down:function(a){(a=this.KEYS[a.which])&&(this[a]=!0)},up:function(a){(a=this.KEYS[a.which])&&
(this[a]=!1)},blur:function(){for(var a in this.KEYS)this[this.KEYS[a]]=!1},key:function(a){return this.KEYS[a.which]},colon:function(a){return(a=a.which)&&String.fromCharCode(a)==":"},printable:function(a){var c=a.which;if(a.type=="keydown"){if(c==32||c>=48&&c<=90||c>=96&&c<=111||c>=186&&c<=192||c>=219&&c<=222)return!0}else if(c>=32&&c<=126||c>=160&&c<=500||String.fromCharCode(c)==":")return!0;return!1}}})();
(function(){VS.utils.inflector={trim:function(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},escapeRegExp:function(a){return a.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")}}})();
(function(){var a=jQuery;a.fn.extend({setMode:function(a,c){c=c||"mode";var d=RegExp("\\w+_"+c+"(\\s|$)","g"),e=a===null?"":a+"_"+c;this.each(function(){this.className=(this.className.replace(d,"")+" "+e).replace(/\s\s/g," ")});return e},autoGrowInput:function(){return this.each(function(){var b=a(this),c=a("<div />").css({opacity:0,top:-9999,left:-9999,position:"absolute",whiteSpace:"nowrap"}).addClass("VS-input-width-tester").addClass("VS-interface");b.next(".VS-input-width-tester").remove();b.after(c);
b.unbind("keydown.autogrow keypress.autogrow resize.autogrow change.autogrow").bind("keydown.autogrow keypress.autogrow resize.autogrow change.autogrow",function(a,e){e&&(a=e);var g=b.val();if(VS.app.hotkeys.key(a)=="backspace"){var h=b.getCursorPosition();h>0&&(g=g.slice(0,h-1)+g.slice(h,g.length))}else VS.app.hotkeys.printable(a)&&!VS.app.hotkeys.command&&(g+=String.fromCharCode(a.which));g=g.replace(/&/g,"&amp;").replace(/\s/g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");c.html(g);b.width(c.width()+
3);b.trigger("updated.autogrow")});b.trigger("resize.autogrow")})},getCursorPosition:function(){var b=0,c=this.get(0);if(document.selection){c.focus();b=document.selection.createRange();var d=document.selection.createRange().text.length;b.moveStart("character",-c.value.length);b=b.text.length-d}else if(c&&a(c).is(":visible")&&c.selectionStart!=null)b=c.selectionStart;return b},setCursorPosition:function(b){return this.each(function(){return a(this).selectRange(b,b)})},selectRange:function(a,c){return this.each(function(){if(this.setSelectionRange)this.focus(),
this.setSelectionRange(a,c);else if(this.createTextRange){var d=this.createTextRange();d.collapse(!0);d.moveEnd("character",c);d.moveStart("character",a);c-a>=0&&d.select()}})},getSelection:function(){var a=this[0];if(a.selectionStart!=null){var c=a.selectionStart,d=a.selectionEnd;return{start:c,end:d,length:d-c,text:a.value.substr(c,d-c)}}else if(document.selection){var e=document.selection.createRange();if(e)return a=a.createTextRange(),c=a.duplicate(),a.moveToBookmark(e.getBookmark()),c.setEndPoint("EndToStart",
a),c=c.text.length,d=c+e.text.length,{start:c,end:d,length:d-c,text:e.text}}return{start:0,end:0,length:0}}})})();
(function(){VS.app.SearchParser={ALL_FIELDS:/('.+?'|".+?"|[^'"\s]{2}\S*):\s*('.+?'|".+?"|[^'"\s]\S*)/g,CATEGORY:/('.+?'|".+?"|[^'"\s]{2}\S*):\s*/,parse:function(a){a=this._extractAllFacets(a);VS.app.searchQuery.reset(a);return a},_extractAllFacets:function(a){for(var b=[],c=a;a;){var d,e;c=a;var g=this._extractNextField(a);g?g.indexOf(":")!=-1?(d=g.match(this.CATEGORY)[1].replace(/(^['"]|['"]$)/g,""),e=g.replace(this.CATEGORY,"").replace(/(^['"]|['"]$)/g,""),a=VS.utils.inflector.trim(a.replace(g,
""))):g.indexOf(":")==-1&&(d="text",e=g,a=VS.utils.inflector.trim(a.replace(e,""))):(d="text",e=this._extractSearchText(a),a=VS.utils.inflector.trim(a.replace(e,"")));d&&e&&(g=new VS.model.SearchFacet({category:d,value:VS.utils.inflector.trim(e)}),b.push(g));if(c==a)break}return b},_extractNextField:function(a){var b=a.match(/^\s*(\S+)\s+(?=\w+:\s?(('.+?'|".+?")|([^'"]{2}\S*)))/);return b&&b.length>=1?b[1]:this._extractFirstField(a)},_extractFirstField:function(a){return(a=a.match(this.ALL_FIELDS))&&
a.length&&a[0]},_extractSearchText:function(a){return VS.utils.inflector.trim((a||"").replace(this.ALL_FIELDS,""))}}})();
(function(){VS.model.SearchFacet=Backbone.Model.extend({serialize:function(){var a=this.quoteCategory(this.get("category")),b=VS.utils.inflector.trim(this.get("value"));if(!b)return"";if(!_.contains(VS.options.unquotable||[],a)&&a!="text")b=this.quoteValue(b);a!="text"?a+=": ":a="";return a+b},quoteCategory:function(a){var b=/"/.test(a),c=/'/.test(a),d=/\s/.test(a);return b&&!c?"'"+a+"'":d||c&&!b?'"'+a+'"':a},quoteValue:function(a){var b=/"/.test(a),c=/'/.test(a);return b&&!c?"'"+a+"'":'"'+a+'"'}})})();
(function(){VS.model.SearchQuery=Backbone.Collection.extend({model:VS.model.SearchFacet,value:function(){return this.map(function(a){return a.serialize()}).join(" ")},find:function(a){var b=this.detect(function(b){return b.get("category")==a});return b&&b.get("value")},count:function(a){return this.select(function(b){return b.get("category")==a}).length},values:function(a){var b=this.select(function(b){return b.get("category")==a});return _.map(b,function(a){return a.get("value")})},has:function(a,
b){return this.any(function(c){var d=c.get("category")==a;if(!b)return d;return d&&c.get("value")==b})},withoutCategory:function(a){return this.map(function(b){if(b.get("category")!=a)return b.serialize()}).join(" ")}})})();
(function(){window.JST=window.JST||{};window.JST.search_box=_.template('<div class="VS-search">\n  <div class="VS-search-box-wrapper VS-search-box">\n    <div class="VS-icon VS-icon-search"></div>\n    <div class="VS-search-inner"></div>\n    <div class="VS-icon VS-icon-cancel VS-cancel-search-box" title="clear search"></div>\n  </div>\n</div>');window.JST.search_facet=_.template('<% if (model.has(\'category\')) { %>\n  <div class="category"><%= model.get(\'category\') %>:</div>\n<% } %>\n\n<div class="search_facet_input_container">\n  <input type="text" class="search_facet_input VS-interface" value="" />\n</div>\n\n<div class="search_facet_remove VS-icon VS-icon-cancel"></div>');
window.JST.search_input=_.template('<input type="text" />')})();(function(){Backbone.View.prototype.setMode=function(a,c){this.modes||(this.modes={});this.modes[c]!==a&&($(this.el).setMode(a,c),this.modes[c]=a)};var a=Backbone.Model.prototype.set;Backbone.Model.prototype.set=function(b,c){var d={};if(b)for(var e in b)d[e]=b[e]!==""?b[e]:null;return a.call(this,d,c)}})();
window.DateUtils={RFC_EXTRACTOR:/(\d{4})-(\d{1,2})-(\d{1,2})(?:T(\d{1,2}):(\d{2}):(\d{2})(?:\.\d+)?(Z|[+-](\d{2}):?(\d{2}))?)?/i,MONTHS:["January","February","March","April","May","June","July","August","September","October","November","December"],SHORT_MONTHS:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],DAYS:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],SHORT_DAYS:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],AMPM:["AM","PM","am","pm","a","p"],
HOUR_SELECT:["12 AM","1 AM","2 AM","3 AM","4 AM","5 AM","6 AM","7 AM","8 AM","9 AM","10 AM","11 AM","12 PM","1 PM","2 PM","3 PM","4 PM","5 PM","6 PM","7 PM","8 PM","9 PM","10 PM","11 PM"],FORMATS:[[/%A/g,"DateUtils.DAYS[d.getDay()]"],[/%a/g,"DateUtils.SHORT_DAYS[d.getDay()]"],[/%B/g,"DateUtils.MONTHS[d.getMonth()]"],[/%b/g,"DateUtils.SHORT_MONTHS[d.getMonth()]"],[/%d/g,"DateUtils.pad(d.getDate(), 2)"],[/%e/g,"d.getDate()"],[/%H/g,"DateUtils.pad(d.getHours(), 2)"],[/%I/g,"DateUtils.pad((d.getHours() % 12) || 12, 2)"],
[/%k/g,"d.getHours()"],[/%l/g,"(d.getHours() % 12) || 12"],[/%M/g,"DateUtils.pad(d.getMinutes(), 2)"],[/%m/g,"DateUtils.pad(d.getMonth()+1, 2)"],[/%n/g,"d.getMonth()+1"],[/%P/g,"d.getHours() < 12 ? DateUtils.AMPM[0] : DateUtils.AMPM[1]"],[/%p/g,"d.getHours() < 12 ? DateUtils.AMPM[2] : DateUtils.AMPM[3]"],[/%q/g,"d.getHours() < 12 ? DateUtils.AMPM[4] : DateUtils.AMPM[5]"],[/%S/g,"DateUtils.pad(d.getSeconds(), 2)"],[/%y/g,"DateUtils.pad(d.getFullYear() % 100, 2)"],[/%Y/g,"d.getFullYear()"]],pad:function(a,
b,c){for(a=a.toString(c||10);a.length<b;)a="0"+a;return a},create:function(a){a=a.replace(/\n/g,"\\n").replace(/"/g,'\\"');a='return "'+a.replace(/"/g,'\\"')+'"';_.each(this.FORMATS,function(b){a=a.replace(b[0],'"\n+ ('+b[1]+') +\n"')});return new Function("d",a)},parseRfc:function(a){var b=this.RFC_EXTRACTOR.exec(a);if(!b)throw Error('Invalid RFC3339 Date: "'+a+'"');a=b[4]||0;var c=b[5]||0,d=b[6]||0;if(!b[7])return new Date(b[1],b[2]-1,b[3],a,c,d);var e=(b[8]||0)*1,g=(b[9]||0)*1;b[7].indexOf("-")>=
0&&(e=-e,g=-g);return new Date(Date.UTC(b[1],b[2]-1,b[3],a*1-e,c*1-g,d))}};window.dc||(window.dc={});
dc.inflector={small:"(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)",punct:"([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)",titleize:function(a){a=a.replace(/[-.\/_]/g," ").replace(/\s+/gm," ");for(var b=this.capitalize,c=[],d=/[:.;?!] |(?: |^)["\u00d2]/g,e=0;;){var g=d.exec(a);c.push(a.substring(e,g?g.index:a.length).replace(/\b([A-Za-z][a-z.'\u00d5]*)\b/g,function(a){return/[A-Za-z]\.[A-Za-z]/.test(a)?a:b(a)}).replace(RegExp("\\b"+this.small+"\\b","ig"),this.lowercase).replace(RegExp("^"+
this.punct+this.small+"\\b","ig"),function(a,c,d){return c+b(d)}).replace(RegExp("\\b"+this.small+this.punct+"$","ig"),b));e=d.lastIndex;if(g)c.push(g[0]);else break}return c.join("").replace(/ V(s?)\. /ig," v$1. ").replace(/(['\u00d5])S\b/ig,"$1s").replace(/\b(AT&T|Q&A)\b/ig,function(a){return a.toUpperCase()})},trim:function(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},squeeze:function(a){return a.replace(/\s+/g," ")},trimExcerpt:function(a){a=a.replace(/^([^<>]{0,100}?[.,!]|[^<>\s]+)/g,
"");a=a.replace(/(([.,!]\s?)[^<>]{0,100}?|[^<>\s]+)$/g,"$2");return"&hellip;"+a+"&hellip;"},camelize:function(a){var b=a.split("-"),c=b.length;if(c==1)return b[0];a=a.charAt(0)=="-"?b[0].charAt(0).toUpperCase()+b[0].substring(1):b[0];for(var d=1;d<c;d++)a+=b[d].charAt(0).toUpperCase()+b[d].substring(1);return a},lowercase:function(a){return a.toLowerCase()},capitalize:function(a){return a.charAt(0).toUpperCase()+a.substring(1).toLowerCase()},underscore:function(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,
"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/-/g,"_").toLowerCase()},spacify:function(a){return a.replace(/_/g," ")},dasherize:function(a){return a.replace(/_/g,"-")},singularize:function(a){return a.replace(/s$/,"")},pluralize:function(a,b){if(b==1)return a;if(a=="this")return"these";if(a=="person")return"people";if(a.match(/day$/i))return a.replace(/day$/i,"days");if(a.match(/y$/i))return a.replace(/y$/i,"ies");return a+"s"},classify:function(a){return this.camelize(this.capitalize(this.dasherize(this.singularize(a))))},
possessivize:function(a){var b=a.charAt(a.length-1)=="s";return a+(b?"'":"'s")},truncate:function(a,b,c){b=b||30;c=c==null?"...":c;return a.length>b?a.slice(0,b-c.length)+c:a},truncateWords:function(a,b,c){b=b||30;c=c==null?"...":c;if(a.length>b){var d=a.substr(0,b).split("").reverse().join("").search(/\W\w/);a=d!=-1?a.substr(0,b-d-1)+c:this.truncate(a,b,c)}return a},sluggify:function(a){return this.trim(a.replace(/['"]+/g,"").replace(/\W+/g," ")).toLowerCase().replace(/\s+/g,"-")},commify:function(a,
b){for(var c=[],d=0,e=a.length;d<e;d++){var g=a[d];b.quote&&(g='"'+g+'"');c.push(g);c.push(d==a.length-1?"":d==a.length-2&&b.conjunction?", "+b.conjunction+" ":", ")}return c.join("")},autolink:function(a,b){a=a.replace(/(https?:\/\/([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)+([a-zA-z]{2,6})(\/[a-zA-Z0-9$_.+!#*(),;\/?:@&~=%-]*)?)/g,'<a href="$1">$1</a>');b&&(a=a.replace(/(^|\s)@(\w{1,15})/g,'$1<a href="http://twitter.com/$2">@$2</a>'));return a},bytesToMB:function(a){var b=Math.round(a/1024*100)*0.01;a="KB";
b>1E3&&(b=Math.round(b*0.1)*0.01,a="MB");b=b.toString().split(".");b=b[0]+(b.length>1?"."+b[1].substr(0,1):"");return b+" "+a},normalizeUrl:function(a){a=dc.inflector.trim(a);if(!a)return null;return/^https?:\/\//.test(a)?a:"http://"+a},stripTags:function(a){return a.replace(/<\w+(\s*("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi,"")},escapeRegExp:function(a){return a.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},escapeHTML:function(a){return a.replace(/&(?!\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,
"&gt;").replace(/"/g,"&quot;")}};
(function(a){a(document).ajaxSend(function(b,c){var d=a("meta[name='csrf-token']").attr("content");c.setRequestHeader("X-CSRF-Token",d)});var b="placeholder"in document.createElement("input");a.fn.extend({align:function(b,c,d){c=c||"";d=d||{};var k=document.documentElement.scrollTop||document.body.scrollTop||0,l=document.documentElement.scrollLeft||document.body.scrollLeft||0,s=document.documentElement.clientWidth,z=document.documentElement.clientHeight;if(b==window)var q={left:l,top:k,width:a(window).width(),
height:a(window).height()};else{b=a(b);var x=b.offset();q={left:x.left,top:x.top,width:b.innerWidth(),height:b.innerHeight()}}b={width:this.innerWidth(),height:this.innerHeight()};x=c.indexOf("-left")>=0?q.left:c.indexOf("left")>=0?q.left-b.width:c.indexOf("-right")>=0?q.left+q.width-b.width:c.indexOf("right")>=0?q.left+q.width:q.left+(q.width-b.width)/2;q=c.indexOf("-top")>=0?q.top:c.indexOf("top")>=0?q.top-b.height:c.indexOf("-bottom")>=0?q.top+q.height-b.height:c.indexOf("bottom")>=0?q.top+q.height:
q.top+(q.height-b.height)/2;c=c.indexOf("no-constraint")>=0?!1:!0;x+=d.left||0;q+=d.top||0;c&&(x=Math.max(l,Math.min(x,l+s-b.width)),q=Math.max(k,Math.min(q,k+z-b.height)));a(this).css({position:"absolute",left:x+"px",top:q+"px"});return this},setMode:function(a,b){b=b||"mode";var c=RegExp("\\w+_"+b+"(\\s|$)","g"),d=a===null?"":a+"_"+b;this.each(function(){this.className=(this.className.replace(c,"")+" "+d).replace(/\s\s/g," ")});return d},serializeJSON:function(){return _.reduce(this.serializeArray(),
function(a,b){a[b.name]=b.value;return a},{})},outerHTML:function(){return a("<div></div>").append(this.clone()).html()},autohide:function(b){var c=this;b=_.extend({clickable:null,onHide:null},b||{});c._autoignore=!0;setTimeout(function(){delete c._autoignore},0);if(!c._autohider)c.forceHide=function(d){if(!d&&b.onHide)b.onHide();c.hide();a(document).unbind("click",c._autohider);a(document).unbind("keypress",c._autohider);c._autohider=null;c.forceHide=null},c._autohider=function(d){if(!(d.which>1)&&
!c._autoignore&&(!b.clickable||!(c[0]==d.target||_.include(a(d.target).parents(),c[0]))))(!b.onHide||b.onHide(d))&&c.forceHide(d)},a(document).bind("click",this._autohider),a(document).bind("keypress",this._autohider)},draggable:function(b){b||(b={});this.each(function(){var c=this,d=null,k=null,l=null,s=function(a){a.stopPropagation();a.preventDefault();return!1},z=_.bind(function(a){if(!c._drag)return s(a);d?d.css({top:a.pageY-l,left:a.pageX-k}):(c.style.left=c._drag.left+a.pageX-c._drag.x+"px",
c.style.top=c._drag.top+a.pageY-c._drag.y+"px")},c),q=_.bind(function(k){a(document.body).unbind("selectstart",s);a(document.body).unbind("mouseup",q);a(document.body).unbind("mousemove",z);a(d||c).removeClass("dragging");d&&a(d).remove();c._drag=null;if(b.onDrop)b.onDrop(k)},c),x=_.bind(function(x){var K;K=a(x.target).closest("input, select, textarea, label, a, canvas, .tickLabel, .minibutton, .text_link, .selectable_text, .not_draggable").length?!0:a(x.target).parents(".is_draggable").andSelf().length?
s(x):!0;if(K)return!0;b.ghost&&(k=a(c).width()/2,l=a(c).height()/2,d=a(c).clone().css({position:"absolute",cursor:"copy","z-index":1E3,top:x.pageY-l,left:x.pageX-k}).appendTo(document.body));a(d||c).addClass("dragging");c._drag={left:parseInt(c.style.left,10)||0,top:parseInt(c.style.top,10)||0,x:x.pageX,y:x.pageY};a(document.body).bind("selectstart",s);a(document.body).bind("mouseup",q);a(document.body).bind("mousemove",z)},c);a(c).bind(b.ghost?"dragstart":"mousedown",x)})},selectable:function(b){var c=
a(document),d=a(".selection");a(this).bind("mousedown",_.bind(function(k){if(!(k.which>1)&&(!b.ignore||!a(k.target).closest(b.ignore).length)){var l=this.offset();if(!(k.pageX>l.left+this.outerWidth()-17||k.pageY>l.top+this.outerHeight()-17)){k.preventDefault();dc.app.searchBox&&(dc.app.searchBox.removeFocus(),dc.app.searchBox.disableFacets());var s=a(b.select),z=this.scrollTop(),q=this.scrollLeft(),x=k.pageX,B=k.pageY,K=function(a){return{left:Math.min(x,a.pageX),top:Math.min(B,a.pageY),width:Math.abs(a.pageX-
x),height:Math.abs(a.pageY-B)}},M=function(c){if(!(c.pageX==x&&c.pageY==B)){var d=K(c);c=d.left+q;for(var g=d.top+z,h=c+d.width,k=g+d.height,l=[],G=0;G<s.length;G++){var F=a(s[G]);d=F.offset();var M=d.left+q;d=d.top+z;var v=M+F.outerWidth(),R=d+F.outerHeight();c>v||h<M||g>R||k<d||l.push(F)}if(b.onSelect)b.onSelect(l)}},F=_.bind(function(a){a.stopPropagation();a.preventDefault();d.show().css(K(a));M(a)},this),G=_.bind(function(a){a.stopPropagation();a.preventDefault();c.unbind("mouseup",G).unbind("mousemove",
F);M(a);d.hide()},this);c.bind("mouseup",G).bind("mousemove",F)}}},this))},textWithNewlines:function(b){var c="";a.each(b||this,function(){a.each(this.childNodes,function(){if(this.nodeType!=8){var b=this.tagName&&this.tagName.toLowerCase();if(b=="div"||b=="p"||b=="br")c+="\n";c+=this.nodeType!=1?this.nodeValue:a.fn.textWithNewlines([this])}})});return c},placeholder:function(c){if(!b){var d=a.extend({},{className:"placeholder"},c),h;this.each(function(){var b=a(this),c=b.attr("placeholder"),e=a('<div class="'+
d.className+'">'+c+"</div>");e.hide().prependTo(b[0].parentNode);b.bind("blur",function(){b.val()==""&&e.show()});b.bind("focus",function(){h=this;e.hide()});e.bind("click",function(){a(h).blur();b.focus()});b.blur()})}}});jQuery.expr[":"].focus=function(a){return a===document.activeElement&&(a.type||a.href)};var c=["DOMMouseScroll","mousewheel"],d=function(b){var c=[].slice.call(arguments,1),d=0;b=a.event.fix(b||window.event);b.type="mousewheel";var k=b.wheelDelta||b.originalEvent.wheelDelta;k?d=
k/3:b.detail&&(d=-b.detail*9);c.unshift(b,d);return a.event.handle.apply(this,c)};a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=c.length;a;)this.addEventListener(c[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=c.length;a;)this.removeEventListener(c[--a],d,!1);else this.onmousewheel=null}}})(jQuery);
dc.model.Selectable={firstSelection:null,selectedCount:0,selectAll:function(){this.each(function(a){a.set({selected:!0})})},deselectAll:function(){this.each(function(a){a.set({selected:!1})})},selected:function(){return this.select(function(a){return a.get("selected")})},firstSelected:function(){return this.detect(function(a){return a.get("selected")})},selectedIds:function(){return _.pluck(this.selected(),"id")},_resetSelection:function(){this.firstSelection=null;this.selectedCount=0},_add:function(a,
b){var c=a.attributes||a;if(c.selected==null)c.selected=!1;a=Backbone.Collection.prototype._add.call(this,a,b);a.get("selected")&&(this.selectedCount+=1)},_remove:function(a,b){a=Backbone.Collection.prototype._remove.call(this,a,b);this.selectedCount>0&&a.get("selected")&&(this.selectedCount-=1)},_onModelEvent:function(a,b,c){Backbone.Collection.prototype._onModelEvent.call(this,a,b,c);if(a=="change"&&b.hasChanged("selected")){if((a=b.get("selected"))&&this.selectedCount==0)this.firstSelection=b;
else if(!a&&this.firstSelection==b)this.firstSelection=null;this.selectedCount+=a?1:-1;_.defer(_(this.trigger).bind(this,"select",this))}}};dc.app.validator={check:function(a,b){return this[b].test(a)},url:/^(https?:)\/\/([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)+([a-zA-z]{2,6})(\/[a-zA-Z0-9$_.+!#*(),;\/?:@&~=%-]*)?$/,email:/^([\w\.\-\+\=]+)@((?:[a-z0-9\-_]+\.)+[a-z]{2,6})$/i};
dc.access={DELETED:0,PRIVATE:1,ORGANIZATION:2,EXCLUSIVE:3,PUBLIC:4,PENDING:5,INVISIBLE:6,ERROR:7,NAMES:{0:"deleted",1:"private",2:"organization",3:"exclusive",4:"public",5:"pending",6:"invisible",7:"error"}};
dc.model.Account=Backbone.Model.extend({DISABLED:0,ADMINISTRATOR:1,CONTRIBUTOR:2,REVIEWER:3,FREELANCER:4,ROLE_NAMES:["disabled","administrator","contributor","reviewer","freelancer"],GRAVATAR_BASE:location.protocol+(location.protocol=="https:"?"//secure.":"//www.")+"gravatar.com/avatar/",DEFAULT_AVATAR:location.protocol+"//"+location.host+"/images/embed/icons/user_blue_32.png",BLANK_ACCOUNT:{first_name:"",last_name:"",email:"",role:2},constructor:function(a,b){a&&(a=_.extend({},this.BLANK_ACCOUNT,
a));Backbone.Model.call(this,a||this.BLANK_ACCOUNT,b)},organization:function(){return Organizations.get(this.get("organization_id"))},openDocuments:function(a){a||(a={});a=a.published?" filter: published":"";dc.app.searcher.search("account: "+this.get("slug")+a)},openOrganizationDocuments:function(){dc.app.searcher.search("group: "+dc.account.organization.slug)},allowedToEdit:function(a){return this.ownsOrOrganization(a)||this.collaborates(a)},ownsOrOrganization:function(a){return a.get("account_id")==
this.id||a.get("organization_id")==this.get("organization_id")&&(this.isAdmin()||this.isContributor())&&_.contains([dc.access.PUBLIC,dc.access.EXCLUSIVE,dc.access.ORGANIZATION,"public","exclusive","organization"],a.get("access"))},collaborates:function(a){a.get("document_id");for(var b=a.get("project_ids"),c=0,d=Projects.length;c<d;c++){var e=Projects.models[c];if(_.contains(b,e.get("id"))&&!e.get("hidden"))for(var g=0,h=e.collaborators.length;g<h;g++)if(e.collaborators.models[g].ownsOrOrganization(a))return!0}return!1},
fullName:function(a){var b=this.get("first_name")+" "+this.get("last_name");return a?b.replace(/\s/g,"&nbsp;"):b},documentsTitle:function(){return dc.inflector.possessivize(this.fullName())+" Documents"},isAdmin:function(){return this.attributes.role==this.ADMINISTRATOR},isContributor:function(){return this.attributes.role==this.CONTRIBUTOR},isReviewer:function(){return this.attributes.role==this.REVIEWER},isReal:function(){var a=this.attributes.role;return a==this.ADMINISTRATOR||a==this.CONTRIBUTOR||
a==this.FREELANCER},isPending:function(){return!!this.get("pending")},searchUrl:function(){return"/#search/"+encodeURIComponent("account: "+this.get("slug"))},gravatarUrl:function(a){var b=this.get("hashed_email"),c=encodeURIComponent(this.DEFAULT_AVATAR);return this.GRAVATAR_BASE+b+".jpg?s="+a+"&d="+c},resendWelcomeEmail:function(a){$.ajax(_.extend(a||{},{type:"POST",dataType:"json",url:"/accounts/"+this.id+"/resend_welcome"}))}});
dc.model.AccountSet=Backbone.Collection.extend({model:dc.model.Account,url:"/accounts",comparator:function(a){return(a.get("last_name")||"").toLowerCase()+" "+(a.get("first_name")||"").toLowerCase()},getBySlug:function(a){return this.detect(function(b){return b.get("slug")===a})},current:function(){if(!dc.account)return null;return this.get(dc.account.id)},others:function(){return this.filter(function(a){return a.id!==dc.account.id})},forceLogout:function(){dc.ui.Dialog.alert("You are no longer logged in to DocumentCloud.",
{onClose:function(){window.location="/logout"}})}});window.Accounts=new dc.model.AccountSet;
dc.analytics={initialize:function(){window._gaq=window._gaq||[];_gaq.push(["_setAccount","UA-9312438-1"]);_gaq.push(["_trackPageview"]);var a=document.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)},trackEvent:function(a){a.indexOf("search/")!=-1&&(a="search");_gaq.push(["_trackPageview","/#"+a])}};
dc.model.Document=Backbone.Model.extend({constructor:function(a,b){a.selected=!1;a.selectable=!0;if(a.annotation_count==null)a.annotation_count=0;Backbone.Model.call(this,a,b);var c=this.id;this.notes=new dc.model.NoteSet;this.notes.url=function(){return"/documents/"+c+"/annotations"};this.entities=new dc.model.EntitySet;this.get("annotations")&&this.notes.reset(this.get("annotations"));this.pageEntities=new dc.model.EntitySet;this.reviewers=new dc.model.AccountSet},url:function(){if(!this.collection)return"/documents/"+
this.id;return Backbone.Model.prototype.url.call(this)},viewerUrl:function(){var a=this.get("document_viewer_url").replace(/^https?:/,"");return window.location.protocol+a},publishedUrl:function(){return this.get("remote_url")||this.get("detected_remote_url")},canonicalId:function(){return this.id+"-"+this.get("slug")},formatDay:DateUtils.create("%b %e, %Y"),formatTime:DateUtils.create("%l:%M %P"),publishAtDate:function(){var a=this.get("publish_at");return a&&DateUtils.parseRfc(a)},formattedPublishAtDate:function(){var a=
this.publishAtDate();return a&&this.formatDay(a)+" at "+this.formatTime(a)},mergeData:function(a,b){var c=this.get("data");_.each(b,function(a){delete c[a]});_.each(a,function(a,b){a?c[b]=a:delete c[b]});this.save({data:c});this.change()},sortedData:function(){return Documents.sortData(this.get("data"))},hasNotes:function(){return!!this.get("annotation_count")},hasLoadedNotes:function(){return this.notes.length&&this.notes.length==this.get("annotation_count")},fetchMentions:function(a){$.getJSON(this.url()+
"/mentions",{q:a},_.bind(function(a){this.set(a)},this))},reprocessText:function(a){var b={};if(a)b.ocr=!0;$.ajax({url:this.url()+"/reprocess_text",data:b,type:"POST",dataType:"json",success:_.bind(function(){this.set({access:dc.access.PENDING})},this)})},openViewer:function(a){if(!this.checkBusy())return window.open(this.viewerUrl()+(a||""))},openEntity:function(a,b){window.open(this.viewerUrl()+"?entity="+a+"&offset="+b)},openPublishedViewer:function(){if(!this.checkBusy()){if(!this.isPublished())return dc.ui.Dialog.alert('"'+
this.get("title")+'" is not published.');return window.open(this.publishedUrl())}},openAppropriateVersion:function(a){return!dc.account&&this.isPublished()?this.openPublishedViewer():this.openViewer(a)},openText:function(){this.checkBusy()||window.open(this.get("full_text_url"))},openPDF:function(){this.checkBusy()||window.open(this.get("pdf_url"))},pageThumbnailURL:function(a,b){b||(b="thumbnail");return this.get("page_image_url").replace("{size}",b).replace("{page}",a)},allowedToEdit:function(){if(this.viewerEditable)return!0;
return Accounts.current()&&Accounts.current().allowedToEdit(this)},checkAllowedToEdit:function(a){a=a||"You don't have permission to edit \""+this.get("title")+'".';if(this.allowedToEdit())return!0;dc.ui.Dialog.alert(a);return!1},checkBusy:function(){if(this.get("access")!=dc.access.PENDING)return!1;dc.ui.Dialog.alert('"'+this.get("title")+'" is still being processed. Please wait for it to finish.');return!0},uniquePageEntityValues:function(){return _.uniq(this.pageEntities.map(function(a){return a.get("value")}))},
isPending:function(){return this.get("access")==dc.access.PENDING},isPublic:function(){return this.get("access")==dc.access.PUBLIC},isPublished:function(){return this.isPublic()&&this.publishedUrl()},ensurePerPageNoteCounts:function(a){this.perPageNoteCounts?a(this.perPageNoteCounts):$.getJSON("/documents/"+this.id+"/per_page_note_counts",{},_.bind(function(b){a(this.perPageNoteCounts=b)},this))},decrementNotes:function(){var a=this.get("annotation_count");if(a<=0)return!1;this.set({annotation_count:a-
1})},removePages:function(a){Documents.removePages(this,a)},reorderPages:function(a){Documents.reorderPages(this,a)},toString:function(){return"Document "+this.id+' "'+this.get("title")+'"'}});
dc.model.DocumentSet=Backbone.Collection.extend({model:dc.model.Document,EMBED_FORBIDDEN:"At this stage in the beta, you may only embed documents you've uploaded yourself.",POLL_INTERVAL:1E4,NUM_MENTIONS:3,url:"/documents",constructor:function(a){Backbone.Collection.call(this,a);this._polling=!1;_.bindAll(this,"poll","downloadViewers","downloadSelectedPDF","downloadSelectedFullText","printNotes","_onModelChanged");this.bind("change",this._onModelChanged)},comparator:function(a){return a.get("index")},
pending:function(){return this.select(function(a){return a.isPending()})},subtitle:function(a){return a>1?a+" Documents":""},sharedAttribute:function(a,b){var c=_.uniq(_.map(a,function(a){return a.get(b)}));return c.length>1?!1:c[0]},sharedData:function(a){a=_.clone(a);var b=a.shift(),c=_.clone(b.get("data"));_.each(a,function(a){for(var b in c)a.attributes.data[b]!==c[b]&&delete c[b]});return c},sortData:function(a){var b=[],c;for(c in a)b.push([c,a[c]]);return b.sort(function(a,b){return a[0]>b[0]?
1:-1})},selectedPublicCount:function(){return _.reduce(this.selected(),function(a,b){return a+b.isPublic()?1:0},0)},allowedToEdit:function(a,b){return!_.any(a,function(a){return!a.checkAllowedToEdit(b)})},chosen:function(a){var b=this.selected();b=!a||_.include(b,a)?b:[a];if(_.any(b,function(a){return a.checkBusy()}))return[];return b},downloadViewers:function(a){a=_.map(a,function(a){return a.id});var b=dc.ui.Dialog.progress("Preparing "+dc.inflector.pluralize("document",a.length)+" for download...");
dc.app.download("/download/"+a.join("/")+"/document_viewer.zip",function(){b.close()})},downloadSelectedPDF:function(){if(this.selectedCount<=1)return this.selected()[0].openPDF();dc.app.download("/download/"+this.selectedIds().join("/")+"/original_documents.zip")},downloadSelectedFullText:function(){if(this.selectedCount<=1)return this.selected()[0].openText();dc.app.download("/download/"+this.selectedIds().join("/")+"/document_text.zip")},printNotes:function(){var a=this.selected();if(!_.any(a,
function(a){return a.hasNotes()}))return dc.ui.Dialog.alert('"'+a[0].get("title")+'" does not contain any printable notes.');a=_.map(a,function(a){return"docs[]="+a.id}).join("&");window.open(SERVER_ROOT+"/notes/print?"+a)},startPolling:function(){this._polling=setInterval(this.poll,this.POLL_INTERVAL)},stopPolling:function(){clearInterval(this._polling);this._polling=null},poll:function(){var a=_.compact(_.pluck(this.pending(),"id"));if(!a.length)return this.stopPolling();a.length>5&&(a=[a.shift(),
a.shift(),a[Math.floor(Math.random()*a.length)]]);$.get("/documents/status.json",{"ids[]":a},_.bind(function(a){_.each(a.documents,function(a){var b=Documents.get(a.id);b&&b.get("access")!=a.access&&b.set(a)});this.pending().length||this.stopPolling()},this),"json")},verifyDestroy:function(a){if(this.allowedToEdit(a)){var b="Really delete "+a.length+" "+dc.inflector.pluralize("document",a.length)+"?";dc.ui.Dialog.confirm(b,_.bind(function(){var b=a.length,d=dc.ui.Dialog.progress("Deleting Documents&hellip;");
_(a).each(function(a){a.destroy({success:function(){--b||d.close()}})});Projects.removeDocuments(a);return!0},this))}},removePages:function(a,b,c){c=c||{};$.ajax({url:"/"+this.resource+"/"+a.id+"/remove_pages",type:"POST",data:{pages:b},dataType:"json",success:function(b){a.set(b);c.success&&c.success(a,b)},error:_.bind(function(b){this._handleError(a,c.error,null,b)},this)})},reorderPages:function(a,b,c){c=c||{};$.ajax({url:"/"+this.resource+"/"+a.id+"/reorder_pages",type:"POST",data:{page_order:b},
dataType:"json",success:function(b){a.set(b);c.success&&c.success(a,b)},error:_.bind(function(b){this._handleError(a,c.error,null,b)},this)})},editAccess:function(a,b){var c={information:this.subtitle(a.length)};if(this.allowedToEdit(a)){var d=this.sharedAttribute(a,"access")||dc.access.PRIVATE;dc.ui.Dialog.choose("Access Level",[{text:"Public Access",description:"Anyone on the internet can search for and view the document.",value:dc.access.PUBLIC,selected:d==dc.access.PUBLIC},{text:"Private Access",
description:"Only people with explicit permission (via collaboration) have access.",value:dc.access.PRIVATE,selected:d==dc.access.PRIVATE},{text:"Private to "+dc.account.organization.name,description:"Only the people in your organization have access. (No freelancers.)",value:dc.access.ORGANIZATION,selected:d==dc.access.ORGANIZATION}],function(c){_.each(a,function(a){a.save({access:parseInt(c,10)})});var d="Access updated for "+a.length+" "+dc.inflector.pluralize("document",a.length);_.any(a,function(a){return a.suppressNotifier})||
dc.ui.notifier.show({mode:"info",text:d});b&&b(c);return!0},c)}},add:function(a,b){Backbone.Collection.prototype.add.call(this,a,b);this._checkForPending()},reset:function(a,b){this._resetSelection();this.pending().length||this.stopPolling();Backbone.Collection.prototype.reset.call(this,a,b)},_onModelChanged:function(a){a.hasChanged("access")&&a.isPending()&&this._checkForPending()},_checkForPending:function(){if(this._polling)return!1;if(!this.pending().length)return!1;this.startPolling()}},{entitle:function(){var a=
VS.app.searchQuery,b,c,d,e;a.count("project")==1?b=a.find("project"):dc.account&&a.find("account")==Accounts.current().get("slug")?c=a.find("filter")=="published"?"your_published_documents":"your_documents":(d=Accounts.getBySlug(a.find("account")))?b=d.documentsTitle():dc.account&&a.find("group")==dc.account.organization.slug?c="org_documents":a.has("group")&&(e=Organizations.findBySlug(a.find("group")))?b=dc.inflector.possessivize(e.get("name"))+" Documents":c=a.find("filter")=="published"?"published_documents":
a.find("filter")=="popular"?"popular_documents":a.find("filter")=="annotated"?"annotated_documents":"all_documents";return b||dc.model.Project.topLevelTitle(c)}});_.extend(dc.model.DocumentSet.prototype,dc.model.Selectable);window.Documents=new dc.model.DocumentSet;
dc.model.Entity=Backbone.Model.extend({DIMS:{height:19,bucket:3,min:2,margin:1},initialize:function(){this.excerpts={}},occurrences:function(){if(!this._occurrences)this._occurrences=_.map(this.get("occurrences").split(","),function(a){a=a.split(":");return[parseInt(a[0],10),parseInt(a[1],10)]}),this.occurrenceCount=this._occurrences.length;return this._occurrences},loadExcerpt:function(a,b){var c;if(c=this.excerpts[a])return b(c);$.get("/documents/occurrence.json",{id:this.id,occurrence:a},_.bind(function(c){b(this.excerpts[a]=
c.excerpts[0])},this),"json")},buckets:function(a){var b=Documents.get(this.get("document_id")).get("char_count"),c=Math.floor(a/(this.DIMS.bucket+this.DIMS.margin)),d=this.occurrences();a=[];for(var e=5,g=0,h=d.length;g<h;g++){var k=d[g],l=Math.floor(k[0]/(b/c));l=a[l]||(a[l]={height:0,offset:0,length:0});var s=l.height+=1;if(l.length<k[1])l.offset=k[0],l.length=k[1];e<s&&(e=s)}b=this.DIMS.height/e;g=0;for(h=a.length;g<h;g++)if(l=a[g])l.height=Math.round((b*l.height-1)/2)*2+1+this.DIMS.min;return a}},
{DISPLAY_NAME:{city:"Cities",country:"Countries",date:"Dates",phone:"Phone Numbers",email:"Email Addresses",organization:"Organizations",person:"People",place:"Places",state:"States",term:"Terms"},PER_PAGE:10,ORDER:["person","organization","place","term","email","phone","city","state","country"],SPARK_GRAPHS:["person","organization","place","term"],fetch:function(a,b,c){this._fetch(Documents.pluck("id"),{kind:a,value:b},c)},fetchId:function(a,b,c){this._fetch([a],{entity_id:b},c)},_fetch:function(a,
b,c){dc.ui.spinner.show();a=_.extend({"ids[]":a},b);$.get("/documents/entity.json",a,function(a){c(_.map(a.entities,function(a){return new dc.model.Entity(a)}));dc.ui.spinner.hide()},"json")}});
dc.model.EntitySet=Backbone.Collection.extend({model:dc.model.Entity,index:function(){if(!this._index){var a=this._index=_.groupBy(this.models,function(a){return a.attributes.kind});_.each(a,function(b,c){a[c]=_.sortBy(b,function(a){return-a.occurrences().length})})}return this._index},sumOccurrences:function(a){this.index();for(var b=0,c=this.models.length;c--;){var d=this.models[c];if(!a||d.attributes.kind==a)b+=d.occurrenceCount}return b}},{populateDocuments:function(a){a=_.compact(_.map(a,function(a){return Documents.get(a.id)}));
var b=function(){_.each(a,function(a){a.entities.trigger("load")})},c=_.select(a,function(a){return!a.entities.loaded});if(!c.length)return b();dc.ui.spinner.show();$.get("/documents/entities.json",{"ids[]":_.pluck(c,"id")},function(a){a=_.groupBy(a.entities,"document_id");_.each(a,function(a,b){var c=Documents.get(b).entities;c.loaded=!0;c.reset(a)});dc.ui.spinner.hide();b()},"json")}});window.EntityDates=new dc.model.EntitySet;EntityDates.comparator=function(a){return a.get("date")};
dc.model.Note=Backbone.Model.extend({document:function(){return this._document=this._document||Documents.get(this.get("document_id"))},checkAllowedToEdit:function(){if(!dc.account)return!1;if(this.document().viewerEditable)return!0;return Accounts.current().allowedToEdit(this)},imageUrl:function(){return this._imageUrl=this._imageUrl||this.document().get("page_image_url").replace("{size}","normal").replace("{page}",this.get("page"))},coordinates:function(){if(this._coordinates)return this._coordinates;
var a=this.get("location");if(!a)return null;a=_.map(a.image.split(","),function(a){return parseInt(a,10)});return this._coordinates={top:a[0],left:a[3],right:a[1],height:a[2]-a[0],width:a[1]-a[3]}}});dc.model.NoteSet=Backbone.Collection.extend({model:dc.model.Note,url:"/notes",comparator:function(a){var b=a.coordinates();return a.get("page")*1E4+(b?b.top:0)},unrestricted:function(){return this.filter(function(a){return a.get("access")!="private"})}});
dc.model.Organization=Backbone.Model.extend({groupSearchUrl:function(){return"/#search/"+encodeURIComponent(this.query())},openDocuments:function(){dc.app.searcher.search(this.query())},query:function(){return"group: "+this.get("slug")},statistics:function(){var a=this.get("document_count"),b=this.get("note_count");return a+" "+dc.inflector.pluralize("document",a)+", "+b+" "+dc.inflector.pluralize("note",b)}});
dc.model.OrganizationSet=Backbone.Collection.extend({model:dc.model.Organization,url:"/organizations",comparator:function(a){return a.get("name").toLowerCase().replace(/^the\s*/,"")},findBySlug:function(a){return this.detect(function(b){return b.get("slug")==a})}});window.Organizations=new dc.model.OrganizationSet;
dc.model.Project=Backbone.Model.extend({constructor:function(a,b){var c=a.collaborators||[];delete a.collaborators;Backbone.Model.call(this,a,b);this.collaborators=new dc.model.AccountSet(c);this._setCollaboratorsResource()},set:function(a,b){a||(a={});if(a.title)a.title=dc.inflector.trim(a.title).replace(/"/g,"");if(a.account_id)a.owner=a.account_id==dc.account.id;Backbone.Model.prototype.set.call(this,a,b);a.id&&this._setCollaboratorsResource();return this},slug:function(){return this.id+"-"+dc.inflector.sluggify(this.get("title"))},
open:function(){dc.app.searcher.search(this.toSearchParam())},edit:function(){$(document.body).append((new dc.ui.ProjectDialog({model:this})).render().el)},addDocuments:function(a){var b=this.get("id"),c=_.uniq(_.pluck(a,"id"));if(a=_.reduce(a,function(a,c){var g=c.get("project_ids");_.contains(g,b)||(c.set({project_ids:g.concat([b])}),a+=1);return a},0))this.set({document_count:this.get("document_count")+a}),this.notifyProjectChange(a,!1),$.ajax({url:"/projects/"+b+"/add_documents",type:"POST",data:{document_ids:c},
success:_.bind(function(a){this.set(a)},this)})},removeDocuments:function(a,b){var c=this.get("id"),d=_.uniq(_.pluck(a,"id")),e=_.reduce(a,function(a,b){var d=b.get("project_ids");_.contains(d,c)&&(b.set({project_ids:_.without(d,c)}),a+=1);return a},0);e&&(Projects.firstSelected()===this&&Documents.remove(a),this.set({document_count:this.get("document_count")-e}),this.notifyProjectChange(e,!0),b||$.ajax({url:"/projects/"+c+"/remove_documents",type:"POST",data:{document_ids:d},success:_.bind(function(a){this.set(a)},
this)}))},notifyProjectChange:function(a,b){var c;c=(b?"Removed ":"Added ")+a+" "+dc.inflector.pluralize("document",a)+(b?' from "':' to "')+this.get("title")+'"';dc.ui.notifier.show({mode:"info",text:c})},contains:function(a){return _.contains(a.get("project_ids"),this.get("id"))},containsAny:function(a){var b=this;return _.any(a,function(a){return b.contains(a)})},toSearchParam:function(){return"project: "+dc.app.searcher.quote(this.get("title"))},statistics:function(){var a=this.get("document_count"),
b=this.get("annotation_count"),c=this.collaborators.length;return a+" "+dc.inflector.pluralize("document",a)+", "+b+" "+dc.inflector.pluralize("note",b)+(c?", "+c+" "+dc.inflector.pluralize("collaborator",c):"")},_setCollaboratorsResource:function(){if(this.collaborators&&this.id)this.collaborators.url="/projects/"+this.id+"/collaborators"}});
dc.model.Project.topLevelTitle=function(a){switch(a){case "all_documents":return"All Documents";case "your_documents":return"Your Documents";case "annotated_documents":return"Annotated Documents";case "popular_documents":return"Popular Documents";case "published_documents":return"Published Documents";case "your_published_documents":return"Your Published Documents";case "org_documents":return dc.inflector.possessivize(dc.account.organization.name)+" Documents"}};
dc.model.ProjectSet=Backbone.Collection.extend({model:dc.model.Project,url:"/projects",comparator:function(a){return a.get("title").toLowerCase()},find:function(a){return this.detect(function(b){return b.get("title").toLowerCase()==a.toLowerCase()})},startingWith:function(a){var b=RegExp("^"+a);return this.select(function(a){return!!a.get("title").match(b)})},incrementCountById:function(a){a=this.get(a);a.set({document_count:a.get("document_count")+1})},removeDocuments:function(a){this.each(function(b){b.removeDocuments(a,
!0)})}});_.extend(dc.model.ProjectSet.prototype,dc.model.Selectable);window.Projects=new dc.model.ProjectSet;dc.model.SearchEmbed=Backbone.Model.extend({});dc.model.SearchEmbeds=Backbone.Collection.extend({model:dc.model.SearchEmbed});
dc.model.UploadDocument=Backbone.Model.extend({FILE_EXTENSION_MATCHER:/\.([^.]+)$/,MAX_FILE_SIZE:209715200,set:function(a){var b=a.file;if(b){delete a.file;var c=b.fileName||b.name;c=c.match(/[^\/\\]+$/)[0];a.title=dc.inflector.titleize(c.replace(this.FILE_EXTENSION_MATCHER,""));c=c.match(this.FILE_EXTENSION_MATCHER);a.extension=c&&c[1];a.size=b.fileSize||b.size||null}Backbone.Model.prototype.set.call(this,a);return this},overSizeLimit:function(){return this.get("size")>=this.MAX_FILE_SIZE}});
dc.model.UploadDocumentSet=Backbone.Collection.extend({model:dc.model.UploadDocument,comparator:function(a){return a.get("position")}});window.UploadDocuments=new dc.model.UploadDocumentSet;
dc.ui.Dialog=Backbone.View.extend({className:"dialog",options:{title:"Untitled Dialog",text:null,information:null,description:null,choices:null,password:!1,editor:!1,draggable:!0},events:{"click .cancel":"cancel","click .ok":"confirm","focus input":"_addFocus","focus textarea":"_addFocus","blur input":"_removeFocus","blur textarea":"_removeFocus"},render:function(a){this.modes||(this.modes={});a=a||{};this.options.mode&&this.setMode(this.options.mode,"dialog");this.options.draggable&&this.setMode("is",
"draggable");_.bindAll(this,"close","_maybeConfirm","_maybeClose");$(this.el).html(JST["common/dialog"](_.extend({},this.options,a)));var b=this.contentEl=this.$(".content");this._controls=this.$(".controls");this._information=this.$(".information");this.options.width&&$(this.el).css({width:this.options.width});this.options.content&&b.val(this.options.content);$(document.body).append(this.el);this.delegateEvents();this.center();this.options.draggable&&$(this.el).draggable();this._returnCloses()&&
$(document.body).bind("keypress",this._maybeConfirm);$(document.body).bind("keydown",this._maybeClose);b[0]&&_.defer(function(){b.focus()});!a.noOverlay&&dc.app.workspace&&$(document.body).addClass("overlay");return this},append:function(a){this._controls.before(a)},addControl:function(a){this._controls.prepend(a)},val:function(){return this.options.choices&&this.options.mode=="prompt"?this.$("input:radio:checked").val():this.contentEl.val()},title:function(a){this.$(".title").text(a)},cancel:function(){if(this.options.onCancel)this.options.onCancel(this);
this.close()},info:function(a,b){this._information.removeClass("error").text(a).show();b||this._information.delay(3E3).fadeOut()},error:function(a,b){this._information.stop().addClass("error").text(a).show();b||this._information.delay(3E3).fadeOut()},confirm:function(){if(this.options.onConfirm&&!this.options.onConfirm(this))return!1;this.close()},close:function(){if(this.options.onClose)this.options.onClose(this);$(this.el).remove();this._returnCloses()&&$(document.body).unbind("keypress",this._maybeConfirm);
$(document.body).unbind("keydown",this._maybeClose);$(document.body).removeClass("overlay")},center:function(){$(this.el).align(window,"",{top:-50})},showSpinner:function(){this.$(".spinner_dark").show()},hideSpinner:function(){this.$(".spinner_dark").hide()},validateUrl:function(a){if(dc.app.validator.check(a,"url"))return!0;this.error("Please enter a valid URL.");return!1},validateEmail:function(a){if(dc.app.validator.check(a,"email"))return!0;this.error("Please enter a valid email address.");return!1},
_returnCloses:function(){return _.include(["alert","short_prompt","confirm"],this.options.mode)},_maybeClose:function(a){a.which==27&&this.close()},_maybeConfirm:function(a){a.which==13&&this.confirm()},_addFocus:function(a){$(a.target).addClass("focus");$(this.el).css({zoom:1})},_removeFocus:function(a){$(a.target).removeClass("focus")}});
_.extend(dc.ui.Dialog,{alert:function(a,b){return(new dc.ui.Dialog(_.extend({mode:"alert",title:null,text:a},b))).render()},prompt:function(a,b,c,d){return(new dc.ui.Dialog(_.extend({mode:"prompt",password:!(!d||!d.password),title:a,text:"",content:b,onConfirm:c&&function(a){return c(a.val(),a)}},d))).render()},confirm:function(a,b,c){return(new dc.ui.Dialog(_.extend({mode:"confirm",title:null,text:a,onConfirm:b},c))).render()},choose:function(a,b,c,d){return(new dc.ui.Dialog(_.extend({mode:"prompt",
title:a,choices:b,text:"",onConfirm:c&&function(a){return c(a.val())}},d))).render()},contact:function(){var a=new dc.ui.Dialog({id:"contact_us",mode:"custom",title:"Contact Us",saveText:"Send",onConfirm:function(a){var c={message:a.val()};if(!dc.account&&(c.email=a.$(".contact_email").val(),!a.validateEmail(c.email)))return!1;$.post("/ajax_help/contact_us",c,function(){dc.ui.notifier.show({mode:"info",text:"Your message was sent successfully."})});return!0}});a.render();a.setMode("prompt","dialog");
a.$(".custom").html(JST["common/contact"]());a.contentEl=a.$(".content");a.$("input").placeholder();a.center()},progress:function(a,b){return(new dc.ui.Dialog(_.extend({mode:"progress",text:a,title:null},b))).render()}});
dc.ui.Menu=Backbone.View.extend({className:"minibutton menu",options:{id:null,standalone:!1},events:{click:"open",selectstart:"_stopSelect"},constructor:function(a){this.modes={};_.bindAll(this,"close");Backbone.View.call(this,a);this.items=[];this.content=$(JST["common/menu"](this.options));this.itemsContainer=$(".menu_items",this.content);this.addIcon=$(".bullet_add",this.content);this.modes.open="not";a.items&&this.addItems(a.items)},render:function(){$(this.el).html(JST["common/menubutton"]({label:this.options.label}));
this._label=this.$(".label");$(document.body).append(this.content);return this},open:function(){var a=this.content;if(this.modes.enabled=="not")return!1;if(this.modes.open=="is"&&!this.options.standalone)return this.close();this.setMode("is","open");if(this.options.onOpen)this.options.onOpen(this);a.show();a.align(this.el,"-left bottom no-constraint");a.autohide({onHide:this.close});return this},close:function(a){if(a&&this.options.onClose&&!this.options.onClose(a))return!1;this.setMode("not","open");
return!0},enable:function(){this.setMode("is","enabled")},disable:function(){this.setMode("not","enabled")},activate:function(a){this._activateCallback=a;this.setMode("is","active")},deactivate:function(){if(this.modes.active=="is")return this.setMode("not","active"),this._activateCallback&&this._activateCallback(),!1},clear:function(){this.items=[];$(this.itemsContainer).html("");this.content.setMode(null,"selected")},setLabel:function(a){$(this._label).text(a||this.options.label)},addItems:function(a){this.items=
this.items.concat(a);a=_(a).map(_.bind(function(a){var c=a.attrs||{};_.extend(c,{"class":"menu_item "+(c["class"]||"")});var d=this.make("div",c,a.title);a.menuEl=$(d);a.onClick&&$(d).bind("click",function(c){if($(d).hasClass("disabled"))return!1;a.onClick(c)});return d},this));$(this.itemsContainer).append(a)},select:function(a){this.selectedItem=a;a.menuEl.addClass("selected")},deselect:function(){this.selectedItem&&this.selectedItem.menuEl.removeClass("selected");this.selectedItem=null},_stopSelect:function(){return!1}});
dc.ui.Notifier=Backbone.View.extend({id:"notifier",events:{click:"hide"},options:{position:"center center",text:"ok",left:0,top:0,duration:2E3,leaveOpen:!1,mode:"warn"},constructor:function(a){Backbone.View.call(this,a);$(document.body).append(this.el);_.bindAll(this,"show","hide")},show:function(a){a=_.extend({},this.options,a);this.setMode(a.mode,"style");$(this.el).html(a.text).fadeIn("fast");$(this.el).show();this.timeout&&clearTimeout(this.timeout);if(!a.leaveOpen)this.timeout=setTimeout(this.hide,
a.duration)},hide:function(a){this.timeout=null;a===!0?$(this.el).hide():$(this.el).fadeOut("fast")}});
dc.ui.Scroll=Backbone.View.extend({OVERLAP_MARGIN:50,SPEED:500,className:"scroll",events:{"click .scroll_up":"scrollUp","click .scroll_down":"scrollDown",mousewheel:"_mouseScroll"},constructor:function(a){Backbone.View.call(this);this.content=$(a);this.upButton=this.make("div",{"class":"scroll_up"});this.downButton=this.make("div",{"class":"scroll_down"});_.bindAll(this,"check")},render:function(){this.content.addClass("scroll_content");this.content.wrap(this.el);this.setElement($(this.content).closest(".scroll")[0]);
this.content.before(this.upButton);this.content.after(this.downButton);$(window).resize(this.check);return this},scrollUp:function(){var a=this.content[0].scrollTop-(this.content.innerHeight()-this.OVERLAP_MARGIN);this.content.animate({scrollTop:a},this.SPEED,null,_.bind(this.setPosition,this,a))},scrollDown:function(){var a=this.content[0].scrollTop+(this.content.innerHeight()-this.OVERLAP_MARGIN);this.content.animate({scrollTop:a},this.SPEED,null,_.bind(this.setPosition,this,a))},check:function(){var a=
this.hasOverflow();this.setMode(a?"is":"not","active");a||this.setMode(null,"position");this.setPosition(this.content[0].scrollTop)},checkLater:function(){_.defer(this.check)},hasOverflow:function(){return this.content.innerHeight()<this.content[0].scrollHeight},setPosition:function(a){a=a<=0?"top":a+this.content.innerHeight()>=this.content[0].scrollHeight?"bottom":"middle";this.modes.position!=a&&this.setMode(a,"position")},_mouseScroll:function(a,b){if(!(this.modes.active=="not"||b>=0&&this.modes.position==
"top"||b<=0&&this.modes.position=="bottom")){var c=this.content[0].scrollTop-b;this.content[0].scrollTop=c;this.setPosition(c);return!1}}});dc.ui.spinner={show:function(){this.ensureElement();this.el.stop(!0,!0).fadeIn("fast")},hide:function(){this.ensureElement();this.el.stop(!0,!0).fadeOut("fast",function(){$(this).css({display:"none"})})},ensureElement:function(){this.el||(this.el=$("#spinner"))}};_.bindAll(dc.ui.spinner,"show","hide");
dc.ui.Tooltip=Backbone.View.extend({id:"tooltip",className:"interface",OFFSET:5,MAX_WIDTH:320,options:{text:"info",left:0,top:0},constructor:function(a){Backbone.View.call(this,a);this._open=!1;_.bindAll(this,"hide","show");$(this.el).html(JST["common/tooltip"]());this._title=this.$("#tooltip_title");this._content=this.$("#tooltip_text");$(document.body).append(this.el)},show:function(a){a=_.extend(this.options,a);a.top+=this.OFFSET;this.setMode(a.mode,"style");this._title.html(a.title);this._content.html(a.text);
var b=$(this.el).outerWidth(),c=$(window).width()-this.OFFSET-b;a.left+=a.left<c?this.OFFSET:-(b+2);$(this.el).css({top:a.top,left:a.left});this._open||this.fadeIn();a.leaveOpen||$(document).bind("mouseover",this.hide);this._open=!0},hide:function(){if(this._open)this._open=!1,$(document).unbind("mouseover",this.hide),this.fadeOut()},fadeIn:function(){$.browser.msie?$(this.el).show():$(this.el).stop(!0,!0).fadeIn("fast")},fadeOut:function(){$.browser.msie?$(this.el).hide():$(this.el).stop(!0,!0).fadeOut("fast")}});
dc.ui.AccountDialog=dc.ui.Dialog.extend({id:"account_list",className:"account_list dialog",events:{"click .ok":"close","click .new_account":"newAccount"},constructor:function(){dc.ui.Dialog.call(this,{mode:"custom",title:"Manage Accounts: "+dc.account.organization.name,information:"group: "+dc.account.organization.slug});Accounts.bind("reset",_.bind(this._renderAccounts,this));this._open=this._rendered=!1;$(this.el).hide()},render:function(){dc.ui.Dialog.prototype.render.call(this);this._rendered=
!0;this._container=this.$(".custom");this._container.setMode("not","draggable");this._container.html(JST["account/dialog"]({}));Accounts.current().isAdmin()&&this.addControl(this.make("div",{"class":"minibutton dark new_account",style:"width: 90px;"},"New Account"));this.list=this.$(".account_list_content");this._renderAccounts();return this},open:function(){this._open=!0;this._rendered?($(document.body).addClass("overlay"),this.center(),$(this.el).show()):this.render()},close:function(){dc.ui.notifier.hide();
$(this.el).hide();$(document.body).removeClass("overlay");this._open=!1},isOpen:function(){return this._open},newAccount:function(){this.list.append((new dc.ui.AccountView({model:new dc.model.Account,kind:"row",dialog:this})).render("edit").el);this._container[0].scrollTop=this._container[0].scrollHeight},_renderAccounts:function(){dc.ui.spinner.hide();this.list.append(Accounts.map(function(a){return(new dc.ui.AccountView({model:a,kind:"row"})).render().el}));$(this.el).show();this.center()}});
dc.ui.AccountView=Backbone.View.extend({AVATAR_SIZES:{badge:30,row:25,admin:25,collaborator:25,reviewer:25},TAGS:{badge:"div",row:"tr",admin:"tr",collaborator:"tr",reviewer:"tr"},events:{"click .edit_account":"showEdit","click .change_password":"promptPasswordChange","click .resend_welcome":"resendWelcomeEmail","click .admin_link":"_openAccounts","click .save_changes":"_doneEditing","click .cancel_changes":"_cancelEditing","click .disable_account":"_disableAccount","click .enable_account":"_enableAccount",
"click .login_as .minibutton":"_loginAsAccount"},constructor:function(a){this.modes={};this.kind=a.kind;this.tagName=this.TAGS[this.kind];this.className="account_view "+this.kind+(this.tagName=="tr"?" not_draggable":"");this.dialog=a.dialog||dc.app.accounts;Backbone.View.call(this,a);this.template=JST["account/"+this.kind];_.bindAll(this,"_onSuccess","_onError");this._boundRender=_.bind(this.render,this,"display");this.observe(this.model)},observe:function(a){this.model&&this.model.unbind("change",
this._boundRender);this.model=a;this.model.bind("change",this._boundRender)},render:function(a,b){if(this.modes.view!="edit"){a=a||"display";b=b||{};var c=_.extend({account:this.model,email:this.model.get("email"),size:this.size(),current:Accounts.current()},b);this.isRow()&&this.setMode(a,"view");$(this.el).html(this.template(c));a=="edit"&&this.$("option.role_"+this.model.get("role")).attr({selected:"selected"});this.model.isPending()&&$(this.el).addClass("pending");this._loadAvatar();this._setPlaceholders();
this.setMode(this.model.ROLE_NAMES[this.model.get("role")],"role");return this}},size:function(){return this.AVATAR_SIZES[this.kind]},isRow:function(){return this.kind=="row"||this.kind=="admin"||this.kind=="reviewer"},serialize:function(){var a=this.$("input, select").serializeJSON();if(a.role)a.role=parseInt(a.role,10);return a},showEdit:function(){this.$("option.role_"+this.model.get("role")).attr({selected:"selected"});this.setMode("edit","view")},promptPasswordChange:function(){this.dialog.close();
dc.ui.Dialog.prompt("Enter your new password:","",_.bind(function(a){this.model.save({password:a},{success:_.bind(function(){dc.ui.notifier.show({text:"Password updated",duration:5E3,mode:"info"})},this)});return!0},this),{password:!0,mode:"short_prompt"})},resendWelcomeEmail:function(){dc.ui.spinner.show();var a=this.model;a.resendWelcomeEmail({success:_.bind(function(){dc.ui.spinner.hide();dc.ui.notifier.show({mode:"info",text:"A welcome message has been sent to "+a.get("email")+"."})},this)})},
_setPlaceholders:function(){this.$("input[name=first_name], input[name=last_name], input[name=email]").placeholder()},_loadAvatar:function(){var a=new Image,b=this.model.gravatarUrl(this.size());a.onload=_.bind(function(){this.$("img.avatar").attr({src:b})},this);a.src=b},_openAccounts:function(a){a.preventDefault();this.dialog.open()},_doneEditing:function(){var a=this.serialize(),b={success:this._onSuccess,error:this._onError};if(this.model.isNew()){if(!a.email)return $(this.el).remove();dc.ui.spinner.show();
this.model.newRecord=!0;this.model.set(a);Accounts.create(this.model,b)}else!this.model.invalid&&!this.model.changedAttributes(a)?this.setMode("display","view"):(dc.ui.spinner.show(),this.model.save(a,b))},_cancelEditing:function(){this.setMode("display","view")},_disableAccount:function(){this.dialog.isOpen()&&this.dialog.close();var a=dc.ui.Dialog.confirm(null,_.bind(function(){this.setMode("display","view");this.model.save({role:this.model.DISABLED});dc.ui.notifier.show({text:this.model.fullName()+
" has been disabled.",duration:5E3,mode:"info"});return!0},this),{id:"disable_account_confirm",title:"Really disable "+this.model.fullName()+"'s account?",description:this.model.fullName()+" will not be able to log in to DocumentCloud. Public documents and annotations provided by "+this.model.fullName()+' will remain available. <span class="contact_support text_link">Contact support</span> to completely purge '+this.model.fullName()+"'s account.",saveText:"Disable"});$(".contact_support",a.el).bind("click",
function(){a.close();dc.ui.Dialog.contact()})},_enableAccount:function(){this.setMode("display","view");this.model.save({role:this.model.CONTRIBUTOR})},_loginAsAccount:function(){window.location="/admin/login_as?email="+encodeURIComponent(this.model.get("email"))},_onSuccess:function(a){this.model.invalid=!1;this.setMode("display","view");this.model.trigger("change");dc.ui.spinner.hide();if(this.model.newRecord)this.model.newRecord=!1,dc.ui.notifier.show({text:"Signup sent to "+a.get("email"),duration:5E3,
mode:"info"})},_onError:function(a,b){b=JSON.parse(b.responseText);a.invalid=!0;dc.ui.spinner.hide();this.showEdit();this.dialog.error(b.errors&&b.errors[0]||"Could not add the account.")}});
dc.ui.ShareDialog=dc.ui.Dialog.extend({id:"share_dialog",className:"dialog",events:{"click .close":"close","click .preview":"previewEmail","click .next":"_nextStep","click .previous":"_previousStep","click .add_reviewer":"_showEnterEmail","click .cancel_add":"_cancelAddReviewer","click .minibutton.add":"_submitAddReviewer","click .remove_reviewer":"_removeReviewer","click .resend_reviewer":"_resendInstructions","keypress .reviewer_management_email":"_maybeAddReviewer","keypress .reviewer_management_firstname":"_maybeAddReviewer",
"keypress .reviewer_management_lastname":"_maybeAddReviewer"},EMAIL_DIALOG_OPTIONS:{mode:"short_prompt",description:"Enter the email address of the first reviewer to invite:",saveText:"Next",closeText:"Cancel"},initialize:function(a){_.bindAll(this,"_renderReviewers","_refreshReviewers","_onAddSuccess","_onAddError","_onRemoveSuccess","_onRemoveError","_showEnterEmail","_nextStep");this.renderedAccounts={};this._boundRender=[];this.currentStep=1;this.newReviewers=[];this.docs=new dc.model.DocumentSet(a.docs);
$(this.el).hide().empty();dc.ui.spinner.show();this.fetchReviewers();this.docs.all(function(a){return a.get("reviewer_count")==0})&&this.renderEmailDialog()},render:function(){dc.ui.Dialog.prototype.render.call(this);this.setMode("share","dialog");this._container=this.$(".custom");this._container.html(JST["account/share_dialog"]({defaultAvatar:dc.model.Account.prototype.DEFAULT_AVATAR,docCount:this.docs.length}));this._next=this.$(".next");this._previous=this.$(".previous");this._emailEl=this.$(".reviewer_management input[name=email]");
$(this.el).show();dc.ui.spinner.hide();this._setPlaceholders();this._setStep();this._enabledNextButton();this.center();return this},reviewers:function(){return _.flatten(this.docs.map(function(a){return a.reviewers.models}))},accountsToEmail:function(){return _.uniq(_.filter(this.reviewers(),function(a){return a.get("needsEmail")}))},eachReviewer:function(a){_.each(this.reviewers(),_.bind(a,this))},docsForReviewers:function(a){return this.docs.select(function(b){return _.any(a,function(a){return b.reviewers.get(a)})})},
renderEmailDialog:function(){var a="Share "+(this.docs.length==1?'"'+dc.inflector.truncate(this.docs.first().get("title"),35)+'"':this.docs.length+" Documents");this.showingEmailDialog=!0;dc.ui.spinner.hide();dc.ui.Dialog.prompt(a,"",_.bind(function(a){this.showingEmailDialog=!1;this._renderReviewers();this._showEnterEmail();this._focusEmail(a);this._submitAddReviewer();return!0},this),this.EMAIL_DIALOG_OPTIONS)},managementError:function(a,b){this.$(".reviewer_management .error").toggleClass("error_white",
!b).text(a)},customMessage:function(){return dc.inflector.trim(this.$(".email_message").val())},previewEmail:function(){var a=this.docsForReviewers(_.pluck(this.accountsToEmail(),"id"));a=_.map(a,function(a){return"document_ids[]="+a.id}).join("&");window.open("/reviewers/preview_email?"+a+"&message="+encodeURIComponent(this.customMessage()))},fetchReviewers:function(){$.ajax({url:"/reviewers",type:"GET",data:{document_ids:this.docs.pluck("id")},success:this._refreshReviewers,error:this._renderReviewers})},
_refreshReviewers:function(a){this.showingEmailDialog||(_.each(a.reviewers,_.bind(function(a,c){this.docs.get(c).reviewers.reset(a)},this)),this._renderReviewers())},_renderReviewers:function(){this.render();var a=[];this._countDocuments();this.renderedAccounts={};this.eachReviewer(function(b){(b=this._renderReviewer(b))&&a.push(b)});this.$(".account_list_content tr:not(.reviewer_management)").remove();this.$(".account_list_content").prepend(a);this.$(".document_reviewers_empty").toggle(!_.keys(this.renderedAccounts).length);
this._cancelAddReviewer()},_setPlaceholders:function(){this.$("input[name=first_name], input[name=last_name]").placeholder();this._emailEl.placeholder()},_countDocuments:function(){var a=this.accountDocumentCounts={};this.eachReviewer(function(b){a[b.id]=(a[b.id]||0)+1})},_renderReviewer:function(a){if(!this.renderedAccounts[a.id]){var b=this.renderedAccounts[a.id]=new dc.ui.AccountView({model:a,kind:"reviewer",dialog:this});this._rerenderReviewer(a);a.bind("change:needsEmail",_.bind(this._enabledNextButton,
this));a.bind("change:needsEmail",_.bind(this._rerenderReviewer,this,a));this._observeReviewer(a,b);return b.el}},_rerenderReviewer:function(a){this.renderedAccounts[a.id].render("display",{documentCount:this.accountDocumentCounts[a.id],documentsCount:this.docs.length})},_observeReviewer:function(a,b){a.unbind("change",b._boundRender);this._boundRender[a.id]&&a.unbind("change",this._boundRender[a.id]);this._boundRender[a.id]=_.bind(this._rerenderReviewer,this,a);a.bind("change",this._boundRender[a.id])},
_showEnterEmail:function(){if(this.showingManagement)return this._submitAddReviewer(this._showEnterEmail);this.showingManagement=!0;this.$(".reviewer_management").show();this.$(".document_reviewers_empty").hide();this._focusEmail();this._enabledNextButton()},_focusEmail:function(a){var b=this.$(".document_reviewers");b.attr("scrollTop",b.attr("scrollHeight")+100);this._emailEl.focus();a&&this._emailEl.val(a);(a=this._emailEl.val())||this.managementError("Please enter an email address.")},_cancelAddReviewer:function(){this.showingManagement=
!1;this.$(".reviewer_management").hide();this.$(".reviewer_management input").val("");this.$(".document_reviewers_empty").toggle(!_.keys(this.renderedAccounts).length);this._enabledNextButton()},_maybeAddReviewer:function(a){a.which==13&&this._submitAddReviewer()},_submitAddReviewer:function(a,b){var c=this._emailEl.val();if(!c.length&&this.accountsToEmail().length&&b)return this._cancelAddReviewer(),a();if(!dc.app.validator.check(c,"email"))return this._focusEmail(),this.managementError("Please enter a valid email address.",
!0),!1;this.showSpinner();$.ajax({url:"/reviewers",type:"POST",data:{email:dc.inflector.trim(c),first_name:dc.inflector.trim(this.$(".reviewer_management input[name=first_name]").val()),last_name:dc.inflector.trim(this.$(".reviewer_management input[name=last_name]").val()),document_ids:this.docs.pluck("id")},success:_.bind(function(b){this._onAddSuccess(b,a)},this),error:this._onAddError})},_onAddSuccess:function(a,b){_.each(a.documents,function(a){Documents.get(a.id).set(a)});var c=new dc.model.Account(a.account);
this.docs.each(function(a){var b=a.reviewers.get(c.id);b||a.reviewers.add(c);(b||c).set({needsEmail:!0})});this.showingManagement=!1;this._renderReviewers();b&&b();this._enabledNextButton()},_onAddError:function(a){var b=a.status;a=JSON.parse(a.responseText);a.errors&&_.any(a.errors,function(a){a=a.toLowerCase();return a.indexOf("first name")!=-1||a.indexOf("last name")!=-1})?(this._showReviewerNameInputs(),this.managementError("Please provide the reviewer's name.")):a.errors?this.managementError(a.errors[0],
!0):b==403?this.error("You are not allowed to add reviewers."):this.managementError("Please enter the email address of a reviewer.",!0);this.hideSpinner();this._focusEmail();this._enabledNextButton()},_showReviewerNameInputs:function(){this.$("input[name=first_name], input[name=last_name]").show();this.$(".enter_full_name_label").show();this.$(".enter_email_label").hide();this._setPlaceholders()},_removeReviewer:function(a){this.showSpinner();var b=parseInt($(a.target).attr("data-account-id"),10),
c=_.detect(this.reviewers(),function(a){return a.id==b});a=this.docsForReviewers([c.id]);var d=_.pluck(a,"id");$.ajax({url:"/reviewers/"+b,type:"DELETE",data:{account_id:b,document_ids:d},success:_.bind(function(a){this._onRemoveSuccess(a,d,c)},this),error:this._onRemoveError});this._enabledNextButton()},_onRemoveSuccess:function(a,b,c){_.each(a,function(a){Documents.get(a.id).set(a)});this.docs.each(_.bind(function(a){_.contains(b,a.id)&&a.reviewers.remove(c)},this));dc.ui.notifier.show({text:c.get("email")+
" is no longer a reviewer on "+b.length+dc.inflector.pluralize(" document",b.length),duration:5E3,mode:"info"});this._renderReviewers();this._enabledNextButton()},_onRemoveError:function(a){this.hideSpinner();a.status==403?this.error("You are not allowed to remove reviewers."):this.error("There was a problem removing the reviewer.");this._enabledNextButton()},_resendInstructions:function(a){var b=parseInt($(a.target).attr("data-account-id"),10);this.eachReviewer(function(a){a.id==b&&a.set({needsEmail:!0})});
this._enabledNextButton();this._nextStep()},_setEmailDescription:function(){var a=this.accountsToEmail();a="DocumentCloud will email reviewing instructions to "+dc.inflector.commify(_.map(a,function(a){return a.fullName()}),{conjunction:"and"})+". If you wish, you may add a personal&nbsp;message.";this.$(".email_description").html(a)},_sendInstructions:function(){var a=this.accountsToEmail();this.showSpinner();this._next.setMode("not","enabled");this._next.html("Sending...");var b=_.pluck(a,"id"),
c=this.docsForReviewers(b),d=_.pluck(c,"id");c=this.customMessage();$.ajax({url:"/reviewers/send_email",type:"POST",data:{account_ids:b,document_ids:d,message:c},success:_.bind(function(){var b="Instructions for reviewing "+(d.length==1?'"'+dc.inflector.truncate(this.docs.get(d[0]).get("title"),30)+'"':d.length+" documents")+" sent to "+(a.length==1?a[0].get("email"):a.length+" people")+".";dc.ui.notifier.show({text:b,duration:5E3,mode:"info"});this.hideSpinner();this.close()},this),error:_.bind(function(){this.hideSpinner();
this.error("Your instructions were not sent. Contact support for help troubleshooting.");this._setStep();this._enabledNextButton()},this)})},_enabledNextButton:function(){this._nextEnabled=this.accountsToEmail().length||this.showingManagement;this._next.setMode(this._nextEnabled?"is":"not","enabled")},_setStep:function(){this.title(this._displayTitle());var a=this.currentStep==2;this._next.html(a?"Send":"Next &raquo;");this.setMode("p"+this.currentStep,"step");a&&this._setEmailDescription()},_displayTitle:function(){if(this.currentStep==
1)return this.docs.length==1?'Share "'+dc.inflector.truncate(this.docs.first().get("title"),30)+'"':"Share "+this.docs.length+" Documents";else{var a=this.accountsToEmail();return"Email Instructions to "+(a.length>1?a.length+" Reviewers":a[0].fullName())}},_nextStep:function(){if(this._nextEnabled){if(this.showingManagement)return this._submitAddReviewer(this._nextStep,!0);this.currentStep>=2?this._sendInstructions():(this.currentStep+=1,this._setStep())}},_previousStep:function(){this.currentStep>
1&&(this.currentStep-=1);this._setStep()}});
dc.ui.Document=Backbone.View.extend({PAGE_LIMIT:50,ERROR_MESSAGE:'<span class="interface">Our system was unable to process     this document. We\'ve been notified of the problem and periodically review     these errors. Please review our     <span class="text_link troubleshoot">troubleshooting suggestions</span> or     <span class="text_link contact_us">contact us</span> for immediate assistance.</span>',className:"document",events:{"click .doc_title":"select","contextmenu .doc_title":"showMenu",
"dblclick .doc_title":"viewDocument","click .icon.doc":"select","contextmenu .icon.doc":"showMenu","dblclick .icon.doc":"viewDocument","click .show_notes":"toggleNotes","click .title .edit_glyph":"openDialog","click .datalines .edit_glyph":"openDataDialog","click .title .lock":"editAccessLevel","click .title .published":"viewPublishedDocuments","click .page_icon":"_openPage","click .reviewer_count":"_openShareDialog","click .occurrence":"_openPage","click .mention b":"_openPage","click .pages .cancel_search":"_hidePages",
"click .page_count":"_togglePageImages","click .search_account":"searchAccount","click .search_group":"searchOrganization","click .search_source":"searchSource","click .change_publish_at":"editPublishAt","click .troubleshoot":"openTroubleshooting","click .contact_us":"openContactUs","click .open_pages":"openPagesInViewer","click .show_mentions":"fetchAllMentions","click .page_list .left":"previousPage","click .page_list .right":"nextPage","click .data_item":"searchData"},constructor:function(a){Backbone.View.call(this,
a);this.el.id="document_"+this.model.id;this._currentPage=0;this._showingPages=!1;this.setMode(this.model.get("annotation_count")?"owns":"no","notes");_.bindAll(this,"_onDocumentChange","_onDrop","_addNote","_renderNotes","_renderPages","_renderEntities","_setSelected","viewDocuments","viewPublishedDocuments","openDialog","setAccessLevelAll","viewEntities","hideNotes","viewPages","viewChosenPages","deleteDocuments","removeFromProject","_openShareDialog","openDataDialog","focus");this.model.bind("change",
this._onDocumentChange);this.model.bind("change:selected",this._setSelected);this.model.bind("focus",this.focus);this.model.bind("view:pages",this.viewPages);this.model.bind("notes:hide",this.hideNotes);this.model.notes.bind("add",this._addNote);this.model.notes.bind("reset",this._renderNotes);this.model.entities.bind("load",this._renderEntities);this.model.pageEntities.bind("reset",this._renderPages)},render:function(a){a||(a={});var b=this;this.model.get("title");var c=_.extend(this.model.toJSON(),
{model:this.model,created_at:this.model.get("created_at").replace(/\s/g,"&nbsp;"),icon:this._iconAttributes(),thumbnail_url:this._thumbnailURL(),data:this.model.sortedData()});if(dc.app.paginator&&dc.app.paginator.mini)c.title=dc.inflector.truncateWords(c.title,50);$(this.el).html(JST["document/tile"](c));this._displayDescription();dc.account&&this.$(".doc.icon").draggable({ghost:!0,onDrop:this._onDrop});this.notesEl=this.$(".notes");this.entitiesEl=this.$(".entities");this.pagesEl=this.$(".pages");
this.entitiesView=new dc.ui.SparkEntities({model:this.model,parent:this,container:this.$(".entities")});this.model.notes.each(function(a){b._addNote(a)});a.notes&&this.model.hasLoadedNotes()&&this.setMode("has","notes");this.setMode(dc.access.NAMES[this.model.get("access")],"access");this.setMode(this.model.allowedToEdit()?"is":"not","editable");this._setSelected();return this},select:function(a){a.preventDefault();if(this.model.get("selectable")){var b=this.model.get("selected"),c=dc.app.hotkeys;
a=Documents.firstSelection||Documents.selected()[0];if(c.command||c.control)this.model.set({selected:!b});else if(c.shift&&a){b=Documents.indexOf(this.model);a=Documents.indexOf(a);var d=Math.min(b,a),e=Math.max(b,a);Documents.each(function(a,b){a.set({selected:b>=d&&b<=e})})}else Documents.deselectAll(),this.model.set({selected:!0})}},viewDocument:function(){this.model.openAppropriateVersion();return!1},viewPublishedDocuments:function(){var a=Documents.chosen(this.model);a.length&&_.each(a,function(a){a.isPublished()&&
a.openPublishedViewer()})},viewDocuments:function(){var a=Documents.chosen(this.model);a.length&&_.each(a,function(a){a.openViewer()})},viewPDF:function(){this.model.openPDF()},viewFullText:function(){this.model.openText()},viewEntities:function(){var a=Documents.chosen(this.model);dc.app.paginator.ensureRows(function(){dc.model.EntitySet.populateDocuments(a)},a[0])},hideNotes:function(){this.setMode(this.model.hasNotes()?"owns":"no","notes")},downloadViewer:function(){this.checkBusy()||this.model.downloadViewer()},
openDialog:function(){this.modes.editable=="is"&&(this.model.checkBusy()||dc.ui.DocumentDialog.open(this.model))},openDataDialog:function(){this.modes.editable=="is"&&(this.model.checkBusy()||dc.ui.DocumentDataDialog.open(this.model))},openPagesInViewer:function(){this.model.openViewer("#pages")},fetchAllMentions:function(){this.model.fetchMentions(dc.app.searchBox.value())},previousPage:function(){this._currentPage--;this.viewPages()},nextPage:function(){this._currentPage++;this.viewPages()},toggleNotes:function(a){a.stopPropagation();
a=_.bind(function(){var a=Documents.get(this.model.id);if(this.modes.notes=="has")return this.setMode("owns","notes");if(!a.checkBusy()){if(a.hasLoadedNotes())return this._renderNotes(),this.setMode("has","notes");dc.ui.spinner.show("loading notes");a.notes.fetch({success:function(){dc.ui.spinner.hide();window.scroll(0,$("#document_"+a.id).offset().top-100)}})}},this);dc.app.paginator.mini?dc.app.paginator.toggleSize(a,this.model):a()},viewPages:function(){this._showingPages=!0;this.model.ensurePerPageNoteCounts(_.bind(function(a){var b=
this._currentPage*this.PAGE_LIMIT+1,c=this.model.get("page_count");this.pagesEl.html(JST["document/page_images"]({doc:this.model,start:b,end:Math.min(b+this.PAGE_LIMIT-1,c),total:c,limit:this.PAGE_LIMIT,notes:a}))},this))},viewChosenPages:function(){var a=Documents.chosen(this.model);dc.app.paginator.ensureRows(function(){_.each(a,function(a){(a=Documents.get(a.id))&&a.trigger("view:pages")})},a[0])},deleteDocuments:function(){Documents.verifyDestroy(Documents.chosen(this.model))},removeFromProject:function(){Projects.firstSelected().removeDocuments(Documents.chosen(this.model))},
searchAccount:function(){dc.app.searcher.addToSearch("account",this.model.get("account_slug"))},searchOrganization:function(){dc.app.searcher.addToSearch("group",this.model.get("organization_slug"))},searchSource:function(){dc.app.searcher.addToSearch("source",this.model.get("source").replace(/"/g,'\\"'))},searchData:function(a){var b=$(a.currentTarget);a=b.find(".data_key").text().replace(/:$/,"");b=b.find(".data_value").text();dc.app.searcher.toggleSearch(a,b)},editAccessLevel:function(){Documents.editAccess([this.model])},
setAccessLevelAll:function(){Documents.editAccess(Documents.chosen(this.model))},editPublishAt:function(){new dc.ui.PublicationDateDialog([this.model])},focus:function(){window.scroll(0,$(this.el).offset().top-100)},openTroubleshooting:function(){dc.app.workspace.help.openPage("troubleshooting")},openContactUs:function(){dc.ui.Dialog.contact()},_openShareDialog:function(){dc.app.shareDialog=new dc.ui.ShareDialog({docs:[this.model],mode:"custom"})},showMenu:function(a){a.preventDefault();var b=dc.ui.Document.sharedMenu||
(dc.ui.Document.sharedMenu=new dc.ui.Menu({id:"document_menu",standalone:!0})),c=Documents.chosen(this.model).length;if(c){c=dc.inflector.pluralize("Delete Document",c);b.clear();var d=[{title:"Open",onClick:this.viewDocuments}];this.model.isPublished()&&d.push({title:"Open Published Version",onClick:this.viewPublishedDocuments});d.push({title:"View Entities",onClick:this.viewEntities});d.push({title:"View Pages",onClick:this.viewChosenPages});this.model.allowedToEdit()&&(d=d.concat([{title:"Edit Document Information",
onClick:this.openDialog},{title:"Edit Document Data",onClick:this.openDataDialog},{title:"Set Access Level",onClick:this.setAccessLevelAll},{title:c,onClick:this.deleteDocuments,attrs:{"class":"warn"}}]));Projects.firstSelected()&&d.splice(d.length-(d[d.length-1].onClick==this.deleteDocuments?1:0),0,{title:"Remove from this Project",onClick:this.removeFromProject});b.addItems(d);b.render().open().content.css({top:a.pageY,left:a.pageX})}},_iconAttributes:function(){switch(this.model.get("access")){case dc.access.PENDING:return{"class":"icon main_icon document_tool spinner",
title:"Uploading..."};case dc.access.ERROR:return{"class":"icon main_icon document_tool alert_gray",title:"Broken document"};case dc.access.ORGANIZATION:return{"class":"icon main_icon document_tool lock",title:"Private to "+(dc.account?dc.account.organization.name:"your organization")};case dc.access.PRIVATE:return{"class":"icon main_icon document_tool lock",title:"Private"};default:if(this.model.isPublished())return{"class":"icon main_icon document_tool published",title:"Open Published Version"};
return{"class":"icon main_icon document_tool hidden",iconless:!0}}},_thumbnailURL:function(){switch(this.model.get("access")){case dc.access.PENDING:return"/images/embed/documents/processing.png";case dc.access.ERROR:return"/images/embed/documents/failed.png";default:return this.model.get("thumbnail_url")}},_displayDescription:function(){var a=this.$(".description_text");if(this.model.get("access")==dc.access.ERROR)return a.html(this.ERROR_MESSAGE);a.text(dc.inflector.stripTags(this.model.get("description")||
""))},_setSelected:function(){this.setMode(this.model.get("selected")?"is":"not","selected")},_onDocumentChange:function(){this.model.hasChanged("selected")||this.render()},_addNote:function(a){a=new dc.ui.Note({model:a,collection:this.model.notes});this.notesEl.append(a.render().el);a.center()},_renderNotes:function(){this.notesEl.empty();this.model.notes.each(this._addNote);this.setMode(this.model.ignoreNotes?"owns":"has","notes")},_renderEntities:function(){this.model.entities.length?this.entitiesView.show():
dc.ui.notifier.show({text:'"'+this.model.get("title")+'" has no entities to display.'})},_togglePageImages:function(){this._showingPages?this._hidePages():this.viewPages()},_renderPages:function(){this._showingPages=!1;this.pagesEl.html(JST["document/pages"]({doc:this.model}));this.focus()},_hidePages:function(){this._showingPages=!1;this._currentPage=0;this.pagesEl.html("")},_openPage:function(a){var b=$(a.target).closest(".page");a=b.attr("data-page");var c=b.attr("data-id");b.hasClass("mention")?
(b=b.find("b").text(),this.model.openViewer("#search/p"+a+"/"+encodeURIComponent(b))):c?this.model.openEntity(c,b.attr("data-offset")):this.model.openViewer("#document/p"+a)},_onDrop:function(a){var b=[this.model],c=Documents.selected();c.length&&_.include(c,this.model)&&(b=c);var d=a.pageX,e=a.pageY;$("#organizer .project").each(function(){var a=$(this).offset().top,c=$(this).offset().left,k=c+$(this).outerWidth(),l=a+$(this).outerHeight();if(c<d&&k>d&&a<e&&l>e)return(a=Projects.getByCid($(this).attr("data-project-cid")))&&
a.addDocuments(b),!1})}});
dc.ui.DocumentDataDialog=dc.ui.Dialog.extend({className:"dialog datalog",dataEvents:{"click .minus":"_removeDatum","click .plus":"_addDatum","click .remove_all":"_removeAll"},constructor:function(a){this.events=_.extend({},this.events,this.dataEvents);this.docs=a;this.multiple=a.length>1;this.originalData=Documents.sharedData(this.docs);this._rowTemplate=JST["document/data_dialog_row"];dc.ui.Dialog.call(this,{mode:"custom",title:"Edit Data for "+this._title(),saveText:"Save"});this.render();$(document.body).append(this.el)},
render:function(){dc.ui.Dialog.prototype.render.call(this);var a=Documents.sortData(this.originalData),b=_.any(this.docs,function(a){return!_.isEmpty(a.get("data"))});this._container=this.$(".custom");this._container.html(JST["document/data_dialog"]({multiple:this.multiple,removeAll:b,data:a}));this.checkNoData();return this},checkNoData:function(){this.$(".data_row").length||this._container.find(".rows").html(this._rowTemplate({key:"",value:"",minus:!1})+this._rowTemplate({key:"",value:"",minus:!0})+
this._rowTemplate({key:"",value:"",minus:!0}))},serialize:function(){var a={};_.each(this.$(".data_row"),function(b){a[$(b).find(".key").val()]=$(b).find(".value").val()});return a},confirm:function(){var a=this.serialize(),b=_.detect(_.keys(a),function(a){return _.include(dc.searchPrefixes,a.toLowerCase())});if(b)this.error('"'+b+'" cannot be used as a key');else{var c=_.without.apply(_,[_.keys(this.originalData)].concat(_.keys(a)));_.each(this.docs,function(b){b.mergeData(a,c)});this.close()}},
_removeDatum:function(a){$(a.target).closest(".data_row").remove();this.checkNoData()},_addDatum:function(a){var b=$(this._rowTemplate({key:"",value:"",minus:!0}));$(a.target).closest(".data_row").after(b);b.find(".key").focus();this.checkNoData()},_removeAll:function(){this.close();var a=this.docs,b="Are you sure you want to remove all data from "+this._title()+"?";dc.ui.Dialog.confirm(b,function(){_.each(a,function(a){a.save({data:{}})});return!0});this.close()},_title:function(){if(this.multiple)return this.docs.length+
" Documents";return'"'+dc.inflector.truncate(this.docs[0].get("title"),25)+'"'},_returnCloses:function(){return!0}},{open:function(a){a=Documents.chosen(a);a.length&&Documents.allowedToEdit(a)&&new dc.ui.DocumentDataDialog(a)}});
dc.ui.DocumentDialog=dc.ui.Dialog.extend({ATTRIBUTES:["title","source","description","related_article","remote_url","access"],id:"edit_document_dialog",className:"dialog docalog",events:{"click .cancel":"close","click .ok":"save","focus input":"_addFocus","focus textarea":"_addFocus","blur input":"_removeFocus","blur textarea":"_removeFocus","click .delete":"destroy","change .attribute":"_markChanged"},constructor:function(a){this.docs=a;this.multiple=a.length>1;a="Edit "+this._title();dc.ui.Dialog.call(this,
{mode:"custom",title:a,editor:!0});this.render();$(document.body).append(this.el)},render:function(){dc.ui.Dialog.prototype.render.call(this);this._container=this.$(".custom");this._container.html(JST["document/document_dialog"]({docs:this.docs,multiple:this.multiple}));var a=this._sharedAttributes();a.access=a.access||dc.access.PRIVATE;_.each(this.ATTRIBUTES,_.bind(function(b){$("#document_edit_"+b).val(a[b]||"")},this));this.center();return this},save:function(){var a=this._sharedAttributes(),b=
{};_.each(this.ATTRIBUTES,_.bind(function(c){var d=this.$("#document_edit_"+c);if(d.length){var e=d.val();c=="access"&&(e=parseInt(e,10));if(c=="related_article"||c=="remote_url")e=dc.inflector.normalizeUrl(e);e!=a[c]&&d.hasClass("change")&&(b[c]=e)}},this));if(_.any(["related_article","remote_url"],_.bind(function(a){if(b[a]&&!this.validateUrl(b[a]))return this.$("#document_edit_"+a).addClass("error"),!0},this)))return!1;this.close();_.isEmpty(b)||(_.each(this.docs,function(a){a.save(b)}),_.any(this.docs,
function(a){return a.suppressNotifier})||dc.ui.notifier.show({mode:"info",text:"Updated "+this.docs.length+" "+dc.inflector.pluralize("document",this.docs.length)}))},destroy:function(){this.close();Documents.selected().length==0&&this.docs[0].set({selected:!0});Documents.verifyDestroy(Documents.selected())},_title:function(){if(this.multiple)return this.docs.length+" Documents";return'"'+dc.inflector.truncate(this.docs[0].get("title"),35)+'"'},_markChanged:function(a){$(a.target).addClass("change")},
_sharedAttributes:function(){return _.reduce(this.ATTRIBUTES,_.bind(function(a,b){a[b]=Documents.sharedAttribute(this.docs,b);return a},this),{})}},{open:function(a){a=Documents.chosen(a);a.length&&Documents.allowedToEdit(a)&&new dc.ui.DocumentDialog(a)}});
dc.ui.DocumentEmbedDialog=dc.ui.Dialog.extend({events:{"click .preview":"preview","change select":"update","click select":"update","keyup input":"update","focus input":"update","click input":"update","change input":"update","change .viewer_open_to":"_renderOpenTo","click .next":"nextStep","click .previous":"previousStep","click .close":"close","click .snippet":"selectSnippet","click .set_publish_at":"openPublishAtDialog","click .edit_access":"editAccessLevel","click .remove_lines":"removeLines"},
totalSteps:3,STEPS:[null,null,"Step Two: Configure the Document Viewer","Step Three: Copy and Paste the Embed Code"],DEMO_ERROR:'Demo accounts are not allowed to embed documents. <a href="/contact">Contact us</a> if you need a full featured account. View an example of the embed code <a href="/help/publishing">here</a>.',DEFAULT_OPTIONS:{width:null,height:null,sidebar:!0,text:!0},constructor:function(a){this.model=a;this.currentStep=1;dc.ui.Dialog.call(this,{mode:"custom",title:this.displayTitle()});
this.render()},render:function(){if(dc.account.organization.demo)return dc.ui.Dialog.alert(this.DEMO_ERROR);dc.ui.Dialog.prototype.render.call(this);this.$(".custom").html(JST["workspace/document_embed_dialog"]({doc:this.model}));this._next=this.$(".next");this._previous=this.$(".previous");this._widthEl=this.$("input[name=width]");this._heightEl=this.$("input[name=height]");this._viewerSizeEl=this.$("select[name=viewer_size]");this._sidebarEl=this.$("input[name=sidebar]");this._showTextEl=this.$("input[name=show_text]");
this._showPDFEl=this.$("input[name=show_pdf]");this._openToEl=this.$(".open_to");dc.app.preferences.get("embed_options")&&this._loadPreferences();this.setMode("document_embed","dialog");this.update();this.setStep();this.center();return this},displayTitle:function(){if(this.currentStep==1)return'Step One: Review "'+dc.inflector.truncate(this.model.get("title"),25)+'"';return this.STEPS[this.currentStep]},preview:function(){var a=encodeURIComponent(JSON.stringify(this.embedOptions()));a="/documents/"+
this.model.canonicalId()+"/preview?options="+a;window.open(a);return!1},update:function(){this._toggleDimensions();this._savePreferences()},embedOptions:function(){var a={},b=this.$(".page_select").val(),c=this.$(".note_select").val();if(this._viewerSizeEl.val()=="fixed"){var d=parseInt(this._widthEl.val(),10),e=parseInt(this._heightEl.val(),10);if(d)a.width=d;if(e)a.height=e}if(!this._sidebarEl.is(":checked"))a.sidebar=!1;if(!this._showTextEl.is(":checked"))a.text=!1;if(!this._showPDFEl.is(":checked"))a.pdf=
!1;if(b)a.page=parseInt(b,10);if(c)b=this.model.notes.get(parseInt(c,10)),a.page=b.get("page"),a.note=b.id;return a},editAccessLevel:function(){this.close();Documents.editAccess([this.model])},openPublishAtDialog:function(){this.close();new dc.ui.PublicationDateDialog([this.model])},removeLines:function(){this.$(".snippet").val(this.$(".snippet").val().replace(/[\r\n]/g,""))},_savePreferences:function(){dc.app.preferences.set({embed_options:JSON.stringify(this.embedOptions())})},_loadPreferences:function(){var a=
JSON.parse(dc.app.preferences.get("document_embed_options"))||this.DEFAULT_OPTIONS;(a.width||a.height)&&this._viewerSizeEl.val("fixed");this._widthEl.val(a.width);this._heightEl.val(a.height);this._sidebarEl.attr("checked",a.sidebar);this._showTextEl.attr("checked",a.text)},_renderOpenTo:function(a){switch($(a.currentTarget).val()){case "first_page":return this._openToEl.empty();case "page":return this._openToEl.html(JST["document/page_select"]({doc:this.model}));case "note":this.model.ignoreNotes=
!0,this.model.notes.fetch({success:_.bind(function(){this._openToEl.html(JST["document/note_select"]({doc:this.model}));delete this.model.ignoreNotes},this)})}},_renderEmbedCode:function(){var a=this.embedOptions();a.container='"#DV-viewer-'+this.model.canonicalId()+'"';a=_.map(a,function(a,c){return c+": "+a});this.$(".publish_embed_code").html(JST["document/embed_code"]({doc:this.model,options:a.join(",\n    ")}))},_toggleDimensions:function(){this.$(".dimensions").toggle(this._viewerSizeEl.val()==
"fixed")},saveUpdatedAttributes:function(){var a=this.$("input[name=access_level]").is(":checked")?dc.access.PUBLIC:this.model.get("access"),b=this.$("input[name=related_article]").removeClass("error").val(),c={access:a,related_article:dc.inflector.normalizeUrl(b)};if(c=this.model.changedAttributes(c)){if(_.any(["related_article"],_.bind(function(a){if(c[a]&&!this.validateUrl(c[a]))return this.$("input[name="+a+"]").addClass("error"),!0},this)))return!1;dc.ui.spinner.show();this.model.save(c,{success:function(){dc.ui.spinner.hide()}})}return!0},
nextStep:function(){if(this.currentStep==1&&!this.saveUpdatedAttributes())return!1;if(this.currentStep>=this.totalSteps)return this.close();this.currentStep==2&&this._renderEmbedCode();this.currentStep+=1;this.setStep()},previousStep:function(){this.currentStep>1&&(this.currentStep-=1);this.setStep()},setStep:function(){this.title(this.displayTitle());this.$(".publish_step").setMode("not","enabled");this.$(".publish_step_"+this.currentStep).setMode("is","enabled");this.info("Step "+this.currentStep+
" of "+this.totalSteps,!0);var a=this.currentStep==this.totalSteps;this._previous.setMode(this.currentStep==1?"not":"is","enabled");this._next.html(a?"Finish":"Next &raquo;").setMode("is","enabled")},selectSnippet:function(){this.$(".snippet").select()}});
dc.ui.DocumentList=Backbone.View.extend({SLOP:3,id:"document_list",events:{mousedown:"_startDeselect",click:"_endDeselect"},constructor:function(a){Backbone.View.call(this,a);_.bindAll(this,"reset","_removeDocument","_addDocument","_onSelect","_maybeSelectOrDelete");$(document).bind("keydown",this._maybeSelectOrDelete);Documents.bind("reset",this.reset);Documents.bind("remove",this._removeDocument);Documents.bind("add",this._addDocument)},render:function(){$(".search_tab_content").selectable({ignore:".noselect, .minibutton",
select:".icon.doc",onSelect:this._onSelect});return this},reset:function(){$(window).unbind("resize.entities");$(this.el).html("");var a=Documents.map(function(a){return(new dc.ui.Document({model:a})).render({notes:!0}).el});$(this.el).append(a.concat(this.make("div",{"class":"clear"})))},_onSelect:function(a){var b={};_.each(a,function(a){a=$(a).attr("data-id");b[a]=!0;Documents.get(a).set({selected:!0})});!dc.app.hotkeys.shift&&!dc.app.hotkeys.command&&_.each(Documents.selected(),function(a){b[a.id]||
a.set({selected:!1})})},_maybeSelectOrDelete:function(a){var b=Documents.selectedCount&&a.which==8,c=dc.app.hotkeys.command&&(a.which==97||a.which==65);if(!(!c&&!b||$(a.target).closest("input, textarea").length))return c?Documents.selectAll():b&&Documents.verifyDestroy(Documents.selected()),!1},_startDeselect:function(a){this._pageX=a.pageX;this._pageY=a.pageY},_endDeselect:function(a){!dc.app.hotkeys.shift&&!dc.app.hotkeys.command&&!dc.app.hotkeys.control&&!$(a.target).hasClass("doc_title")&&!$(a.target).hasClass("doc")&&
!$(a.target).hasClass("edit_glyph")&&(Math.abs(a.pageX-this._pageX)>this.SLOP||Math.abs(a.pageY-this._pageY)>this.SLOP||Documents.deselectAll())},_addDocument:function(a){a=new dc.ui.Document({model:a});$(this.el).prepend(a.render().el)},_removeDocument:function(a){$("#document_"+a.id).remove()}});
dc.ui.Note=Backbone.View.extend({className:"note noselect",events:{"click .title_link":"viewNoteInDocument","click .edit_note":"editNote","click .cancel_note":"cancelNote","click .save_note":"saveNote","click .save_draft_note":"saveNote","click .delete_note":"deleteNote"},constructor:function(a){Backbone.View.call(this,a);_.bindAll(this,"render");this.model.bind("change",this.render)},render:function(){var a=_.extend(this.model.toJSON(),{note:this.model,ownsNote:!0,disableLinks:this.options.disableLinks||
!1});$(this.el).html(JST["document/note"](a));this.setMode("display","visible");this.setMode(this.model.get("access"),"access");this.setMode(this.model.checkAllowedToEdit()?"is":"not","editable");return this},center:function(){var a=this.$(".note_excerpt"),b=this.model.coordinates();if(b){var c=b.left+b.width/2,d=a.closest(".note_excerpt_wrap").width(),e=d/2;b.left+b.width>d&&(b.width>d?a.css("left",-1*b.left):a.css("left",e-c))}},viewNoteInDocument:function(){var a="#document/p"+this.model.get("page")+
"/a"+this.model.get("id");window.open(this.model.document().viewerUrl()+a)},editNote:function(){if(!this.model.checkAllowedToEdit())return dc.ui.Dialog.alert("You don't have permission to edit this note.");this.$(".note_title_input").val(this.model.get("title"));this.$(".note_text_edit").val(this.model.get("content"));this.setMode("edit","visible")},cancelNote:function(){this.setMode("display","visible")},saveNote:function(a){var b=this.model.get("access");$(a.target).hasClass("save_draft_note")?
b="exclusive":this.model.get("access")=="exclusive"&&(b="public");this.model.save({title:this.$(".note_title_input").val(),content:this.$(".note_text_edit").val(),access:b});this.render()},deleteNote:function(){dc.ui.Dialog.confirm("Are you sure you want to delete this note?",_.bind(function(){this.model.destroy({success:_.bind(function(){$(this.el).remove();this.model.document().decrementNotes()},this)});return!0},this))}});
dc.ui.NoteEmbedDialog=dc.ui.Dialog.extend({events:{"change select":"update","click select":"update","click .next":"nextStep","click .previous":"previousStep","click .close":"close","click .snippet":"selectSnippet","click .set_publish_at":"openPublishAtDialog","click .edit_access":"editAccessLevel","click .remove_lines":"removeLines"},totalSteps:2,STEPS:[null,"Step One: Select a Note to Embed","Step Two: Copy and Paste the Embed Code"],DEMO_ERROR:'Demo accounts are not allowed to embed notes. <a href="/contact">Contact us</a> if you need a full featured account. View an example of the embed code <a href="/help/publishing#step_5">here</a>.',
DEFAULT_OPTIONS:{},constructor:function(a,b){this.currentStep=1;this.doc=a;this.initialNoteId=b;this.height=0;dc.ui.Dialog.call(this,{mode:"custom",title:this.displayTitle()});dc.ui.spinner.show();this.fetchNotes()},fetchNotes:function(){this.doc.notes.fetch({silent:!0,success:_.bind(function(){dc.ui.spinner.hide();this.render()},this)})},render:function(){if(dc.account.organization.demo)return dc.ui.Dialog.alert(this.DEMO_ERROR);dc.ui.Dialog.prototype.render.call(this);this.$(".custom").html(JST["workspace/note_embed_dialog"]({doc:this.doc,
notes:this.doc.notes.select(function(a){return a.get("access")=="public"}),initialNoteId:this.initialNoteId}));this._next=this.$(".next");this._previous=this.$(".previous");this._noteSelectEl=this.$("select[name=note]");this._preview=this.$(".note_preview");this.setMode("embed","dialog");this.setMode("note_embed","dialog");this.update();this.setStep();this.center();dc.ui.spinner.hide();return this},displayTitle:function(){return this.STEPS[this.currentStep]},update:function(){this.note=this.doc.notes.get(parseInt(this._noteSelectEl.val(),
10));this._renderNote();this._renderEmbedCode();if(this._preview.height()>this.height)this.center(),this.height=this._preview.height()},removeLines:function(){this.$(".snippet").val(this.$(".snippet").val().replace(/[\r\n]/g,""))},_renderNote:function(){var a=new dc.ui.Note({model:this.note,collection:this.doc.notes,disableLinks:!0});this.$(".note_preview").html(a.render().el);a.center()},embedOptions:function(){return{}},_renderEmbedCode:function(){var a=this.embedOptions();a=_.map(a,function(a,
c){return c+": "+a});this.$(".publish_embed_code").html(JST["workspace/note_embed_code"]({note:this.note,options:a.join(",\n    ")}))},nextStep:function(){this.currentStep+=1;if(this.currentStep>this.totalSteps)return this.close();this.currentStep==2&&this.update();this.setStep()},previousStep:function(){this.currentStep>1&&(this.currentStep-=1);this.setStep()},setStep:function(){this.title(this.displayTitle());this.$(".publish_step").setMode("not","enabled");this.$(".publish_step_"+this.currentStep).setMode("is",
"enabled");this.info("Step "+this.currentStep+" of "+this.totalSteps,!0);var a=this.currentStep==this.totalSteps;this._previous.setMode(this.currentStep==1?"not":"is","enabled");this._next.html(a?"Finish":"Next &raquo;").setMode("is","enabled")},selectSnippet:function(){this.$(".snippet").select()},editAccessLevel:function(){this.close();Documents.editAccess([this.doc])},openPublishAtDialog:function(){this.close();new dc.ui.PublicationDateDialog([this.doc])}});
dc.ui.PublicationDateDialog=dc.ui.Dialog.extend({id:"pubdate_dialog",className:"dialog",events:{"click .cancel":"close","click .ok":"save","click .delete":"removeDate","click .public_now":"editAccess"},constructor:function(a){if(Documents.allowedToEdit(a))this.docs=a,this.multiple=a.length>1,a="Set Publication Date for "+this._title(),dc.ui.Dialog.call(this,{mode:"custom",title:a,editor:!0,closeText:"Cancel",deleteText:"Remove"}),this.render(),$(document.body).append(this.el)},render:function(){dc.ui.Dialog.prototype.render.call(this);
this._container=this.$(".custom");var a=Documents.sharedAttribute(this.docs,"publish_at");this._container.html(JST["document/publication_date_dialog"]({multiple:this.multiple,date:a?DateUtils.parseRfc(a):new Date(+new Date+36E5)}));this.center();return this},editAccess:function(){this.close();Documents.editAccess(this.docs)},save:function(){var a=this._getDate();if(a<new Date)this.close(),dc.ui.Dialog.alert("You can't set a document to be published in the past.");else{var b=JSON.stringify(a);_.each(this.docs,
function(a){a.save({publish_at:b})});this.close()}},removeDate:function(){_.each(this.docs,function(a){a.save({publish_at:null})});this.close()},_title:function(){if(this.multiple)return this.docs.length+" Documents";return'"'+dc.inflector.truncate(this.docs[0].get("title"),35)+'"'},_getDate:function(){return new Date(this.$(".date_year").val(),parseInt(this.$(".date_month").val(),10)-1,this.$(".date_day").val(),this.$(".date_hour").val())}});
dc.ui.SparkEntities=Backbone.View.extend({BLOCK_WIDTH:275,LEFT_WIDTH:120,RIGHT_MARGIN:50,MAX_WIDTH:700,TOOLTIP_DELAY:200,RESIZE_DELAY:333,SEARCH_DISTANCE:5,events:{"click .cancel_search":"hide","click .show_all":"renderKind","click .entity_line_title":"_showPages","click .entity_list_title":"_showPages","click .entity_bucket_wrap":"_openEntity","click .arrow.left":"render","mouseleave .entity_buckets":"hideTooltip","mouseenter .entity_bucket_wrap":"_onMouseEnter","mouseleave .entity_bucket_wrap":"_onMouseLeave"},
initialize:function(){this.template=JST["document/entities"];this.options.container.append(this.el);this.showLater=_.debounce(this.showLater,this.TOOLTIP_DELAY);this.rerenderLater=_.debounce(_.bind(this.rerender,this),this.RESIZE_DELAY);this._renderState={doc:this.model,distance:this.SEARCH_DISTANCE}},show:function(){this._open=!0;$(window).bind("resize.entities",this.rerenderLater);this.render()},render:function(){this._renderState.only=!1;this.rerender();return this},renderKind:function(a){this._renderState.only=
$(a.currentTarget).attr("data-kind");this.rerender();this.model.trigger("focus")},calculateWidth:function(){var a=$(this.el).width();if(this._renderState.only)return Math.min(a-(this.LEFT_WIDTH+this.RIGHT_MARGIN),this.MAX_WIDTH);else{var b=Math.floor(a/(this.BLOCK_WIDTH+this.LEFT_WIDTH+this.RIGHT_MARGIN));return Math.min(Math.floor((a-(this.LEFT_WIDTH+this.RIGHT_MARGIN)*b)/b),this.MAX_WIDTH)}},rerender:function(){this.options.container.show();var a=_.extend(this._renderState,{width:this.calculateWidth()});
$(this.el).html(this.template(a))},hide:function(){this._open=!1;$(window).unbind("resize.entities",this.rerenderLater);$(this.el).html("");this.options.container.hide()},showTooltip:function(){if(this._current){var a,b=_.bind(function(a){this._current&&dc.ui.tooltip.show({left:this._current.offset().left,top:this._current.offset().top+15,title:this._entity.get("value"),text:"<b>p."+a.page_number+"</b> "+dc.inflector.trimExcerpt(a.excerpt),leaveOpen:!0})},this);(a=this._entity.excerpts[this._occurrence])?
b(a):this.showLater(b)}},showLater:function(a){this._current&&this._entity.loadExcerpt(this._occurrence,a)},hideTooltip:function(){dc.ui.tooltip.hide()},_setCurrent:function(a){var b=$(a.currentTarget);if(!b.hasClass("occurs")){a=b.index();for(var c=b.parent().children(),d=1,e=this.SEARCH_DISTANCE;d<=e;d++){b=c[a+d];var g=c[a-d];if(b=$(b).hasClass("occurs")&&$(b)||$(g).hasClass("occurs")&&$(g))break}}if(!b)return this.hideTooltip(),!1;b.addClass("active");this._current=b;this._occurrence=b.find(".entity_bucket").attr("data-occurrence");
this._entity=this.model.entities.get(b.closest(".entity_line").attr("data-id"));return!0},_openEntity:function(a){this._setCurrent(a)&&this.model.openEntity(this._entity.id,this._occurrence.split(":")[0])},_onMouseEnter:function(a){this._setCurrent(a)&&this.showTooltip()},_onMouseLeave:function(){this._current&&this._current.removeClass("active");this._occurrence=this._entity=this._current=null},_showPages:function(a){a=$(a.currentTarget).closest("[data-id]").attr("data-id");dc.model.Entity.fetchId(this.model.id,
a,_.bind(function(a){this.hide();this.model.pageEntities.reset(a)},this))}});
dc.ui.UploadDialog=dc.ui.Dialog.extend({id:"upload_dialog",className:"dialog",INSERT_PAGES_MESSAGE:"This document will close while it's being rebuilt. Long documents may take a long time to rebuild.",constructor:function(a){a=_.extend({},{editable:!0,insertPages:!1,autostart:!1,collection:UploadDocuments,mode:"custom",title:"Upload Documents",saveText:"Upload",closeText:"Cancel",multiFileUpload:!1},a);_.bindAll(this,"setupUpload","_countDocuments","cancelUpload","_onSelect","_onProgress","_onComplete",
"_onAllComplete");dc.ui.Dialog.call(this,a);a.autostart&&$(this.el).addClass("autostart");dc.app.navigation&&dc.app.navigation.bind("tab:documents",_.bind(function(){_.defer(this.setupUpload)},this));this.collection.bind("add",this._countDocuments);this.collection.bind("remove",this._countDocuments)},render:function(){this.options.multiFileUpload=window.FileList&&$("input[type=file]")[0].files instanceof FileList;this._tiles={};this._project=_.first(Projects.selected());var a={};if(this._project){var b=
dc.inflector.truncate(this._project.get("title"),35);a.information="Project: "+b}dc.ui.Dialog.prototype.render.call(this,a);this.$(".custom").html(JST["document/upload_dialog"]());this._list=this.$(".upload_list");this._renderDocumentTiles();this._countDocuments();this.center();this.options.autostart||this.checkQueueLength();return this},_renderDocumentTiles:function(){var a=this._tiles,b=this.options.editable,c=this.options.multiFileUpload;this.collection.each(function(d){var e=new dc.ui.UploadDocumentTile({editable:b,
model:d,multiFileUpload:c});a[d.id]=e.render()});this._list.append(_.pluck(_.values(a),"el"))},setupUpload:function(){if(!(this.form||dc.app.navigation&&!dc.app.navigation.isOpen("documents"))){var a="/import/upload_document";this.options.insertPages&&(a="/documents/"+this.options.documentId+"/upload_insert_document");this.form=$("#new_document_form");this.form.fileUpload({url:a,onAbort:this.cancelUpload,initUpload:this._onSelect,onProgress:this._onProgress,onLoad:this._onComplete,dragDropSupport:!0,
dropZone:$("body")})}},setupFileInput:function(){$("#new_document_input").show().change(_.bind(function(){this._project=_.first(Projects.selected());$("#new_document_project").val(this._project?this._project.id:"");$("#new_document_form").submit()},this))},_onSelect:function(a,b,c,d,e,g){a=b[c];this.collection.add(new dc.model.UploadDocument({id:dc.inflector.sluggify(a.fileName||a.name),uploadIndex:c,file:a,position:c,handler:e,xhr:d,startUpload:g}));if(c==b.length-1){if(this.collection.any(function(a){return a.overSizeLimit()}))return this.close(),
dc.ui.Dialog.alert('You can only upload documents less than 200MB in size. Please <a href="/help/troubleshooting">optimize your document</a> before continuing.');this.render();this.options.autostart&&this.startUpload(c)}},cancelUpload:function(){if(this.collection.length<=1)return this.error("You must upload at least one document."),!1;return!0},_uploadData:function(a,b){var c=this._tiles[a].serialize(),d=this.collection.get(a),e=this.options;d.set(c);if(e.multiFileUpload&&d.get("size"))c.multi_file_upload=
!0;c.authenticity_token=$("meta[name='csrf-token']").attr("content");if(this.$("#make_public").is(":checked"))c.make_public=!0;c.email_me=this.$("#email_on_complete").is(":checked")?this.collection.length:0;if(this._project)c.project=this._project.id;if(_.isNumber(e.insertPageAt))c.insert_page_at=e.insertPageAt;if(_.isNumber(e.replacePagesStart))c.replace_pages_start=e.replacePagesStart;if(_.isNumber(e.replacePagesEnd))c.replace_pages_end=e.replacePagesEnd;if(e.documentId)c.document_id=e.documentId;
if(e.insertPages)c.document_number=b+1;if(e.insertPages)c.document_count=this.collection.length;e.autostart||this.showSpinner();this._list[0].scrollTop=0;return c},_onProgress:function(a,b,c){b=dc.inflector.sluggify(b[c].fileName||b[c].name);a=parseInt(a.loaded/a.total*100,10);this._tiles[b].setProgress(a)},_onComplete:function(a,b,c,d){a=dc.inflector.sluggify(b[c].fileName||b[c].name);d=d.responseText&&JSON.parse(d.responseText);this._tiles[a].setProgress(100);if(d&&d.bad_request)return this.error("Upload failed.");
else if(!this.options.insertPages&&d)Documents.add(new dc.model.Document(d)),this._project&&Projects.incrementCountById(this._project.id);else if(this.options.insertPages&&d)this.documentResponse=d;this._tiles[a].hide();c==this.collection.length-1?this._onAllComplete():this.startUpload(c+1)},_onAllComplete:function(){this.hideSpinner();if(this.options.insertPages){try{window.opener&&window.opener.Documents&&window.opener.Documents.get(this.options.documentId).set(this.documentResponse)}catch(a){}dc.ui.Dialog.alert(this.INSERT_PAGES_MESSAGE,
{onClose:function(){window.close();_.defer(dc.ui.Dialog.alert,"The pages are being processed. Please close this document.")}})}this.close()},_countDocuments:function(){var a=this.collection.length;this.title("Upload "+(a>1?a:"")+dc.inflector.pluralize(" Document",a));var b=dc.inflector.pluralize("document",a);this.$(".upload_public_count").text(b);this.$(".upload_email_count").text("the "+b+(a==1?" has":" have"))},checkQueueLength:function(){$.getJSON("/documents/queue_length.json",{},_.bind(function(a){a=
a.queue_length;a<=0||this.info("There "+(a>1?"are":"is")+" "+a+" "+dc.inflector.pluralize("document",a)+" ahead of you in line.",!0)},this))},insertPagesAttrs:function(a){_.each(a,_.bind(function(a,c){this.options[c]=a},this))},confirm:function(){if(_.select(this._tiles,function(a){return a.ensureTitle()}).length)return this.error("Please enter a title for "+(this.collection.length==1?"the document.":"all documents."));this.$(".ok").setMode("not","enabled");this.startUpload(0)},startUpload:function(a){var b=
this._tiles,c=this.collection.models[a];c.get("handler").formData=this._uploadData(c.get("id"),a);c.get("startUpload")();b[c.get("id")].startProgress()},cancel:function(){this.close()},close:function(){this.collection.reset();dc.ui.Dialog.prototype.close.call(this)}});
dc.ui.UploadDocumentTile=Backbone.View.extend({className:"row",events:{"click .remove_queue":"removeUploadFile","click .open_edit":"openEdit","click .apply_all":"applyAll"},render:function(){var a=JST["document/upload_document_tile"]({editable:this.options.editable,autostart:this.options.autostart,model:this.model,multiFileUpload:this.options.multiFileUpload});$(this.el).html(a);this._title=this.$("input[name=title]");this._progress=this.$(".progress_bar");return this},serialize:function(){return{title:this._title.val(),
description:this.$("textarea[name=description]").val(),source:this.$("input[name=source]").val(),access:this.$("select[name=access]").val()}},removeUploadFile:function(){dc.app.uploader.cancelUpload(this.model.get("uploadIndex"))&&(this.hide(),this.model.get("xhr").abort(),UploadDocuments.remove(this.model))},applyAll:function(){var a=dc.app.uploader.el,b=this.serialize();$("textarea[name=description]",a).val(b.description);$("input[name=source]",a).val(b.source);$("select[name=access]",a).val(b.access);
dc.app.uploader.info("Update applied to all files.")},openEdit:function(){this.$(".upload_edit").toggle();this.$(".open_edit").toggleClass("active")},startProgress:function(){this._percentage=0;this.options.multiFileUpload&&this._progress.show()},setProgress:function(a){if(!(a<=this._percentage))this._percentage=a,this._progress.stop(!0).animate({width:a+"%"},{queue:!1,duration:400})},ensureTitle:function(){var a=dc.inflector.trim(this._title.val())=="";this._title.closest(".text_input").toggleClass("error",
a);return a},hide:function(){$(this.el).animate({opacity:0},200).slideUp(200,function(){$(this).remove()})}});
dc.ui.EntityList=Backbone.View.extend({id:"entities",events:{"click .row":"_filterFacet","click .cancel_search":"_removeFacet","click .more":"_loadFacet","click .less":"_showLess","click .show_pages":"_showPages"},ENTITY_KINDS:["city","country","term","state","person","place","organization","email","phone"],renderFacets:function(a,b,c){this._docCount=c;var d=this.extractEntities(dc.app.searchBox.value());_.each(d,function(b){var d=a[b.type];if(d){var h=null,k=_.detect(d,function(a,c){h=c;return a.value.toLowerCase()==
b.value.toLowerCase()});k?(k.active=!0,d.splice(h,1)):(k={value:b.value,count:c,active:!0},d.pop());a[b.type].unshift(k)}});this._facets=a;$(this.el).html(JST["workspace/entities"]({entities:a,limit:b}));dc.app.scroller.checkLater()},mergeFacets:function(a,b,c){this.renderFacets(_.extend(this._facets,a),b,c)},_facetValueFor:function(a){a=$(a).closest(".row");var b=a.attr("data-value");return{category:a.attr("data-category"),value:b}},_filterFacet:function(a){a=this._facetValueFor(a.target);dc.app.searcher.addToSearch(a.category,
a.value)},_removeFacet:function(a){$(a.target).closest(".row").removeClass("active");a=this._facetValueFor(a.target);dc.app.searcher.removeFromSearch(a.category);return!1},_loadFacet:function(a){$(a.target).html("loading &hellip;");dc.app.searcher.loadFacet($(a.target).attr("data-category"))},_showLess:function(a){this._facets[$(a.target).attr("data-category")].splice(6);this.renderFacets(this._facets,5,this._docCount)},_showPages:function(a){a=$(a.target).closest(".row");var b=a.attr("data-category"),
c=a.attr("data-value"),d=a.hasClass("active"),e=_.bind(function(){dc.model.Entity.fetch(b,c,this._connectExcerpts)},this),g=e;if(!d){var h=this._facetValueFor(a);g=_.bind(function(){dc.app.searcher.addToSearch(h.category,h.value,e)},this)}dc.app.paginator.ensureRows(g);return!1},_connectExcerpts:function(a){a=_.reduce(a,function(a,c){var d=c.get("document_id");a[d]=a[d]||[];a[d].push(c);return a},{});_.each(a,function(a){Documents.get(a[0].get("document_id")).pageEntities.reset(a)})},extractEntities:function(){var a=
VS.app.searchQuery.filter(_.bind(function(a){return _.include(this.ENTITY_KINDS,a.get("category"))},this));return _.sortBy(_.map(a,function(a){return{type:a.get("category"),value:a.get("value")}}),function(a){return a.value.toLowerCase()}).reverse()}});
dc.ui.TimelineDialog=dc.ui.Dialog.extend({GRAPH_OPTIONS:{xaxis:{mode:"time",minTickSize:[1,"day"]},yaxis:{ticks:[],min:-0.5},selection:{mode:"x",color:"#09f"},legend:{show:!1},series:{lines:{show:!1},points:{show:!0,radius:4,fill:!0,fillColor:"rgba(255, 255, 235, 0.7)"}},grid:{backgroundColor:"#fff",tickColor:"#ddd",borderWidth:0,hoverable:!0,clickable:!0}},ROW_HEIGHT:50,MIN_HEIGHT:100,DATE_FORMAT:"%b %d, %y",POINT_COLOR:"#555",id:"timeline_dialog",events:{"click .zoom_out":"_zoomOut","click .ok":"confirm",
"plothover .timeline_plot":"_showTooltop","plotselected .timeline_plot":"_zoomIn","plotclick .timeline_plot":"_openPage"},constructor:function(a){this.documents=a;dc.ui.Dialog.call(this,{mode:"custom",title:this.displayTitle(),information:"Drag a range of dates to zoom in."});dc.ui.spinner.show();this._loadDates()},render:function(){dc.ui.Dialog.prototype.render.call(this);this.$(".custom").html(JST["document/timeline"]({docs:this.documents,minHeight:this.MIN_HEIGHT,rowHeight:this.ROW_HEIGHT}));this._zoomButton=
this.make("span",{"class":"minibutton zoom_out dark not_enabled"},"Zoom Out");this.addControl(this._zoomButton);this.center();return this},displayTitle:function(){if(this.documents.length==1)return'Timeline for "'+dc.inflector.truncate(this.documents[0].get("title"),55)+'"';return"Timeline for "+this.documents.length+" Documents"},drawPlot:function(){$.plot(this.$(".timeline_plot"),this._data,this._options)},_loadDates:function(){var a=_.pluck(this.documents,"id");$.getJSON("/documents/dates",{"ids[]":a},
_.bind(this._plotDates,this))},_plotDates:function(a){dc.ui.spinner.hide();if(a.dates.length==0)return this._noDates();this.render();var b=this.POINT_COLOR,c={},d={},e=this._dateIds={};_.each(this.documents,function(a,h){e[a.id]={};c[a.id]=[];d[a.id]={pos:h,color:b}});_.each(a.dates,function(a){var b=a.document_id,k=a.date*1E3;e[b][k]=a.id;c[b].push([k,d[b].pos])});this._data=_.map(c,function(a,b){return{data:a,color:d[b].color,docId:parseInt(b,10)}});this._options=_.clone(this.GRAPH_OPTIONS);this._options.xaxis.min=
null;this._options.xaxis.max=null;this._options.yaxis.max=this.documents.length-0.5;this._options.yaxis.ticks=_.map(this.documents,function(a){return[d[a.id].pos,dc.inflector.truncate(a.get("title"),30)]});this.drawPlot()},_showTooltop:function(a,b,c){this._pos=b;if(!this._request){if(!c)return dc.ui.tooltip.hide();a=this._dateIds[c.series.docId][c.datapoint[0]];if(b=EntityDates.get(a))return this._renderTooltip(b);this._request=$.getJSON("/documents/dates",{id:a},_.bind(function(a){delete this._request;
a&&(a=new dc.model.Entity(a.date),EntityDates.add(a),this._renderTooltip(a))},this))}},_renderTooltip:function(a){var b=dc.inflector.truncate(Documents.get(a.get("document_id")).get("title"),45);a=a.get("excerpts")[0];dc.ui.tooltip.show({left:this._pos.pageX,top:this._pos.pageY,title:b,text:"<b>p."+a.page_number+"</b> "+dc.inflector.trimExcerpt(a.excerpt)})},_openPage:function(a,b,c){c&&(a=c.datapoint[0]/1E3,c=Documents.get(c.series.docId),window.open(c.viewerUrl()+"?date="+a))},_zoomIn:function(a,
b){$(this._zoomButton).setMode("is","enabled");this._options.xaxis.min=b.xaxis.from;this._options.xaxis.max=b.xaxis.to;this.drawPlot()},_zoomOut:function(){$(this._zoomButton).setMode("not","enabled");this._options.xaxis.min=null;this._options.xaxis.max=null;this.drawPlot()},_noDates:function(){var a=this.documents.length;this.close();var b="None of the "+a+" documents contained recognizable dates.";a<=1&&(b='"'+this.documents[0].get("title")+'" does not contain any recognizable dates.');dc.ui.Dialog.alert(b)}});
dc.ui.Organizer=Backbone.View.extend({id:"organizer",PRIVATE_SEARCHES:["all_documents","your_documents","your_published_documents","org_documents"],PUBLIC_SEARCHES:["all_documents","annotated_documents","published_documents","popular_documents"],events:{"click #new_project":"promptNewProject","click .all_documents":"showAllDocuments","click .your_documents":"showYourDocuments","click .org_documents":"showOrganizationDocuments","click .annotated_documents":"showAnnotatedDocuments","click .published_documents":"showPublishedDocuments",
"click .popular_documents":"showPopularDocuments","click .your_published_documents":"showYourPublishedDocuments","click .account_links .text_link":"showAccountDocuments","click .toggle_account_links":"toggleAccountLinks","click .organization.box":"showOtherOrgDocuments"},constructor:function(a){Backbone.View.call(this,a);_.bindAll(this,"_addSubView","_removeSubView","renderAccounts");this._bindToSets();this.subViews=[]},render:function(){var a=dc.account?this.PRIVATE_SEARCHES:this.PUBLIC_SEARCHES;
$(this.el).append(JST["organizer/sidebar"]({searches:a}));this.projectInputEl=this.$("#project_input");this.projectList=this.$(".project_list");this.sidebar=$("#sidebar");this.renderAccounts();this.renderAll();return this},renderAll:function(){dc.account?(Projects.isEmpty()&&this.setMode("no","projects"),Projects.each(this._addSubView)):this.$(".organization_list").html(JST["organizer/organizations"]())},renderAccounts:function(){this.$(".account_links").html(JST["organizer/account_links"]())},promptNewProject:function(){var a=
this;dc.ui.Dialog.prompt("Create a New Project","",function(b,c){if(b=dc.inflector.trim(b)){if(Projects.find(b))return a._warnAlreadyExists(b);var d=_.inject(Documents.selected(),function(a,b){return a+b.get("annotation_count")},0);Projects.create({title:b,annotation_count:d,document_ids:Documents.selectedIds(),owner:!0},{wait:!0});return!0}else c.error("Please enter a title.")},{mode:"short_prompt"})},highlight:function(a,b){Projects.deselectAll();this.$(".organization").removeClass("is_selected");
if(dc.account){var c=a&&Projects.find(a);if(c)return c.set({selected:!0})}else(c=b&&Organizations.findBySlug(b))&&this.$("#organization_"+c.id).addClass("is_selected")},showAllDocuments:function(){dc.app.searcher.search("")},showYourDocuments:function(){Accounts.current().openDocuments()},showAnnotatedDocuments:function(){dc.app.searcher.search("filter: annotated")},showPublishedDocuments:function(){dc.app.searcher.search("filter: published")},showPopularDocuments:function(){dc.app.searcher.search("filter: popular")},
showAccountDocuments:function(a){a=$(a.target).attr("data-cid");Accounts.getByCid(a).openDocuments()},showYourPublishedDocuments:function(){Accounts.current().openDocuments({published:!0})},showOrganizationDocuments:function(){this.setMode("show","accounts");Accounts.current().openOrganizationDocuments()},showOtherOrgDocuments:function(a){a=$(a.currentTarget);Organizations.get(a.attr("data-id")).openDocuments()},toggleAccountLinks:function(){this.setMode(this.modes.accounts=="show"?"hide":"show",
"accounts")},_bindToSets:function(){Projects.bind("add",this._addSubView);Projects.bind("remove",this._removeSubView);Accounts.bind("all",this.renderAccounts)},_warnAlreadyExists:function(a){dc.ui.notifier.show({text:'A project named "'+a+'" already exists'});return!1},_addSubView:function(a){this.setMode("has","projects");a=(new dc.ui.Project({model:a})).render();this.subViews.push(a);var b=Projects.indexOf(a.model),c=Projects.at(b-1),d=c&&c.view;b==0||!c||!d?$(this.projectList).prepend(a.el):$(d.el).after(a.el);
dc.app.scroller.checkLater()},_removeSubView:function(a){this.subViews=_.without(this.subViews,a.view);$(a.view.el).remove();dc.app.scroller.checkLater()}});
dc.ui.Project=Backbone.View.extend({className:"project box",events:{click:"showDocuments","click .edit_glyph":"editProject"},constructor:function(a){Backbone.View.call(this,a);_.bindAll(this,"render");this.model.bind("change",this.render);this.model.view=this},render:function(){var a=_.extend(this.model.toJSON(),{statistics:this.model.statistics()});$(this.el).html(JST["organizer/project"](a));$(this.el).attr({id:"project_"+this.model.cid,"data-project-cid":this.model.cid});this.setMode(this.model.get("selected")?
"is":"not","selected");return this},showDocuments:function(a){if($(a.target).hasClass("edit_glyph"))return!1;this.model.open()},editProject:function(){this.model.edit();return!1}});
dc.ui.ProjectDialog=dc.ui.Dialog.extend({id:"project_dialog",events:{"click .ok":"confirm","click .cancel":"close","click .delete":"_deleteProject","click .add_collaborator":"_showEnterEmail","click .minibutton.add":"_addCollaborator","keypress #collaborator_email":"_maybeAddCollaborator","click .remove":"_removeCollaborator"},constructor:function(a){this.model=a.model;dc.ui.Dialog.call(this,{mode:"custom",title:"Edit Project"})},render:function(a){a||$(this.el).hide();dc.ui.Dialog.prototype.render.call(this,
{editor:!0,information:this.model.statistics()});this.$(".custom").html(JST["organizer/project_dialog"]({model:this.model}));this.$("#project_title").val(this.model.get("title"));this.$("#project_description").val(this.model.get("description")||"");this.model.get("owner")||this.$(".minibutton.delete").text("Remove");this.model.collaborators.length&&(a=this.model.collaborators.map(_.bind(function(a){return(new dc.ui.AccountView({model:a,kind:"collaborator"})).render(null,{project:this.model}).el},
this)),this.$(".collaborator_list tbody").append(a),this.$(".collaborators").show());$(this.el).show();this.center();this._setPlaceholders();return this},confirm:function(){var a=this.model,b=this.$("#project_title").val(),c=this.$("#project_description").val(),d=Projects.any(function(c){return c!==a&&c.get("title")==b});if(!b)return this.error("Please specify a project title.");if(d)return this.error("There is already a project with that title.");this.model.save({title:b,description:c});this.close()},
_setPlaceholders:function(){this.$("#project_title, #project_description").placeholder()},_deleteProject:function(){var a=Projects.selected()[0]==this.model;if(this.model.get("owner"))this.model.destroy();else{Projects.remove(this.model);var b=Accounts.current().clone();b.collection=this.model.collaborators;b.destroy()}this.close();a&&!dc.app.searcher.flags.outstandingSearch&&dc.app.searcher.loadDefault({clear:!0})},_maybeAddCollaborator:function(a){a.which==13&&this._addCollaborator()},_addCollaborator:function(){var a=
this.$("#collaborator_email").val();if(!a)return this.error("Please enter an email address.");this.showSpinner();this.model.collaborators.create({email:a},{wait:!0,success:_.bind(function(){this.model.change();this.render(!0)},this),error:_.bind(function(a,c){errorResp=JSON.parse(c.responseText);errorResp.errors?this.error(errorResp.errors[0]):this.error("No DocumentCloud account was found with that email.");this.hideSpinner()},this)})},_removeCollaborator:function(a){this.showSpinner();this.model.collaborators.get(parseInt($(a.target).attr("data-id"),
10)).destroy({success:_.bind(function(){this.model.change();this.render(!0)},this)})},_showEnterEmail:function(){this.$(".add_collaborator").hide();this.$(".enter_email").show();this.$("#collaborator_email").focus()}});
dc.ui.ProjectMenu=dc.ui.Menu.extend({constructor:function(a){_.bindAll(this,"renderProjects");a=_.extend({id:"projects_menu",label:"Projects",onOpen:this.renderProjects},a);dc.ui.Menu.call(this,a)},renderProjects:function(a){a.clear();var b=Documents.selected(),c=!b.length?" disabled":"",d=Projects.map(function(d){var g=(d.containsAny(b)?"checked":"")+c;return{title:d.get("title"),attrs:{"class":g},onClick:_.bind(a.options.onClick,a,d)}});d.unshift({title:"New Project",attrs:{"class":"plus"},onClick:function(){dc.app.organizer.promptNewProject()}});
a.addItems(d)}});
dc.ui.Paginator=Backbone.View.extend({DEFAULT_PER_PAGE:10,MINI_PER_PAGE:30,SORT_TEXT:{score:"by relevance",title:"by title",created_at:"by date",source:"by source",page_count:"by length"},id:"paginator",className:"interface",query:null,page:null,view:null,events:{"click .arrow.left":"previousPage","click .arrow.right":"nextPage","click .current_placeholder":"editPage","change .current_page":"changePage","click .sorter":"chooseSort"},constructor:function(a){Backbone.View.call(this,a);this.setSize(dc.app.preferences.get("paginator_mini")||
!1);this.sortOrder=dc.app.preferences.get("sort_order")||"score"},setQuery:function(a){this.query=a;this.page=a.page;$(document.body).addClass("paginated");this.render()},setSortOrder:function(a){this.sortOrder=a;dc.app.preferences.set({sort_order:a});this.$(".sorter").text(this.SORT_TEXT[this.sortOrder]);dc.app.searcher.loadPage()},queryParams:function(){var a={per_page:dc.app.paginator.pageSize(),order:dc.app.paginator.sortOrder};if(!this.mini)a.mentions=Documents.NUM_MENTIONS;return a},hide:function(){$(document.body).removeClass("paginated")},
pageSize:function(){return this.mini?this.MINI_PER_PAGE:this.DEFAULT_PER_PAGE},pageFactor:function(){return this.mini?this.MINI_PER_PAGE/this.DEFAULT_PER_PAGE:this.DEFAULT_PER_PAGE/this.MINI_PER_PAGE},pageCount:function(){return Math.ceil(this.query.total/this.pageSize())},render:function(){this.setMode("not","editing");var a=$(this.el);a.html("");if(!this.query)return this;a.html(JST["workspace/paginator"]({q:this.query,sort_text:this.SORT_TEXT[this.sortOrder],per_page:this.pageSize(),page_count:this.pageCount()}));
return this},setSize:function(a){this.mini=a;$(document.body).toggleClass("minidocs",this.mini)},ensureRows:function(a,b){this.mini?this.toggleSize(a,b):a()},toggleSize:function(a,b){this.setSize(!this.mini);dc.app.preferences.set({paginator_mini:this.mini});a=_.isFunction(a)?a:null;var c=Math.floor(((this.page||1)-1)/this.pageFactor())+1;b&&(c+=Math.floor(Documents.indexOf(b)/this.pageSize()));dc.app.searcher.loadPage(c,a)},chooseSort:function(){var a=dc.ui.Dialog.choose("Sort Documents By&hellip;",
[{text:"Relevance",value:"score",selected:this.sortOrder=="score"},{text:"Date Uploaded",value:"created_at",selected:this.sortOrder=="created_at"},{text:"Title",value:"title",selected:this.sortOrder=="title"},{text:"Source",value:"source",selected:this.sortOrder=="source"},{text:"Length",value:"page_count",selected:this.sortOrder=="page_count"}],_.bind(function(a){this.setSortOrder(a);return!0},this),{mode:"short_prompt"});$(a.el).addClass("short_choice")},editPage:function(){this.setMode("is","editing");
this.$(".current_page").focus()},previousPage:function(){dc.app.searcher.loadPage((this.page||1)-1)},nextPage:function(){dc.app.searcher.loadPage((this.page||1)+1)},changePage:function(a){a=parseInt($(a.target).val(),10);a!=this.page&&dc.app.searcher.loadPage(a)}});
dc.ui.SearchEmbedDialog=dc.ui.Dialog.extend({events:{"click .preview":"preview","change select":"update","click select":"update","keyup input":"update","focus input":"update","click input":"update","change input":"update","blur .per_page":"_validatePerPage","click .next":"nextStep","click .previous":"previousStep","click .close":"close","click .snippet":"selectSnippet","click .change_access":"changeAccess","click .remove_lines":"removeLines"},totalSteps:2,STEPS:[null,"Step One: Configure the Embedded Documents",
"Step Two: Copy and Paste the Embed Code"],DEMO_ERROR:'Demo accounts are not allowed to embed document sets. <a href="/contact">Contact us</a> if you need a full featured account. View an example of the embed code <a href="/help/publishing#step_4">here</a>.',DEFAULT_OPTIONS:{order:"title",per_page:12,search_bar:!0,title:null,q:""},constructor:function(a){this.currentStep=1;this.docs=a;this.query=a.length?_.map(a,function(a){return"document: "+a.id}).join(" "):dc.app.searcher.publicQuery()||"";dc.ui.Dialog.call(this,
{mode:"custom",title:this.displayTitle()});dc.ui.spinner.show();this.fetchCounts()},fetchCounts:function(){$.ajax({url:"/search/restricted_count.json",data:{q:this.query},dataType:"json",success:_.bind(function(a){this.restrictedCount=a.restricted_count;this.documentsCount=this.docs.length||dc.app.paginator.query.total;this.publicCount=this.documentsCount-this.restrictedCount;this.render()},this)})},render:function(){if(dc.account.organization.demo)return dc.ui.Dialog.alert(this.DEMO_ERROR);dc.ui.Dialog.prototype.render.call(this);
this.$(".custom").html(JST["workspace/search_embed_dialog"]({query:this.query,projectQuery:VS.app.searchQuery.has("project"),restrictedCount:this.restrictedCount,documentsCount:this.documentsCount,publicCount:this.publicCount}));this._next=this.$(".next");this._previous=this.$(".previous");this._orderEl=this.$("select[name=order]");this._perPageEl=this.$("input[name=per_page]");this._titleEl=this.$("input[name=title]");this._searchBarEl=this.$("input[name=search_bar]");this._loadPreferences();this.setMode("embed",
"dialog");this.setMode("search_embed","dialog");this.update();this.setStep();this.center();dc.ui.spinner.hide();return this},displayTitle:function(){return this.STEPS[this.currentStep]},preview:function(){var a=JSON.stringify(this.embedOptions());a=$.param({q:this.query,slug:dc.inflector.sluggify(this.query),options:a});window.open("http://"+window.location.host+"/search/preview?"+a);return!1},update:function(){this._renderPerPageLabel();this._renderEmbedCode();this._savePreferences()},embedOptions:function(){var a=
{};a.q=this.query;a.container="#DC-search-"+dc.inflector.sluggify(this.query);a.title=this._titleEl.val().replace(/\"/g,'\\"');a.order=this._orderEl.val();a.per_page=this._perPageEl.val();a.search_bar=this._searchBarEl.is(":checked");a.organization=dc.account.organization.id;return a},removeLines:function(){this.$(".snippet").val(this.$(".snippet").val().replace(/[\r\n]/g,""))},_savePreferences:function(){dc.app.preferences.set({search_embed_options:JSON.stringify(this.embedOptions())})},_deletePreferences:function(){dc.app.preferences.remove("search_embed_options")},
_loadPreferences:function(){var a=_.extend({},this.DEFAULT_OPTIONS,JSON.parse(dc.app.preferences.get("search_embed_options")));this._orderEl.val(a.order);this._perPageEl.val(a.per_page);this._searchBarEl.attr("checked",!!a.search_bar)},_renderEmbedCode:function(){var a=this.embedOptions();a.title='"'+a.title+'"';a.container='"'+a.container+'"';a.q='"'+a.q+'"';a.order='"'+a.order+'"';a=_.map(a,function(a,c){return c+": "+a});this.$(".publish_embed_code").html(JST["search/embed_code"]({query:dc.inflector.sluggify(this.query),
options:a.join(",\n    ")}))},_renderPerPageLabel:function(){var a=this._perPageEl.val(),b=this.$(".publish_option_perpage_sidelabel");!a||!parseInt(a,10)?a="&nbsp;":(a=Math.max(1,Math.ceil(this.publicCount/a)),a=[this.publicCount,dc.inflector.pluralize(" document",this.publicCount)," / ",a,dc.inflector.pluralize(" page",a)].join(""));b.html(a)},_validatePerPage:function(){var a=this.$("input[name=per_page]"),b=a.val();b.length==0&&(b=this.DEFAULT_OPTIONS.per_page);b<=0&&(b=this.DEFAULT_OPTIONS.per_page);
b>100&&(b=100);a.val(b)},nextStep:function(){this.currentStep+=1;if(this.currentStep>this.totalSteps)return this.close();this.currentStep==2&&this._renderEmbedCode();this.setStep()},previousStep:function(){this.currentStep>1&&(this.currentStep-=1);this.setStep()},setStep:function(){this.title(this.displayTitle());this.$(".publish_step").setMode("not","enabled");this.$(".publish_step_"+this.currentStep).setMode("is","enabled");this.info("Step "+this.currentStep+" of "+this.totalSteps,!0);var a=this.currentStep==
this.totalSteps;this._previous.setMode(this.currentStep==1?"not":"is","enabled");this._next.html(a?"Finish":"Next &raquo;").setMode("is","enabled")},selectSnippet:function(){this.$(".snippet").select()},changeAccess:function(){var a=this.query;a.indexOf("filter:restricted")==-1&&(a+=" filter:restricted");dc.app.searcher.search(a);this.close()}});
dc.ui.Help=Backbone.View.extend({PAGES:[{url:"",title:"Introduction"},{url:"tour",title:"Guided Tour"},{url:"accounts",title:"Adding Accounts"},{url:"searching",title:"Searching Documents and Data"},{url:"uploading",title:"Uploading Documents"},{url:"troubleshooting",title:"Troubleshooting Failed Uploads"},{url:"modification",title:"Document Modification"},{url:"notes",title:"Editing Notes and Sections"},{url:"collaboration",title:"Collaboration"},{url:"privacy",title:"Privacy"},{url:"publishing",
title:"Publishing &amp; Embedding"},{url:"api",title:"The DocumentCloud API"}],events:{"click .contact_us":"openContactDialog","click .uservoice":"openUserVoice"},initialize:function(){this.currentPage=null;this.PAGE_URLS=_.pluck(this.PAGES,"url")},render:function(){dc.app.navigation.bind("tab:help",_.bind(this.openHelpTab,this));this._toolbar=$("#help_toolbar");dc.account&&this._toolbar.prepend(this._createHelpMenu().render().el);return this},openContactDialog:function(){dc.ui.Dialog.contact()},
openUserVoice:function(){window.open("http://documentcloud.uservoice.com")},openPage:function(a){var b=!_.include(this.PAGE_URLS,a)||a===this.currentPage;this.currentPage=a;this.saveHistory();if(b)return dc.app.navigation.open("help");a||(a=dc.account?"index":"public");$.get("/ajax_help/"+a+".html",function(a){$("#help_content").html(a)});dc.app.navigation.open("help")},openHelpTab:function(){this.currentPage?this.saveHistory():this.openPage("")},saveHistory:function(){Backbone.history.navigate("help"+
(this.currentPage?"/"+this.currentPage:""))},_createHelpMenu:function(){return this.menu=new dc.ui.Menu({id:"how_to_menu",label:"Guides &amp; How To's",items:_.map(this.PAGES,_.bind(function(a){return{onClick:_.bind(this.openPage,this,a.url),title:a.title}},this))})}});
dc.ui.Navigation=Backbone.View.extend({SECTIONS:{documents:"sidebar",search:"panel",help:"panel"},constructor:function(){Backbone.View.call(this,{el:document.body});this.modes={}},render:function(){this.tabs=_.reduce(_.keys(this.SECTIONS),_.bind(function(a,b){var c=$("#"+b+"_tab");a[b]=c.click(_.bind(this._switchTab,this,b));return a},this),{});this.open("documents");$("#toplinks .open_accounts").click(function(){dc.app.accounts.open()});this.setMode("search","panel_tab");return this},open:function(a,
b){if(this.isOpen(a))return!1;this._switchTab(a,b)},isOpen:function(a){return this.modes[this.SECTIONS[a]+"_tab"]==a},_switchTab:function(a,b){var c=this.tabs[a];$(".tab.active",$(c).closest(".tabs")).removeClass("active");c.addClass("active");this.setMode(a,this.SECTIONS[a]+"_tab");b!==!0&&this.trigger("tab:"+a);_.defer(dc.app.scroller.check)}});_.extend(dc.ui.Navigation.prototype,Backbone.Events);
dc.ui.Panel=Backbone.View.extend({className:"panel_container",initialize:function(){_.bindAll(this,"_setMinHeight")},render:function(){$(this.el).html(JST["workspace/panel"]({}));this.content=this.$(".panel_content");$(window).resize(this._setMinHeight);_.defer(this._setMinHeight);return this},add:function(a,b){this.$("#"+a+"_container").append(b)},_setMinHeight:function(){$(this.el).css({"min-height":$(window).height()-100})}});
dc.ui.Sidebar=Backbone.View.extend({id:"sidebar",render:function(){$(this.el).html(JST["workspace/sidebar"]({}));this.content=this.$("#sidebar_content");dc.app.scroller=(new dc.ui.Scroll(this.content)).render();return this},add:function(a,b){this.$("#"+a+"_container").append(b)}});
dc.ui.Toolbar=Backbone.View.extend({id:"toolbar",events:{"click #open_viewers":"_clickOpenViewers","click #size_toggle":"_toggleSize"},MENUS:["edit","sort","project","publish","analyze"],constructor:function(a){this._floating=!1;Backbone.View.call(this,a);_.bindAll(this,"_updateSelectedDocuments","_deleteSelectedDocuments","editTitle","editSource","editDescription","editRelatedArticle","editAccess","openDocumentEmbedDialog","openNoteEmbedDialog","openSearchEmbedDialog","openPublicationDateDialog",
"requestDownloadViewers","checkFloat","_openTimeline","_viewEntities","editPublishedUrl","openShareDialog","_markOrder","_removeFromSelectedProject","_enableAnalyzeMenu");this.sortMenu=this._createSortMenu();this.analyzeMenu=this._createAnalyzeMenu();this.publishMenu=this._createPublishMenu();if(dc.account)this.editMenu=this._createEditMenu(),this.projectMenu=new dc.ui.ProjectMenu({onClick:this._updateSelectedDocuments})},render:function(){var a=$(this.el);a.html(JST["workspace/toolbar"]({}));_.each(this.MENUS,
_.bind(function(b){var c=this[b+"Menu"];c&&$("."+b+"_menu_container",a).append(c.render().el)},this));this.openButton=this.$("#open_viewers");this.floatEl=this.$("#floating_toolbar");$(window).scroll(_.bind(function(){_.defer(this.checkFloat)},this));return this},edit:function(a,b){var c=Documents.selected();if(Documents.allowedToEdit(c,b))return a.call(this,c)},editTitle:function(){this.edit(function(a){var b=a[0];dc.ui.Dialog.prompt("Title",b.get("title"),function(a){b.save({title:a});return!0},
{mode:"short_prompt"})})},editDescription:function(){this.edit(function(a){var b=Documents.sharedAttribute(a,"description")||"";dc.ui.Dialog.prompt("Description",b,function(b){_.each(a,function(a){a.save({description:b})});return!0},{information:Documents.subtitle(a.length)})})},editSource:function(){this.edit(function(a){var b=Documents.sharedAttribute(a,"source")||"";dc.ui.Dialog.prompt("Source",b,function(b){_.each(a,function(a){a.save({source:b})});return!0},{mode:"short_prompt",information:Documents.subtitle(a.length)})})},
editRelatedArticle:function(){this.edit(function(a){var b=Documents.sharedAttribute(a,"related_article")||"",c=a.length>1?"these documents:":"this document:";dc.ui.Dialog.prompt("Related Article URL",b,function(b,c){if((b=dc.inflector.normalizeUrl(b))&&!c.validateUrl(b))return!1;_.each(a,function(a){a.save({related_article:b})});return!0},{mode:"short_prompt",information:Documents.subtitle(a.length),description:"Enter the URL of the article that references "+c})})},editPublishedUrl:function(){this.edit(function(a){var b=
Documents.sharedAttribute(a,"remote_url")||"",c=a.length>1?"these documents are":"this document is";dc.ui.Dialog.prompt("Published URL",b,function(b,c){if((b=dc.inflector.normalizeUrl(b))&&!c.validateUrl(b))return!1;_.each(a,function(a){a.save({remote_url:b})});return!0},{mode:"short_prompt",information:Documents.subtitle(a.length),description:"Enter the URL at which "+c+" embedded:"})})},editAccess:function(){Documents.editAccess(Documents.selected())},editData:function(){var a=Documents.selected();
Documents.allowedToEdit(a)&&new dc.ui.DocumentDataDialog(a)},openViewers:function(a,b,c){if(!Documents.selectedCount)return dc.ui.Dialog.alert("Please select a document to open.");var d=function(a){_.each(a,function(a){a=a.openAppropriateVersion(b);if(c)a.DV||(a.DV={}),a.DV.afterLoad=c})};a?this.edit(d):d(Documents.selected())},openSearchEmbedDialog:function(){var a=Documents.chosen();dc.app.searchEmbedDialog=new dc.ui.SearchEmbedDialog(a)},openDocumentEmbedDialog:function(){var a=Documents.chosen();
if(a.length){if(a.length!=1)return dc.ui.Dialog.alert("Please select a single document in order to create the embed.");a=a[0];a.checkAllowedToEdit(Documents.EMBED_FORBIDDEN)&&(new dc.ui.DocumentEmbedDialog(a)).render()}},openNoteEmbedDialog:function(){var a=Documents.chosen();if(a.length){if(a.length!=1)return dc.ui.Dialog.alert("Please select a single document in order to create the embed.");a=a[0];if(a.notes.length&&!a.notes.any(function(a){return a.get("access")=="public"})||!a.notes.length&&!a.get("public_note_count"))return dc.ui.Dialog.alert("Please select a document with at least one public note.");
if(a.checkAllowedToEdit(Documents.EMBED_FORBIDDEN))dc.app.noteEmbedDialog=new dc.ui.NoteEmbedDialog(a)}},openShareDialog:function(){var a=Documents.chosen();if(a.length&&Documents.allowedToEdit(a))dc.app.shareDialog=new dc.ui.ShareDialog({docs:a,mode:"custom"})},openCurrentProject:function(){Projects.firstSelected().edit()},openPublicationDateDialog:function(){var a=Documents.chosen();a.length&&Documents.allowedToEdit(a)&&new dc.ui.PublicationDateDialog(a)},requestDownloadViewers:function(){if(dc.account.organization.demo)return dc.ui.Dialog.alert('Demo accounts are not allowed to download viewers. <a href="/contact">Contact us</a> if you need a full featured account.');
var a=Documents.chosen();a.length&&Documents.downloadViewers(a)},checkFloat:function(){var a=dc.app.navigation.isOpen("search")&&$(window).scrollTop()>$(this.el).offset().top-30;if(this._floating!=a)$(document.body).toggleClass("floating_toolbar",this._floating=a)},_updateSelectedDocuments:function(a){var b=Documents.selected();a.containsAny(b)?a.removeDocuments(b):a.addDocuments(b)},_removeFromSelectedProject:function(){var a=Documents.selected();Projects.firstSelected().removeDocuments(a)},_deleteSelectedDocuments:function(){Documents.verifyDestroy(Documents.selected())},
_openTimeline:function(){var a=Documents.chosen();if(a.length||!Documents.selectedCount){if(a.length>10)return dc.ui.Dialog.alert("You can only view a timeline for ten documents at a time.");a.length<=0&&(a=Documents.models.slice(0,10));if(a.length<=0)return dc.ui.Dialog.alert("In order to view a timeline, please select some documents.");new dc.ui.TimelineDialog(a)}},_viewEntities:function(){var a=Documents.chosen();if(a.length||!Documents.selectedCount){if(a.length<=0)a=Documents.models;dc.app.paginator.ensureRows(function(){dc.model.EntitySet.populateDocuments(a)},
a[0])}},_panel:function(){return this._panelEl=this._panelEl||$(this.el).parents(".panel_content")[0]},_chooseSort:function(a){dc.app.paginator.setSortOrder($(a.target).attr("data-order"))},_markOrder:function(a){$(".menu_item",a.content).removeClass("checked").filter('[data-order="'+dc.app.paginator.sortOrder+'"]').addClass("checked")},_enableMenuItems:function(a){var b=Documents.length,c=Documents.selectedCount,d=Documents.selectedPublicCount();$(".menu_item:not(.plus,.always)",a.content).toggleClass("disabled",
!c).attr("title",c?"":"No documents selected");$(".singular",a.content).toggleClass("disabled",c!=1);$(".private_only",a.content).toggleClass("disabled",!c||d>0).attr("title",c&&d>0?"already public":"");$(".menu_item.always",a.content).toggleClass("disabled",!b);$(".menu_item.project",a.content).toggleClass("hidden",!Projects.firstSelected())},_enableAnalyzeMenu:function(a){this._enableMenuItems(a);var b=Documents.selectedCount==1;$(".share_documents",a.content).text(b?"Share this Document":"Share these Documents");
$(".share_project",a.content).toggleClass("disabled",!Projects.selectedCount)},_createPublishMenu:function(){var a=[{title:"Embed Document Viewer",onClick:this.openDocumentEmbedDialog,attrs:{"class":"singular"}},{title:"Embed Document List",onClick:this.openSearchEmbedDialog,attrs:{"class":"always"}},{title:"Embed a Note",onClick:this.openNoteEmbedDialog,attrs:{"class":"singular"}},{title:"Set Publication Date",onClick:this.openPublicationDateDialog,attrs:{"class":"private_only"}},{title:"Download Document Viewer",
onClick:this.requestDownloadViewers}],b=[{title:"Download Original PDF",onClick:Documents.downloadSelectedPDF},{title:"Download Full Text",onClick:Documents.downloadSelectedFullText},{title:"Print Notes",onClick:Documents.printNotes}];a=dc.account?a.concat(b):b;return new dc.ui.Menu({label:dc.account?"Publish":"Save",onOpen:this._enableMenuItems,items:a})},_createSortMenu:function(){return new dc.ui.Menu({label:"Sort",onOpen:this._markOrder,items:[{title:"Sort by Relevance",attrs:{"data-order":"score"},
onClick:this._chooseSort},{title:"Sort by Date Uploaded",attrs:{"data-order":"created_at"},onClick:this._chooseSort},{title:"Sort by Title",attrs:{"data-order":"title"},onClick:this._chooseSort},{title:"Sort by Source",attrs:{"data-order":"source"},onClick:this._chooseSort},{title:"Sort by Length",attrs:{"data-order":"page_count"},onClick:this._chooseSort}]})},_createEditMenu:function(){return new dc.ui.Menu({label:"Edit",onOpen:this._enableMenuItems,items:[{title:"Edit Document Information",attrs:{"class":"multiple"},
onClick:function(){dc.ui.DocumentDialog.open()}},{title:"Title",attrs:{"class":"singular indent"},onClick:this.editTitle},{title:"Source",attrs:{"class":"multiple indent"},onClick:this.editSource},{title:"Description",attrs:{"class":"multiple indent"},onClick:this.editDescription},{title:"Access Level",attrs:{"class":"multiple indent"},onClick:this.editAccess},{title:"Related Article URL",attrs:{"class":"multiple indent"},onClick:this.editRelatedArticle},{title:"Published URL",attrs:{"class":"multiple indent"},
onClick:this.editPublishedUrl},{title:"Edit Document Data",attrs:{"class":"multiple"},onClick:this.editData},{title:"Modify Original Document",attrs:{"class":"multiple"},onClick:_.bind(this.openViewers,this,!0,"#pages",null)},{title:"Remove from this Project",attrs:{"class":"multiple project"},onClick:this._removeFromSelectedProject},{title:"Delete Documents",attrs:{"class":"multiple warn"},onClick:this._deleteSelectedDocuments}]})},_createAnalyzeMenu:function(){var a=[{title:"View Entities",attrs:{"class":"always"},
onClick:this._viewEntities},{title:"View Timeline",attrs:{"class":"always"},onClick:this._openTimeline}],b=[{title:"Share these Documents",attrs:{"class":"multiple share_documents"},onClick:this.openShareDialog},{title:"Share this Project",attrs:{"class":"share_project"},onClick:this.openCurrentProject}];return new dc.ui.Menu({label:"Analyze",onOpen:this._enableAnalyzeMenu,items:dc.account?a.concat(b):a})},_openEditPageTextEditor:function(a){_.defer(function(){a.window.dc.app.editor.editPageTextEditor.open()})},
_openInsertEditor:function(a){_.defer(function(){a.window.dc.app.editor.replacePagesEditor.open()})},_openRemoveEditor:function(a){_.defer(function(){a.window.dc.app.editor.removePagesEditor.open()})},_openReorderEditor:function(a){_.defer(function(){a.window.dc.app.editor.reorderPagesEditor.open()})},_clickOpenViewers:function(){this.openViewers()},_toggleSize:function(){dc.app.paginator.toggleSize()}});
dc.app.download=function(a,b){dc.ui.spinner.show();var c=document.createElement("iframe");c.src=a;c.style.display="none";var d=setInterval(function(){c.contentDocument.readyState=="complete"&&(dc.ui.spinner.hide(),clearInterval(d),b&&b(),$(c).remove())},100);$(document.body).append(c)};dc.app.editor=new Backbone.View;
_.extend(dc.app.editor,{initialize:function(a,b){this.setElement("body");this.docId=a;this.options=b;_.bindAll(this,"closeAllEditors","confirmStateChange");dc.app.hotkeys.initialize();this.createSubViews();this.renderSubViews();currentDocument.api.onChangeState(this.closeAllEditors)},confirmStateChange:function(a){if(!this._openDialog)this._openDialog=dc.ui.Dialog.confirm("You have unsaved changes. Are you sure you want to leave without saving them?",a,{onClose:_.bind(function(){this._openDialog=
null},this)})},setSaveState:function(a){this.unsavedChanges=a;currentDocument.api.setConfirmStateChange(a?this.confirmStateChange:null)},createSubViews:function(){dc.ui.notifier=new dc.ui.Notifier;this.controlPanel=new dc.ui.ViewerControlPanel;this.sectionEditor=new dc.ui.SectionEditor;this.annotationEditor=new dc.ui.AnnotationEditor;this.removePagesEditor=new dc.ui.RemovePagesEditor({editor:this});this.reorderPagesEditor=new dc.ui.ReorderPagesEditor({editor:this});this.editPageTextEditor=new dc.ui.EditPageTextEditor({editor:this});
this.replacePagesEditor=new dc.ui.ReplacePagesEditor({editor:this})},renderSubViews:function(){var a="DV-isContributor";this.options.isReviewer&&(a="DV-isReviewer");this.options.isOwner&&(a="DV-isOwner");$(".DV-docViewer").addClass(a);$(".DV-well").append(this.controlPanel.render().el);$(".DV-logo").hide();$(".DV-thumbnailsView").show();currentDocument.api.roundTabCorners();a=$(".DV-supplemental");a.hasClass("DV-noNavigation")&&a.removeClass("DV-noNavigation").addClass("DV-noNavigationMargin")},closeAllEditors:function(){this.removePagesEditor.close();
this.reorderPagesEditor.close();this.replacePagesEditor.close();this.editPageTextEditor.close();return!0}});
dc.app.hotkeys={KEYS:{"16":"shift","17":"control","91":"command","93":"command","224":"command","13":"enter","37":"left","38":"upArrow","39":"right","40":"downArrow","46":"delete","8":"backspace","9":"tab","188":"comma"},initialize:function(){_.bindAll(this,"down","up","blur");$(document).bind("keydown",this.down);$(document).bind("keyup",this.up);$(window).bind("blur",this.blur)},down:function(a){(a=this.KEYS[a.which])&&(this[a]=!0)},up:function(a){(a=this.KEYS[a.which])&&(this[a]=!1)},blur:function(){for(var a in this.KEYS)this[this.KEYS[a]]=
!1},key:function(a){return this.KEYS[a.which]},colon:function(a){return(a=a.which)&&String.fromCharCode(a)==":"},printable:function(a){var b=a.which;if(a.type=="keydown"){if(b==32||b>=48&&b<=90||b>=96&&b<=111||b>=186&&b<=192||b>=219&&b<=222)return!0}else if(b>=32&&b<=126||b>=160&&b<=500||String.fromCharCode(b)==":")return!0;return!1}};
dc.app.cookies={get:function(a){var b=RegExp("\\s*"+a+"=(.*)$");a=document.cookie.split(";");return(a=_.detect(a,function(a){return a.match(b)}))?decodeURIComponent(a.match(b)[1]):null},set:function(a,b,c){var d=c?new Date:null;d&&(c=="remove"?d.setYear(d.getFullYear()-1):d.setYear(d.getFullYear()+2));c=d?"; expires="+d.toUTCString():"";document.cookie=a+"="+encodeURIComponent(b)+"; path=/"+c},remove:function(a){this.set(a,this.get(a),"remove")}};
dc.app.preferences={get:function(a,b){var c=this._prefs()[a];return!c||b&&!_.include(b,c)?null:c},set:function(a){this._setPrefs(_.extend(this._prefs(),a))},remove:function(a){var b=this._prefs();delete b[a];this._setPrefs(b)},_prefs:function(){return JSON.parse(dc.app.cookies.get("document_cloud_preferences")||"{}")},_setPrefs:function(a){dc.app.cookies.set("document_cloud_preferences",JSON.stringify(a),!0)}};
dc.controllers.Searcher=Backbone.Router.extend({NO_RESULTS:{project:"This project does not contain any documents.",account:"This account does not have any documents.",group:"This organization does not have any documents.",published:"This account does not have any published documents.",annotated:"There are no annotated documents.",search:"Your search did not match any documents.",all:"There are no documents."},PAGE_MATCHER:/\/p(\d+)$/,DOCUMENTS_URL:"/search/documents.json",FACETS_URL:"/search/facets.json",
fragment:null,flags:{},routes:{"search/*query/p:page":"searchByHash","search/*query":"searchByHash"},initialize:function(){this.searchBox=dc.app.searchBox;this.flags.hasEntities=!1;this.currentSearch=null;this.titleBox=$("#title_box_inner");_.bindAll(this,"_loadSearchResults","_loadFacetsResults","_loadFacetResults","loadDefault","loadFacets");dc.app.navigation.bind("tab:search",this.loadDefault)},urlFragment:function(){return this.fragment+(this.page?"/p"+this.page:"")},loadDefault:function(a){a||
(a={});a.clear&&(Documents.reset(),this.searchBox.value(""));this.currentSearch||(Documents.isEmpty()?this.searchBox.value()?this.search(this.searchBox.value()):dc.account&&dc.account.hasDocuments?Accounts.current().openDocuments():Projects.first()?Projects.first().open():a.showHelp&&dc.account?dc.app.navigation.open("help"):this.search(""):(this.navigate(this.urlFragment()),this.showDocuments()))},loadPage:function(a,b){a=a||this.page||1;var c=dc.app.paginator.pageCount();a<1&&(a=1);a>c&&(a=c);this.search(this.searchBox.value(),
a,b)},quote:function(a){return a.match(/\s/)?'"'+a+'"':a},publicQuery:function(){var a=[],b=VS.app.searchQuery.values("project");_.each(b,function(b){a.push(Projects.find(b))});b=VS.app.searchQuery.withoutCategory("project");b=_.map(a,function(a){return"projectid: "+a.slug()}).join(" ")+" "+b;return b=b.replace(/(document: \d+)-\S+/g,"$1")},queryText:function(){return VS.app.searchQuery.find("text")},search:function(a,b,c){dc.ui.spinner.show();dc.app.navigation.open("search");this.currentSearch&&
this.currentSearch.abort();this.searchBox.value(a);this.flags.related=a.indexOf("related:")>=0;this.flags.specific=a.indexOf("document:")>=0;this.flags.hasEntities=!1;this.page=b<=1?null:b;this.fragment="search/"+a;this.showDocuments();this.navigate(this.urlFragment());Documents.reset();this._afterSearch=c;a=_.extend(dc.app.paginator.queryParams(),{q:a});if(dc.app.navigation.isOpen("entities"))a.include_facets=!0;if(this.page)a.page=this.page;this.currentSearch=$.ajax({url:this.DOCUMENTS_URL,data:a,
success:this._loadSearchResults,error:function(a){a.status==403&&Accounts.forceLogout()},dataType:"json"})},showDocuments:function(){var a=this.searchBox.value();a=dc.model.DocumentSet.entitle(a);var b=VS.app.searchQuery.find("project"),c=VS.app.searchQuery.find("group");$(document.body).setMode("active","search");this.titleBox.html(a);dc.app.organizer.highlight(b,c)},doneSearching:function(){var a=dc.app.paginator.query.total,b=dc.inflector.pluralize("Document",a),c=this.searchType();this.flags.specific?
this.titleBox.text(a+" "+b):c=="search"&&(b=VS.app.searchQuery.has("project"),b=" in "+(b?"\u201c":"")+this.titleBox.html()+(b?"\u201d":""),this.titleBox.html((a?a+" "+dc.inflector.pluralize("Result",a):"No Results")+b));a<=0&&($(document.body).setMode("empty","search"),a=this.NO_RESULTS[c]||this.NO_RESULTS.search,$("#no_results .explanation").text(a));dc.ui.spinner.hide();dc.app.scroller.checkLater()},searchType:function(){var a=!1,b=!1;VS.app.searchQuery.each(function(c){var d=c.get("category");
c.get("value")&&(!a&&!b?a=d:(b=!0,a=!1))});if(a=="filter")return VS.app.searchQuery.first().get("value");else if(a=="projectid")return"project";else if(_.contains(["project","group","account"],a))return a;else if(!a&&!b)return"all";return"search"},loadFacets:function(){if(!this.flags.hasEntities){var a=this.searchBox.value()||"";dc.ui.spinner.show();this.currentSearch=$.get(this.FACETS_URL,{q:a},this._loadFacetsResults,"json")}},loadFacet:function(a){dc.ui.spinner.show();this.currentSearch=$.get(this.FACETS_URL,
{q:this.searchBox.value(),facet:a},this._loadFacetResults,"json")},searchByHash:function(a,b){_.defer(_.bind(function(){this.search(decodeURIComponent(a),b&&parseInt(b,10))},this))},toggleSearch:function(a,b){VS.app.searchQuery.has(a)?this.removeFromSearch(a):this.addToSearch(a,b)},addToSearch:function(a,b,c){VS.app.searchQuery.has(a,b)||(VS.app.searchQuery.add({category:a,value:b}),this.search(VS.app.searchQuery.value(),null,c))},removeFromSearch:function(a){this.search(VS.app.searchQuery.withoutCategory(a));
return!0},viewEntities:function(a){dc.app.navigation.open("entities",!0);this.search(_.map(a,function(a){return"document: "+a.canonicalId()}).join(" "))},_loadSearchResults:function(a){dc.app.paginator.setQuery(a.query,this);a.facets&&this._loadFacetsResults(a);a=a.documents;for(var b=0,c=a.length;b<c;b++)a[b].index=b;Documents.reset(a);this.doneSearching();this.currentSearch=null;this._afterSearch&&this._afterSearch()},_loadFacetsResults:function(a){dc.app.workspace.entityList.renderFacets(a.facets,
5,a.query.total);dc.ui.spinner.hide();this.currentSearch=null;this.flags.hasEntities=!0},_loadFacetResults:function(a){dc.app.workspace.entityList.mergeFacets(a.facets,500,a.query.total);dc.ui.spinner.hide();this.currentSearch=null}});
dc.controllers.Workspace=Backbone.Router.extend({routes:{"help/:page":"help",help:"help"},initialize:function(){this.createSubViews();this.renderSubViews();dc.app.searcher=new dc.controllers.Searcher;Backbone.history.start({pushState:!0,root:dc.account?"/":"/public/"})||dc.app.searcher.loadDefault({showHelp:!0})},help:function(a){this.help.openPage(a||"")},createSubViews:function(){dc.app.paginator=new dc.ui.Paginator;dc.app.navigation=new dc.ui.Navigation;dc.app.toolbar=new dc.ui.Toolbar;dc.app.organizer=
new dc.ui.Organizer;dc.ui.notifier=new dc.ui.Notifier;dc.ui.tooltip=new dc.ui.Tooltip;dc.app.searchBox=VS.init(this.searchOptions());this.sidebar=new dc.ui.Sidebar;this.panel=new dc.ui.Panel;this.documentList=new dc.ui.DocumentList;this.entityList=new dc.ui.EntityList;if(dc.account)dc.app.uploader=new dc.ui.UploadDialog,dc.app.accounts=new dc.ui.AccountDialog,this.accountBadge=new dc.ui.AccountView({model:Accounts.current(),kind:"badge"})},renderSubViews:function(){var a=$("#content");a.append(this.sidebar.render().el);
a.append(this.panel.render().el);dc.app.navigation.render();dc.app.hotkeys.initialize();this.help=(new dc.ui.Help({el:$("#help")[0]})).render();this.panel.add("search_box",dc.app.searchBox.render().el);this.panel.add("pagination",dc.app.paginator.el);this.panel.add("search_toolbar",dc.app.toolbar.render().el);this.panel.add("document_list",this.documentList.render().el);this.sidebar.add("entities",this.entityList.render().el);$("#no_results_container").html(JST["workspace/no_results"]({}));this.sidebar.add("organizer",
dc.app.organizer.render().el);dc.account&&this.sidebar.add("account_badge",this.accountBadge.render().el)},searchOptions:function(){return{unquotable:["text","account","document","filter","group","access","projectid"],callbacks:{search:function(a){dc.app.searcher.flags.outstandingSearch||(dc.app.paginator.hide(),_.defer(dc.app.toolbar.checkFloat),dc.app.searcher.search(a));return!1},focus:function(){Documents.deselectAll()},valueMatches:function(a,b,c){switch(a){case "account":c(Accounts.map(function(a){return{value:a.get("slug"),
label:a.fullName()}}));break;case "project":c(Projects.pluck("title"));break;case "filter":c(["annotated","popular","published","unpublished","restricted"]);break;case "access":c(["public","private","organization","pending","error"]);break;case "title":c(_.uniq(Documents.pluck("title")));break;case "source":c(_.uniq(_.compact(Documents.pluck("source"))));break;case "group":c(Organizations.map(function(a){return{value:a.get("slug"),label:a.get("name")}}));break;case "document":c(Documents.map(function(a){return{value:a.canonicalId(),
label:a.get("title")}}));break;default:c(_.compact(_.uniq(Documents.reduce(function(b,c){_.size(c.get("data"))&&b.push(c.get("data")[a]);return b},[]))))}},facetMatches:function(a){var b=[{label:"project",category:""},{label:"text",category:""},{label:"title",category:""},{label:"description",category:""},{label:"source",category:""},{label:"account",category:""},{label:"document",category:""},{label:"filter",category:""},{label:"group",category:""},{label:"access",category:""},{label:"projectid",
category:""}],c=_.map(_.keys(Documents.reduce(function(a,b){_.size(b.get("data"))&&_.extend(a,b.get("data"));return a},{})),function(a){return{label:a,category:""}});a&&a(b.concat(c))}}}}});
(function(){window.JST=window.JST||{};window.JST["account/admin"]=_.template('<td class="first">\n  <div class="pending_wrap">\n    <div class="pending_badge icon alert_yellow"></div>\n  </div>\n  <img class="avatar" src="<%= account.DEFAULT_AVATAR %>" width="<%= size %>" height="<%= size %>" />\n</td>\n<td class="name">\n  <span class="display">\n    <a href="<%= account.searchUrl() %>"><%= account.fullName(true) %></a>&nbsp;<span class="pending_notification">(pending)</span>\n  </span>\n</td>\n<td class="email">\n  <span class="display">\n    <%= email %>\n  </span>\n</td>\n<td class="organization">\n  <span class="display">\n    <%= account.get(\'organization_name\') %>\n  </span>\n</td>\n<td class="document_count">\n  <span class="display">\n    <% var pub = account.get(\'public_document_count\'), priv = account.get(\'private_document_count\'); %>\n    <span class="public" title="public documents"><%= pub %></span>\n    <%= pub && priv ? \'/\' : \'\' %>\n    <span class="private" title="private documents"><%= priv %></span>\n  </span>\n</td>\n<td class="page_count">\n  <span class="display">\n    <%= account.get(\'page_count\') %>\n  </span>\n</td>\n<td class="login_as">\n  <div class="minibutton">Login</div>\n</td>\n<td class="last">\n</td>\n');window.JST["account/badge"]=
_.template('<img class="avatar" src="<%= account.DEFAULT_AVATAR %>" width="<%= size %>" height="<%= size %>" />\n<div class="name">\n  <%= dc.inflector.truncate(account.fullName(), 20) %>\n</div>\n<div class="controls">\n  <a href="#" class="admin_link text_link">Manage Accounts</a>\n  &nbsp;/&nbsp;\n  <a href="/logout" class="text_link">Log Out</a>\n</div>\n');window.JST["account/collaborator"]=_.template('<td class="first">\n  <img class="avatar" src="<%= account.DEFAULT_AVATAR %>" width="<%= size %>" height="<%= size %>" />\n</td>\n<td class="name selectable_text">\n  <%= dc.inflector.truncate(account.fullName(true), 25) %>\n</td>\n<td class="organization_name selectable_text">\n  <%= dc.inflector.truncate(account.get(\'organization_name\'), 25) %>\n</td>\n<td class="last">\n  <% if (account.id != project.get(\'account_id\')) { %>\n    <span class="remove text_link" data-id="<%= account.id %>">remove</span>\n  <% } else { %>\n    (project owner)\n  <% } %>\n</td>\n');
window.JST["account/dialog"]=_.template('<table border="0" cellspacing="0" cellpadding="0">\n  <tbody class="account_list_content">\n  </tbody>\n</table>\n');window.JST["account/reviewer"]=_.template('<% var fullName = dc.inflector.truncate(account.fullName(true), 40); %>\n<% var email    = dc.inflector.truncate(account.get(\'email\'), 23); %>\n\n<td class="first">\n  <img class="avatar" src="<%= account.DEFAULT_AVATAR %>" width="<%= size %>" height="<%= size %>" />\n</td>\n\n<td class="email">\n  <% if (account.isReviewer()) { %>\n    <div class="display selectable_text">\n      <%= email %>\n    </div>\n    <div class="edit">\n      <div class="text_input dark small">\n        <input name="email" type="text" placeholder="Email" value="<%= account.get(\'email\') %>" />\n      </div>\n    </div>\n  <% } else { %>\n    <div class="selectable_text">\n      <%= email %>\n    </div>\n  <% } %>\n</td>\n\n<td class="name">\n  <% if (account.isReviewer()) { %>\n    <div class="display">\n      <span class="account_name selectable_text">\n        <%= fullName %>\n      </span>\n    </div>\n    <div class="edit">\n      <div class="name_wrapper">\n        <div class="text_input dark small">\n          <input name="first_name" id="reviewer_first_name" type="text" placeholder="First name" value="<%= account.get(\'first_name\') %>" />\n        </div>\n        <div class="text_input dark small">\n          <input name="last_name" id="reviewer_last_name" type="text" placeholder="Last name" value="<%= account.get(\'last_name\') %>" />\n        </div>\n      </div>\n    </div>\n  <% } else { %>\n    <span class="account_name selectable_text">\n      <%= fullName %>\n    </span>\n  <% } %>\n</td>\n\n<td class="edit_column">\n  <div class="display">\n    <span class="edit_account icon edit_glyph_dark"></span>\n  </div>\n  <div class="edit">\n    <div class="cancel_changes icon cancel_search_dark"></div>\n  </div>\n</td>\n\n<td class="last nowrap">\n  <div class="display">\n    <% if (documentsCount && documentsCount > 1) { %>\n      <span class="document_count">sharing <%= documentCount %>/<%= documentsCount %> <%= dc.inflector.pluralize(\'document\', documentsCount) %></span>\n    <% } else if (!account.get(\'needsEmail\')) { %>\n      <span class="resend_reviewer text_link" data-account-id="<%= account.id %>">resend instructions</span>\n    <% } %>\n  </div>\n  <div class="edit">\n    <% if (account.isReviewer()) { %>\n      <div class="minibutton default save_changes">\n        Save\n      </div>\n    <% } %>\n    <div class="minibutton warn remove_reviewer" data-account-id="<%= account.id %>">Revoke</div>\n  </div>\n</td>\n');
window.JST["account/row"]=_.template('<td class="first">\n  <div class="pending_wrap">\n    <div class="pending_badge icon alert_yellow"></div>\n  </div>\n  <img class="avatar" src="<%= account.DEFAULT_AVATAR %>" width="<%= size %>" height="<%= size %>" />\n</td>\n<td class="name">\n  <span class="display selectable_text">\n    <%= dc.inflector.truncate(account.fullName(true) || \'\', 25) %>&nbsp;<span class="pending_notification">(pending)</span>\n  </span>\n  <div class="edit name_wrapper">\n    <div class="text_input dark small">\n      <input name="first_name" type="text" placeholder="first name" value="<%= account.get(\'first_name\') %>" />\n    </div>\n    <div class="text_input dark small">\n      <input name="last_name" type="text" placeholder="last name" value="<%= account.get(\'last_name\') %>" />\n    </div>\n  </div>\n</td>\n<td class="email">\n  <span class="display selectable_text">\n    <%= dc.inflector.truncate(email || \'\', 25) %>\n  </span>\n  <div class="text_input edit dark small">\n    <input name="email" type="text" placeholder="email" value="<%= email %>" />\n  </div>\n</td>\n<td class="role">\n  <span class="display">\n    <% if (account.ROLE_NAMES[account.get(\'role\')] == \'disabled\') { %>\n      <span class="disabled">(disabled)</span>\n    <% } else { %>\n      <%= account.ROLE_NAMES[account.get(\'role\')] %>\n    <% } %>\n  </span>\n  <span class="edit">\n    <% if (account.ROLE_NAMES[account.get(\'role\')] == \'disabled\') { %>\n      <span class="disabled">(disabled)</span>\n    <% } else { %>\n      <select name="role" class="account_role" <%= current && current.isAdmin() && account.id != current.id ? \'\' : \'disabled="disabled"\' %>>\n        <option class="role_1" value="1">Administrator</option>\n        <option class="role_2" value="2">Contributor</option>\n        <option class="role_4" value="4">Freelancer</option>\n      </select>\n    <% } %>\n  </span>\n</td>\n<td class="last">\n  <% if (account == current || (current && current.isAdmin())) { %>\n  <div class="edit_account icon edit_glyph_dark display"></div>\n  <% if (account == current) { %>\n    <span class="change_password display text_link">change password</span>\n  <% } else if (account.isPending()) { %>\n    <span class="resend_welcome display text_link">resend welcome email</span>\n   <% } %>\n  <div class="edit controls_wrapper">\n    <div class="minibutton default save_changes">OK</div>\n    <% if (account.id && account.id > 0 && account.id != dc.account.id) { %>\n      <% if (account.ROLE_NAMES[account.get(\'role\')] == \'disabled\') { %>\n        <div class="minibutton warn enable_account">Re-enable</div>\n      <% } else { %>\n        <div class="minibutton warn disable_account">Disable</div>\n      <% } %>\n      \n    <% } %>\n  </div>\n  <% } %>\n</td>\n');
window.JST["account/share_dialog"]=_.template('<div class="document_reviewers_empty">\n  <p>There are no reviewers on <% if (docCount == 1) { %>this document<% } else { %>these documents<% }%>.</p>\n</div>\n\n<div class="step_one document_reviewers not_draggable account_list">\n  <table border="0" cellspacing="0" cellpadding="0" class="account_list_content">\n    <tr class="reviewer_management">\n      \n      <td class="first">\n        <img class="avatar" src="<%= defaultAvatar %>" width="24" height="24" />\n      </td>\n      \n      <td class="email">\n        <div class="text_input dark small">\n          <input name="email" type="text" value="" placeholder="Email" class="reviewer_management_email" />\n        </div>\n      </td>\n      \n      <td class="name selectable_text">\n        <div class="name_wrapper">\n          <div class="text_input dark small">\n            <input name="first_name" ype="text" value="" placeholder="First name" class="reviewer_management_firstname" />\n          </div>\n          <div class="text_input dark small">\n            <input name="last_name" type="text" value="" placeholder="Last name" class="reviewer_management_lastname" />\n          </div>\n        </div>\n      </td>\n    \n      <td class="edit_column">\n        <div class="cancel_add icon cancel_search_dark"></div>\n      </td>\n      \n      <td class="last error"></td>\n      \n    </tr>\n  </table>\n</div>\n\n<div class="step_two is_custom_email">\n  <div class="email_description dialog_info">\n  </div>\n  <div class="prompt">\n    <textarea class="email_message text_area dark content" placeholder="Optional: Include a personal message&hellip;"></textarea>\n  </div>\n  <div class="dialog_info">\n    Before continuing, you can take a moment to \n    <span class="text_link preview">preview the email message</span>.\n  </div>\n</div>\n\n<div class="step_controls">\n  <div class="minibutton next default">Next <span class="text_arrow">&raquo;</span></div>\n  <div class="minibutton previous dark"><span class="text_arrow">&laquo;</span> Back</div>\n  <div class="minibutton close dark">Close</div>\n  <div class="minibutton add_reviewer default" style="width: 90px;">Add Reviewer</div>\n</div>\n');
window.JST["common/contact"]=_.template('<div class="text">\n  Use this form (or email to\n  <a href="mailto:support@documentcloud.org">support@documentcloud.org</a>)\n  to contact us for assistance. If you need to speak to someone immediately, you\n  can call us at (202) 505-1010.<br />\n  See <a href="/contact">documentcloud.org/contact</a> for more ways to get in touch.\n</div>\n\n<% if (!dc.account) { %>\n  <div class="text_input dark small">\n    <input name="email" class="contact_email" type="text" placeholder="Email&hellip;" />\n  </div>\n<% } %>\n\n<div class="prompt">\n  <textarea class="text_area dark small content" placeholder="Message&hellip;"></textarea>\n</div>');
window.JST["common/date_select"]=_.template('<select class="date_month">\n  <% var monthNum = date.getMonth() + 1; %>\n  <% _.each(DateUtils.MONTHS, function(month, value) { %>\n    <% value += 1; %>\n    <option value="<%= value %>" <%= value === monthNum ? \'selected="selected"\' : \'\' %>>\n      <%= month %>\n    </option>\n  <% }); %>\n</select>\n\n<select class="date_day" name="date[day]">\n  <% var day = date.getDate(); %>\n  <% for (var i = 1; i <= 31; i++) { %>\n    <option value="<%= i %>" <%= i === day ? \'selected="selected"\' : \'\' %>>\n      <%= i %>\n    </option>\n  <% } %>\n</select>\n\n<select class="date_year">\n  <% var year = date.getFullYear(); %>\n  <% var yearStart = (new Date).getFullYear(); %>\n  <% var yearEnd = yearStart + 5; %>\n  <% for (var i = yearStart; i < yearEnd; i++) { %>\n    <option value="<%= i %>" <%= i === year ? \'selected="selected"\' : \'\' %>>\n      <%= i %>\n    </option>\n  <% } %>\n</select>');
window.JST["common/dialog"]=_.template('<% if (title) { %>\n  <div class="title"><%= title %></div>\n<% } %>\n<div class="information selectable_text"><%= information || \'\' %></div>\n<% var spinner_style = mode == \'progress\' ? \'\' : \'display:none;\'; %>\n<div class="icon spinner_dark" style="<%= spinner_style %>"></div>\n<% if (description) { %>\n  <div class="description">\n    <%= description %>\n  </div>\n<% } %>\n<% if (text) { %>\n  <div class="text"><%= text %></div>\n<% } %>\n<% if (mode == \'custom\') { %>\n  <div class="custom"></div>\n<% } %>\n<% if( mode == \'prompt\' || mode == \'short_prompt\') { %>\n  <div class="<%= mode %>">\n    <% if (choices && mode == \'short_prompt\') { %>\n      <select class="content">\n        <% _.each(choices, function(choice) { %>\n          <option value="<%= choice.value %>" <%= choice.selected ? \'selected="true"\' : \'\' %>><%= choice.text %></option>\n        <% }); %>\n      </select>\n    <% } else if (choices) { %>\n      <div class="choices">\n        <% _.each(choices, function(choice, i) { %>\n          <input class="input" type="radio" name="choice" id="choice_<%= i %>" value="<%= choice.value %>" <%= choice.selected ? \'checked="true"\' : \'\' %>/>\n          <label for="choice_<%= i %>"><%= choice.text %></label>\n          <div class="choice_description selectable_text"><%= choice.description %></div>\n        <% }); %>\n      </div>\n    <% } else if (mode == \'prompt\') { %>\n      <textarea class="text_area dark content"></textarea>\n    <% } else { %>\n      <div class="text_input dark">\n        <input class="content" type="<%= password ? \'password\' : \'text\' %>" value="" />\n      </div>\n    <% } %>\n  </div>\n<% } %>\n<% if (mode != \'progress\') { %>\n  <div class="controls">\n    <% var saveText = saveText || ((editor || mode == \'prompt\' || mode == \'short_prompt\') ? \'Save\' : (mode == \'alert\' || mode == \'confirm\') ? \'OK\' : \'Close\'); %>\n    <% var closeText = closeText || (mode == \'confirm\' || saveText == \'Close\' ? \'Cancel\' : \'Close\'); %>\n    <% if (editor) { %>\n      <% var deleteText = deleteText || \'Delete\'; %>\n      <span class="minibutton delete warn"><%= deleteText %></span>\n    <% } %>\n    <span class="minibutton cancel dark"><%= closeText %></span>\n    <span class="minibutton ok default"><%= saveText %></span>\n  </div>\n<% } %>');
window.JST["common/hour_select"]=_.template('<select class="date_hour">\n  <% var hour = date.getHours(); %>\n  <% _.each(DateUtils.HOUR_SELECT, function(time, value) { %>\n    <option value="<%= value %>" <%= value === hour ? \'selected="selected"\' : \'\' %>>\n      <%= time %>\n    </option>\n  <% }); %>\n</select>');window.JST["common/menu"]=_.template('<% var mid = id ? id + "_content" : \'\'; %>\n<div class="menu_content interface <%= standalone ? \'standalone\' : \'attached\' %>" id="<%= mid %>">\n  <div class="menu_items">\n  </div>\n</div>\n\n');
window.JST["common/menubutton"]=_.template('<div class="wrapper">\n  <div class="label">\n    <%= label %>\n  </div>\n</div>\n<div class="corner"></div>\n');window.JST["common/tooltip"]=_.template('<div id="tooltip_title"></div>\n<div id="tooltip_text"></div>');window.JST["document/data_dialog"]=_.template('<div class="description">\n  Edit key/value pairs describing \n  <%= multiple ? "these documents" : "this document"%><% if (removeAll) { %>, \n  or <span class="text_link remove_all">remove all data</span><% } %>.\n  <br />\n  For example: &ldquo;birth: 1935-01-08&rdquo;, or &ldquo;status: released&rdquo;\n</div>\n\n<div class="rows">\n  <% _.each(data, function(pair) { %>\n    <%= JST["document/data_dialog_row"]({key: pair[0], value: pair[1], minus: true}) %>\n  <% }); %>\n</div>');
window.JST["document/data_dialog_row"]=_.template('<div class="data_row <%= minus ? \'\' : \'no_minus\' %>">\n  <div class="text_input dark small first float_left">\n    <input type="text" class="key" value="<%= dc.inflector.escapeHTML(key) %>" />\n  </div>\n  <div class="float_left">:&nbsp;&nbsp;</div>\n  <div class="text_input dark small float_left">\n    <input type="text" class="value" value="<%= dc.inflector.escapeHTML(value) %>" />\n  </div>\n  <div class="icon minus not_draggable float_left"></div>\n  <div class="icon plus not_draggable float_left"></div>\n  <br class="clear" />\n</div>');
window.JST["document/document_dialog"]=_.template('<% if (!multiple) { %>\n  <div class="row">\n    <label for="document_edit_title" title="Title of this document">\n      Title:\n    </label>\n    <div class="text_input dark small">\n      <input name="title" id="document_edit_title" class="attribute" type="text" />\n    </div>\n    <br class="clear" />\n  </div>\n<% } %>\n\n<div class="row">\n  <label for="document_edit_source" title="The source from which you obtained this document">\n    Source:\n  </label>\n  <div class="text_input dark small">\n    <input name="source" id="document_edit_source" class="attribute" type="text" />\n  </div>\n  <br class="clear" />\n</div>\n\n<div class="row tall">\n  <label for="document_edit_description" title="Paragraph description of this document">\n    Description:\n  </label>\n  <textarea name="description" id="document_edit_description" class="text_area dark small content attribute"></textarea>\n  <br class="clear" />\n</div>\n\n<div class="row">\n  <label for="document_edit_related_article" title="URL of the web article that refers to this document">\n    Related Article URL:\n  </label>\n  <div class="text_input dark small">\n    <input name="related_article" id="document_edit_related_article" class="attribute" type="text" />\n  </div>\n  <br class="clear" />\n</div>\n\n<% if (!multiple) { %>\n  <div class="row">\n    <label for="document_edit_remote_url" title="Most users won\'t need to add this. URL of the page on your site where this document is embedded">\n      Published URL:\n    </label>\n    <div class="text_input dark small">\n      <input name="remote_url" id="document_edit_remote_url" class="attribute" type="text" />\n    </div>\n    <br class="clear" />\n  </div>\n<% } %>\n\n<div class="row last">\n  <label for="document_edit_access">\n    Access Level:\n  </label>\n  <select name="access" class="document_access attribute" id="document_edit_access">\n    <option value="4">Public Access</option>\n    <option value="1">Private Access</option>\n    <option value="2">Private to <%= dc.account.organization.name %></option>\n  </select>\n</div>\n');
window.JST["document/embed_code"]=_.template('<div class="dialog_info selectable_text interface">\n  <span class="text_link remove_lines">Remove line breaks</span>\n  Add this HTML to your site to create a document viewer.\n</div>\n\n<textarea class="snippet">\n&lt;div id="DV-viewer-<%= doc.canonicalId() %>" class="DV-container"&gt;&lt;/div&gt;\n&lt;script src="http://s3.documentcloud.org/viewer/loader.js"&gt;&lt;/script&gt;\n&lt;script&gt;\n  DV.load(\'<%= doc.get("document_viewer_js") %>\', {\n    <%= options %>\n  });\n&lt;/script&gt;\n</textarea>\n\n<div class="dialog_info selectable_text interface">\n  You can find plenty of examples of embedded documents on our list of\n  <a class="text_link" href="http://www.documentcloud.org/featured" target="_blank">featured reporting</a>.\n</div>\n');
window.JST["document/entities"]=_.template('<% var entities = doc.entities; %>\n<% var renderedButton = false; %>\n\n<% var renderList = only ? [only] : dc.model.Entity.ORDER; %>\n<% _.each(renderList, function(kind) { %>\n  <% var list  = (entities.index()[kind] || []); %>\n  <% var graph = only || _.include(dc.model.Entity.SPARK_GRAPHS, kind); %>\n  <% var page  = only ? list : list.slice(0, dc.model.Entity.PER_PAGE); %>\n  <% if (list.length) { %>\n    <div class="entity_group">\n      \n      <div class="entity_group_header">\n        <% if (!renderedButton) { %>\n          <span class="icon cancel_search" title="hide entities"></span>\n          <% renderedButton = true; %>\n        <% } %>\n        <% if (only) { %>\n          <span class="arrow left interface">\u2190</span>\n        <% } %>\n        <span class="entity_group_title interface">\n          <%= list.length + \' \' + (list.length == 1 ? dc.inflector.capitalize(kind) : dc.model.Entity.DISPLAY_NAME[kind]) %>\n        </span>\n        <% if (list.length > page.length) { %>\n          <span class="text_link show_all" data-kind="<%= kind %>">Show all</span>\n        <% } %>\n      </div>\n      \n      <% if (graph) { %>\n        \n        <% for (var i = 0, l = page.length; i < l; i++) { %>\n          <% var entity = page[i]; %>\n          <div class="entity_line" data-id="<%= entity.id %>">\n            <div class="entity_line_title quiet_link">\n              <%= entity.escape(\'value\') %>\n            </div>\n            <div class="entity_buckets" style="width:<%= width %>px;">\n              <div class="entity_rule"></div>\n              <div>\n                <% var buckets = entity.buckets(width); %>\n                <% for (var j = 0, k = buckets.length + distance; j < k; j++) { %>\n                  <% var bucket = buckets[j]; %>\n                  <div class="<%= bucket ? \'occurs\' : \'\' %> entity_bucket_wrap">\n                    <% if (bucket) { %>\n                      <div class="entity_bucket" data-occurrence="<%= bucket.offset + \':\' + bucket.length %>" style="height:<%= bucket.height %>px; margin-top: -<%= Math.floor(bucket.height / 2) %>px;"></div>\n                    <% } %>\n                  </div>\n                <% } %>\n              </div>\n            </div>\n          </div>\n        <% } %>\n        \n      <% } else { %>\n        \n        <div class="entity_list" style="width:<%= width + 120 %>px;">\n          <% for (var i = 0, l = page.length; i < l; i++) { %>\n            <% var entity = page[i]; %>\n            <span class="entity_list_title quiet_link" data-id="<%= entity.id %>"><%= entity.escape(\'value\') %></span><%= ((i < l - 1) ? \', \' : \'\') %>\n          <% } %>\n        </div>\n        \n      <% } %>\n      \n    </div>\n  <% } %>\n<% }); %>\n');
window.JST["document/mentions"]=_.template('<div class="mentions">\n  <div class="mentions_header">\n    <span class="icon cancel_search" title="hide pages"></span>\n    <span class="mentions_title noselect interface"><%= mentions.length %>\n    <%= total > mentions.length ? "of " + total : "" %>\n    <%= dc.inflector.pluralize(\'page\', total) %>\n    mentioning &ldquo;<%= query %>&rdquo;</span>\n    <% if (total > mentions.length) { %>\n      <span class="text_link noselect show_mentions">Show all <%= total %> pages</span>\n    <% } %>\n  </div>\n  <% _.each(mentions, function(mention) { %>\n    <div class="page mention" data-page="<%= mention.page %>">\n      <div class="page_icon">\n        <img class="page_image" alt="page <%= mention.page %>" src="<%= model.pageThumbnailURL(mention.page) %>" />\n        <div class="page_number">p. <%= mention.page %></div>\n      </div>\n      <div class="page_excerpt noselect"><%= dc.inflector.trimExcerpt(dc.inflector.squeeze(mention.text)) %></div>\n      <div class="clear"></div>\n    </div>\n  <% }); %>\n  <div class="clear"></div>\n</div>');
window.JST["document/note"]=_.template('<div class="note_contents">\n  <div class="note_title display">\n    <span class="<% if (!disableLinks) { %>title_link<% } %>"><%= note.get(\'title\') %> <span class="page_number">(p. <%= note.get(\'page\') %>)</span></span>\n  </div>\n  <% if (note.get(\'access\') == \'exclusive\') { %>\n    <div class="note_draft_label interface display">Draft</div>\n  <% } %>\n  \n  <% if (note.get(\'access\') == \'private\') { %>\n    <div class="icon lock display" title="Private note"></div>\n  <% } %>\n  <div class="edit_note icon edit_glyph display"></div>\n  <br class="clear display" />\n  <div class="note_title_edit edit text_input light">\n    <div class="inner">\n      <input type="text" class="note_title_input" value="" />\n    </div>\n  </div>\n  <% var coords = note.coordinates(); %>\n  <% if (coords) { %>\n    <div class="note_excerpt_wrap">\n      <div class="note_excerpt" style="height: <%= coords.height %>px;">\n        <div class="left_cover"  style="height: <%= coords.height %>px; width: <%= coords.left %>px;"></div>\n        <div class="right_cover" style="height: <%= coords.height %>px; width: <%= 750 - coords.right %>px;"></div>\n        <img class="note_image" src="<%= note.imageUrl() %>" alt="" style="top: -<%= coords.top %>px;" />\n      </div>\n    </div>\n  <% } %>\n  <div class="note_text display"><%= note.get(\'content\') %></div>\n  <div class="annotation_meta">\n    <% if (note.get(\'author\')) { %>\n      <div class="annotation_author interface display">Annotated by: <%= note.get(\'author\') %><% if (note.get(\'author_organization\')) { %>, <i><%= note.get(\'author_organization\') %><% } %></i></div>\n    <% } %>\n    <% if (note.get(\'access\') == \'exclusive\') { %>\n      <div class="annotation_access interface display">\n        This draft is only visible to you and collaborators.\n      </div>\n    <% } else if (note.get(\'access\') == \'private\') { %>\n      <div class="annotation_access interface display">\n        This private note is only visible to you.\n      </div>\n    <% } %>\n  </div>\n  <div class="note_text_edit_wrap">\n    <textarea class="note_text_edit text_area edit"></textarea>\n  </div>\n  <div class="note_controls edit">\n    <div class="minibutton warn delete_note float_left">Delete</div>\n    <div class="minibutton default save_note float_right">\n      <% if (note.get(\'access\') == \'exclusive\') { %>\n        Publish\n      <% } else { %>\n        Save\n      <% } %>\n    </div>\n    <% if (_.contains([\'public\', \'exclusive\'], note.get(\'access\'))) { %>\n      <div class="minibutton save_draft_note float_right">Save as Draft</div>\n    <% } %>\n    <div class="minibutton cancel_note float_right">Cancel</div>\n  </div>\n</div>\n');
window.JST["document/note_select"]=_.template('<% var notes = doc.notes.unrestricted(); %>\n<% if (notes.length) { %>\n  <select class="note_select">\n    <% _.each(doc.notes.unrestricted(), function(note) { %>\n      <% var title = dc.inflector.truncate(note.get(\'title\'), 30); %>\n      <option value="<%= note.id %>">p.<%= note.get(\'page\') %> &ndash; <%= title %></option>\n    <% }); %>\n  </select>\n<% } else { %>\n  <div class="error">\n    This document has no public notes.\n  </div>\n<% } %>');
window.JST["document/page_images"]=_.template('<div class="page_list">\n  <div class="pages_header">\n    <span class="icon cancel_search" title="hide pages"></span>\n    <span class="pages_title interface noselect">\n      <% if (start > 1) { %>\n        <span class="arrow left">&larr;</span>\n      <% } %>\n      <% if (total > limit) { %>\n        <b><%= start %> &ndash; <%= end %></b> of\n      <% } %>\n      <% var totalLine = total + \' \' + dc.inflector.pluralize(\'page\', total); %>\n      <% if (total <= limit) { %>\n        <b class="pages_only"><%= totalLine %></b>\n      <% } else { %>\n        <%= totalLine %>\n      <% } %>\n      <% if (end < total) { %>\n        <span class="arrow right">&rarr;</span>\n      <% } %>\n    </span>\n    <span class="text_link open_pages noselect">Open all pages in viewer</span>\n  </div>\n  <% for (var page = start, l = end; page <= l; page++) { %>\n    <div class="page" data-page="<%= page %>">\n      <div class="page_icon">\n        <% if (notes[page]) { %>\n          <div class="icon mini_note"></div>\n        <% } %>\n        <img class="page_image" alt="" src="<%= doc.pageThumbnailURL(page, \'small\') %>" />\n        <div class="page_number">p. <%= page %></div>\n      </div>\n    </div>\n  <% } %>\n  <div class="clear"></div>\n</div>\n\n');
window.JST["document/page_select"]=_.template('<select class="page_select">\n  <% for (var i = 1; i <= doc.get(\'page_count\'); i++) { %>\n    <option value="<%= i %>"><%= i %></option>\n  <% } %>\n</select>');window.JST["document/pages"]=_.template('<%\n  var numbers = [];\n  var mentions = _.sortBy(_.flatten(doc.pageEntities.map(function(ent) {\n    return _.map(_.sortBy(ent.get(\'excerpts\'), function(obj) {\n      return obj.offset;\n    }), function(obj) {\n      numbers.push(obj.page_number);\n      return {id : ent.id, page_number : obj.page_number, excerpt : obj.excerpt, offset : obj.offset};\n    });\n  })), function(page) {\n    return page.page_number;\n  });\n  var pageCount = _.uniq(numbers).length;\n%>\n<% if (pageCount) { %>\n  <div class="pages_header">\n    <span class="icon cancel_search" title="hide pages"></span>\n    <span class="pages_title interface"><%= pageCount >= 200 ? \'over \' : \'\' %> <%= mentions.length %> <%= dc.inflector.pluralize(\'mention\', mentions.length) %>\n    of <%= dc.inflector.commify(doc.uniquePageEntityValues(), {quote : true, conjunction : \'or\'}) %>\n    on <%= pageCount %>\n    <%= dc.inflector.pluralize(\'page\', pageCount) %></span>\n  </div>\n  <% _.each(mentions, function(mention) { %>\n    <div class="page" data-page="<%= mention.page_number %>" data-id="<%= mention.id %>" data-offset="<%= mention.offset %>">\n      <div class="page_icon">\n        <img class="page_image" alt="page <%= mention.page_number %>" src="<%= doc.pageThumbnailURL(mention.page_number) %>" />\n        <div class="page_number">p. <%= mention.page_number %></div>\n      </div>\n      <div class="page_excerpt noselect"><%= dc.inflector.trimExcerpt(mention.excerpt) %></div>\n      <div class="clear"></div>\n    </div>\n  <% }); %>\n  <div class="clear"></div>\n<% } %>\n\n');
window.JST["document/publication_date_dialog"]=_.template("<div class=\"description\">\n  <% var pronoun = multiple ? 'them' : 'it'; %>\n  <%= multiple ? 'These documents are' : 'This document is' %> private.\n  You must make <%= pronoun %> public before\n  <%= multiple ? 'they' : 'it' %> will be visible on your website or in\n  searches of DocumentCloud's catalog. You can choose to make <%= pronoun %>\n  public at a future date, or you can\n  <span class=\"text_link public_now\">change <%= pronoun %> now</span>.\n</div>\n\nMake public on:\n<span class=\"datetime\">\n  <%= JST['common/date_select']({date : date}) %>\n</span>\n\nat\n<span class=\"datetime\">\n  <%= JST['common/hour_select']({date : date}) %>\n</span>\n");
window.JST["document/tile"]=_.template('<div class="select"></div>\n<div class="hoverable">\n  <img class="icon doc generic is_draggable <%= dc.account ? \'noselect\' : \'\' %>" src="<%= thumbnail_url %>" data-id="<%= id %>" />\n  <div class="title noselect">\n    <a href="<%= document_viewer_url %>" class="doc_title noselect"><%= title %></a>&nbsp;<span class="<%= icon["class"] %>" title="<%= icon.title %>">&#65279;</span>&nbsp;<span class="icon document_tool edit_glyph <%= icon.iconless ? \'\' : \'bottom\' %>" title="Edit Document Information">&#65279;</span>\n  </div>\n</div>\n<% if (annotation_count) { %>\n  <span class="show_notes">\n    <span class="icon cancel_search" title="hide notes"></span><span class="text_link"><span class="note_count"><%= annotation_count %></span> <%= dc.inflector.pluralize(\'note\', annotation_count) %></span>\n  </span>\n  <div class="icon mini_note"></div>\n<% } %>\n<div class="metalines interface">\n  <span class="noselect">\n    <% if (page_count) { %>\n      <span class="quiet_link page_count"><%= page_count + \' \' + dc.inflector.pluralize(\'page\', page_count) %></span> -\n    <% } %>\n    <% if (model.allowedToEdit() && reviewer_count) { %>\n      <span class="reviewer_count quiet_link"><%= reviewer_count + \' \' + dc.inflector.pluralize(\'reviewer\', reviewer_count) %></span> -\n    <% } %>\n    <% if (source) { %>Source: <span class="quiet_link search_source"><%= source %></span> -<% } %>\n    Contributed by\n    <span class="quiet_link search_account"><%= account_name %></span>,\n    <span class="quiet_link search_group"><%= organization_name %></span> -\n    <%= created_at %>\n    <% if (publish_at) { %>\n      - (Public on\n      <span class="quiet_link change_publish_at"><%= model.formattedPublishAtDate() %></span>)\n    <% } %>\n  </span>\n</div>\n<div class="description"><span class="noselect description_text"></span></div>\n<% if (data.length) { %>\n  <div class="datalines interface">\n    <% for (var i = 0, l = data.length; i < l; i++) { %>\n      <% var key = data[i][0], value = data[i][1]; %>\n      <% var active = _.any(dc.app.paginator.query.data, function(pair){ return pair[0] == key && pair[1] == value; }); %>\n      <% var className = dc.app.paginator && active ? \'active\' : \'\'; %>\n      <span class="data_item noselect gradient_white <%= className %>"><span class="data_key"><%= key %>:</span>\n      <span class="data_value"><%= value %></span></span>\n    <% } %>\n    <span class="icon document_tool edit_glyph" title="Edit Data">&#65279;</span>\n  </div>\n<% } %>\n<div class="notes"></div>\n<div class="entities noselect"></div>\n<div class="pages">\n  <% if (mentions && mentions.length) { %>\n    <% var query = dc.app.searcher.queryText(); %>\n    <%= JST[\'document/mentions\']({mentions: mentions, total: total_mentions, query: query, model: model}) %>\n  <% } %>\n</div>\n');
window.JST["document/timeline"]=_.template('<div class="timeline_plot" style="height: <%= docs.length <= 1 ? minHeight : rowHeight * docs.length %>px;">\n');window.JST["document/upload_dialog"]=_.template('<div class="uploads">\n  <div class="line top"></div>\n  <div class="upload_list not_draggable"></div>\n  <div class="line bottom"></div>\n</div>\n\n<div class="upload_options">\n  <input type="checkbox" id="make_public" name="make_public" value="1" />\n  <label for="make_public">\n    Make <span class="upload_public_count">documents</span> public.\n  </label>\n  <input type="checkbox" id="email_on_complete" name="email_on_complete" value="1" />\n  <label for="email_on_complete">\n    Email me when \n    <span class="upload_email_count">documents have</span>\n    finished processing.\n  </label>\n</div>');
window.JST["document/upload_document_tile"]=_.template('<div class="upload_title">\n  <% if (editable) { %>\n    <div class="icon remove_queue cancel_search_dark not_draggable" title="Remove file"></div>\n    <div class="icon edit_glyph_dark open_edit not_draggable" title="Edit details"></div>\n  <% } %>\n  <div class="upload_file_size">\n    <% if (model.get(\'size\')) { %>\n      (<%= dc.inflector.bytesToMB(model.get(\'size\')) %>)\n    <% } %>\n    <% if (autostart) { %>\n      <div class="spinner_dark icon"></div>\n    <% } %>\n  </div>\n  <label class="icon file file_<%= model.get(\'extension\') %>" for="document_upload_title_<%= model.id %>" title="<%= model.get(\'title\') %>"></label>\n  <div class="text_input small dark">\n    <div class="progress_bar" style="display:none;"></div>\n    <% if (editable) { %>\n      <input name="title" id="document_upload_title_<%= model.id %>" type="text" value="<%= model.get(\'title\') %>"/>\n    <% } else { %>\n      <input name="title" id="document_upload_title_<%= model.id %>" type="hidden" value="<%= model.get(\'title\') %>"/>\n      <div class="document_title"><%= model.get(\'title\') %></div>\n    <% } %>\n  </div>\n</div>\n\n<% if (editable) { %>\n  <div class="upload_edit">\n    <div class="upload_description">\n      <div class="upload_description_row">\n        <label for="document_upload_description_<%= model.id %>">\n          Description:\n        </label>\n        <textarea name="description" id="document_upload_description_<%= model.id %>" class="text_area content dark small interface"></textarea>\n      </div>\n    </div>\n\n    <div class="upload_source">\n      <label for="document_upload_source_<%= model.id %>">\n        Source:\n      </label>\n      <div class="text_input small dark">\n        <input name="source" id="document_upload_source_<%= model.id %>" type="text" />\n      </div>\n    </div>\n\n    <div class="upload_access">\n      <label for="document_upload_access_<%= model.id %>">\n        Access Level:\n      </label>\n      <select name="access" class="document_access" id="document_upload_access_<%= model.id %>">\n        <option value="public">Public Access</option>\n        <option value="private" selected="true">Private Access</option>\n        <option value="organization">Private to <%= dc.account.organization.name %></option>\n      </select>\n    </div>\n\n    <div class="apply_all" title="Apply this description, source, and access level to all files">\n      <span class="text_link">Apply to All Files</span>\n    </div>\n  </div>\n<% } %>');
window.JST["home/tweet"]=_.template('<div class="tweet <%= index == 1 ? \'right\' : \'\' %>">\n  <div class="bird"></div>\n  <div class="content">\n    <div class="text">\n      &ldquo;<%= dc.inflector.autolink(text, true) %>&rdquo;\n    </div>\n    <div class="user sans">\n      &mdash; <a class="name" href="http://twitter.com/<%= user.screen_name %>"><%= user.name %></a>,\n      <a class="date" href="http://twitter.com/<%= user.screen_name %>/status/<%= id_str %>"><%= date %></a>\n    </div>\n  </div>\n</div>');
window.JST["organizer/account_links"]=_.template('<% _.each(Accounts.others(), function(account) { %>\n  <div class="account_link">\n    - &nbsp;<span class="interface text_link" data-cid="<%= account.cid %>"><%= account.fullName() %></span>\n    <% if (account.ROLE_NAMES[account.get(\'role\')] == \'disabled\') { %>\n      (disabled)\n    <% } %>\n  </div>\n<% }); %>');window.JST["organizer/organizations"]=_.template('<% Organizations.each(function(org) { %>\n\n<div id="organization_<%= org.id %>" class="organization box" data-id="<%= org.id %>">\n  <div class="pointer"></div>\n  <div class="title interface">\n    <%= org.get(\'name\') %>\n  </div>\n  <div class="counts interface">\n    <%= org.statistics() %>\n  </div>\n</div>\n\n<% }); %>');
window.JST["organizer/project"]=_.template('<div class="pointer"></div>\n<div class="title interface">\n  <% var words = title.split(\' \'); %>\n  <%= words.slice(0, words.length - 1).join(\' \') %>\n  <span class="last_word">\n    <%= words.slice(words.length - 1).join(\' \') %>\n    <span class="icon edit_glyph">&#65279;</span>\n  </span>\n</div>\n<% if (description) { %>\n  <div class="description interface">\n    <%= description %>\n  </div>\n<% } %>\n<div class="counts interface">\n  <%= statistics %>\n  <% if (!owner) { %>\n    <br />Shared with you by <%= account_full_name %>\n  <% } %>\n</div>\n\n');
window.JST["organizer/project_dialog"]=_.template('<div class="text_input dark">\n  <input name="title" id="project_title" type="text" value="" placeholder="Title..." />\n</div>\n<div class="text_input dark small description_wrap">\n  <textarea name="description" id="project_description" class="text_area dark small content attribute" placeholder="Description..."></textarea>\n</div>\n\n<div class="slug">\n  <span style="padding-right: 10px;" class="selectable_text">Project ID: <%= model.slug() %></span>\n</div>\n\n<div class="collaboration">\n  <div class="collaborators" style="display:none;">\n    <div class="collaborators_title">\n      Collaborators:\n    </div>\n    <div class="collaborator_list_wrapper not_draggable">\n      <table class="collaborator_list" border="0" cellspacing="0" cellpadding="0">\n        <tbody>\n        </tbody>\n      </table>\n    </div>\n  </div>\n  <div class="collaborator_management">\n    <div class="add_collaborator text_link">Add a collaborator to this project</div>\n    <div class="enter_email" style="display:none;">\n      <div class="text_input dark small">\n        <input name="collaborator_email" id="collaborator_email" type="text" value="" />\n      </div>\n      <div class="minibutton default add">Add</div>\n      <label class="enter_email_label" for="collaborator_email">Enter email address:</label>\n    </div>\n  </div>\n</div>\n\n\n\n');
window.JST["organizer/sidebar"]=_.template('<div id="organizer_projects" class="project_list_container">\n\n  <div class="project_list_wrap">\n\n    <div class="top_level_search">\n      <% _.each(searches, function(item) { %>\n        <div>\n          <% if (item === \'org_documents\' && Accounts.length > 1) { %>\n            <div class="icon toggle toggle_account_links"></div>\n          <% } %>\n          <span class="<%= item %> interface text_link"><%= dc.model.Project.topLevelTitle(item) %></span>\n        </div>\n      <% }); %>\n      <div class="account_links"></div>\n    </div>\n\n    <% if (dc.account) { %>\n      \n      <div id="project_controls" class="block">\n        <form id="new_document_form" class="float_left" action="/import/upload_document" method="POST" enctype="multipart/form-data" target="upload_iframe">\n          <div class="minibutton float_left plus" id="new_document"><div class="icon white_plus"></div>New Documents</div>\n          <button type="submit">New Document</button>\n          <input id="new_document_project" name="project_id" type="text" style="display:none;" value="" />\n          <input id="new_document_input" name="file" type="file" multiple />\n          <iframe id="upload_iframe" name="upload_iframe" src="about:blank" class="hidden_iframe">\n          </iframe>\n        </form>\n        <div class="minibutton float_right plus" id="new_project"><div class="icon white_plus"></div>New Project</div>\n        <div class="clear"></div>\n      </div>\n\n      <div class="project_list">\n        <\!-- Render target for projects. --\>\n      </div>\n\n      <div class="project_help help_text">\n        <p>\n          This account doesn\'t have any projects yet.\n          To start one, click on the "New Project" button above.\n        </p>\n      </div>\n\n    <% } else { %>\n      \n      <div class="organization_list">\n        <\!-- Render target for organizations --\>\n      </div>\n      \n      <div class="block explanation first_explanation">\n        Select a contributing organization in the list above to view their \n        public documents.\n      </div>\n      \n    <% } %>\n\n  </div>\n\n</div>');
window.JST["search/embed_code"]=_.template('<div class="publish_info publish_prepare_section_label selectable_text interface">\n  <span class="text_link remove_lines">Remove line breaks</span>\n  Add this HTML to your site to embed these documents.\n</div>\n\n<textarea class="snippet">\n&lt;div id="DC-search-<%= query %>" class="DC-search-container"&gt;&lt;/div&gt;\n&lt;script src="http://s3.documentcloud.org/embed/loader.js"&gt;&lt;/script&gt;\n&lt;script&gt;\n  dc.embed.load(\'<%= window.SERVER_ROOT_HTTP %>/search/embed/\', {\n    <%= options %>\n  });\n&lt;/script&gt;\n</textarea>\n\n<div class="publish_info publish_prepare_section_label selectable_text interface hidden">\n  You can find examples of embedded searches on our list of\n  <a class="text_link" href="http://www.documentcloud.org/featured" target="_blank">featured reporting</a>.\n</div>\n');
window.JST["workspace/document_embed_dialog"]=_.template('<div class="publish_step publish_step_1 is_enabled">\n\n  <div class="publish_section">\n    <div class="text_input dark small">\n      <input type="text" name="related_article" value="<%= doc.get(\'related_article\') %>" id="publish_prepare_related_article" />\n    </div>\n    <label for="publish_prepare_related_article">Related article URL:</label>\n    <p class="dialog_info selectable_text interface">\n      Providing the URL of the article or that references this\n      document will enable a "Related Article" link within the document viewer.\n      Many readers arrive at a document from a web search &mdash; the link guides\n      them back to the document\'s original context.\n    </p>\n  </div>\n\n  <div class="publish_section">\n    <% if (doc.isPublic()) { %>\n      <label>This document is already public.</label>\n    <% } else if (doc.get(\'publish_at\')) { %>\n      <label>This document will be public on <%= doc.formattedPublishAtDate() %></label>\n    <% } else { %>\n      <% var checked = doc.isPublic() ? \'checked="checked"\' : \'\' ; %>\n      <input type="checkbox" name="access_level" id="publish_prepare_access_level" <%= checked %> />\n      <label for="publish_prepare_access_level">Make document public:</label>\n    <% } %>\n    <p class="dialog_info selectable_text interface">\n      <% if (doc.isPublic()) { %>\n        This document is public. It is currently available to users who search\n        DocumentCloud\'s catalog and will be visible to the public when you\n        embed it on your website. Change the\n        <span class="text_link edit_access">access level</span>.\n      <% } else { %>\n        This document is private. It will not be visible to your readers until you\n        make it public. Change the <span class="text_link edit_access">access level</span> now\n        or <%= doc.get(\'publish_at\') ? \'\' : \'set the\' %>\n        <span class="text_link set_publish_at">publication date</span>.\n        <br /><br />  \n        If you want to test the embed before publication, make sure to edit the\n        embed code to use secure HTTPS URLs, and then switch back to regular HTTP \n        before making the document public.\n      <% } %>\n    </p>\n  </div>\n\n</div>\n\n<div class="publish_step publish_step_2">\n\n  <div class="publish_section">\n    <label>Document viewer size:</label>\n    <select name="viewer_size">\n      <option value="full" selected="selected">Full Page</option>\n      <option value="fixed">Fixed Size</option>\n    </select>\n    <span class="dimensions">\n      <label for="publish_option_width">\n        Width:\n        <input id="publish_option_width" type="text" name="width" value="" />px\n      </label>\n      &nbsp;&nbsp;\n      <label for="publish_option_height">\n        Height:\n        <input id="publish_option_height" type="text" name="height" value="" />px\n      </label>\n    </span>\n    <p class="dialog_info selectable_text interface">\n      Choose whether to display your document in a\n      <a class="text_link" href="http://www.propublica.org/documents/item/memo-on-goldman-sachs-timberwolf-cdo-nov.-10-2006" target="_blank">full page layout</a>,\n      or a <a class="text_link" href="http://voices.washingtonpost.com/thefix/white-house/rahm-emanuel-ruled-ineligible.html" target="_blank">fixed size box</a>.\n    </p>\n  </div>\n\n  <div class="publish_section">\n    <label for="publish_option_text">Viewer opens to:</label>\n    <select class="viewer_open_to" name="viewer_open_to">\n      <option value="first_page">First Page</option>\n      <option value="page">Page ...</option>\n      <% if (doc.get(\'annotation_count\')) { %>\n        <option value="note">Note ...</option>\n      <% } %>\n    </select>\n    <div class="open_to"></div>\n    <p class="dialog_info selectable_text interface">\n      Tell the viewer to open directly to a specific page or annotation.\n    </p>\n  </div>\n\n  <div class="publish_section">\n    <input id="publish_option_sidebar" type="checkbox" name="sidebar" checked />\n    <label for="publish_option_sidebar">Show the sidebar:</label>\n    <p class="dialog_info selectable_text interface">\n      If your layout has limited horizontal space, uncheck this box to hide the sidebar.\n    </p>\n  </div>\n\n  <div class="publish_section">\n    <input id="publish_option_text" type="checkbox" name="show_text" checked />\n    <label for="publish_option_text">Show the text tab:</label>\n    <p class="dialog_info selectable_text interface">\n      If the quality of the document\'s text is poor, uncheck this box to hide the text tab.\n    </p>\n  </div>\n\n  <div class="publish_section">\n    <input id="publish_option_pdf" type="checkbox" name="show_pdf" checked />\n    <label for="publish_option_pdf">Link to the original PDF:</label>\n    <p class="dialog_info selectable_text interface">\n      Uncheck this box to remove the PDF link from the document viewer.\n    </p>\n  </div>\n\n  <div class="publish_section">\n    <p class="dialog_info selectable_text interface">\n      Before continuing, please take a moment to\n      <span class="text_link preview">preview the document viewer</span>.\n    </p>\n  </div>\n\n</div>\n\n<div class="publish_step publish_step_3">\n  <div class="publish_embed_code publish_section"></div>\n</div>\n\n\n<div class="publish_wizard_controls">\n  <div class="minibutton next default">Next <span class="text_arrow">&raquo;</span></div>\n  <div class="minibutton previous dark"><span class="text_arrow">&laquo;</span> Back</div>\n  <div class="minibutton close dark">Close</div>\n</div>\n');
window.JST["workspace/entities"]=_.template('<% var empty = true; %>\n<% _.each(dc.model.Entity.ORDER, function(category, i) { %>\n  <% var list = entities[category] || []; %>\n  <% if (list.length) { %>\n    <% empty = false; %>\n    <div class="section <%= i == 0 ? \'first\' : \'\' %>">\n      <div class="category interface"><%= dc.model.Entity.DISPLAY_NAME[category] %></div>\n      <div class="rows">\n        <% _.each(list.slice(0, limit), function(facet) { %>\n          <div class="row <%= facet.active ? \'active\' : \'\' %>" data-value="<%= facet.value %>" data-category="<%= category %>">\n            <span class="facet interface"><%= facet.value %></span>&nbsp;<span class="count" title="Mentioned in <%= facet.count %> documents">(<%= facet.count %>)</span>&nbsp;<span class="show_pages text_link interface">show&nbsp;pages</span>\n            <% if (facet.active) { %>\n              <div class="icon cancel_search" title="remove this entity from your search"></div>\n            <% } %>\n          </div>\n        <% }); %>\n      </div>\n      <% if (list.length == 6) { %>\n        <div class="more text_link interface" data-category="<%= category %>">Show more&hellip;</div>\n      <% } else if (list.length > 6) { %>\n        <div class="less text_link interface" data-category="<%= category %>">Show less&hellip;</div>\n      <% } %>\n    </div>\n  <% } %>\n<% }); %>\n<% if (empty) { %>\n  <div class="no_results">\n    No entities were found that match your search.\n  </div>\n<% } else { %>\n  <div class="block explanation">\n    The entities listed above are present within the documents that match\n    your search. Select an entity to filter your search results.\n    <a class="calais_info text_link" href="http://opencalais.com/" target="_blank">\n      <div class="icon calais_30"></div>Entities provided by OpenCalais\n    </a>\n  </div>\n<% } %>');
window.JST["workspace/no_results"]=_.template('<div id="no_results">\n  <div class="icon document generic"></div>\n  <div class="explanation"></div>\n</div>');window.JST["workspace/note_embed_code"]=_.template('<div class="publish_info publish_prepare_section_label selectable_text interface">\n  <span class="text_link remove_lines">Remove line breaks</span>\n  Add this HTML to your site to embed the note.\n</div>\n\n<textarea class="snippet">\n&lt;div id="DC-note-<%= note.get(\'id\') %>" class="DC-note-container"&gt;&lt;/div&gt;\n&lt;script src="http://s3.documentcloud.org/notes/loader.js"&gt;&lt;/script&gt;\n&lt;script&gt;\n  dc.embed.loadNote(\'<%= window.SERVER_ROOT_HTTP %>/documents/<%= note.get(\'document_id\') %>/annotations/<%= note.get(\'id\') %>.js\'<% if (options) { %>, {\n    <%= options %>\n  }<% } %>);\n&lt;/script&gt;\n</textarea>\n\n<div class="publish_info publish_prepare_section_label selectable_text interface hidden">\n  You can find examples of embedded annotations on our list of\n  <a class="text_link" href="http://www.documentcloud.org/featured" target="_blank">featured reporting</a>.\n</div>\n');
window.JST["workspace/note_embed_dialog"]=_.template('<div class="publish_step publish_step_1 is_enabled">\n  \n  <% if (doc.get(\'access\') != dc.access.PUBLIC) { %>\n    <div class="publish_section dialog_info selectable_text interface">\n      This document is private: notes on this document will not \n      be visible to the public until the document is public.\n      Change the <span class="text_link edit_access">access level</span> now\n      or <%= doc.get(\'publish_at\') ? \'\' : \'set the\' %>\n      <span class="text_link set_publish_at">publication date</span>.\n    </div>\n  <% } %>\n\n  <div class="publish_section publish_info selectable_text">\n    <label for="embed_note_select">Choose note:</label>\n    <select name="note" id="embed_note_select">\n      <% _.each(notes, function(note) { %>\n        <option value="<%= note.get(\'id\') %>" <% if (note.get(\'id\') == initialNoteId) { %>selected="true"<% } %>><%= note.get(\'title\') %></option>\n      <% }); %>\n    </select>\n  </div>\n  \n  <div class="publish_section">\n    <div class="note_preview not_draggable"></div>\n  </div>\n\n</div>\n\n<div class="publish_step publish_step_2">\n  <div class="publish_embed_code publish_section"></div>\n</div>\n\n\n<div class="publish_wizard_controls">\n  <div class="minibutton next default">Next <span class="text_arrow">&raquo;</span></div>\n  <div class="minibutton previous dark"><span class="text_arrow">&laquo;</span> Back</div>\n  <div class="minibutton close dark">Close</div>\n</div>\n');
window.JST["workspace/paginator"]=_.template('<% var to = Math.min(q.to, q.total); %>\n<div class="description noselect">\n  <% if (q.total > per_page) { %>\n    <span class="range"><%= \'\' + (q.from + 1) %> &ndash; <%= to %></span>\n    of\n  <% } %>\n  <%= q.total %> <%= dc.inflector.pluralize(\'document\', q.total) %>\n</div>\n\n<div class="sorter noselect quiet_link">\n  (<%= sort_text %>)\n</div>\n\n<div class="legal">\n  <a class="quiet_link" href="/terms">Terms</a> &nbsp;&ndash;&nbsp;\n  <a class="quiet_link" href="/privacy">Privacy</a>\n</div>\n\n<% if (q.total > per_page) { %>\n  <div class="noselect enumeration">\n    <% if (q.page > 1) { %>\n      <span class="arrow left">&larr;</span>\n    <% } %>\n      Page\n      <input type="text" class="current_page" value="<%= q.page %>" />\n      <span class="current_placeholder quiet_link"><%= q.page %></span> of <%= page_count %>\n    <% if (q.page < page_count) { %>\n      <span class="arrow right">&rarr;</span>\n    <% } %>\n  </div>\n<% } %>');
window.JST["workspace/panel"]=_.template('<div id="workspace_tabs" class="tabs">\n  <div id="search_tab" data-tab="search" class="tab active">\n    Search\n    <div class="tab_corner left"></div>\n    <div class="tab_corner right"></div>\n  </div>\n  <div id="help_tab" data-tab="help" class="tab trailing">\n    Help\n    <div class="tab_corner left"></div>\n    <div class="tab_corner right"></div>\n  </div>\n</div>\n\n<div class="panel_content">\n  <div class="search_tab_content">\n    <div id="title_box">\n      <span id="title_box_inner" class="noselect"></span>\n    </div>\n    <div id="search_box_container" class="active_search empty_search noselect"></div>\n    <div id="search_toolbar_container" class="active_search empty_search"></div>\n    <div id="document_list_container" class="active_search"></div>\n    <div id="no_results_container" class="empty_search"></div>\n    <div id="pagination_container" class="active_search"></div>\n  </div>\n  \n  <div id="help" class="help_tab_content">\n    \n    <div id="help_toolbar">\n      <div class="minibutton uservoice">Discuss Features &amp; Bugs</div>\n      <div class="minibutton contact_us">Contact DocumentCloud</div>\n    </div>\n    \n    <div id="help_content"></div>\n    \n  </div>\n</div>\n');
window.JST["workspace/search_embed_dialog"]=_.template('<div class="publish_step publish_step_1 is_enabled">\n\n  <div class="publish_section publish_info selectable_text">\n    <%= publicCount %> public <%= dc.inflector.pluralize(\'document\', documentsCount) %>\n    <%= projectQuery ? \'in this project\' : \'matching this search\' %>\n    will appear in this set.\n    <% if (restrictedCount > 0) {  %>\n      <span class="publish_section text_link change_access"><%= restrictedCount %> private <%= dc.inflector.pluralize(\'document\', restrictedCount) %></span>\n      will not appear until published.\n    <% } %>\n    Future documents\n    <%= projectQuery ? \'added to this project\' : \'matching this search\' %>\n    will appear in your embed.\n  </div>\n\n  <div class="publish_config">\n\n    <div class="publish_section">\n      <label for="publish_option_input_title">Title: </label>\n      <div class="text_input dark small">\n        <input id="publish_option_input_title" class="input_title" name="title" />\n      </div>\n      <span class="sidelabel">(optional)</span>\n    </div>\n\n    <div class="publish_section">\n      <label for="publish_option_order">Order documents by:</label>\n      <select id="publish_option_order" class="embed_order" name="order">\n        <option value="title">Title</option>\n        <option value="score">Relevance</option>\n        <option value="created_at">Date Uploaded</option>\n        <option value="source">Source</option>\n        <option value="page_count">Length</option>\n      </select>\n    </div>\n\n    <div class="publish_section">\n      <label for="publish_option_per_page">Documents per page:</label>\n      <div class="text_input dark small">\n        <input id="publish_option_per_page" class="per_page" name="per_page" type="text" />\n      </div>\n      <span class="sidelabel publish_option_perpage_sidelabel"></span>\n    </div>\n\n    <div class="publish_section search_bar">\n      <label>Search Bar:</label>\n      <input type="checkbox" name="search_bar" id="publish_option_search_bar" />\n      <label for="publish_option_search_bar" class="sidelabel">Allow readers to search this set of documents.</label>\n    </div>\n\n  </div>\n\n  <div class="publish_section">\n    <p class="publish_info selectable_text interface">\n      Before continuing, please take a moment to\n      <span class="text_link preview">preview the document set</span>.\n      <br /><br />\n      Published documents will open at the URL where they were originally published,\n      while other public documents will open on DocumentCloud.\n    </p>\n  </div>\n\n</div>\n\n<div class="publish_step publish_step_2">\n  <div class="publish_embed_code publish_section"></div>\n</div>\n\n\n<div class="publish_wizard_controls">\n  <div class="minibutton next default">Next <span class="text_arrow">&raquo;</span></div>\n  <div class="minibutton previous dark"><span class="text_arrow">&laquo;</span> Back</div>\n  <div class="minibutton close dark">Close</div>\n</div>\n');
window.JST["workspace/sidebar"]=_.template('<div id="sidebar_background"></div>\n<div id="sidebar_content">\n  \n  <div id="organizer_container"></div>\n  \n  <div id="entities_container">\n    \n    <div id="entities" class="block">\n      Entities are temporarily unavailable.\n      <br /><br />\n      If you need assistance, please \n      email us at support@documentcloud.org.\n    </div>\n    \n  </div>\n  \n  <div id="account_badge_container"></div>\n  \n</div>\n');window.JST["workspace/toolbar"]=
_.template('<div id="floating_toolbar">\n  <div id="open_viewers" class="minibutton">Open</div>\n  <div class="edit_menu_container"></div>\n  <div class="sort_menu_container"></div>\n  <div class="project_menu_container"></div>\n  <div class="analyze_menu_container"></div>\n  <div class="publish_menu_container"></div>\n  <div id="size_toggle"></div>\n  <div id="floating_line"></div>\n</div>\n')})();

