/* // Underscore.js 1.1.7 // (c) 2011 Jeremy Ashkenas, DocumentCloud Inc. // Underscore is freely distributable under the MIT license. // Portions of Underscore are inspired or borrowed from Prototype, // Oliver Steele's Functional, and John Resig's Micro-Templating. // For all details and documentation: // http://documentcloud.github.com/underscore */ (function(){var t=this,D=t._,z={},q=Array.prototype,F=Object.prototype,w=q.slice,H=q.unshift,o=F.toString,r=F.hasOwnProperty,k=q.forEach,y=q.map,e=q.reduce,p=q.reduceRight,u=q.filter,A=q.every,E=q.some,d=q.indexOf,m=q.lastIndexOf;F=Array.isArray;var n=Object.keys,b=Function.prototype.bind,a=function(c){return new s(c)};typeof module!=="undefined"&&module.exports?(module.exports=a,a._=a):t._=a;a.VERSION="1.1.7";var j=a.each=a.forEach=function(c,i,l){if(c!=null)if(k&&c.forEach===k)c.forEach(i,l);else if(c.length=== +c.length)for(var x=0,C=c.length;x=x.computed&&(x={value:C,computed:G})});return x.value}; a.min=function(c,i,l){if(!i&&a.isArray(c))return Math.min.apply(Math,c);var x={computed:Infinity};j(c,function(C,G,J){G=i?i.call(l,C,G,J):C;GJ?1:0}),"value")};a.groupBy=function(c,i){var l={};j(c,function(x,C){var G=i(x,C);(l[G]||(l[G]=[])).push(x)});return l};a.sortedIndex= function(c,i,l){l||(l=a.identity);for(var x=0,C=c.length;x>1;l(c[G])=0})})};a.difference=function(c,i){return a.filter(c,function(l){return!a.include(i,l)})};a.zip=function(){for(var c=w.call(arguments),i=a.max(a.pluck(c,"length")),l=Array(i),x=0;x=0;l--)i=[c[l].apply(this,i)]; return i[0]}};a.after=function(c,i){return function(){if(--c<1)return i.apply(this,arguments)}};a.keys=n||function(c){if(c!==Object(c))throw new TypeError("Invalid object");var i=[],l;for(l in c)r.call(c,l)&&(i[i.length]=l);return i};a.values=function(c){return a.map(c,a.identity)};a.functions=a.methods=function(c){var i=[],l;for(l in c)a.isFunction(c[l])&&i.push(l);return i.sort()};a.extend=function(c){j(w.call(arguments,1),function(i){for(var l in i)i[l]!==void 0&&(c[l]=i[l])});return c};a.defaults= function(c){j(w.call(arguments,1),function(i){for(var l in i)c[l]==null&&(c[l]=i[l])});return c};a.clone=function(c){return a.isArray(c)?c.slice():a.extend({},c)};a.tap=function(c,i){i(c);return c};a.isEqual=function(c,i){if(c===i)return true;var l=typeof c;if(l!=typeof i)return false;if(c==i)return true;if(!c&&i||c&&!i)return false;if(c._chain)c=c._wrapped;if(i._chain)i=i._wrapped;if(c.isEqual)return c.isEqual(i);if(i.isEqual)return i.isEqual(c);if(a.isDate(c)&&a.isDate(i))return c.getTime()===i.getTime(); if(a.isNaN(c)&&a.isNaN(i))return false;if(a.isRegExp(c)&&a.isRegExp(i))return c.source===i.source&&c.global===i.global&&c.ignoreCase===i.ignoreCase&&c.multiline===i.multiline;if(l!=="object")return false;if(c.length&&c.length!==i.length)return false;l=a.keys(c);var x=a.keys(i);if(l.length!=x.length)return false;for(var C in c)if(!(C in i)||!a.isEqual(c[C],i[C]))return false;return true};a.isEmpty=function(c){if(a.isArray(c)||a.isString(c))return c.length===0;for(var i in c)if(r.call(c,i))return false; return true};a.isElement=function(c){return!!(c&&c.nodeType==1)};a.isArray=F||function(c){return o.call(c)==="[object Array]"};a.isObject=function(c){return c===Object(c)};a.isArguments=function(c){return!(!c||!r.call(c,"callee"))};a.isFunction=function(c){return!(!c||!c.constructor||!c.call||!c.apply)};a.isString=function(c){return!!(c===""||c&&c.charCodeAt&&c.substr)};a.isNumber=function(c){return!!(c===0||c&&c.toExponential&&c.toFixed)};a.isNaN=function(c){return c!==c};a.isBoolean=function(c){return c=== true||c===false};a.isDate=function(c){return!(!c||!c.getTimezoneOffset||!c.setUTCFullYear)};a.isRegExp=function(c){return!(!c||!c.test||!c.exec||!(c.ignoreCase||c.ignoreCase===false))};a.isNull=function(c){return c===null};a.isUndefined=function(c){return c===void 0};a.noConflict=function(){t._=D;return this};a.identity=function(c){return c};a.times=function(c,i,l){for(var x=0;x/g,interpolate:/<%=([\s\S]+?)%>/g};a.template=function(c,i){var l=a.templateSettings;l="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+c.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(l.interpolate,function(x,C){return"',"+C.replace(/\\'/g,"'")+",'"}).replace(l.evaluate||null,function(x,C){return"');"+C.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g, "\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";l=new Function("obj",l);return i?l(i):l};var s=function(c){this._wrapped=c};a.prototype=s.prototype;var v=function(c,i){return i?a(c).chain():c},B=function(c,i){s.prototype[c]=function(){var l=w.call(arguments);H.call(l,this._wrapped);return v(i.apply(a,l),this._chain)}};a.mixin(a);j(["pop","push","reverse","shift","sort","splice","unshift"],function(c){var i=q[c];s.prototype[c]=function(){i.apply(this._wrapped,arguments);return v(this._wrapped, this._chain)}});j(["concat","join","slice"],function(c){var i=q[c];s.prototype[c]=function(){return v(i.apply(this._wrapped,arguments),this._chain)}});s.prototype.chain=function(){this._chain=true;return this};s.prototype.value=function(){return this._wrapped}})();/* // Backbone.js 0.5.3 // (c) 2010 Jeremy Ashkenas, DocumentCloud Inc. // Backbone may be freely distributed under the MIT license. // For all details and documentation: // http://documentcloud.github.com/backbone */ (function(){var t=this,D=t.Backbone,z;z=typeof exports!=="undefined"?exports:t.Backbone={};z.VERSION="0.5.3";var q=t._;if(!q&&typeof require!=="undefined")q=require("underscore")._;var F=t.jQuery||t.Zepto;z.noConflict=function(){t.Backbone=D;return this};z.emulateHTTP=false;z.emulateJSON=false;z.Events={bind:function(b,a,j){var f=this._callbacks||(this._callbacks={});(f[b]||(f[b]=[])).push([a,j]);return this},unbind:function(b,a){var j;if(b){if(j=this._callbacks)if(a){j=j[b];if(!j)return this;for(var f= 0,h=j.length;f/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")},has:function(b){return this.attributes[b]!=null},set:function(b,a){a||(a={});if(!b)return this;if(b.attributes)b=b.attributes;var j=this.attributes,f=this._escapedAttributes;if(!a.silent&&this.validate&&!this._performValidation(b,a))return false;if(this.idAttribute in b)this.id=b[this.idAttribute]; var h=this._changing;this._changing=true;for(var g in b){var s=b[g];if(!q.isEqual(j[g],s)){j[g]=s;delete f[g];this._changed=true;a.silent||this.trigger("change:"+g,this,s,a)}}!h&&!a.silent&&this._changed&&this.change(a);this._changing=false;return this},unset:function(b,a){if(!(b in this.attributes))return this;a||(a={});var j={};j[b]=void 0;if(!a.silent&&this.validate&&!this._performValidation(j,a))return false;delete this.attributes[b];delete this._escapedAttributes[b];b==this.idAttribute&&delete this.id; this._changed=true;a.silent||(this.trigger("change:"+b,this,void 0,a),this.change(a));return this},clear:function(b){b||(b={});var a,j=this.attributes,f={};for(a in j)f[a]=void 0;if(!b.silent&&this.validate&&!this._performValidation(f,b))return false;this.attributes={};this._escapedAttributes={};this._changed=true;if(!b.silent){for(a in j)this.trigger("change:"+a,this,void 0,b);this.change(b)}return this},fetch:function(b){b||(b={});var a=this,j=b.success;b.success=function(f,h,g){if(!a.set(a.parse(f, g),b))return false;j&&j(a,f)};b.error=n(b.error,a,b);return(this.sync||z.sync).call(this,"read",this,b)},save:function(b,a){a||(a={});if(b&&!this.set(b,a))return false;var j=this,f=a.success;a.success=function(g,s,v){if(!j.set(j.parse(g,v),a))return false;f&&f(j,g,v)};a.error=n(a.error,j,a);var h=this.isNew()?"create":"update";return(this.sync||z.sync).call(this,h,this,a)},destroy:function(b){b||(b={});if(this.isNew())return this.trigger("destroy",this,this.collection,b);var a=this,j=b.success;b.success= function(f){a.trigger("destroy",a,a.collection,b);j&&j(a,f)};b.error=n(b.error,a,b);return(this.sync||z.sync).call(this,"delete",this,b)},url:function(){var b=d(this.collection)||this.urlRoot||m();if(this.isNew())return b;return b+(b.charAt(b.length-1)=="/"?"":"/")+encodeURIComponent(this.id)},parse:function(b){return b},clone:function(){return new this.constructor(this)},isNew:function(){return this.id==null},change:function(b){this.trigger("change",this,b);this._previousAttributes=q.clone(this.attributes); this._changed=false},hasChanged:function(b){if(b)return this._previousAttributes[b]!=this.attributes[b];return this._changed},changedAttributes:function(b){b||(b=this.attributes);var a=this._previousAttributes,j=false,f;for(f in b)q.isEqual(a[f],b[f])||(j=j||{},j[f]=b[f]);return j},previous:function(b){if(!b||!this._previousAttributes)return null;return this._previousAttributes[b]},previousAttributes:function(){return q.clone(this._previousAttributes)},_performValidation:function(b,a){var j=this.validate(b); if(j)return a.error?a.error(this,j,a):this.trigger("error",this,j,a),false;return true}});z.Collection=function(b,a){a||(a={});if(a.comparator)this.comparator=a.comparator;q.bindAll(this,"_onModelEvent","_removeReference");this._reset();b&&this.reset(b,{silent:true});this.initialize.apply(this,arguments)};q.extend(z.Collection.prototype,z.Events,{model:z.Model,initialize:function(){},toJSON:function(){return this.map(function(b){return b.toJSON()})},add:function(b,a){if(q.isArray(b))for(var j=0,f= b.length;j').hide().appendTo("body")[0].contentWindow;this.navigate(b)}this._hasPushState?F(window).bind("popstate",this.checkUrl):"onhashchange"in window&&!a?F(window).bind("hashchange",this.checkUrl):setInterval(this.checkUrl,this.interval);this.fragment=b;y=true;b=window.location;a=b.pathname==this.options.root;if(this._wantsPushState&&!this._hasPushState&&!a)return this.fragment=this.getFragment(null, true),window.location.replace(this.options.root+"#"+this.fragment),true;else if(this._wantsPushState&&this._hasPushState&&a&&b.hash){this.fragment=b.hash.replace(r,"");window.history.replaceState({},document.title,b.protocol+"//"+b.host+this.options.root+this.fragment)}if(!this.options.silent)return this.loadUrl()},route:function(b,a){this.handlers.unshift({route:b,callback:a})},checkUrl:function(){var b=this.getFragment();b==this.fragment&&this.iframe&&(b=this.getFragment(this.iframe.location.hash)); if(b==this.fragment||b==decodeURIComponent(this.fragment))return false;this.iframe&&this.navigate(b);this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(b){var a=this.fragment=this.getFragment(b);return q.any(this.handlers,function(j){if(j.route.test(a))return j.callback(a),true})},navigate:function(b,a){var j=(b||"").replace(r,"");if(!(this.fragment==j||this.fragment==decodeURIComponent(j))){if(this._hasPushState){var f=window.location;j.indexOf(this.options.root)!=0&&(j=this.options.root+ j);this.fragment=j;window.history.pushState({},document.title,f.protocol+"//"+f.host+j)}else if(window.location.hash=this.fragment=j,this.iframe&&j!=this.getFragment(this.iframe.location.hash)){this.iframe.document.open().close();this.iframe.location.hash=j}a&&this.loadUrl(b)}}});z.View=function(b){this.cid=q.uniqueId("view");this._configure(b||{});this._ensureElement();this.delegateEvents();this.initialize.apply(this,arguments)};var e=/^(\S+)\s*(.*)$/,p=["model","collection","el","id","attributes", "className","tagName"];q.extend(z.View.prototype,z.Events,{tagName:"div",$:function(b){return F(b,this.el)},initialize:function(){},render:function(){return this},remove:function(){F(this.el).remove();return this},make:function(b,a,j){b=document.createElement(b);a&&F(b).attr(a);j&&F(b).html(j);return b},delegateEvents:function(b){if(b||(b=this.events))for(var a in q.isFunction(b)&&(b=b.call(this)),F(this.el).unbind(".delegateEvents"+this.cid),b){var j=this[b[a]];if(!j)throw Error('Event "'+b[a]+'" does not exist'); var f=a.match(e),h=f[1];f=f[2];j=q.bind(j,this);h+=".delegateEvents"+this.cid;f===""?F(this.el).bind(h,j):F(this.el).delegate(f,h,j)}},_configure:function(b){this.options&&(b=q.extend({},this.options,b));for(var a=0,j=p.length;a])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+A+'="'+h.key+'" $2'):B:z(B,h,B._ctnt)}):h;if(g)return s;s=s.join("");s.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function(B,c,i,l){v=t(i).get();o(v);if(c)v=q(c).concat(v);if(l)v=v.concat(q(l))});return v?v:q(s)}function q(h){var g=document.createElement("div");g.innerHTML=h;return t.makeArray(g.childNodes)}function F(h){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+t.trim(h).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g, function(g,s,v,B,c,i,l){g=t.tmpl.tag[v];if(!g)throw"Unknown template tag: "+v;v=g._default||[];if(i&&!/\w$/.test(c)){c+=i;i=""}if(c){c=H(c);l=l?","+H(l)+")":i?")":"";l=i?c.indexOf(".")>-1?c+H(i):"("+c+").call($item"+l:c;i=i?l:"(typeof("+c+")==='function'?("+c+").call($item):("+c+"))"}else i=l=v.$1||"null";B=H(B);return"');"+g[s?"close":"open"].split("$notnull_1").join(c?"typeof("+c+")!=='undefined' && ("+c+")!=null":"true").split("$1a").join(i).split("$1").join(l).split("$2").join(B||v.$2||"")+"__.push('"})+ "');}return __;")}function w(h,g){h._wrap=z(h,true,t.isArray(g)?g:[E.test(g)?g:t(g).html()]).join("")}function H(h){return h?h.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function o(h){function g(C){function G(N){N+=s;I=c[N]=c[N]||D(I,d[I.parent.key+s]||I.parent)}var J,K=C,I,O;if(O=C.getAttribute(A)){for(;K.parentNode&&(K=K.parentNode).nodeType===1&&!(J=K.getAttribute(A)););if(J!==O){K=K.parentNode?K.nodeType===11?0:K.getAttribute(A)||0:0;if(!(I=d[O])){I=m[O];I=D(I,d[K]||m[K]);I.key=++a;d[a]=I}j&& G(O)}C.removeAttribute(A)}else if(j&&(I=t.data(C,"tmplItem"))){G(I.key);d[I.key]=I;K=(K=t.data(C.parentNode,"tmplItem"))?K.key:0}if(I){for(J=I;J&&J.key!=K;){J.nodes.push(C);J=J.parent}delete I._ctnt;delete I._wrap;t.data(C,"tmplItem",I)}}var s="_"+j,v,B,c={},i,l,x;i=0;for(l=h.length;i=0;x--)g(B[x]);g(v)}}function r(h,g,s,v){if(!h)return f.pop();f.push({_:h,tmpl:g,item:this,data:s,options:v})}function k(h,g,s){return t.tmpl(t.template(h), g,s,this)}function y(h,g){var s=h.options||{};s.wrapped=g;return t.tmpl(t.template(h.tmpl),h.data,s,h.item)}function e(h,g){var s=this._wrap;return t.map(t(t.isArray(s)?s.join(""):s).filter(h||"*"),function(v){if(g)v=v.innerText||v.textContent;else{var B;if(!(B=v.outerHTML)){B=document.createElement("div");B.appendChild(v.cloneNode(true));B=B.innerHTML}v=B}return v})}function p(){var h=this.nodes;t.tmpl(null,null,null,this).insertBefore(h[0]);t(h).remove()}var u=t.fn.domManip,A="_tmplitem",E=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /, d={},m={},n,b={key:0,data:{}},a=0,j=0,f=[];t.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(h,g){t.fn[h]=function(s){var v=[];s=t(s);var B,c,i;B=this.length===1&&this[0].parentNode;n=d||{};if(B&&B.nodeType===11&&B.childNodes.length===1&&s.length===1){s[g](this[0]);v=this}else{c=0;for(i=s.length;c0?this.clone(true):this).get();t(s[c])[g](B);v=v.concat(B)}j=0;v=this.pushStack(v,h,s.selector)}s=n;n=null;t.tmpl.complete(s); return v}});t.fn.extend({tmpl:function(h,g,s){return t.tmpl(this[0],h,g,s)},tmplItem:function(){return t.tmplItem(this[0])},template:function(h){return t.template(h,this[0])},domManip:function(h,g,s){if(h[0]&&t.isArray(h[0])){for(var v=t.makeArray(arguments),B=h[0],c=B.length,i=0,l;i").join(">").split('"').join(""").split("'").join("'")}});t.extend(t.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"}, wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){d= {}},afterManip:function(h,g,s){var v=g.nodeType===11?t.makeArray(g.childNodes):g.nodeType===1?[g]:[];s.call(h,g);o(v);j++}})})(jQuery);/* JavaScript Debug - v0.4 - 6/22/2010 http://benalman.com/projects/javascript-debug-console-log/ Copyright (c) 2010 "Cowboy" Ben Alman Dual licensed under the MIT and GPL licenses. http://benalman.com/about/license/ With lots of help from Paul Irish! http://paulirish.com/ */ window.debug=function(){function t(p){if(w&&(H||!q||!q.log))w.apply(D,p)}for(var D=this,z=Array.prototype.slice,q=D.console,F={},w,H,o=9,r=["error","warn","info","debug","log"],k="assert clear count dir dirxml exception group groupCollapsed groupEnd profile profileEnd table time timeEnd trace".split(" "),y=k.length,e=[];--y>=0;)(function(p){F[p]=function(){o!==0&&q&&q[p]&&q[p].apply(q,arguments)}})(k[y]);for(y=r.length;--y>=0;)(function(p,u){F[u]=function(){var A=z.call(arguments),E=[u].concat(A); e.push(E);t(E);if(q&&(o>0?o>p:r.length+o<=p))q.firebug?q[u].apply(D,A):q[u]?q[u](A):q.log(A)}})(y,r[y]);F.setLevel=function(p){o=typeof p==="number"?p:9};F.setCallback=function(){var p=z.call(arguments),u=e.length,A=u;w=p.shift()||null;H=typeof p[0]==="boolean"?p.shift():false;for(A-=typeof p[0]==="number"?p.shift():u;A");t.subscribe=function(z,q){function F(){return q.apply(this,Array.prototype.slice.call(arguments,1))}F.guid=q.guid=q.guid||(t.guid?t.guid++:t.event.guid++);D.bind(z,F)};t.unsubscribe=function(){D.unbind.apply(D,arguments)};t.publish=function(){D.trigger.apply(D,arguments)}})(jQuery);/* Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) Licensed under the MIT License (LICENSE.txt). Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. Thanks to: Seamus Leahy for adding deltaX and deltaY Version: 3.0.6 Requires: 1.2.2+ */ (function(t){function D(F){var w=F||window.event,H=[].slice.call(arguments,1),o=0,r=0,k=0;return F=t.event.fix(w),F.type="mousewheel",w.detail&&(o=-w.detail/3),w.wheelDeltaY!==undefined&&(k=w.wheelDeltaY/120),w.wheelDeltaX!==undefined&&(r=-1*w.wheelDeltaX/120),H.unshift(F,o,r,k),(t.event.dispatch||t.event.handle).apply(this,H)}var z=["DOMMouseScroll","mousewheel"];if(t.event.fixHooks)for(var q=z.length;q;)t.event.fixHooks[z[--q]]=t.event.mouseHooks;t.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var F= z.length;F;)this.addEventListener(z[--F],D,false);else this.onmousewheel=D},teardown:function(){if(this.removeEventListener)for(var F=z.length;F;)this.removeEventListener(z[--F],D,false);else this.onmousewheel=null}};t.fn.extend({mousewheel:function(F){return F?this.bind("mousewheel",F):this.trigger("mousewheel")},unmousewheel:function(F){return this.unbind("mousewheel",F)}})})(jQuery);/* jQuery.UI.iPad plugin Copyright (c) 2010 Stephen von Takach licensed under MIT. Date: 27/8/2010 Project Home: http://code.google.com/p/jquery-ui-for-ipad-and-iphone/ */ $(function(){$.extend($.support,{touch:"ontouchend"in document});$.fn.addTouch=function(){$.support.touch&&this.each(function(t,D){D.addEventListener("touchstart",iPadTouchHandler,false);D.addEventListener("touchmove",iPadTouchHandler,false);D.addEventListener("touchend",iPadTouchHandler,false);D.addEventListener("touchcancel",iPadTouchHandler,false)})}});var lastTap=null,tapValid=false,tapTimeout=null;function cancelTap(){tapValid=false} var rightClickPending=false,rightClickEvent=null,holdTimeout=null,cancelMouseUp=false;function cancelHold(){if(rightClickPending){window.clearTimeout(holdTimeout);rightClickPending=false;rightClickEvent=null}}function startHold(t){if(!rightClickPending){rightClickPending=true;rightClickEvent=t.changedTouches[0];holdTimeout=window.setTimeout("doRightClick();",800)}} function doRightClick(){rightClickPending=false;var t=rightClickEvent,D=document.createEvent("MouseEvent");D.initMouseEvent("mouseup",true,true,window,1,t.screenX,t.screenY,t.clientX,t.clientY,false,false,false,false,0,null);t.target.dispatchEvent(D);D=document.createEvent("MouseEvent");D.initMouseEvent("mousedown",true,true,window,1,t.screenX,t.screenY,t.clientX,t.clientY,false,false,false,false,2,null);t.target.dispatchEvent(D);D=document.createEvent("MouseEvent");D.initMouseEvent("contextmenu", true,true,window,1,t.screenX+50,t.screenY+5,t.clientX+50,t.clientY+5,false,false,false,false,2,null);t.target.dispatchEvent(D);cancelMouseUp=true;rightClickEvent=null} function iPadTouchStart(t){var D=t.changedTouches[0],z="mouseover",q=document.createEvent("MouseEvent");q.initMouseEvent(z,true,true,window,1,D.screenX,D.screenY,D.clientX,D.clientY,false,false,false,false,0,null);D.target.dispatchEvent(q);z="mousedown";q=document.createEvent("MouseEvent");q.initMouseEvent(z,true,true,window,1,D.screenX,D.screenY,D.clientX,D.clientY,false,false,false,false,0,null);D.target.dispatchEvent(q);if(tapValid){window.clearTimeout(tapTimeout);if(D.target==lastTap){lastTap= null;tapValid=false;z="click";q=document.createEvent("MouseEvent");q.initMouseEvent(z,true,true,window,1,D.screenX,D.screenY,D.clientX,D.clientY,false,false,false,false,0,null);D.target.dispatchEvent(q);z="dblclick";q=document.createEvent("MouseEvent");q.initMouseEvent(z,true,true,window,1,D.screenX,D.screenY,D.clientX,D.clientY,false,false,false,false,0,null);D.target.dispatchEvent(q)}else{lastTap=D.target;tapValid=true;tapTimeout=window.setTimeout("cancelTap();",600);startHold(t)}}else{lastTap= D.target;tapValid=true;tapTimeout=window.setTimeout("cancelTap();",600);startHold(t)}} function iPadTouchHandler(t){var D="";if(!(t.touches.length>1)){switch(t.type){case "touchstart":if($(t.changedTouches[0].target).is("select"))return;iPadTouchStart(t);t.preventDefault();return false;case "touchmove":cancelHold();D="mousemove";t.preventDefault();break;case "touchend":if(cancelMouseUp){cancelMouseUp=false;t.preventDefault();return false}cancelHold();D="mouseup";break;default:return}t=t.changedTouches[0];var z=document.createEvent("MouseEvent");z.initMouseEvent(D,true,true,window,1, t.screenX,t.screenY,t.clientX,t.clientY,false,false,false,false,0,null);t.target.dispatchEvent(z);if(D=="mouseup"&&tapValid&&t.target==lastTap){z=document.createEvent("MouseEvent");z.initMouseEvent("click",true,true,window,1,t.screenX,t.screenY,t.clientX,t.clientY,false,false,false,false,0,null);t.target.dispatchEvent(z)}}};(function(){function t(f){return(f+"").replace(m,"")}function D(f,h,g){for(var s=f.length;s=g)return v}return 0}function H(f){return f.split("\u00a0").join(" ").toUpperCase()}function o(f){for(var h=[],g=0,s=f.length;g< s;g++)h[g]=H(f[g]);return h}function r(f,h,g,s){f=f.getFullYear();if(!s&&h.eras)f-=h.eras[g].offset;return f}function k(f,h){for(var g=0,s=false,v=0,B=f.length;v31)return null;break;case "MMM":case "MMMM":I=g;L=L===3;P=I.months;var Q=I.monthsGenitive||I.months,R=I._upperMonths;M=I._upperMonthsGen;if(!R){I._upperMonths=R=[o(P.names),o(P.namesAbbr)];I._upperMonthsGen=M=[o(Q.names),o(Q.namesAbbr)]}N= H(N);I=q(L?R[1]:R[0],N);if(I<0)I=q(L?M[1]:M[0],N);if(I<0||I>11)return null;break;case "M":case "MM":I=M-1;if(I<0||I>11)return null;break;case "y":case "yy":case "yyyy":if(L<4){K=g;N=M;M=new Date;P=w(M);if(N<100){L=K.twoDigitYearMax;L=typeof L==="string"?(new Date).getFullYear()%100+parseInt(L,10):L;K=r(M,K,P);N+=K-K%100;if(N>L)N-=100}K=N}else K=M;if(K<0||K>9999)return null;break;case "h":case "hh":s=M;if(s===12)s=0;if(s<0||s>11)return null;break;case "H":case "HH":s=M;if(s<0||s>23)return null;break; case "m":case "mm":v=M;if(v<0||v>59)return null;break;case "s":case "ss":B=M;if(B<0||B>59)return null;break;case "tt":case "t":i=g.PM&&(N===g.PM[0]||N===g.PM[1]||N===g.PM[2]);if(!i&&(!g.AM||N!==g.AM[0]&&N!==g.AM[1]&&N!==g.AM[2]))return null;break;case "f":case "ff":case "fff":c=M*Math.pow(10,3-L);if(c<0||c>999)return null;break;case "ddd":case "dddd":O=N;N=L===3;M=void 0;M=g.days;L=g._upperDays;if(!L)g._upperDays=L=[o(M.names),o(M.namesAbbr),o(M.namesShort)];O=H(O);if(N){M=q(L[1],O);if(M===-1)M=q(L[2], O)}else M=q(L[0],O);O=M;if(O<0||O>6)return null;break;case "zzz":L=N.split(/:/);if(L.length!==2)return null;C=parseInt(L[0],10);if(C<-12||C>13)return null;L=parseInt(L[1],10);if(L<0||L>59)return null;C=C*60+(N.indexOf("-")===0?-L:L);break;case "z":case "zz":C=M;if(C<-12||C>13)return null;C*=60;break;case "g":case "gg":if(!N||!g.eras)return null;N=t(N.toLowerCase());L=0;for(M=g.eras.length;L1&&Q.length1)v=parseInt(h.slice(1),10);var B=h.charAt(0).toUpperCase(),c;switch(B){case "D":h="n";if(v!==-1)f=D(""+f,v,true);if(s<0)f=-f;break;case "N":c=g;case "C":c=c||g.currency;case "P":c=c||g.percent;h=s<0?c.pattern[0]:c.pattern[1]||"n";if(v===-1)v=c.decimals;b:{var i=f*(B==="P"?100:1);B=c;c=B.groupSizes;f=c[0];s=1;var l=Math.pow(10,v),x=Math.round(i*l)/l;isFinite(x)||(x=i); l="";l=(x+"").split(/e/i);x=l.length>1?parseInt(l[1],10):0;i=l[0];l=i.split(".");i=l[0];l=l.length>1?l[1]:"";if(x>0){l=D(l,x,false);i+=l.slice(0,x);l=l.substr(x)}else if(x<0){x=-x;i=D(i,x+1);l=i.slice(-x,i.length)+l;i=i.slice(0,-x)}l=v>0?B["."]+(l.length>v?l.slice(0,v):D(l,v)):"";v=i.length-1;B=B[","];for(x="";v>=0;){if(f===0||f>v){f=i.slice(0,v+1)+(x.length?B+x+l:l);break b}x=i.slice(v-f+1,v+1)+(x.length?B+x:"");v-=f;if(s -1){f=f.replace(g.numberFormat.currency.symbol,"");f=f.replace(g.numberFormat.currency["."],g.numberFormat["."])}f=t(f);if(n.test(f))s=parseFloat(f,h);else if(!h&&b.test(f))s=parseInt(f,16);else{g=F(f,v,v.pattern[0]);h=g[0];g=g[1];if(h===""&&v.pattern[0]!=="-n"){g=F(f,v,"-n");h=g[0];g=g[1]}h=h||"+";var B;f=g.indexOf("e");if(f<0)f=g.indexOf("E");if(f<0){B=g;f=null}else{B=g.substr(0,f);f=g.substr(f+1)}var c=v["."],i=B.indexOf(c);if(i<0){g=B;B=null}else{g=B.substr(0,i);B=B.substr(i+c.length)}c=v[","]; g=g.split(c).join("");i=c.replace(/\u00A0/g," ");if(c!==i)g=g.split(i).join("");h+=g;if(B!==null)h+="."+B;if(f!==null){v=F(f,v,"-n");h+="e"+(v[0]||"+")+v[1]}if(a.test(h))s=parseFloat(h)}return s};A.parseDate=function(f,h,g){g=this.findClosestCulture(g);var s,v;if(h){if(typeof h==="string")h=[h];if(h.length){v=0;for(var B=h.length;v9||p<0?String(e):"0"+p}t=timeglider;var q=jQuery,F={},w={},H={},o={},r={},k=/^(\-?\d+)?(\-\d{1,2})?(\-\d{1,2})?(?:T| )?(\d{1,2})?(?::)?(\d{1,2})?(?::)?(\d{1,2})?(\+|\-)?(\d{1,2})?(?::)?(\d{1,2})?/;t.TG_Date=function(e,p,u){var A,E,d;u=u||0;if(typeof e=="number"){A=E=y.getDateFromSec(e);d=e+u}else if(typeof e!=="object"){if(e=="today")e=y.getToday();A=E=e}if(k.test(A)){e=y.parse8601(A);if(e.tz_ho)e=y.toFromUTC(e, {hours:e.tz_ho,minutes:e.tz_mi},"to");q.extend(this,e);this.rd=y.getRataDie(this);this.mo_num=this.ye>0?(this.ye-1)*12+this.mo:-1*((Math.abs(this.ye)-1)*12+(12-(this.mo-1)));this.sec=d||(this.rd>0?1:-1)*(Math.abs(this.rd)*86400+this.ho*3600+(this.mi-1)*60);this.date_display=p?p.toLowerCase().substr(0,2):"da";this.dateStr=E}else return{error:"invalid date"};return this};var y=t.TG_Date;y.getTimeUnitSerial=function(e,p){var u=0,A;A=e.ye<0?Math.ceil:Math.floor;switch(p){case "da":u=e.rd;break;case "mo":u= e.mo_num;break;case "ye":u=e.ye;break;case "de":u=A(e.ye/10);break;case "ce":u=A(e.ye/100);break;case "thou":u=A(e.ye/1E3);break;case "tenthou":u=A(e.ye/1E4);break;case "hundredthou":u=A(e.ye/1E5);break;case "mill":u=A(e.ye/1E6);break;case "tenmill":u=A(e.ye/1E7);break;case "hundredmill":u=A(e.ye/1E8);break;case "bill":u=A(e.ye/1E9)}return u};y.getMonthDays=function(e,p){return y.isLeapYear(p)==true&&e==2?29:y.monthsDayNums[e]};y.twentyFourToTwelve=function(e){var p={};p.ye=e.ye;p.mo=e.mo;p.da=e.da; p.ho=e.ho;p.mi=e.mi;p.ampm="am";if(e.ho)if(e.ho>=12){p.ampm="pm";p.ho=e.ho>12?e.ho-12:12}else if(e.ho==0){p.ho=12;p.ampm="am"}else p.ho=e.ho;else{p.ho=12;p.mi=0;p.ampm="am"}return p};y.getMonthAdj=function(e,p){var u=y.getDateFromMonthNum(e);switch(u.mo){case 1:case 3:case 5:case 7:case 8:case 10:case 12:u=Math.floor(p+p/28*3);return{width:u,days:31};case 2:if(y.isLeapYear(u.ye)==true){u=Math.floor(p+p/28);return{width:u,days:29}}else return{width:p,days:28};default:u=Math.floor(p+p/28*2);return{width:u, days:30}}};y.getDateFromMonthNum=function(e){var p=0;if(e>0){p=e%12;if(p==0)p=12;e=Math.ceil(e/12)}else{p=Math.abs(e)%12;p=12-p+1;if(p==13)p=1;e=-1*Math.ceil(Math.abs(e)/12)}return{ye:e,mo:p}};y.getMonthWidth=function(e,p,u){var A=u/28,E;switch(e){case 1:case 3:case 5:case 7:case 8:case 10:case 12:E=3;break;case 4:case 6:case 9:case 11:E=2;break;case 2:E=y.isLeapYear(p)==true?1:0}return{width:Math.floor(u+A*E),numDays:28+E}};y.getToday=function(){var e=new Date;return e.getFullYear()+"-"+(e.getMonth()+ 1)+"-"+e.getDate()+" "+e.getHours()+":"+e.getMinutes()+":00"};y.getMonthFromRemDays=function(e,p){var u=0;var A=u=0;u=y.isLeapYear(p)?1:0;if(e<=31){A=1;u=e}else if(e>31&&e<=59+u){A=2;u=e-(31+u)}else if(e>59+u&&e<=90+u){A=3;u=e-(59+u)}else if(e>90+u&&e<=120+u){A=4;u=e-(90+u)}else if(e>120+u&&e<=151+u){A=5;u=e-(120+u)}else if(e>151+u&&e<=181+u){A=6;u=e-(151+u)}else if(e>181+u&&e<=212+u){A=7;u=e-(181+u)}else if(e>212+u&&e<=243+u){A=8;u=e-(212+u)}else if(e>243+u&&e<=273+u){A=9;u=e-(243+u)}else if(e>273+ u&&e<=304+u){A=10;u=e-(273+u)}else if(e>304+u&&e<=334+u){A=11;u=e-(304+u)}else{A=12;u=e-(334+u)}return{mo:A,da:u}};y.getDateFromRD=function(e){if(o[e])return o[e];for(var p=Math.floor(e),u=Math.floor(p/146097)*400,A=p-Math.floor(p/146097)*146097,E=1,d=u+1,m=d+400;d<=m;d++)if(A>365){A-=365;if(y.isLeapYear(d))A-=1;E++}else d=m;u+=E;if(A==0)A=1;A=y.getMonthFromRemDays(A,u);E=(e-p)*1440;p=Math.floor(E%60);E=Math.floor(E/60);if(y.isLeapYear(u)&&A.mo==2)A.da+=1;p=u+"-"+A.mo+"-"+A.da+" "+E+":"+p+":00";return o[e]= p};y.getDateFromSec=function(e){if(r[e])return r[e];var p=y.getDateFromRD(e/86400);return r[e]=p};y.isLeapYear=function(e){return e%400==0?true:e%100==0?false:e%4==0?true:false};y.getRataDie=function(e){function p(b,a){if(w[b+"-"+a])return w[b+"-"+a];for(var j=0,f=b;f2)if(y.isLeapYear(a))j+=1;return j}var A=e.ye,E=e.mo;e=e.da;var d=0;if(F[A+"-"+E+"-"+e])return F[A+"-"+E+"-"+e];if(A>=0){if(A==0)A=1;d=Math.floor(A/400)*146097;var m=parseInt(p(A-A%400,A)),n=parseInt(u(E,A));d=d+m+n+e-366}else if(A<0)d=y.getBCRataDie({ye:A,mo:E,da:e});return F[A+"-"+E+"-"+e]=d};y.monthNamesLet=["","J","F","M","A","M","J","J","A","S","O","N","D"];y.monthsDayNums=[0,31,28,31,30,31,30,31,31,30,31,30,31,29]; y.units=["da","mo","ye","de","ce","thou","tenthou","hundredthou","mill","tenmill","hundredmill","bill"];y.getBCRataDie=function(e){var p=e.ye,u=e.mo;e=e.da;if(H[p+"-"+u+"-"+e])return H[p+"-"+u+"-"+e];if(u==0)u=1;if(e==0)e=1;var A=-1*((Math.abs(p)-1)*366+[0,335,306,275,245,214,184,153,122,92,61,31,0][u]+(y.monthsDayNums[u]-e+1));return H[p+"-"+u+"-"+e]=A};y.setCulture=function(e){jQuery.global.culture=jQuery.global.cultures[e];y.monthNames=q.merge([""],jQuery.global.culture.calendar.months.names); y.monthNamesAbbr=q.merge([""],jQuery.global.culture.calendar.months.namesAbbr);y.dayNames=jQuery.global.culture.calendar.days.names;y.dayNamesAbbr=jQuery.global.culture.calendar.days.namesAbbr;y.dayNamesShort=jQuery.global.culture.calendar.days.namesShort;y.patterns=jQuery.global.culture.calendar.patterns};y.prototype={format:function(e,p,u){u=u||{hours:0,minutes:0};if(p==true)switch(this.date_display.substr(0,2)){case "no":return"";case "ye":e="yyyy";break;case "mo":e="MMM yyyy";break;case "da":e= "MMM d, yyyy";break;case "ho":e="MMM d, yyyy h:mm tt";break;default:e="f"}if(this.ye>-27E4){p=y.toFromUTC(_.clone(this),u,"from");p=new Date(p.ye,p.mo-1,p.da,p.ho,p.mi,p.se,0);return q.global.format(p,e)}else return this.ye}};y.getTimeOffset=function(e){e=e.replace(/[^-\d:]/gi,"");var p=e.split(":"),u=parseInt(p[0],10);p=parseInt(p[1],10);var A=u+(u<0?-1:1)*(p/60);return{decimal:A,hours:u,minutes:p,seconds:A*3600,string:e}};y.tzOffsetStr=function(e,p){if(e){if(e.length==19)e+=p;else if(e.length== 16)e+=":00"+p;return e}};y.parse8601=function(e){var p,u,A,E,d,m,n,b;d=function(a){return a?parseInt(a.replace("-",""),10):0};b=e.match(k);e=parseInt(b[1]);if(!e)return{error:"invalid date; no year provided"};p=d(b[2])||1;u=d(b[3])||1;A=d(b[4])||1;E=d(b[5])||0;d=d(b[6])||0;m=b[7]||"+";n=parseInt(b[8],10)||0;if(m=="-")n*=-1;b=parseInt(b[9],10)||0;if(m=="-")b*=-1;return{ye:e,mo:p,da:u,ho:A,mi:E,se:d,tz_ho:n,tz_mi:b}};y.getLastDayOfMonth=function(e,p){var u=[0,31,28,31,30,31,30,31,31,30,31,30,31],A= 0;return A=p==2&&y.isLeapYear(e)==true?29:u[p]};y.getDateTimeStrings=function(e){var p=y.parse8601(e);e=p.ye+"-"+z(p.mo)+"-"+z(p.da);var u="pm";if(p.ho>12){p.ho-=12;u="pm"}else{if(p.ho==0)p.ho="12";u="am"}p=D(p.ho)+":"+z(p.mi)+" "+u;return{date:e,time:p}};y.transValidateDateString=function(e){if(!e)return false;var p=e.match(/^(\-?\d+|today|now) ?(bce?)?-?(\d{1,2})?-?(\d{1,2})?/);e=y.zeroButt;if(p){var u=p[1],A=p[2]||"",E=p[3]||"07";p=p[4]||"1";if(parseInt(u,10)<0||A.substr(0,1)=="b")u=-1*Math.abs(u); return y.validateDate(u,E,p)?u+"-"+e(E)+"-"+e(p):false}else return false};y.transValidateTimeString=function(e){if(!e)return"12:00:00";e=e.toLowerCase().match(/^(\d{1,2}|noon):?(\d{1,2})?:?(\d{1,2})? ?(am|pm)?/i);var p="";p=y.zeroButt;if(e[1])if(e[0]=="noon")p="12:00:00";else{var u=parseInt(e[1],10)||12,A=parseInt(e[2],10)||0,E=parseInt(e[3],10)||0;e=e[4]||"am";if(y.validateTime(u,A,E)==false)return false;if(e=="pm"&&u<12)u+=12;p=p(u)+":"+p(A)+":"+p(E)}else p=false;return p};y.validateTime=function(e, p,u){if(e<0||e>23||p<0||p>59||u<0||u>59)return false;return true};y.validateDate=function(e,p,u){var A=y.getMonthDays(p,e);if(u>A||u<=0)return false;if(p>12||p<0)return false;if(e==0)return false;return true};y.zeroButt=function(e){e=parseInt(e,10);return e>9?String(e):"0"+e};y.toFromUTC=function(e,p,u){var A=0,E=[0,31,28,31,30,31,30,31,31,30,31,30,31,29];A={};if(u=="from"){A.ho=-1*p.hours;A.mi=-1*p.minutes}else if(u=="to"){A.ho=p.hours;A.mi=p.minutes}else{A.ho=-1*e.tz_ho;A.mi=-1*e.tz_mi}if(A.ho== 0&&A.mi==0)return e;u=e.ho+e.mi/60+(-1*A.ho+A.mi*-1/60);if(u<0){A=24+u;if(e.da>1)e.da-=1;else if(e.mo==1){e.ye-=1;e.mo=12;e.da=31}else{e.mo-=1;e.da=y.getLastDayOfMonth(e.ye,e.mo)}}else if(u>=24){A=u-24;if(y.isLeapYear(e.ye)&&e.mo==2&&e.da==28)e.da=29;else if(e.da==E[e.mo]){if(e.mo==12){e.ye+=1;e.mo=1}else e.mo+=1;e.da=1}else e.da+=1}else A=u;E=function(d){d=Math.abs(d);var m=Math.floor(d);return{ho:m,mi:Math.round((d-m)*60),se:0}}(A);e.ho=E.ho;e.mi=E.mi;if(p){e.tz_ho=p.tz_ho;e.tz_mi=p.tz_mi}else{e.tz_ho= 0;e.tz_mi=0}return{ye:e.ye,mo:e.mo,da:e.da,ho:e.ho,mi:e.mi,se:e.se}};y.timezones=[{offset:"-12:00",name:"Int'l Date Line West"},{offset:"-11:00",name:"Bering & Nome"},{offset:"-10:00",name:"Alaska-Hawaii Standard Time"},{offset:"-10:00",name:"U.S. Hawaiian Standard Time"},{offset:"-10:00",name:"U.S. Central Alaska Time"},{offset:"-09:00",name:"U.S. Yukon Standard Time"},{offset:"-08:00",name:"U.S. Pacific Standard Time"},{offset:"-07:00",name:"U.S. Mountain Standard Time"},{offset:"-07:00",name:"U.S. Pacific Daylight Time"}, {offset:"-06:00",name:"U.S. Central Standard Time"},{offset:"-06:00",name:"U.S. Mountain Daylight Time"},{offset:"-05:00",name:"U.S. Eastern Standard Time"},{offset:"-05:00",name:"U.S. Central Daylight Time"},{offset:"-04:00",name:"U.S. Atlantic Standard Time"},{offset:"-04:00",name:"U.S. Eastern Daylight Time"},{offset:"-03:30",name:"Newfoundland Standard Time"},{offset:"-03:00",name:"Brazil Standard Time"},{offset:"-03:00",name:"Atlantic Daylight Time"},{offset:"-03:00",name:"Greenland Standard Time"}, {offset:"-02:00",name:"Azores Time"},{offset:"-01:00",name:"West Africa Time"},{offset:"00:00",name:"Greenwich Mean Time/UTC"},{offset:"00:00",name:"Western European Time"},{offset:"01:00",name:"Central European Time"},{offset:"01:00",name:"Middle European Time"},{offset:"01:00",name:"British Summer Time"},{offset:"01:00",name:"Middle European Winter Time"},{offset:"01:00",name:"Swedish Winter Time"},{offset:"01:00",name:"French Winter Time"},{offset:"02:00",name:"Eastean EU"},{offset:"02:00",name:"USSR-zone1"}, {offset:"02:00",name:"Middle European Summer Time"},{offset:"02:00",name:"French Summer Time"},{offset:"03:00",name:"Baghdad Time"},{offset:"03:00",name:"USSR-zone2"},{offset:"03:30",name:"Iran"},{offset:"04:00",name:"USSR-zone3"},{offset:"05:00",name:"USSR-zone4"},{offset:"05:30",name:"Indian Standard Time"},{offset:"06:00",name:"USSR-zone5"},{offset:"06:30",name:"North Sumatra Time"},{offset:"07:00",name:"USSR-zone6"},{offset:"07:00",name:"West Australian Standard Time"},{offset:"07:30",name:"Java"}, {offset:"08:00",name:"China & Hong Kong"},{offset:"08:00",name:"USSR-zone7"},{offset:"08:00",name:"West Australian Daylight Time"},{offset:"09:00",name:"Japan"},{offset:"09:00",name:"Korea"},{offset:"09:00",name:"USSR-zone8"},{offset:"09:30",name:"South Australian Standard Time"},{offset:"09:30",name:"Central Australian Standard Time"},{offset:"10:00",name:"Guam Standard Time"},{offset:"10:00",name:"USSR-zone9"},{offset:"10:00",name:"East Australian Standard Time"},{offset:"10:30",name:"Central Australian Daylight Time"}, {offset:"10:30",name:"South Australian Daylight Time"},{offset:"11:00",name:"USSR-zone10"},{offset:"11:00",name:"East Australian Daylight Time"},{offset:"12:00",name:"New Zealand Standard Time"},{offset:"12:00",name:"Int'l Date Line East"},{offset:"13:00",name:"New Zealand Daylight Time"}];y.boil=D;y.unboil=z})(timeglider);(function(t){var D=t.levelHeight=8;t.TG_Org=function(){var z=this,q=t.icon_folder;this.blocks=[];this.ids=[];this.vis=[];this.tree=[];this.pol=-1;this.addBlock=function(o,r){o.right=o.left+o.width;o.bottom=o.top+o.height;o.tickScope=r;z.freshBlocks.push(o);z.blocks.push(o)};this.clearFresh=function(){z.freshBlocks=[]};this.getBorg=function(){return this};this.getBlocks=function(){return this.blocks};this.getHTML=function(o,r){if(o=="sweep"){z.tree=[];for(var k=0;k<300;k++)z.tree[k]=[];this.vis=[]}this.blocks.sort(F); var y,e,p="",u="";k="";var A=0,E={},d=this.freshBlocks.length;e="";var m=0;y="";for(var n=0;n"}else p="";if(E.y_position>0)E.top=z.pol*E.y_position;else H(E,0);e=E.span_color?";background-color:"+E.span_color:"";E.fontsize<10?E.opacity=E.fontsize/10:E.opacity=1;if(E.span==true){y="timeglider-event-spanning";e="
"}else e=y="";u=E.icon?"":"";if(r&&z.pol==-1&&Math.abs(E.top)>r-32)k+="
+
";else{A=z.pol===1?42:0;k+="
"+u+p+e+"
"+E.title+"
"}}}}return{html:k,highest:0}};var F=function(o,r){var k=r.importance,y=o.importance;if(o.image&&!r.image)return-1;return ky?1:0},w=function(o,r){if(!(r.left+-16>o.right||r.right=o.left&&r.left<=o.right||r.right>=o.left&&r.right<=o.right||r.right>=o.right&&r.left<=o.left||r.right<=o.right&&r.left>=o.left)if(r.bottom<=o.bottom&&r.bottom>=o.top||r.top<=o.bottom&&r.top>=o.top||r.bottom==o.bottom&&r.top==o.top)return true; return false},H=function(o,r){var k=false,y=z.tree,e=_.union(y[r],y[r+1]),p=r+1,u=false;k=2;var A=0,E=false;if(e!=undefined){for(var d=0;d0){for(var o,r,k,y,e=w.events.length,p=0;p0?true:false;w.display="expanded";F.eventCollection.setTimelineHash(w.timeline_id, H);delete w.events;return w},initialize:function(w){this.set(this._chewTimeline(w));this.bind("change",function(){})}})})(timeglider);(function(t){var D=t.TG_Date,z="",q="",F={},w=0,H=0,o=0,r="",k=jQuery,y={},e="",p,u,A,E=k.support.touch?"touchstart":"click";t.TG_PlayerView=function(d,m){var n=this;q=m;F=q.options;z="#"+d._id;e=d._id;r=F.base_namespace+"#"+e;this.gens=0;this._views={PLACE:z,CONTAINER:z+" .timeglider-container",DATE:z+" .timeglider-date-display",TIMELINE_MENU:z+" .timeglider-timeline-menu",TIMELINE_MENU_UL:z+" .timeglider-timeline-menu ul",TIMELINE_LIST_BT:z+" .timeglider-list-bt",SLIDER_CONTAINER:z+" .timeglider-slider-container", SLIDER:z+" .timeglider-slider",ZOOM_DISPLAY:z+" .timeglider-zoomlevel-display",TRUCK:z+" .timeglider-truck",CENTERLINE:z+" .timeglider-centerline",TICKS:z+" .timeglider-ticks",HANDLE:z+" .timeglider-handle",FOOTER:z+" .timeglider-footer",FILTER_BT:z+" .timeglider-filter-bt",FILTER_BOX:z+" .timeglider-filter-box",SETTINGS_BT:z+" .timeglider-settings-bt"};p=this._views.CONTAINER;u=this._views.TICKS;A=this._views.DATE;this.imageLaneHeight=40;this.initTimelineVOffset=100;this.tick_height=34;this.dragScopeState= {state:"okay",pos:0};this._templates={};this._templates={test:"testola",event_modal_small:"

${title}

{{html image}}{{html description}}

",event_modal_full:k.template(null,"
x

${title}

{{html description}}

{{html image}}
"), filter_modal:k.template(null,"

filter

show:
hide:
  • clear
  • apply
"), timeline_list_modal:k.template(null,"

timelines

    "),settings_modal:k.template(null,"

    settings

    "), legend_modal:k.template(null,"
      {{html legend_list}}
    all
    ")};this.timelineModal=t.TG_TimelineView.extend({tagName:"div",model:t.TG_Timeline,className:"tg-modal timeglider-timeline-modal ui-widget-content",events:{"click .close-button-remove":"remove"}, template:"

    ${title}

    {{html description}}

    ",initialize:function(){this.model.bind("change",this.render,this)},render:function(){k(this.el).html(k.tmpl(this.template,this.model.attributes)).attr("id",this.model.get("id")+"_timelineModal");return this},remove:function(){k(this.el).fadeOut()}});k(p).delegate(".tg-timeline-envelope .timeline-info","click",function(){var a=k(this).data("timeline_id");n.openTimelineModal(a)}).delegate(".tg-timeline-envelope .expand-collapse", "click",function(){var a=k(this).data("timeline_id");n.expandCollapseTimeline(a)}).delegate(".tg-timeline-envelope .tg-timeline-legend-bt","click",function(){var a=k(this).data("timeline_id");n.legendModal(a)}).delegate(".close-button-remove","click",function(){var a=k(this).parent().attr("id");k("#"+a).remove()}).delegate(".full_modal_scrim, .full_modal_close","click",function(){k(".full_modal").remove()}).delegate(".timeglider-more-plus","click",function(){q.zoom(-1)}).delegate(".timeglider-more-plus", "hover",function(){k(this).data("event_id")}).delegate(".timeglider-legend-close","click",function(){var a=k(p+" .timeglider-legend");a.fadeOut(300,function(){a.remove()})}).delegate(".timeglider-legend-all","click",function(){k(p+" .timeglider-legend li").each(function(){k(this).removeClass("tg-legend-icon-selected")});q.setFilters({origin:"legend",icon:"all"})}).css("height",k(z).height());this.basicFontSize=F.basic_fontsize;F.show_footer==false&&k(this._views.FOOTER).css("display","none");this.dragSpeed= 0;this.dimensions=q.dimensions=this.getWidgetDimensions();this.ticksHandleOffset=this.rightside=this.leftside=this.tickNum=0;this.timeoout_id=1;this.sliderActive=false;this.ztop=1E3;this.filterBoxActivated=false;this.buildSlider();this.setupFilter();this.setPanButton(k(".timeglider-pan-right"),-30);this.setPanButton(k(".timeglider-pan-left"),30);k(this._views.TRUCK).bind("dblclick",function(a){q.registerUIEvent({name:"dblclick",event:a})}).bind("mousewheel",function(a,j){var f=Math.ceil(-1*j*3),h= q.getZoomLevel();q.setZoomLevel(h+f);return false});k(u).draggable({axis:"x",start:function(){},drag:function(){H=Math.floor(k(this).position().left);q.setTicksOffset(H);w=H-o;o=H;var a=n.dragScopeState;if(F.constrain_to_data&&q.activeTimelines.length==1){var j=k(".titleBar"),f=j.data("lef"),h=n.dimensions.container.centerx;if(a.state=="over-left"){k(u).css("left",-1*f+(h-1));n.dragScopeState={state:"okay"};n.registerDragging();return false}else if(a.state=="over-right"){a=-1*f+(h-1)-(j.width()-4); k(u).css("left",a);n.dragScopeState={state:"okay"};n.registerDragging();return false}}return true},stop:function(){n.resetTicksHandle();n.registerDragging();n.registerTitles()}}).delegate(p+" .timeglider-timeline-event",E,function(){var a=k(this).attr("id"),j=q.eventCollection.get(a).attributes;if(timeglider.mode!="authoring")if(j.click_callback)try{var f=j.click_callback.split("."),h=f.length;if(h==1)window[f[0]](j);else if(h==2)window[f[0]][f[1]](j);else if(h==3)window[f[0]][f[1]][f[2]](j)}catch(g){debug.log(j.click_callback+ " method cannot be found")}else n.eventModal(a)}).delegate(".timeglider-timeline-event","mouseover",function(){var a=q.eventCollection.get(k(this).attr("id")).attributes;n.eventHover(k(this),a)}).delegate(".timeglider-timeline-event","mouseout",function(){var a=q.eventCollection.get(k(this).attr("id")).attributes;n.eventUnHover(k(this),a)}).delegate(".timeglider-event-collapsed","hover",function(){q.eventCollection.get(k(this).attr("id"))});n.setCenterline();k.subscribe(r+".mediator.ticksOffsetChange", function(){n.tickHangies();n.registerDragging();n.registerTitles()});k.subscribe(r+".mediator.focusToEvent",function(){});k.subscribe(r+".mediator.zoomLevelChange",function(){n.tickNum=0;n.leftside=0;var a=q.getZoomLevel();k(n._views.SLIDER).slider("value",n.invSliderVal(a));n.displayZoomLevel(a);n.castTicks("zoomLevelChange")});k.subscribe(r+".viewer.rendered",function(){});k.subscribe(r+".mediator.ticksReadySignal",function(){q.ticksReady===true&&n.freshTimelines()});k.subscribe(r+".mediator.refreshSignal", function(){n.tickNum=0;n.leftside=0;n.castTicks("refreshSignal")});k.subscribe(r+".mediator.ticksArrayChange",function(){});k.subscribe(r+".mediator.scopeChange",function(){var a=q.getScope(),j=a.timelineBounds;a=a.focusDateSec;n.dragScopeState=a>j.last?{state:"over-right"}:agesture zoom:"+ q.getZoomLevel())},false);b.addEventListener("gestureend",function(a){a.preventDefault();k("#output").append("
    gesture end:"+q.getZoomLevel())},false);b.addEventListener("gesturechange",function(a){a.preventDefault();a.preventDefault();if(q.gesturing===false){q.gesturing=true;q.gestureStartZoom=q.getZoomLevel()}q.setZoomLevel(Math.ceil(q.gestureStartZoom/a.scale))},false)}};t.TG_PlayerView.prototype={resize:function(){var d=k(z).height();k(p).height(d);this.dimensions=this.getWidgetDimensions(); q.setDimensions(this.dimensions);this.setCenterline();q.refresh()},getWidgetDimensions:function(){var d=k(p),m=d.width(),n=Math.floor(m/2)+1,b=d.height(),a=Math.floor(b/2),j=this.tick_height,f=d.position().left;d=d.offset();var h=F.show_footer==true?k(this._views.FOOTER).height():0;return{container:{width:m,height:b,centerx:n,centery:a,left:f,offset:d},tick:{top:b-h-j},footer:{height:h}}},scaleToImportance:function(d,m){return d/m},displayZoomLevel:function(){var d=q.getZoomLevel();d>0&&F.display_zoom_level== true&&k(this._views.ZOOM_DISPLAY).text(d)},displayFocusDate:_.throttle(function(){var d=q.getFocusDate();k(A).text(d.format("d MMM yyyy",false))},300),setPanButton:function(d,m){var n=this;k(d).live("mousedown",function(){n.intervalMachine("pan",{type:"set",fn:n.pan,args:[m],intvl:33})}).live("mouseup",function(){n.intervalMachine("pan",{type:"clear",fn:n.pan,callback:"resetTicksHandle"})}).live("mouseout",function(){n.intervalMachine("pan",{type:"clear",fn:n.pan,callback:"resetTicksHandle"})})}, intervalMachine:function(d,m){var n=this;if(m.type==="clear"){clearInterval(y[d]);if(m.callback)n[m.callback]()}else y[d]=setInterval(function(){m.fn.apply(n,m.args)},m.intvl)},invSliderVal:function(d){return Math.abs(d-101)},pan:function(d){var m=d||20;d=k(u);m=d.position().left+m;d.css({left:m});q.setTicksOffset(m)},registerTitles:function(){var d,m,n,b,a,j,f,h,g,s,v=k(p).offset().left;k(p+" .timeglider-event-spanning").each(function(){var B=k(this);d=B.offset().left-v;a=B.find(".timeglider-event-title"); m=a.outerWidth();n=a.siblings(".timeglider-event-spanner").outerWidth();if(n>m)if(d<0)Math.abs(d)0){var B=h.width()-g.width();s",b=false,a="selected";k.map(D.timezones,function(j){if(m==j.offset&&b==false){a="selected";b=true}else a="";n+=""});n+="";return n}, buildSettingsMenu:function(){var d=k.tmpl(this._templates.settings_modal,{}).appendTo(this._views.CONTAINER),m=this.getTimezonePulldown("timeglider-settings-timezone",q.timeOffset.string);d.find(".timeglider-settings-timezone").append('

    Make changes below, then click on "save". More settings options to come!

    ').append('timezone: '+m).append("

     

    save
    ");d.position({my:"right bottom", at:"right top",of:k(this._views.SETTINGS_BT),offset:"-8, -30"}).hide();k(p).delegate(".timeglider-settings-modal .close-button","click",function(){d.fadeOut()}).delegate(this._views.SETTINGS_BT,"click",function(){d.fadeIn()}).delegate("#timeglider-settings-save","click",function(){var n=k(p+" #timeglider-settings-timezone").val();q.setTimeoffset(n)})},buildSlider:function(){var d=q.getZoomLevel();if(F.min_zoom==F.max_zoom)k(this._views.SLIDER_CONTAINER).css("display","none");else{F.display_zoom_level== true&&k("
    ").appendTo(this._views.SLIDER_CONTAINER).addClass("timeglider-zoomlevel-display").html(" ");var m=this;d=m.invSliderVal(d);var n=q.max_zoom,b=q.min_zoom;k(this._views.SLIDER).css("height",(1+n-b)*3).slider({steps:100,handle:k(".knob"),animate:300,orientation:"vertical",min:m.invSliderVal(n),max:m.invSliderVal(b),value:d,start:function(){m.sliderActive=true},stop:function(){m.sliderActive=false},change:function(){},slide:function(a,j){q.setZoomLevel(m.invSliderVal(j.value))}})}}, getEventDateLine:function(d){var m="",n="";if(d.span==true)n=" – ";return m+n},eventHover:function(d,m){var n=k(".timeglider-event-hover-info");m.date_display!="no"&&n.position({my:"left bottom",at:"left top",of:d,offset:"1, -10",collision:"flip flip"}).html(this.getEventDateLine(m));d.addClass("tg-event-hovered")}, eventUnHover:function(d){k(".timeglider-event-hover-info").css("left","-1000px");d.removeClass("tg-event-hovered")},clearTicks:function(){this.tickNum=this.leftside=0;k(u).css("left",0);k(p+" .tg-timeline-envelope").remove();k(p+" .timeglider-tick").remove()},castTicks:function(){this.clearTicks();q.getZoomLevel();var d=q.getFocusDate(),m=q.getZoomInfo().width;m=Math.ceil(this.dimensions.container.width/m)+4;var n="l";q.setTicksReady(false);this.addTick({type:"init",focus_date:d});for(d=1;d<=m;d+= 1){this.addTick({type:n});n=n=="l"?"r":"l"}q.setTicksReady(true);this.displayFocusDate()},addTick:function(d){var m=0,n=0,b=n=0,a=0,j=0,f=j="",h={};j={};b={};var g={};j={};h="";var s=q.getZoomInfo().unit;g=q.getZoomInfo().width;a=q.getFocusDate();b=parseInt(this.dimensions.tick.top);a=q.addToTicksArray({type:d.type,unit:s},a);if(s=="mo"){j=D.getMonthAdj(a,g);g=j.width;m=j.days}this.tickNum++;if(d.type=="init"){j=this.tickOffsetFromDate(q.getZoomInfo(),q.getFocusDate(),g);n=Math.ceil(this.dimensions.container.centerx+ j);k(u).data("init-left",n);this.leftside=n;this.rightside=n+g}else if(d.type=="l")this.leftside=n=Math.floor(this.leftside-g);else if(d.type=="r"){n=Math.floor(this.rightside);this.rightside+=g}q.getTickBySerial(a).width=g;q.getTickBySerial(a).left=n;j=this._views.PLACE+"_"+s+"_"+a+"-"+this.tickNum;j=k("
    ").appendTo(u);j.css({width:g,left:n,top:b});b=this.getTickMarksInfo({unit:s,width:g});b=m||b.tperu; n=g/b;if(n>5)for(d=m=0;d16)if(s=="da")f=this.getHourLabelFromHour(d,n);else if(s=="mo")f=d+1;else if(s=="ye")f=n>30?" "+D.monthNamesAbbr[d+1]:" "+D.monthNamesLet[d+1];else if(s=="de"){if(n>44)f=a+""+d}else if(s=="ce")if(n>28)f=a+""+d+"0";h+="
    "+f+"
    ";m+=n}h&&j.append("
    "+h+ "
    ");g={unit:s,width:g,serial:a};h=this.getDateLabelForTick(g);g.seconds=this.getTickSeconds[s](g.serial);j.children("#label").text(h);return g},setCenterline:function(){q.options.show_centerline===true?k(this._views.CENTERLINE).css({height:this.dimensions.container.height,left:this.dimensions.container.centerx}):k(this._views.CENTERLINE).css({display:"none"})},getTickSeconds:{da:function(d){d*=86400;return{start:d,end:d+86400}},mo:function(d){d*=2629800;return{start:d,end:d+2629800}},ye:function(d){d*= 3154E4;return{start:d,end:d+3154E4}},de:function(d){d*=3154E5;return{start:d,end:d+3154E5}},ce:function(d){d*=3154E6;return{start:d,end:d+3154E6}},thou:function(d){d*=3154E6;return{start:d,end:d+3154E6}},tenthou:function(d){d*=3154E6;return{start:d,end:d+3154E6}},hundredthou:function(d){d*=3154E6;return{start:d,end:d+3154E6}},mill:function(d){d*=3154E6;return{start:d,end:d+3154E6}},tenmill:function(d){d*=3154E6;return{start:d,end:d+3154E6}},hundredmill:function(d){d*=3154E6;return{start:d,end:d+3154E6}}, bill:function(d){d*=3154E6;return{start:d,end:d+3154E6}}},getHourLabelFromHour:function(d,m){var n="",b=d,a="";a=0;if(m<16)return"";else{if(d>12)b=d-12;else if(d==0)b=12;if(m>30)n=d>11?" pm":" am";if(m>200){a=m/4-4;return"
    "+b+":00 "+n+"
    "+b+":15 "+n+"
    "+b+":30 "+n+"
    "+b+":45 "+n+"
    "}else return b+(m>60?":00": "")+n}},getTickMarksInfo:function(d){switch(d.unit){case "da":d=24;break;case "mo":d=30;break;case "ye":d=12;break;default:d=10}return{tperu:d}},getDateLabelForTick:function(d){var m=d.serial,n=d.width;switch(d.unit){case "bill":return m==0?"1":m>0?m+" billion":m+" b.y. bce";case "hundredmill":return m==0?"1":m>0?m+"00 million":m+"00 m.y. bce";case "tenmill":return m==0?"1":m>0?m+"0 million":m+"0 m.y. bce";case "mill":return m==0?"1":m>0?m+" million":m+" m.y. bce";case "hundredthou":return m==0?"1": m>0?m+"00,000":m+"00,000 bce";case "tenthou":return m==0?"1":m>0?m+"0,000":m+"0,000 bce";case "thou":return m==0?"1("+m+")":m>0?m+"000":m+"000 bce";case "ce":return m==0?"1("+m+")":m>0?m+"00":m+"00 bce";case "de":return m>120?m*10+"s":m*10;case "ye":return m;case "mo":d=D.getDateFromMonthNum(m);return n<120?D.monthNamesAbbr[d.mo]+" "+d.ye:D.monthNames[d.mo]+", "+d.ye;case "da":d=new D(D.getDateFromRD(m));return n<120?D.monthNamesAbbr[d.mo]+" "+d.da+", "+d.ye:D.monthNames[d.mo]+" "+d.da+", "+d.ye; default:return d.unit+":"+m+":"+n}},tickHangies:function(){var d=k(u).position().left,m=this.rightside+d-this.dimensions.container.width;if(this.leftside+d>-100){d=this.addTick({type:"l"});this.appendTimelines(d,"left")}else if(m<100){d=this.addTick({type:"r"});this.appendTimelines(d,"right")}},tickOffsetFromDate:function(d,m,n){switch(d.unit){case "da":m=m.ho/24+m.mi/1440;n*=m;break;case "mo":d=D.getMonthDays(m.mo,m.ye);m=(m.da-1)/d+m.ho/(24*d)+m.mi/(1440*d);n*=m;break;case "ye":m=((m.mo-1)*30+m.da)/ 365;n*=m;break;case "de":m=m.ye%10/10+m.mo/120;n*=m;break;case "ce":m=m.ye%100/100+m.mo/1200;n*=m;break;case "thou":m=m.ye%1E3/1E3;n*=m;break;case "tenthou":m=m.ye%1E4/1E4;n*=m;break;case "hundredthou":m=m.ye%1E5/1E5;debug.log("hundredthou prop:",m);n*=m;debug.log("hundredthou p:",n);break;case "mill":m=m.ye%1E6/1E6;n*=m;break;case "tenmill":m=m.ye%1E7/1E7;n*=m;break;case "hundredmill":m=m.ye%1E8/1E7;n*=m;break;case "bill":m=m.ye%1E9/1E9;n*=m;break;default:n=0}return-1*n},resetTicksHandle:function(){k(this._views.HANDLE).offset({left:k(p).offset().left})}, easeOutTicks:function(){Math.abs(w)>5&&k(u).animate({left:"+="+3*w},1E3,"easeOutQuad",function(){debug.trace("stopping easing","note")})},getTimelineEventsByTick:function(d){var m=d.tick.unit,n=d.tick.serial;d=q.eventCollection.getTimelineHash(d.timeline.timeline_id);return d[m][n]&&d[m][n].length>0?d[m][n]:[]},passesFilters:function(d,m){var n=true,b="";b="";var a=[],j;b="";a=[];if(md.high_threshold)return false;if(b=q.filters.include){a=b.split(",");n=false;for(j=0;j0){b=d.icon;if(_.indexOf(q.filters.legend,b)==-1)n=false}if(q.filters.tags.length>0)if(d.tags){ev_tags=d.tags.split(",");_.each(ev_tags,function(f){f=k.trim(f);if(_.indexOf(q.filters.tags,f)!==-1)n=true})}else n=false;return n},freshTimelines:function(){var d= this,m,n,b,a=q.activeTimelines,j=q.ticksArray,f="",h,g;n="";var s=d.dimensions.container.centerx,v=d.dimensions.container.width,B=q.getFocusDate().sec,c=q.getZoomInfo(),i=c.spp;c=c.unit;n=[];var l=[];v=Math.floor(i*(v/2));for(var x=B-v,C=B+v,G=b=h=0,J=d.dimensions.container.height,K=G=0;K1E6){var I=b-1E6;b=1E6;if(n<-998E3)n+=I}h.css({top:void 0,left:n,width:b}).data({lef:n,wid:b});if(v=="expanded")m.borg=f=new timeglider.TG_Org;for(h= 0;hC||O.endx){l.unshift(O.id);m.visibleEvents.push(O.id)}});n=this.compileTickEventsAsHtml(m,_.uniq(l),0,"sweep",c);G=F.event_overflow=="scroll"?0:m.hasImagesAbove?G-d.imageLaneHeight:G;if(v=="expanded"){n=f.getHTML("sweep",G);m.borg=f.getBorg()}n!="undefined"&&g.append(n.html);setTimeout(function(){d.registerEventImages(g)}, 3)}d.registerTitles();setTimeout(function(){d.applyFilterActions()},300);k.publish("viewer.rendered")},appendTimelines:function(d,m){for(var n=q.activeTimelines,b=[],a,j="",f=this,h=0;hd.seconds.start)if(_.indexOf(a.visibleEvents,g.id)===-1){b.unshift(g.id);a.visibleEvents.push(g.id)}}); j=this.compileTickEventsAsHtml(a,b,d.serial,"append",d.unit);if(a.display=="expanded")j=a.borg.getHTML(d.serial,a.top);k(p+" .tg-timeline-envelope#"+a.id).append(j.html);this.registerEventImages(void 0)}setTimeout(function(){f.applyFilterActions()},500);k.publish("viewer.rendered")},compileTickEventsAsHtml:function(d,m,n,b,a){var j=0,f=this.dimensions.container.centerx,h=d.display,g="",s=q.startSec,v=q.getZoomInfo(),B=v.spp;v=v.level;var c=j=0,i=d.borg,l={},x="sweep";d.borg.clearFresh();if(b=="append")x= n;for(n=0;nl.width)l.width=l.spanwidth+16}b=Math.ceil(l.fontsize);l.height= b+4;l.top=0-b;if(l.image&&l.image.display_class==="inline"){b=(l.image.scale||100)/100;j=b*l.image.height+2;c=b*l.image.width+2;l.shape={img_ht:j,img_wi:c,top:l.top-j,bottom:l.top-4,left:l.left,right:l.left+c}}else l.shape=null;i.addBlock(l,x)}else if(h=="collapsed")g+="
    "}}return h=="collapsed"?{html:g}:""},setImageLaneHeight:function(d){this.imageLaneHeight=d;q.refresh()},registerEventImages:function(){var d= this;k(p+" .timeglider-event-image-above").each(function(){var m=d.imageLaneHeight,n=k(this),b=k(this).find("img"),a=12,j=b.data("max_height"),f=jlink";else if(typeof d=="object")for(n=0;n"+a+""}return m},eventModal:function(d){k(p+" #"+d+"_modal").remove();var m=this,n=false,b=false,a="";a={};a=0;a=k("#"+d);var j=q.eventCollection.get(d).attributes,f=j.modal_type||F.event_modal.type,h=j.image&&j.image.src?"":"",g=this.createEventLinksMenu(j.link);d={title:j.title,description:j.description,id:d,dateline:m.getEventDateLine(j), links:g,image:h};if(j.video){d.video=j.video;f="full";b=true;d.video=j.video}else if(j.map&&j.map.latlong){n=true;f="full"}switch(f){case "full":d=k.tmpl(m._templates.event_modal_full,d);d.appendTo(p).css({"z-index":m.ztop++}).position({my:"left top",at:"left top",of:p,offset:"0, 0",collision:"none none"});if(n==true){d.find("#insert").append("
    ");a=j.map.zoom||12;n=String(j.map.latlong).split(",");n=new google.maps.LatLng(parseFloat(n[0]),parseFloat(n[1]));a={zoom:a, center:n,mapTypeId:google.maps.MapTypeId.ROADMAP};a=new google.maps.Map(k("#map_modal_map")[0],a);if(j.map.markers)for(n=0;n
    ");j=m.dimensions.container.height;n=m.dimensions.container.width;b=k(p+" .full_modal_panel");d=b.width();a=b.height();b.css({top:(j-a)/2+"px",left:(n-d)/2+"px"});break;case "video":d=k.tmpl(m._templates.event_modal_video,d);d.appendTo(u).css("z-index",m.ztop++).position({my:"right center",at:"left center",of:a,offset:"-12, -1",collision:"flip fit"}).hover(function(){k(this).css("z-index",m.ztop++)});break;default:d=k.tmpl(m._templates.event_modal_small,d);d.appendTo(u).css("z-index", m.ztop++).position({my:"center top",at:"center top",of:p,offset:"0, 100",collision:"fit fit"}).draggable().hover(function(){k(this).css("z-index",m.ztop++)})}},legendModal:function(d){var m=q.timelineCollection.get(d).attributes.legend,n=0,b="",a="",j="";n="";for(n=0;n"+a+""}d={id:d,legend_list:j};k(p+" .timeglider-legend").remove();k.tmpl(this._templates.legend_modal, d).appendTo(p).css("z-index",this.ztop++).toggleClass("timeglider-display-none").position({my:"left top",at:"left top",of:p,offset:"16, -4",collision:"none none"});n=p+" .legend-info, "+p+" .legend-icon";k(n).bind("mouseup",function(f){f=k(f.target).parent().children("img").attr("src");k(this).parent().toggleClass("tg-legend-icon-selected");q.setFilters({origin:"legend",icon:f})})},parseHTMLTable:function(d){var m={},n=+new Date,b=[];k("#"+d).find("tr").each(function(a){var j=k(this).children(),f; if(a===0)b=j.map(function(){return k(this).attr("class").replace(/^.*?\btg-(\S+)\b.*?$/,"$1")}).get();else{f={};j.each(function(h){f[b[h]]=k(this).text()});m["prefix"+n++]=f}});return m}};t.TG_TimelineView=Backbone.View.extend({initialize:function(){var d=this;this.model.bind("change:title",function(){k(d.el).find(".timeline-title-span").text(d.model.get("title"))});this.model.bind("destroy",this.remove,this)},tagName:"div",events:{"click .timeline-title-span":"titleClick"},className:"tg-timeline-envelope", getTemplate:function(){var d="
    ${title}
    ";if(this.model.get("description"))d+="info";if(this.model.get("hasLegend"))d+="legend";d+="exp/col";d+="
    ";return d},render:function(){this.model.get("id"); this.model.get("title");var d=this.getTemplate();k(this.el).html(k.tmpl(d,this.model.attributes)).attr("id",this.model.get("id"));return this},setText:function(){},titleClick:function(){q.timelineTitleClick(this.model.get("id"))},remove:function(){k(this.el).remove()}});t.zoomTree=[{},{unit:"da",width:35E3,level:1,label:"5 hours"},{unit:"da",width:17600,level:2,label:"7 hours"},{unit:"da",width:8800,level:3,label:"10 hours"},{unit:"da",width:4400,level:4,label:"12 hours"},{unit:"da",width:2200,level:5, label:"14 hours"},{unit:"da",width:1100,level:6,label:"17 hours"},{unit:"da",width:550,level:7,label:"22 hours"},{unit:"da",width:432,level:8,label:"1 DAY"},{unit:"da",width:343,level:9,label:"1.5 days"},{unit:"da",width:272,level:10,label:"2 days"},{unit:"da",width:216,level:11,label:"2.5 days"},{unit:"da",width:171,level:12,label:"3 days"},{unit:"da",width:136,level:13,label:"3.5 days"},{unit:"da",width:108,level:14,label:"4 days"},{unit:"mo",width:2509,level:15,label:"6 days"},{unit:"mo",width:1945, level:16,label:"1 WEEK"},{unit:"mo",width:1508,level:17,label:"10 days"},{unit:"mo",width:1169,level:18,label:"2 weeks"},{unit:"mo",width:913,level:19,label:"2.5 weeks"},{unit:"mo",width:719,level:20,label:"3 weeks"},{unit:"mo",width:566,level:21,label:"3.5 weeks"},{unit:"mo",width:453,level:22,label:"1 MONTH"},{unit:"mo",width:362,level:23,label:"5.5 weeks"},{unit:"mo",width:290,level:24,label:"7 weeks"},{unit:"mo",width:232,level:25,label:"2 months"},{unit:"mo",width:186,level:26,label:"2.5 months"}, {unit:"mo",width:148,level:27,label:"3 months"},{unit:"mo",width:119,level:28,label:"4 months"},{unit:"mo",width:95,level:29,label:"5 months"},{unit:"mo",width:76,level:30,label:"6 months"},{unit:"ye",width:723,level:31,label:"9 months"},{unit:"ye",width:573,level:32,label:"1 YEAR"},{unit:"ye",width:455,level:33,label:"1.25 years"},{unit:"ye",width:361,level:34,label:"1.5 years"},{unit:"ye",width:286,level:35,label:"2 years"},{unit:"ye",width:227,level:36,label:"2.5 years"},{unit:"ye",width:179,level:37, label:"3 years"},{unit:"ye",width:142,level:38,label:"4 years"},{unit:"ye",width:113,level:39,label:"5 years"},{unit:"ye",width:89,level:40,label:"6 years"},{unit:"de",width:705,level:41,label:"8 years"},{unit:"de",width:559,level:42,label:"10 years"},{unit:"de",width:443,level:43,label:"13 years"},{unit:"de",width:302,level:44,label:"16 years"},{unit:"de",width:240,level:45,label:"20 years"},{unit:"de",width:190,level:46,label:"25 years"},{unit:"de",width:150,level:47,label:"30 years"},{unit:"de", width:120,level:48,label:"40 years"},{unit:"de",width:95,level:49,label:"50 years"},{unit:"de",width:76,level:50,label:"65 years"},{unit:"ce",width:600,level:51,label:"80 years"},{unit:"ce",width:480,level:52,label:"100 years"},{unit:"ce",width:381,level:53,label:"130 years"},{unit:"ce",width:302,level:54,label:"160 years"},{unit:"ce",width:240,level:55,label:"200 years"},{unit:"ce",width:190,level:56,label:"250 years"},{unit:"ce",width:150,level:57,label:"300 years"},{unit:"ce",width:120,level:58, label:"400 years"},{unit:"ce",width:95,level:59,label:"500 years"},{unit:"ce",width:76,level:60,label:"600 years"},{unit:"thou",width:603,level:61,label:"1000 years"},{unit:"thou",width:478,level:62,label:"1200 years"},{unit:"thou",width:379,level:63,label:"1800 years"},{unit:"thou",width:301,level:64,label:"160 years"},{unit:"thou",width:239,level:65,label:"xxx years"},{unit:"thou",width:190,level:66,label:"xxx years"},{unit:"thou",width:150,level:67,label:"xxx years"},{unit:"thou",width:120,level:68, label:"xxx years"},{unit:"thou",width:95,level:69,label:"8,000 years"},{unit:"thou",width:76,level:70,label:"10,000 years"},{unit:"tenthou",width:603,level:71,label:"15,000 years"},{unit:"tenthou",width:358,level:72,label:"20,000 years"},{unit:"tenthou",width:213,level:73,label:"30,000 years"},{unit:"tenthou",width:126,level:74,label:"60,000 years"},{unit:"tenthou",width:76,level:75,label:"100,000 years"},{unit:"hundredthou",width:603,level:76,label:"180,000 years"},{unit:"hundredthou",width:358, level:77,label:"300,000 years"},{unit:"hundredthou",width:213,level:78,label:"500,000 years"},{unit:"hundredthou",width:126,level:79,label:"800,000 years"},{unit:"hundredthou",width:76,level:80,label:"1 million years"},{unit:"mill",width:603,level:81,label:"1.2 million years"},{unit:"mill",width:358,level:82,label:"2 million years"},{unit:"mill",width:213,level:83,label:"3 million years"},{unit:"mill",width:126,level:84,label:"5 million years"},{unit:"mill",width:76,level:85,label:"10 million years"}, {unit:"tenmill",width:603,level:86,label:"15 million years"},{unit:"tenmill",width:358,level:87,label:"30 million years"},{unit:"tenmill",width:213,level:88,label:"50 million years"},{unit:"tenmill",width:126,level:89,label:"80 million years"},{unit:"tenmill",width:76,level:90,label:"100 million years"},{unit:"hundredmill",width:603,level:91,label:"120 million years"},{unit:"hundredmill",width:358,level:92,label:"200 million years"},{unit:"hundredmill",width:213,level:93,label:"300 million years"}, {unit:"hundredmill",width:126,level:94,label:"500 million years"},{unit:"hundredmill",width:76,level:95,label:"1 billion years"},{unit:"bill",width:603,level:96,label:"15 million years"},{unit:"bill",width:358,level:97,label:"30 million years"},{unit:"bill",width:213,level:98,label:"50 million years"},{unit:"bill",width:126,level:99,label:"80 million years"},{unit:"bill",width:76,level:100,label:"100 billion years"}];t.calculateSecPerPx=function(d){for(var m=1;my?r.get("bounds").last:y}return{first:k,last:y}},loadTimelineData:function(o){var r=this;if(o)if(typeof o==="object")r.parseTimelineData(o);else if(o.substr(0,1)=="#"){o=[r.getTableTimelineData(o)];r.parseTimelineData(o)}else F.getJSON(o,function(k){r.parseTimelineData(k)});else{this.timelineDataLoaded=true;this.setZoomLevel(Math.floor((this.max_zoom+ this.min_zoom)/2));this.tryLoading()}},mapMarkerClick:function(o){this.focusToEvent(o)},getTimelineCollection:function(){return this.timelineCollection},timelineTitleClick:function(o){F.publish(H+".mediator.timelineTitleClick",{timeline_id:o})},getTableTimelineData:function(o){var r={},k=0,y=[],e,p,u="",A=F(o);r.id=o.substr(1);r.title=A.attr("title")||"untitled";r.description=A.attr("description")||"";r.focus_date=A.attr("focus_date")||z.getToday;r.initial_zoom=A.attr("initial_zoom")||20;r.events= [];A.find("tr").each(function(E){var d=F(this).children(),m;if(E===0)y=d.map(function(){return F(this).attr("class").replace(/^.*?\btg-(\S+)\b.*?$/,"$1")}).get();else{m={};d.each(function(n){e=y[n];p=e=="description"?F(this).html():F(this).text();m[e]=p});u="ev_"+k++;m.id=u;r.events.push(m)}});A.css("display","none");return r},parseTimelineData:function(o){var r=0,k=o.length,y={};y={};for(var e=0;e0){r++;this.swallowTimeline(y)}}if(r=== 0)alert("ERROR loading data: Check JSON with jsonLint");else{this.timelineDataLoaded=true;this.tryLoading()}},tryLoading:function(){var o=this.timelineDataLoaded==true;if(this.imagesSized==this.imagesToSize&&o){this.setInitialTimelines();F.publish(H+".mediator.timelineDataLoaded")}},swallowTimeline:function(o){this.sole_timeline_id=o.id;this.timelineCollection.add(o);F.publish(H+".mediator.timelineListChangeSignal")},setInitialTimelines:function(){var o=this,r=this.initial_timeline_id,k="";if(typeof r== "object"){k=this.initial_timeline_id[0];_.each(r,function(y){o.activeTimelines.push(y)})}else if(r.length>0){k=this.initial_timeline_id||this.sole_timeline_id;o.activeTimelines=[k]}else if(this.timelineCollection.length>0){k=this.timelineCollection.pluck("id")[0];o.activeTimelines=[k]}if(timeglider.mode=="authoring")o.setZoomLevel(40);else k?setTimeout(function(){var y=o.timelineCollection.get(k),e=y.get("focusDateObj");o.setFocusDate(e);o.setZoomLevel(y.get("initial_zoom"))},1E3):o.setZoomLevel(40)}, refresh:function(){F.publish(H+".mediator.refreshSignal")},setTicksReady:function(o){this.ticksReady=o;this.startSec=this._focusDate.sec;o===true&&F.publish(H+".mediator.ticksReadySignal")},setTimeoffset:function(o){this.timeOffset=z.getTimeOffset(o);this.refresh()},getTimeoffset:function(){return this.timeOffset},setDimensions:function(o){this.dimensions=o},setFocusDate:function(o){if(o!=this._focusDate)this._focusDate=o},getFocusDate:function(){return this._focusDate},getZoomLevel:function(){return parseInt(this._zoomLevel)}, runTest:function(){var o=z.getDateFromSec(-158112000043140);debug.log("test date:",o)},setZoomLevel:function(o){if(o<=this.max_zoom&&o>=this.min_zoom){this.startSec=this._focusDate.sec;if(o!=this._zoomLevel){this._zoomLevel=o;this._zoomInfo=t.zoomTree[o];F.publish(H+".mediator.zoomLevelChange");F.publish(H+".mediator.scopeChange");return true}else return false}else return false},getZoomInfo:function(){return this._zoomInfo},getDateFromOffset:function(o){var r=this.dimensions.container;o=o-r.offset.left- r.width/2;r=this.getZoomInfo().spp;var k=this.getFocusDate().sec;return new z(Math.floor(k+o*r))},registerUIEvent:function(o){switch(o.name){case "dblclick":o=this.getDateFromOffset(o.event.pageX);F.publish(H+".mediator.dblclick",{date:o})}},setFilters:function(o){switch(o.origin){case "clude":this.filters.include=o.include;this.filters.exclude=o.exclude;break;case "tags":this.filters.tags=o.tags?o.tags.split(","):[];break;case "legend":var r=o.icon.replace(this.options.icon_folder,"");if(r=="all"){this.filters.legend= [];F.publish(H+".mediator.legendAll")}else if(_.indexOf(this.filters.legend,r)==-1)this.filters.legend.push(r);else{o=[];o=F.grep(this.filters.legend,function(k){return k!=r});this.filters.legend=o}}F.publish(H+".mediator.filtersChange");this.refresh()},getTicksOffset:function(){return this._ticksOffset},setTicksOffset:function(o){this._ticksOffset=o;F.publish(H+".mediator.ticksOffsetChange");F.publish(H+".mediator.scopeChange")},getTickBySerial:function(o){for(var r=this.ticksArray,k=r.length,y= 0;yr.optionsMaster[y].max)k+=y+" must be less than or equal to "+r.optionsMaster[y].max+"\n";break;case "timezone":var p=/[+|-]?[0-9]+:[0-9]+/; if(_.indexOf(["New York","Denver","Chicago","Los Angeles"],e)==-1&&e.match(p)==-1)k+="The timezone is not formatted properly";break;case "boolean":if(typeof e!="boolean")k+=e+" needs to be a number.\n"}});return k}})(timeglider);(function(t){var D,z,q=timeglider,F=timeglider.TG_Date;t.widget("timeglider.timeline",{options:{base_namespace:"tg",timezone:"00:00",initial_focus:q.TG_Date.getToday(),editor:"none",min_zoom:1,max_zoom:100,show_centerline:true,data_source:"",culture:"en",basic_fontsize:12,mouse_wheel:"zoom",initial_timeline_id:"",icon_folder:"js/timeglider/icons/",show_footer:true,display_zoom_level:true,constrain_to_data:false,event_modal:{href:"",type:"default"},event_overflow:"plus"},_create:function(){this._id= t(this.element).attr("id");this.element.html("
    loading
    ")}, _init:function(){var w=timeglider.validateOptions(this.options);if(w==""){q.TG_Date.setCulture(this.options.culture);z=new q.TG_Mediator(this.options,this.element);D=new q.TG_PlayerView(this,z);z.setFocusDate(new F(this.options.initial_focus));z.loadTimelineData(this.options.data_source)}else alert("Rats. There's a problem with your widget settings:"+w)},goTo:function(w,H){z.gotoDateZoom(w,H);return this},refresh:function(){z.refresh();return this},resize:function(){D.resize();return this},filterBy:function(w, H){z.filterBy(w,H);return this},addFilterAction:function(w,H,o){z.addFilterAction(w,H,o);return this},removeFilterAction:function(w){z.removeFilterAction(w);return this},getMediator:function(){return z},getEventByID:function(w,H){return z.getEventByID(w,H)},getScope:function(){return z.getScope()},zoom:function(w){switch(w){case "in":w=-1;break;case "out":w=1}if(w>99||w<-99)return false;z.zoom(w)},load:function(w){z.loadTimelineData(w)},panButton:function(w,H){var o=0;switch(H){case "left":o=30;break; case "right":o=-30;break;default:o=H}D.setPanButton(w,o)},destroy:function(){t.Widget.prototype.destroy.apply(this,arguments);t(this.element).html("")}})})(jQuery);