(function(){var j=this,n=j._,i=function(a){this._wrapped=a},m=typeof StopIteration!=="undefined"?StopIteration:"__break__",b=j._=function(a){return new i(a)};if(typeof exports!=="undefined")exports._=b;var k=Array.prototype.slice,o=Array.prototype.unshift,p=Object.prototype.toString,q=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;b.VERSION="0.5.8";b.each=function(a,c,d){try{if(a.forEach)a.forEach(c,d);else if(b.isNumber(a.length))for(var e=0,f=a.length;e<f;e++)c.call(d,a[e],
e,a);else{var g=b.keys(a);f=g.length;for(e=0;e<f;e++)c.call(d,a[g[e]],g[e],a)}}catch(h){if(h!=m)throw h;}return a};b.map=function(a,c,d){if(a&&b.isFunction(a.map))return a.map(c,d);var e=[];b.each(a,function(f,g,h){e.push(c.call(d,f,g,h))});return e};b.reduce=function(a,c,d,e){if(a&&b.isFunction(a.reduce))return a.reduce(b.bind(d,e),c);b.each(a,function(f,g,h){c=d.call(e,c,f,g,h)});return c};b.reduceRight=function(a,c,d,e){if(a&&b.isFunction(a.reduceRight))return a.reduceRight(b.bind(d,e),c);var f=
b.clone(b.toArray(a)).reverse();b.each(f,function(g,h){c=d.call(e,c,g,h,a)});return c};b.detect=function(a,c,d){var e;b.each(a,function(f,g,h){if(c.call(d,f,g,h)){e=f;b.breakLoop()}});return e};b.select=function(a,c,d){if(a&&b.isFunction(a.filter))return a.filter(c,d);var e=[];b.each(a,function(f,g,h){c.call(d,f,g,h)&&e.push(f)});return e};b.reject=function(a,c,d){var e=[];b.each(a,function(f,g,h){!c.call(d,f,g,h)&&e.push(f)});return e};b.all=function(a,c,d){c=c||b.identity;if(a&&b.isFunction(a.every))return a.every(c,
d);var e=true;b.each(a,function(f,g,h){(e=e&&c.call(d,f,g,h))||b.breakLoop()});return e};b.any=function(a,c,d){c=c||b.identity;if(a&&b.isFunction(a.some))return a.some(c,d);var e=false;b.each(a,function(f,g,h){if(e=c.call(d,f,g,h))b.breakLoop()});return e};b.include=function(a,c){if(a&&b.isFunction(a.indexOf))return b.indexOf(a,c)!=-1;var d=false;b.each(a,function(e){if(d=e===c)b.breakLoop()});return d};b.invoke=function(a,c){var d=b.rest(arguments,2);return b.map(a,function(e){return(c?e[c]:e).apply(e,
d)})};b.pluck=function(a,c){return b.map(a,function(d){return d[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);var e={computed:-Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;g>=e.computed&&(e={value:f,computed:g})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;g<e.computed&&(e={value:f,computed:g})});return e.value};b.sortBy=function(a,c,d){return b.pluck(b.map(a,
function(e,f,g){return{value:e,criteria:c.call(d,e,f,g)}}).sort(function(e,f){e=e.criteria;f=f.criteria;return e<f?-1:e>f?1:0}),"value")};b.sortedIndex=function(a,c,d){d=d||b.identity;for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?(e=g+1):(f=g)}return e};b.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(b.isArray(a))return a;if(b.isArguments(a))return k.call(a);return b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=function(a,c,d){return c&&!d?k.call(a,
0,c):a[0]};b.rest=function(a,c,d){return k.call(a,b.isUndefined(c)||d?1:c)};b.last=function(a){return a[a.length-1]};b.compact=function(a){return b.select(a,function(c){return!!c})};b.flatten=function(a){return b.reduce(a,[],function(c,d){if(b.isArray(d))return c.concat(b.flatten(d));c.push(d);return c})};b.without=function(a){var c=b.rest(arguments);return b.select(a,function(d){return!b.include(c,d)})};b.uniq=function(a,c){return b.reduce(a,[],function(d,e,f){if(0==f||(c===true?b.last(d)!=e:!b.include(d,
e)))d.push(e);return d})};b.intersect=function(a){var c=b.rest(arguments);return b.select(b.uniq(a),function(d){return b.all(c,function(e){return b.indexOf(e,d)>=0})})};b.zip=function(){for(var a=b.toArray(arguments),c=b.max(b.pluck(a,"length")),d=new Array(c),e=0;e<c;e++)d[e]=b.pluck(a,String(e));return d};b.indexOf=function(a,c){if(a.indexOf)return a.indexOf(c);for(var d=0,e=a.length;d<e;d++)if(a[d]===c)return d;return-1};b.lastIndexOf=function(a,c){if(a.lastIndexOf)return a.lastIndexOf(c);for(var d=
a.length;d--;)if(a[d]===c)return d;return-1};b.range=function(a,c,d){var e=b.toArray(arguments),f=e.length<=1;a=f?0:e[0];c=f?e[0]:e[1];d=e[2]||1;e=Math.ceil((c-a)/d);if(e<=0)return[];e=new Array(e);f=a;for(var g=0;;f+=d){if((d>0?f-c:c-f)>=0)return e;e[g++]=f}};b.bind=function(a,c){var d=b.rest(arguments,2);return function(){return a.apply(c||j,d.concat(b.toArray(arguments)))}};b.bindAll=function(a){var c=b.rest(arguments);if(c.length==0)c=b.functions(a);b.each(c,function(d){a[d]=b.bind(a[d],a)});
return a};b.delay=function(a,c){var d=b.rest(arguments,2);return setTimeout(function(){return a.apply(a,d)},c)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(b.rest(arguments)))};b.wrap=function(a,c){return function(){var d=[a].concat(b.toArray(arguments));return c.apply(c,d)}};b.compose=function(){var a=b.toArray(arguments);return function(){for(var c=b.toArray(arguments),d=a.length-1;d>=0;d--)c=[a[d].apply(this,c)];return c[0]}};b.keys=function(a){if(b.isArray(a))return b.range(0,a.length);
var c=[];for(var d in a)q.call(a,d)&&c.push(d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=function(a){return b.select(b.keys(a),function(c){return b.isFunction(a[c])}).sort()};b.extend=function(a,c){for(var d in c)a[d]=c[d];return a};b.clone=function(a){if(b.isArray(a))return a.slice(0);return b.extend({},a)};b.tap=function(a,c){c(a);return a};b.isEqual=function(a,c){if(a===c)return true;var d=typeof a;if(d!=typeof c)return false;if(a==c)return true;if(!a&&c||a&&!c)return false;
if(a.isEqual)return a.isEqual(c);if(b.isDate(a)&&b.isDate(c))return a.getTime()===c.getTime();if(b.isNaN(a)&&b.isNaN(c))return true;if(b.isRegExp(a)&&b.isRegExp(c))return a.source===c.source&&a.global===c.global&&a.ignoreCase===c.ignoreCase&&a.multiline===c.multiline;if(d!=="object")return false;if(a.length&&a.length!==c.length)return false;d=b.keys(a);var e=b.keys(c);if(d.length!=e.length)return false;for(var f in a)if(!b.isEqual(a[f],c[f]))return false;return true};b.isEmpty=function(a){return b.keys(a).length==
0};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=function(a){return!!(a&&a.concat&&a.unshift)};b.isArguments=function(a){return a&&b.isNumber(a.length)&&!a.concat&&!a.substr&&!a.apply&&!r.call(a,"length")};b.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)};b.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)};b.isNumber=function(a){return a===+a||p.call(a)==="[object Number]"};b.isDate=function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)};
b.isRegExp=function(a){return!!(a&&a.test&&a.exec&&(a.ignoreCase||a.ignoreCase===false))};b.isNaN=function(a){return b.isNumber(a)&&isNaN(a)};b.isNull=function(a){return a===null};b.isUndefined=function(a){return typeof a=="undefined"};b.noConflict=function(){j._=n;return this};b.identity=function(a){return a};b.breakLoop=function(){throw m;};var s=0;b.uniqueId=function(a){var c=s++;return a?a+c:c};b.templateSettings={start:"<%",end:"%>",interpolate:/<%=(.+?)%>/g};b.template=function(a,c){var d=b.templateSettings;
a=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+a.replace(/[\r\t\n]/g," ").replace(new RegExp("'(?=[^"+d.end[0]+"]*"+d.end+")","g"),"\t").split("'").join("\\'").split("\t").join("'").replace(d.interpolate,"',$1,'").split(d.start).join("');").split(d.end).join("p.push('")+"');}return p.join('');");return c?a(c):a};b.forEach=b.each;b.foldl=b.inject=b.reduce;b.foldr=b.reduceRight;b.filter=b.select;b.every=b.all;b.some=b.any;b.head=b.first;b.tail=b.rest;
b.methods=b.functions;var l=function(a,c){return c?b(a).chain():a};b.each(b.functions(b),function(a){var c=b[a];i.prototype[a]=function(){var d=b.toArray(arguments);o.call(d,this._wrapped);return l(c.apply(b,d),this._chain)}});b.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){c.apply(this._wrapped,arguments);return l(this._wrapped,this._chain)}});b.each(["concat","join","slice"],function(a){var c=Array.prototype[a];i.prototype[a]=
function(){return l(c.apply(this._wrapped,arguments),this._chain)}});i.prototype.chain=function(){this._chain=true;return this};i.prototype.value=function(){return this._wrapped}})();
(function(p,u){function aa(a){u.write('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/'+a+'"><\/script>')}function n(){}function K(a,b,c){var d=p.console;switch(arguments.length){case 1:d.log(a);break;case 2:d.log(a,b);break;default:d.log(a,b,c);break}}function ba(a,b,c){var d=p.console;switch(arguments.length){case 1:d.error(a);break;case 2:d.error(a,b);break;default:d.error(a,b,c);break}}function ia(a,b){var c=u.createElement("div");c.className=a;for(var d=a="",e=0;e<b.length;e++){var f=
b[e];a+=d+(typeof f=="string"?f:v(f));d=" "}c.appendChild(u.createTextNode(a));O.appendChild(c)}function ja(a){return a&&a.tagName&&a.nodeName&&a.ownerDocument&&a.removeAttribute}function ka(a){switch(a.nodeName){case "OPTION":case "PRE":case "TITLE":return true;default:return false}}function la(a,b){if(ka(a))if(W)a.innerText=b;else a.textContent=b;else a.innerHTML=b}function C(a){if(!a||!a.replace)return a;return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Oa(a){if(!a||
!a.replace)return a;return a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;")}function Pa(a,b){if(!a)throw"Missing this";if(!_.isFunction(b))throw"Missing function";return function(){return b.apply(a,arguments)}}function ma(a){var b=u.createElement("div");b.appendChild(a);var c=b.innerHTML;b.removeChild(a);return c}function Qa(a){return a.replace(/^ */,"").replace(/ *$/,"")}function P(a){var b=(""+a).toLowerCase();if(b=="f"||b=="0"||b=="false"||b=="no")a=false;return!!a}function X(a,
b){for(var c in a){var d=b[c],e=typeof d;if(e=="undefined")b[c]=F(v(a[c]));else e=="object"&&d.constructor!=array&&c.substring(0,1)!="$"&&X(a[c],d)}}function na(a){this.location=a;this.delay=25;this.setTimeout=function(b,c){p.setTimeout(b,c)};this.listener=function(b){return b};this.expectedUrl=a.href}function Ra(){var a=k.fn;a.scope=function(){for(var b=this;b&&b.get(0);){var c=b.data("scope");if(c)return c;b=b.parent()}return null};a.controller=function(){return this.data("controller")||Q.instance}}
function Sa(a){if(a.debug=="console"&&!O){O=u.createElement("div");O.id="ng-console";u.getElementsByTagName("body")[0].appendChild(O);K=function(){ia("ng-console-info",arguments)};console.error=function(){ia("ng-console-error",arguments)}}}function ca(a,b){var c={};o(b,function(d,e){c[e]=_(d).bind(a)});return c}function Ta(a,b){var c=new oa(b.server,b.database),d=new w(a[0],c,h,b.location,b);d.updateListeners.push(b.onUpdateView);c=new R(a.find("body"),b.server,b.database);var e=b.database=="$MEMORY"?
new S(p):new pa(b.server,k.getScript);e=new qa(e,new ra(a.find("body")),function(){d.updateView()});var f=new sa(e,c),g="/data/"+b.database,h=new Y(function(l,q){e.request("POST",g,l,q)},f,d.anchor);d.datastore=h;d.updateListeners.push(function(){h.flush()});var i=new x({$anchor:d.anchor,$updateView:_(d.updateView).bind(d),$config:b,$invalidWidgets:[],$console:p.console,$datastore:ca(h,{load:h.load,loadMany:h.loadMany,loadOrCreate:h.loadOrCreate,loadAll:h.loadAll,save:h.save,remove:h.remove,flush:h.flush,
query:h.query,entity:h.entity,entities:h.entities,documentCountsByUser:h.documentCountsByUser,userDocumentIdsByEntity:h.userDocumentIdsByEntity,join:h.join}),$save:function(l){h.saveScope(i.state,l,d.anchor)},$window:p,$uid:function(){return""+(new Date).getTime()},$users:f},"ROOT");a.data("scope",i);d.entity(i);d.compile();c.bind();(new A(a)).bind();var j=_(ca(i,{set:i.set,get:i.get,eval:i.eval})).extend({init:function(){b.location.listen(_(d.onUrlChange).bind(d));d.parseAnchor();d.executeInit();
d.updateView();return j},element:a[0],updateView:_(d.updateView).bind(d),config:b});return j}function G(a,b,c){var d=_.last(b);o(c,function(e){d[e]=_[e]});m[a]=m[a]||{};o(b,function(e){B(m[a],e)})}function w(a,b,c,d,e){this.doc=a;this.location=d;this.datastore=c;this.anchor={};this.widgetFactory=b;this.config=e||{};this.updateListeners=[]}function R(a,b,c){this._document=a;this.serverUrl=b;this.database=c;this._window=p;this.callbacks=[]}function Y(a,b,c){this.post=a;this.users=b;this._cache_collections=
[];this._cache={$collections:this._cache_collections};this.anchor=c;this.bulkRequest=[]}function T(a,b){return{format:a,parse:b||a}}function ta(a){return""+a}function v(a,b){var c=[];da(c,a,b?"\n  ":null,_([]));return c.join("")}function F(a){try{var b=new D(a,true),c=b.primary();b.assertAllConsumed();return c()}catch(d){ba("fromJson error: ",a,d);throw d;}}function da(a,b,c,d){if(typeof b=="object"){if(d.include(b)){a.push("RECURSION");return}d.push(b)}var e=typeof b;if(b===null)a.push("null");else if(e===
"function")return;else if(e==="boolean")a.push(""+b);else if(e==="number")isNaN(b)?a.push("null"):a.push(""+b);else if(e==="string")return a.push(m.String.quoteUnicode(b));else if(e==="object")if(b instanceof Array){a.push("[");var f=b.length;e=false;for(var g=0;g<f;g++){var h=b[g];e&&a.push(",");typeof h=="function"||typeof h=="undefined"?a.push("null"):da(a,h,c,d);e=true}a.push("]")}else if(b instanceof Date)a.push(m.String.quoteUnicode(m.Date.toString(b)));else{a.push("{");c&&a.push(c);e=false;
g=c?c+"  ":false;h=[];for(var i in b)i.indexOf("$$")!==0&&h.push(i);h.sort();for(i=0;i<h.length;i++){var j=h[i];try{f=b[j];if(typeof f!="function"){if(e){a.push(",");c&&a.push(c)}a.push(m.String.quote(j));a.push(":");da(a,f,g,d);e=true}}catch(l){}}a.push("}")}typeof b=="object"&&d.pop()}function H(a,b){this.$$entity=a;this.$loadFrom(b||{});this.$entity=a.title;this.$migrate()}function E(a,b){this.text=a;this.dateParseLength=b?20:-1;this.tokens=[];this.index=0}function D(a,b){this.text=a;this.tokens=
(new E(a,b)).parse();this.index=0}function x(a,b){this.widgets=[];this.watchListeners={};this.name=b;a=a||{};var c=function(){};c.prototype=a;this.state=new c;this.state.$parent=a;if(b=="ROOT")this.state.$root=this.state}function pa(a,b){this.url=a;this.nextId=0;this.getScript=b;this.uuid="_"+(""+Math.random()).substr(2)+"_";this.maxSize=1800}function S(a){this.frame=a}function qa(a,b,c){this.delegate=a;this.update=c;this.status=b}function sa(a,b){this.server=a;this.controlBar=b}function oa(a,b){this.nextUploadId=
0;this.serverUrl=a;this.database=b;this.createSWF=p.swfobject?p.swfobject.createSWF:function(){alert("ERROR: swfobject not loaded!")}}function U(a,b,c,d){this.view=a;this.uploader=c;this.scopeName=b;this.attachmentsPath=d+"/_attachments";this.value=null;this.lastValue=undefined}function Q(a){this.view=a}function ua(a,b,c){this.view=a;this.formatter=c;this.exp=b;this.validator=a.getAttribute("ng-validate");this.required=typeof a.attributes["ng-required"]!="undefined";this.lastErrorText=null;this.lastValue=
undefined;this.initialValue=this.formatter.parse(a.value);a.getAttribute("ng-widget")==="datepicker"&&k(a).datepicker()}function va(a,b,c){this.view=a;this.exp=b;this.lastValue=undefined;this.formatter=c;this.initialValue=this.formatter.parse(a.checked?a.value:"")}function wa(a,b){this.view=a;this.exp=b;this.lastValue=undefined;this.initialValue=a.value}function xa(a,b){this.view=a;this.exp=b;this.lastValue=undefined;this.initialValue=this.selected()}function ya(a,b){this.view=a;this.exp=b;this.lastValue=
this.lastChecked=undefined;this.inputValue=a.value;this.initialValue=a.checked?a.value:null}function L(a,b){this.view=a;this.exp=w.parseBindings(b);this.hasError=false}function za(a,b){this.view=a;this.attrs=b}function Aa(a,b){this.view=a;this.exp=b;this.hasError=false}function Ba(a,b){this.view=a;this.exp=b}function Ca(a,b){this.view=a;this.exp=b}function Da(a,b){this.view=a;this.exp=b}function Ea(a,b){this.view=a;this.exp=b}function Fa(a,b){this.view=a;this.exp=b}function Ga(a,b){this.view=a;this.exp=
b}function Ha(a,b,c,d){this.view=a;this.template=c;this.prefix=d;this.children=[];a=b.match(/^\s*(.+)\s+in\s+(.*)\s*$/);if(!a)throw"Expected ng-repeat in form of 'item in collection' but got '"+b+"'.";b=a[1];this.iteratorExp=a[2];a=b.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/);if(!a)throw"'item' in 'item in collection' should be identifier or (key, value) but get '"+b+"'.";this.valueExp=a[3]||a[1];this.keyExp=a[2]}function A(a){this.doc=a}function ra(){}function ea(a){this.requestCount=0;this.body=
a}function Ia(a,b){this._document=a;this.angular=b;this.config={autoSubmit:true}}p.swfobject||aa("swfobject/2.2/swfobject.js");p.jQuery||aa("jquery/1.4.0/jquery.min.js");(p.jQuery||{fn:{}}).fn.dialog||aa("jqueryui/1.7.2/jquery-ui.min.js");var Ua=p.onload||n;p.onload=function(){(new Ia(u,m)).load(m.startUrlWatcher(),function(a){B(m,a);try{Ua.apply(p,arguments)}catch(b){}})};var fa={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",encode:function(a){var b="",c,d,e,f,g,h,i=
0;for(a=fa._utf8_encode(a);i<a.length;){c=a.charCodeAt(i++);d=a.charCodeAt(i++);e=a.charCodeAt(i++);f=c>>2;c=(c&3)<<4|d>>4;g=(d&15)<<2|e>>6;h=e&63;if(isNaN(d))g=h=64;else if(isNaN(e))h=64;b=b+this._keyStr.charAt(f)+this._keyStr.charAt(c)+this._keyStr.charAt(g)+this._keyStr.charAt(h)}return b},decode:function(a){var b="",c,d,e,f,g,h=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<a.length;){c=this._keyStr.indexOf(a.charAt(h++));d=this._keyStr.indexOf(a.charAt(h++));f=this._keyStr.indexOf(a.charAt(h++));
g=this._keyStr.indexOf(a.charAt(h++));c=c<<2|d>>4;d=(d&15)<<4|f>>2;e=(f&3)<<6|g;b+=String.fromCharCode(c);if(f!=64)b+=String.fromCharCode(d);if(g!=64)b+=String.fromCharCode(e)}return b=fa._utf8_decode(b)},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d<128)b+=String.fromCharCode(d);else{if(d>127&&d<2048)b+=String.fromCharCode(d>>6|192);else{b+=String.fromCharCode(d>>12|224);b+=String.fromCharCode(d>>6&63|128)}b+=String.fromCharCode(d&
63|128)}}return b},_utf8_decode:function(a){for(var b="",c=0,d=c1=c2=0;c<a.length;){d=a.charCodeAt(c);if(d<128){b+=String.fromCharCode(d);c++}else if(d>191&&d<224){c2=a.charCodeAt(c+1);b+=String.fromCharCode((d&31)<<6|c2&63);c+=2}else{c2=a.charCodeAt(c+1);c3=a.charCodeAt(c+2);b+=String.fromCharCode((d&15)<<12|(c2&63)<<6|c3&63);c+=3}}return b}};if(typeof u.getAttribute=="undefined")u.getAttribute=function(){};if(typeof Node=="undefined")Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,
ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};p.console||(p.console={log:n,error:n});var O,W,k=p.jQuery||p.$,o=_.each,B=_.extend,Ja=_.identity,m=p.angular||(p.angular={}),ga=m.validator||(m.validator={}),r=m.filter||(m.filter={}),ha=m.formatter||(m.formatter={}),M=m.callbacks||(m.callbacks={});m.alert||(m.alert=function(){K(arguments);p.alert.apply(p,arguments)});var Ka=Ka||function(a){return k(a).is(":visible")};
na.prototype={listen:function(a){this.listener=a},watch:function(){var a=this,b=function(){if(a.expectedUrl!==a.location.href){var c=a.location.hash.match(/^#\$iframe_notify=(.*)$/);if(c){a.expectedUrl.match(/#/)||(a.expectedUrl+="#");a.location.href=a.expectedUrl;c="_iframe_notify_"+c[1];var d=M[c];delete M[c];try{(d||n)()}catch(e){alert(e)}}else{a.listener(a.location.href);a.expectedUrl=a.location.href}}a.setTimeout(b,a.delay)};b()},set:function(a){var b=this.location.href;b.match(/#/)||(b+="#");
if(b!=a)this.location.href=a;this.existingURL=a},get:function(){return p.location.href}};m.startUrlWatcher=function(){var a=new na(p.location);a.watch();return ca(a,{listen:a.listen,set:a.set,get:a.get})};m.compile=function(a,b){k=p.jQuery;W=k.browser.msie;b=_({onUpdateView:n,server:"",location:{get:n,set:n,listen:n}}).extend(b||{});Sa(b);Ra();return Ta(k(a),b)};var I={typeOf:function(a){if(a===null)return"null";var b=typeof a;if(b=="object"){if(a instanceof Array)return"array";if(a instanceof Date)return"date";
if(a.nodeType==1)return"element"}return b}},Z={},La={includeIf:function(a,b,c){var d=_.indexOf(a,b);if(c)d==-1&&a.push(b);else a.splice(d,1);return a},sum:function(a,b){b=m.Function.compile(b);for(var c=0,d=0;d<a.length;d++){var e=1*b(a[d]);isNaN(e)||(c+=e)}return c},remove:function(a,b){var c=_.indexOf(a,b);c>=0&&a.splice(c,1);return b},find:function(a,b,c){if(b){var d=m.Function.compile(b);_.detect(a,function(e){if(d(e)){c=e;return true}});return c}},findById:function(a,b){return m.Array.find(a,
function(c){return c.$id==b},null)},filter:function(a,b){var c=[];c.check=function(j){for(var l=0;l<c.length;l++)if(!c[l](j))return false;return true};var d=x.getter,e=function(j,l){if(l.charAt(0)==="!")return!e(j,l.substr(1));switch(typeof j){case "boolean":case "number":case "string":return(""+j).toLowerCase().indexOf(l)>-1;case "object":for(var q in j)if(q.charAt(0)!=="$"&&e(j[q],l))return true;return false;case "array":for(q=0;q<j.length;q++)if(e(j[q],l))return true;return false;default:return false}};
switch(typeof b){case "boolean":case "number":case "string":b={$:b};case "object":for(var f in b)f=="$"?function(){var j=(""+b[f]).toLowerCase();j&&c.push(function(l){return e(l,j)})}():function(){var j=f,l=(""+b[f]).toLowerCase();l&&c.push(function(q){return e(d(q,j),l)})}();break;case "function":c.push(b);break;default:return a}for(var g=[],h=0;h<a.length;h++){var i=a[h];c.check(i)&&g.push(i)}return g},add:function(a,b){a.push(_.isUndefined(b)?{}:b);return a},count:function(a,b){if(!b)return a.length;
var c=m.Function.compile(b);return _.reduce(a,0,function(d,e){return d+(c(e)?1:0)})},orderBy:function(a,b,c){function d(f,g){return P(g)?function(h,i){return f(i,h)}:f}function e(f,g){var h=typeof f,i=typeof g;if(h==i){if(h=="string")f=f.toLowerCase();if(h=="string")g=g.toLowerCase();if(f===g)return 0;return f<g?-1:1}else return h<i?-1:1}b=_.isArray(b)?b:[b];b=_.map(b,function(f){var g=false;if(typeof f=="string"&&(f.charAt(0)=="+"||f.charAt(0)=="-")){g=f.charAt(0)=="-";f=f.substring(1)}var h=f?m.Function.compile(f):
_.identity;return d(function(i,j){return e(h(i),h(j))},g)});return _.clone(a).sort(d(function(f,g){for(var h=0;h<b.length;h++){var i=b[h](f,g);if(i!==0)return i}return 0},c))},orderByToggle:function(a,b){var c=false,d=-1;_.detect(a,function(e,f){if(e==b){c=true;d=f;return true}if((e.charAt(0)=="+"||e.charAt(0)=="-")&&e.substring(1)==b){c=e.charAt(0)=="+";d=f;return true}});d>=0&&a.splice(d,1);a.unshift((c?"-":"+")+b);return a},orderByDirection:function(a,b,c,d){c=c||"ng-ascend";d=d||"ng-descend";
a=a[0]||"";var e=true;if(a.charAt(0)=="-"){a=a.substring(1);e=false}else if(a.charAt(0)=="+")a=a.substring(1);return a==b?e?c:d:""},merge:function(a,b,c){var d=a[b];if(!d){d={};a[b]=d}X(c,d);return a}},Va={quote:function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v")+'"'},quoteUnicode:function(a){a=m.String.quote(a);for(var b=[],c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d<128)b.push(a.charAt(c));
else{d="000"+d.toString(16);b.push("\\u"+d.substring(d.length-4))}}return b.join("")},toDate:function(a){var b;if(typeof a=="string"&&(b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/))){a=new Date(0);a.setUTCFullYear(b[1],b[2]-1,b[3]);a.setUTCHours(b[4],b[5],b[6],0);return a}return a}},Ma={toString:function(a){function b(c){return c<10?"0"+c:c}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+
"Z"}},Wa={compile:function(a){if(_.isFunction(a))return a;else if(a){var b=new x;return function(c){b.state=c;return b.eval(a)}}else return function(c){return c}}};G("Global",[I],["extend","clone","isEqual","isElement","isArray","isFunction","isUndefined"]);G("Collection",[I,Z],["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke","pluck","max","min","sortBy","sortedIndex","toArray","size"]);G("Array",[I,Z,La],["first","last","compact","flatten","without",
"uniq","intersect","zip","indexOf","lastIndexOf"]);G("Object",[I,Z,{}],["keys","values"]);G("String",[I,Va],[]);G("Date",[I,Ma],[]);m.Date.toString=Ma.toString;G("Function",[I,Z,Wa],["bind","bindAll","delay","defer","wrap","compose"]);w.parseBindings=function(a){for(var b=[],c=0,d;(d=a.indexOf("{{",c))>-1;){c<d&&b.push(a.substr(c,d-c));c=d;d=a.indexOf("}}",d);d=d<0?a.length:d+2;b.push(a.substr(c,d-c));c=d}c!=a.length&&b.push(a.substr(c,a.length-c));return b.length===0?[a]:b};w.hasBinding=function(a){a=
w.parseBindings(a);return a.length>1||w.binding(a[0])!==null};w.binding=function(a){return(a=a.replace(/\n/gm," ").match(/^\{\{(.*)\}\}$/))?a[1]:null};w.prototype={parseQueryString:function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b},parseAnchor:function(){var a=this,b=this.location.get()||"",c=b.indexOf("#");if(!(c<0)){b=this.parseQueryString(b.substring(c+1));o(a.anchor,function(d,e){delete a.anchor[e]});o(b,function(d,
e){a.anchor[e]=d})}},onUrlChange:function(){this.parseAnchor();this.updateView()},updateAnchor:function(){var a=this.location.get()||"",b=a.indexOf("#");if(b>-1)a=a.substring(0,b);a+="#";b="";for(var c in this.anchor){var d=this.anchor[c];if(typeof d==="undefined"||d===null)delete this.anchor[c];else{a+=b+encodeURIComponent(c);if(d!==true)a+="="+encodeURIComponent(d);b="&"}}this.location.set(a);return a},updateView:function(){(new Date).getTime();var a=k(this.doc).scope();a.clearInvalid();a.updateView();
(new Date).getTime();this.updateAnchor();o(this.updateListeners,function(b){b()})},docFindWithSelf:function(a){var b=k(this.doc),c=b.find(a);if(b.is(a))c=c.andSelf();return c},executeInit:function(){this.docFindWithSelf("[ng-init]").each(function(){var a=k(this),b=a.scope();try{b.eval(a.attr("ng-init"))}catch(c){alert("EVAL ERROR:\n"+a.attr("ng-init")+"\n"+v(c,true))}})},entity:function(a){var b=this;this.docFindWithSelf("[ng-entity]").attr("ng-watch",function(){try{var c=k(this);return a.entity(c.attr("ng-entity"),
b.datastore)+(c.attr("ng-watch")||"")}catch(d){K(d);alert(d)}})},compile:function(){var a=k(this.doc);if(this.config.autoSubmit){var b=this.docFindWithSelf(":submit").not("[ng-action]");b.attr("ng-action","$save()");b.not(":disabled").not("ng-bind-attr").attr("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.precompile(this.doc)(this.doc,a.scope(),"");this.docFindWithSelf("a[ng-action]").live("click",function(){var c=k(this),d=c.scope();try{d.eval(c.attr("ng-action"));c.removeAttr("ng-error");
c.removeClass("ng-exception")}catch(e){c.addClass("ng-exception");c.attr("ng-error",v(e,true))}d.get("$updateView")();return false})},translateBinding:function(a,b,c){b=b.concat();var d=b.pop(),e=w.parseBindings(a.nodeValue);if(e.length>1||w.binding(e[0])){var f=a.parentNode;if(ka(f)){f.setAttribute("ng-bind-template",a.nodeValue);c.push({path:b,fn:function(l){return new L(l,l.getAttribute("ng-bind-template"))}})}else for(var g=0;g<e.length;g++){var h=e[g],i=w.binding(h),j;if(i){j=u.createElement("span");
k(j).attr("ng-bind",i);g===0&&c.push({path:b.concat(d+g),fn:this.ng_bind})}else if(W&&h.charAt(0)==" "){j=u.createElement("span");j.innerHTML="&nbsp;"+h.substring(1)}else j=u.createTextNode(h);f.insertBefore(j,a)}f.removeChild(a)}},precompile:function(a){var b=[];this.precompileNode(a,[],b);return function(c,d,e){for(var f=b.length,g=0;g<f;g++){for(var h=b[g],i=c,j=h.path,l=0;l<j.length;l++)i=i.childNodes[j[l]];try{d.addWidget(h.fn(i,d,e))}catch(q){alert(q)}}}},precompileNode:function(a,b,c){var d=
a.nodeType;if(d==Node.TEXT_NODE)this.translateBinding(a,b,c);else if(!(d!=Node.ELEMENT_NODE&&d!=Node.DOCUMENT_NODE))if(a.getAttribute){d=a.getAttribute("ng-non-bindable");if(!(d||d==="")){if(d=a.attributes){var e=a.getAttribute("ng-bind-attr");a.removeAttribute("ng-bind-attr");e=e?F(e):{};for(var f=d.length,g=0;g<f;g++){var h=d[g],i=h.name;h=W&&i=="href"?decodeURI(a.getAttribute(i,2)):h.value;if(w.hasBinding(h))e[i]=h}d=v(e);d.length>2&&a.setAttribute("ng-bind-attr",d)}a.getAttribute||K(a);var j=
a.getAttribute("ng-repeat");if(j){a.removeAttribute("ng-repeat");var l=this.precompile(a);d=u.createComment("ng-repeat: "+j);e=a.parentNode;e.insertBefore(d,a);e.removeChild(a);function q(s,J,y){var z=k(a).clone();z.css("display","");z.attr("ng-repeat-index",""+y);z.data("scope",s);l(z[0],s,J+y+":");return z}c.push({path:b,fn:function(s,J,y){return new Ha(k(s),j,q,y)}})}else{a.getAttribute("ng-eval")&&c.push({path:b,fn:this.ng_eval});a.getAttribute("ng-bind")&&c.push({path:b,fn:this.ng_bind});a.getAttribute("ng-bind-attr")&&
c.push({path:b,fn:this.ng_bind_attr});a.getAttribute("ng-hide")&&c.push({path:b,fn:this.ng_hide});a.getAttribute("ng-show")&&c.push({path:b,fn:this.ng_show});a.getAttribute("ng-class")&&c.push({path:b,fn:this.ng_class});a.getAttribute("ng-class-odd")&&c.push({path:b,fn:this.ng_class_odd});a.getAttribute("ng-class-even")&&c.push({path:b,fn:this.ng_class_even});a.getAttribute("ng-style")&&c.push({path:b,fn:this.ng_style});a.getAttribute("ng-watch")&&c.push({path:b,fn:this.ng_watch});d=a.nodeName;if(d==
"INPUT"||d=="TEXTAREA"||d=="SELECT"||d=="BUTTON"){var N=this;c.push({path:b,fn:function(s,J,y){s.name=y+s.name.split(":").pop();return N.widgetFactory.createController(k(s),J)}})}if(d=="OPTION")if(!k("<select/>").append(k(a).clone()).html().match(/<option(\s.*\s|\s)value\s*=\s*.*>.*<\/\s*option\s*>/gi))if(w.hasBinding(a.text))k(a).attr("ng-bind-attr",m.toJson({value:a.text}));else a.value=a.text;d=a.childNodes;for(e=0;e<d.length;e++)this.precompileNode(d[e],b.concat(e),c)}}}},ng_eval:function(a){return new Aa(a,
a.getAttribute("ng-eval"))},ng_bind:function(a){return new L(a,"{{"+a.getAttribute("ng-bind")+"}}")},ng_bind_attr:function(a){return new za(a,F(a.getAttribute("ng-bind-attr")))},ng_hide:function(a){return new Ba(a,a.getAttribute("ng-hide"))},ng_show:function(a){return new Ca(a,a.getAttribute("ng-show"))},ng_class:function(a){return new Da(a,a.getAttribute("ng-class"))},ng_class_even:function(a){return new Ea(a,a.getAttribute("ng-class-even"))},ng_class_odd:function(a){return new Fa(a,a.getAttribute("ng-class-odd"))},
ng_style:function(a){return new Ga(a,a.getAttribute("ng-style"))},ng_watch:function(a,b){b.watch(a.getAttribute("ng-watch"))}};R.HTML='<div><div class="ui-widget-overlay"></div><div id="ng-login" ng-non-bindable="true"><div class="ng-login-container"></div></div></div>';R.FORBIDEN='<div ng-non-bindable="true" title="Permission Error:">Sorry, you do not have permission for this!</div>';R.prototype={bind:function(){},login:function(a){this.callbacks.push(a);this.callbacks.length==1&&this.doTemplate("/user_session/new.mini?database="+
encodeURIComponent(this.database)+"&return_url="+encodeURIComponent(this.urlWithoutAnchor()))},logout:function(a){this.callbacks.push(a);this.callbacks.length==1&&this.doTemplate("/user_session/do_destroy.mini")},urlWithoutAnchor:function(){return this._window.location.href.split("#")[0]},doTemplate:function(a){var b=this,c=(new Date).getTime(),d=this.urlWithoutAnchor()+"#$iframe_notify="+c,e=k('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+d+'" src="'+this.serverUrl+a+'" width="500" height="330"/></div>');
this._document.append(e);e.dialog({height:363,width:500,resizable:false,modal:true,title:'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'});M["_iframe_notify_"+c]=function(){e.dialog("destroy");e.remove();o(b.callbacks,function(f){f()});b.callbacks=[]}},notAuthorized:function(){if(!this.forbidenView){this.forbidenView=k(R.FORBIDEN);this.forbidenView.dialog({bgiframe:true,height:70,modal:true})}}};Y.NullEntity=B(function(){},{all:function(){return[]},query:function(){return[]},
load:function(){return{}},title:undefined});Y.prototype={cache:function(a){if(!a.datastore===this)throw"Parameter must be an instance of Entity! "+v(a);var b=a.$entity+"/"+a.$id,c=this._cache[b];if(c)H.copyDirectFields(a,c);else c=this._cache[b]=a;return c},load:function(a,b,c,d){if(b&&b!=="*"){var e=this;this._jsonRequest(["GET",a.$entity+"/"+b],function(f){a.$loadFrom(f);a.$migrate();f=a.$$entity(a);e.cache(f);(c||n)(a)},d)}return a},loadMany:function(a,b,c){var d=this,e=[],f=0;o(b,function(g){e.push(d.load(a(),
g,function(){f++;if(f==b.length)(c||n)(e)}))});return e},loadOrCreate:function(a,b,c){return this.load(a,b,c,function(d){if(d.$status_code==404){a.$id=b;(c||n)(a)}else throw d;})},loadAll:function(a,b){var c=this,d=[];d.$$accept=function(e){return e.$entity==a.title};this._cache_collections.push(d);this._jsonRequest(["GET",a.title],function(e){for(var f=0;f<e.length;f++){var g=a();g.$loadFrom(e[f]);d.push(c.cache(g))}(b||n)(d)});return d},save:function(a,b){var c=this,d={};a.$saveTo(d);this._jsonRequest(["POST",
"",d],function(e){a.$loadFrom(e);var f=c.cache(a);_.each(c._cache_collections,function(g){g.$$accept(a)&&La.includeIf(g,f,true)});if(a.$$anchor)c.anchor[a.$$anchor]=a.$id;b&&b(a)})},remove:function(a,b){var c=this,d={};a.$saveTo(d);this._jsonRequest(["DELETE","",d],function(e){delete c._cache[a.$entity+"/"+a.$id];_.each(c._cache_collections,function(f){for(var g=0;g<f.length;g++)f[g].$id==a.$id&&f.splice(g,1)});(b||n)(e)})},_jsonRequest:function(a,b,c){a.$$callback=b;a.$$failure=c||function(d){throw d;
};this.bulkRequest.push(a)},flush:function(){function a(d,e){K("RESPONSE["+d+"]: ",e);if(e.$status_code==401)b.users.login(function(){b.post(c,a)});else if(e.$status_code)alert(v(e));else for(d=0;d<e.length;d++){var f=e[d],g=c[d],h=f.$status_code;if(h)h==403?b.users.notAuthorized():g.$$failure(f);else g.$$callback(f)}}if(this.bulkRequest.length!==0){var b=this,c=this.bulkRequest;this.bulkRequest=[];K("REQUEST:",c);this.post(c,a)}},saveScope:function(a,b){function c(){d--;d===0&&b&&b()}var d=1;for(var e in a){var f=
a[e];if(f&&f.$save==H.prototype.$save){d++;f.$save(c)}}c()},query:function(a,b,c,d){var e=this,f=[];f.$$accept=function(){return false};this._cache_collections.push(f);this._jsonRequest(["GET",a.title+"/"+b+"="+c],function(g){o(g,function(h){h=a().$loadFrom(h);f.push(e.cache(h))});(d||n)(f)});return f},entities:function(a){var b=[],c=this;this._jsonRequest(["GET","$entities"],function(d){o(d,function(e,f){b.push(c.entity(f))});b.sort(function(e,f){return e.title>f.title?1:-1});(a||n)(b)});return b},
documentCountsByUser:function(){var a={};this.post([["GET","$users"]],function(b,c){B(a,c[0])});return a},userDocumentIdsByEntity:function(a){var b={};this.post([["GET","$users/"+a]],function(c,d){B(b,d[0])});return b},entity:function(a,b){if(!a)return Y.NullEntity;var c=this,d=B(function(e){return new H(d,e)},{title:a,$$factory:true,datastore:this,defaults:b||{},load:function(e,f){return c.load(d(),e,f)},loadMany:function(e,f){return c.loadMany(d,e,f)},loadOrCreate:function(e,f){return c.loadOrCreate(d(),
e,f)},all:function(e){return c.loadAll(d,e)},query:function(e,f,g){return c.query(d,e,f,g)},properties:function(e){c._jsonRequest(["GET",a+"/$properties"],e)}});return d},join:function(a){function b(){throw"Joined entities can not be instantiated into a document.";}function c(f){return f?f.substring(0,f.indexOf(".")):undefined}function d(f){return f.substring(f.indexOf(".")+1)}var e=_(a).chain().map(function(f,g){return g}).sortBy(function(f){var g=[];do{if(_(g).include(f))throw"Infinite loop in join: "+
g.join(" -> ");g.push(f);if(!a[f])throw _("Named entity '<%=name%>' is undefined.").template({name:f});f=c(a[f].on)}while(f);return g.length}).value();if(_(e).select(function(f){return a[f].on}).length!=e.length-1)throw"Exactly one entity needs to be primary.";b.query=function(f,g){var h=[],i=c(f);if(i!=e[0])throw _("Named entity '<%=name%>' is not a primary entity.").template({name:i});var j=1;a[i].join.query(d(f),g,function(l){var q=e[j++],N=a[q],s=N.on,J={};_(l).each(function(y){var z={};h.push(z);
z[i]=y;y=x.getter(z,s);J[y]=y});N.join.loadMany(_.toArray(J),function(y){var z={};_(y).each(function(V){z[V.$id]=V});_(h).each(function(V){var Xa=x.getter(V,s);V[q]=z[Xa]})})});return h};return b}};r.Meta=function(a){if(a)for(var b in a)this[b]=a[b]};r.Meta.get=function(a,b){b=b||"text";switch(typeof a){case "string":return b=="text"?a:undefined;case "object":if(a&&typeof a[b]!=="undefined")return a[b];return;default:return a}};var t;o({currency:function(a){k(this.$element).toggleClass("ng-format-negative",
a<0);return"$"+r.number.apply(this,[a,2])},number:function(a,b){if(isNaN(a)||!isFinite(a))return"";b=typeof b=="undefined"?2:b;var c=a<0;a=Math.abs(a);var d=Math.pow(10,b);a=""+Math.round(a*d);var e=a.substring(0,a.length-b);e=e||"0";d=a.substring(a.length-b);a=c?"-":"";for(c=0;c<e.length;c++){if((e.length-c)%3===0&&c!==0)a+=",";a+=e.charAt(c)}if(b>0){for(c=d.length;c<b;c++)d+="0";a+="."+d.substring(0,b)}return a},date:function(){},json:function(a){k(this.$element).addClass("ng-monospace");return v(a,
true)},trackPackage:function(){var a=[{name:"UPS",url:"http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&track.x=0&track.y=0&InquiryNumber1=",regexp:[/^1Z[0-9A-Z]{16}$/i]},{name:"FedEx",url:"http://www.fedex.com/Tracking?tracknumbers=",regexp:[/^96\d{10}?$/i,/^96\d{17}?$/i,/^96\d{20}?$/i,/^\d{15}$/i,/^\d{12}$/i]},{name:"USPS",url:"http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=",regexp:[/^(91\d{20})$/i,
/^(91\d{18})$/i]}];return function(b,c){b=Qa(b);var d=b.replace(/ /g,""),e;o(a,function(f){o(f.regexp,function(g){if(g.test(d)){g=f.name+": "+b;var h=f.url+b;e=new r.Meta({text:g,url:h,html:'<a href="'+Oa(h)+'">'+g+"</a>",trackingNo:b});_.breakLoop()}});e&&_.breakLoop()});return e?e:b?c||new r.Meta({text:b+" is not recognized"}):null}}(),link:function(a,b){b=b||r.Meta.get(a);var c=r.Meta.get(a,"url")||r.Meta.get(a);if(c){if(m.validator.email(c)===null)c="mailto:"+c;a='<a href="'+C(c)+'">'+b+"</a>";
return new r.Meta({text:b,url:c,html:a})}return a},bytes:function(){var a=["bytes","KB","MB","GB","TB","PB"];return function(b){if(b===null)return"";for(var c=0;b>1E3;){b/=1024;c++}b=""+b;var d=b.indexOf(".");if(d>-1&&d+2<b.length)b=b.substring(0,d+2);return b+" "+a[c]}}(),image:function(a,b,c){if(a&&a.url){var d="";if(b)d=' style="max-width: '+b+"px; max-height: "+(c||b)+'px;"';return new r.Meta({url:a.url,text:a.url,html:'<img src="'+a.url+'"'+d+"/>"})}return null},lowercase:function(a){return(a=
r.Meta.get(a))?(""+a).toLowerCase():a},uppercase:function(a){return(a=r.Meta.get(a))?(""+a).toUpperCase():a},linecount:function(a){a=r.Meta.get(a);if(a===""||!a)return 1;return a.split(/\n|\f/).length},"if":function(a,b){return b?a:undefined},unless:function(a,b){return b?undefined:a},googleChartApi:B(function(a,b,c,d){b=b||{};a={cht:a,chco:t.collect(b,"color"),chtt:t.title(b),chdl:t.collect(b,"label"),chd:t.values(b),chf:"bg,s,FFFFFF00"};if(_.isArray(b.xLabels)){a.chxt="x";a.chxl="0:|"+b.xLabels.join("|")}return t.encode(a,
c,d)},{values:function(a){var b=[];o(a.series||[],function(c){var d=[];o(c.values||[],function(e){d.push(e)});b.push(d.join(","))});a=b.join("|");return a===""?null:"t:"+a},title:function(a){var b=[];a=a.title||[];o(_.isArray(a)?a:[a],function(c){b.push(encodeURIComponent(c))});return b.join("|")},collect:function(a,b){var c=[],d=0;o(a.series||[],function(e){var f=[];e=e[b]||[];o(_.isArray(e)?e:[e],function(g){f.push(encodeURIComponent(g));d++});c.push(f.join("|"))});return d?c.join(","):null},encode:function(a,
b,c){b=b||200;c=c||b;var d="http://chart.apis.google.com/chart?",e=[];a.chs=b+"x"+c;o(a,function(f,g){f&&e.push(g+"="+f)});e.sort();d+=e.join("&");return new r.Meta({url:d,html:'<img width="'+b+'" height="'+c+'" src="'+d+'"/>'})}}),qrcode:function(a,b,c){return t.encode({cht:"qr",chl:encodeURIComponent(a)},b,c)},chart:{pie:function(a,b,c){return t("p",a,b,c)},pie3d:function(a,b,c){return t("p3",a,b,c)},pieConcentric:function(a,b,c){return t("pc",a,b,c)},barHorizontalStacked:function(a,b,c){return t("bhs",
a,b,c)},barHorizontalGrouped:function(a,b,c){return t("bhg",a,b,c)},barVerticalStacked:function(a,b,c){return t("bvs",a,b,c)},barVerticalGrouped:function(a,b,c){return t("bvg",a,b,c)},line:function(a,b,c){return t("lc",a,b,c)},sparkline:function(a,b,c){return t("ls",a,b,c)},scatter:function(a,b,c){return t("s",a,b,c)}},html:function(a){return new r.Meta({html:a})},linky:function(a){if(!a)return a;for(var b=/(ftp|http|https|mailto):\/\/([^\(\)|\s]+)/,c,d=a,e=[];c=d.match(b);){c=c[0].replace(/[\.\;\,\(\)\{\}\<\>]$/,
"");var f=d.indexOf(c);e.push(C(d.substr(0,f)));e.push('<a href="'+c+'">');e.push(c);e.push("</a>");d=d.substring(f+c.length)}e.push(C(d));return new r.Meta({text:a,html:e.join("")})}},function(a,b){r[b]=a});t=r.googleChartApi;B(ha,{noop:T(Ja,Ja),"boolean":T(ta,P),number:T(ta,function(a){return 1*a}),list:T(function(a){return a?a.join(", "):a},function(a){return a?_(_(a.split(",")).map(k.trim)).select(_.identity):[]}),trim:T(function(a){return a?$.trim(""+a):""})});array=[].constructor;m.toJson=v;
m.fromJson=F;H.copyDirectFields=function(a,b){if(!(a===b||!a||!b)){var c=function(e,f,g){return g.substring(0,2)!=="$$"&&typeof e[g]!=="function"&&typeof f[g]!=="function"};for(var d in b)c(a,b,d)&&delete b[d];for(d in a)if(c(a,b,d))b[d]=a[d]}};B(H.prototype,{$migrate:function(){X(this.$$entity.defaults,this);return this},$merge:function(a){X(a,this);return this},$save:function(a){this.$$entity.datastore.save(this,a===true?undefined:a);a===true&&this.$$entity.datastore.flush();return this},$delete:function(a){this.$$entity.datastore.remove(this,
a===true?undefined:a);a===true&&this.$$entity.datastore.flush();return this},$loadById:function(a,b){this.$$entity.datastore.load(this,a,b);return this},$loadFrom:function(a){H.copyDirectFields(a,this);return this},$saveTo:function(a){H.copyDirectFields(this,a);return this}});E.OPERATORS={"null":function(){return null},"true":function(){return true},"false":function(){return false},"+":function(a,b,c){return(b||0)+(c||0)},"-":function(a,b,c){return(b||0)-(c||0)},"*":function(a,b,c){return b*c},"/":function(a,
b,c){return b/c},"%":function(a,b,c){return b%c},"^":function(a,b,c){return b^c},"=":function(a,b,c){return a.scope.set(b,c)},"==":function(a,b,c){return b==c},"!=":function(a,b,c){return b!=c},"<":function(a,b,c){return b<c},">":function(a,b,c){return b>c},"<=":function(a,b,c){return b<=c},">=":function(a,b,c){return b>=c},"&&":function(a,b,c){return b&&c},"||":function(a,b,c){return b||c},"&":function(a,b,c){return b&c},"|":function(a,b,c){return c(a,b)},"!":function(a,b){return!b}};E.ESCAPE={n:"\n",
f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'};E.prototype={peek:function(){return this.index+1<this.text.length?this.text.charAt(this.index+1):false},parse:function(){for(var a=this.tokens,b=E.OPERATORS,c=true;this.index<this.text.length;){var d=this.text.charAt(this.index);if(d=='"'||d=="'"){this.readString(d);c=true}else if(d=="("||d=="["){a.push({index:this.index,text:d});this.index++}else if(d=="{"){c=this.peek();if(c==":"||c=="("){a.push({index:this.index,text:d+c});this.index++}else a.push({index:this.index,
text:d});this.index++;c=true}else if(d==")"||d=="]"||d=="}"){a.push({index:this.index,text:d});this.index++;c=false}else if(d==":"||d=="."||d==","||d==";"){a.push({index:this.index,text:d});this.index++;c=true}else if(c&&d=="/"){this.readRegexp();c=false}else if(this.isNumber(d)){this.readNumber();c=false}else if(this.isIdent(d)){this.readIdent();c=false}else if(this.isWhitespace(d))this.index++;else{c=d+this.peek();var e=b[d],f=b[c];if(f){a.push({index:this.index,text:c,fn:f});this.index+=2}else if(e){a.push({index:this.index,
text:d,fn:e});this.index+=1}else throw"Lexer Error: Unexpected next character ["+this.text.substring(this.index)+"] in expression '"+this.text+"' at column '"+(this.index+1)+"'.";c=true}}return a},isNumber:function(a){return"0"<=a&&a<="9"},isWhitespace:function(a){return a==" "||a=="\r"||a=="\t"||a=="\n"||a=="\u000b"},isIdent:function(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"},readNumber:function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);
if(c=="."||this.isNumber(c))a+=c;else break;this.index++}a=1*a;this.tokens.push({index:b,text:a,fn:function(){return a}})},readIdent:function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.isIdent(c)||this.isNumber(c))a+=c;else break;this.index++}c=E.OPERATORS[a];if(!c){c=function(d){return d.scope.get(a)};c.isAssignable=a}this.tokens.push({index:b,text:a,fn:c})},readString:function(a){var b=this.index,c=this.dateParseLength;this.index++;
for(var d="",e=false;this.index<this.text.length;){var f=this.text.charAt(this.index);if(e){if(f=="u"){f=this.text.substring(this.index+1,this.index+5);this.index+=4;d+=String.fromCharCode(parseInt(f,16))}else{e=E.ESCAPE[f];d+=e?e:f}e=false}else if(f=="\\")e=true;else if(f==a){this.index++;this.tokens.push({index:b,text:d,fn:function(){return d.length==c?m.String.toDate(d):d}});return}else d+=f;this.index++}throw"Lexer Error: Unterminated quote ["+this.text.substring(b)+"] starting at column '"+(b+
1)+"' in expression '"+this.text+"'.";},readRegexp:function(){var a=this.index;this.index++;for(var b="",c=false;this.index<this.text.length;){var d=this.text.charAt(this.index);if(c){b+=d;c=false}else if(d==="\\"){b+=d;c=true}else if(d==="/"){this.index++;c="";if(this.isIdent(this.text.charAt(this.index))){this.readIdent();c=this.tokens.pop().text}var e=new RegExp(b,c);this.tokens.push({index:a,text:b,flags:c,fn:function(){return e}});return}else b+=d;this.index++}throw"Lexer Error: Unterminated RegExp ["+
this.text.substring(a)+"] starting at column '"+(a+1)+"' in expression '"+this.text+"'.";}};D.ZERO=function(){return 0};D.prototype={error:function(a,b){throw"Token '"+b.text+"' is "+a+" at column='"+(b.index+1)+"' of expression '"+this.text+"' starting at '"+this.text.substring(b.index)+"'.";},peekToken:function(){if(this.tokens.length===0)throw"Unexpected end of expression: "+this.text;return this.tokens[0]},peek:function(a,b,c,d){var e=this.tokens;if(e.length>0){e=e[0];var f=e.text;if(f==a||f==
b||f==c||f==d||!a&&!b&&!c&&!d)return e}return false},expect:function(a,b,c,d){if(a=this.peek(a,b,c,d)){this.tokens.shift();return this.currentToken=a}return false},consume:function(a){if(!this.expect(a)){var b=this.peek();throw"Expecting '"+a+"' at column '"+(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}},_unary:function(a,b){return function(c){return a(c,b(c))}},_binary:function(a,b,c){return function(d){return b(d,a(d),c(d))}},hasTokens:function(){return this.tokens.length>
0},assertAllConsumed:function(){if(this.tokens.length!==0)throw"Did not understand '"+this.text.substring(this.tokens[0].index)+"' while evaluating '"+this.text+"'.";},statements:function(){for(var a=[];;){this.tokens.length>0&&!this.peek("}",")",";","]")&&a.push(this.filterChain());if(!this.expect(";"))return function(b){for(var c,d=0;d<a.length;d++){var e=a[d];if(e)c=e(b)}return c}}},filterChain:function(){for(var a=this.expression(),b;;)if(b=this.expect("|"))a=this._binary(a,b.fn,this.filter());
else return a},filter:function(){return this._pipeFunction(r)},validator:function(){return this._pipeFunction(ga)},_pipeFunction:function(a){for(var b=this.functionIdent(a),c=[];;)if(this.expect(":"))c.push(this.expression());else{var d=function(e,f){f=[f];for(var g=0;g<c.length;g++)f.push(c[g](e));g=function(){var h=this;o(e,function(i,j){if(j.charAt(0)=="$")h[j]=i})};g.prototype=e.self;return b.apply(new g,f)};return function(){return d}}},expression:function(){return this.throwStmt()},throwStmt:function(){if(this.expect("throw")){var a=
this.assignment();return function(b){throw a(b);}}else return this.assignment()},assignment:function(){var a=this.logicalOR(),b;if(b=this.expect("=")){if(!a.isAssignable)throw"Left hand side '"+this.text.substring(0,b.index)+"' of assignment '"+this.text.substring(b.index)+"' is not assignable.";return this._binary(function(){return a.isAssignable},b.fn,this.logicalOR())}else return a},logicalOR:function(){for(var a=this.logicalAND(),b;;)if(b=this.expect("||"))a=this._binary(a,b.fn,this.logicalAND());
else return a},logicalAND:function(){var a=this.equality(),b;if(b=this.expect("&&"))a=this._binary(a,b.fn,this.logicalAND());return a},equality:function(){var a=this.relational(),b;if(b=this.expect("==","!="))a=this._binary(a,b.fn,this.equality());return a},relational:function(){var a=this.additive(),b;if(b=this.expect("<",">","<=",">="))a=this._binary(a,b.fn,this.relational());return a},additive:function(){for(var a=this.multiplicative(),b;b=this.expect("+","-");)a=this._binary(a,b.fn,this.multiplicative());
return a},multiplicative:function(){for(var a=this.unary(),b;b=this.expect("*","/","%");)a=this._binary(a,b.fn,this.unary());return a},unary:function(){var a;return this.expect("+")?this.primary():(a=this.expect("-"))?this._binary(D.ZERO,a.fn,this.unary()):(a=this.expect("!"))?this._unary(a.fn,this.unary()):this.primary()},functionIdent:function(a){var b=this.expect(),c=b.text.split(".");a=a;for(var d,e=0;e<c.length;e++){d=c[e];if(a)a=a[d]}if(typeof a!="function")throw"Function '"+b.text+"' at column '"+
(b.index+1)+"' in '"+this.text+"' is not defined.";return a},primary:function(){var a;if(this.expect("(")){a=this.filterChain();this.consume(")");a=a}else if(this.expect("["))a=this.arrayDeclaration();else if(this.expect("{"))a=this.object();else if(this.expect("{:"))a=this.closure(false);else if(this.expect("{("))a=this.closure(true);else{var b=this.expect();(a=b.fn)||this.error("not a primary expression",b)}for(;b=this.expect("(","[",".");)if(b.text==="(")a=this.functionCall(a);else if(b.text===
"[")a=this.objectIndex(a);else if(b.text===".")a=this.fieldAccess(a);else throw"IMPOSSIBLE";return a},closure:function(a){var b=[];if(a){if(!this.expect(")")){for(b.push(this.expect().text);this.expect(",");)b.push(this.expect().text);this.consume(")")}this.consume(":")}var c=this.statements();this.consume("}");return function(d){return function(e){var f=new x(d.scope.state);f.set("$",e);for(var g=0;g<b.length;g++)f.set(b[g],arguments[g]);return c({scope:f})}}},fieldAccess:function(a){var b=this.expect().text,
c=function(d){return x.getter(a(d),b)};c.isAssignable=b;return c},objectIndex:function(a){var b=this.expression();this.consume("]");if(this.expect("=")){var c=this.expression();return function(d){return a(d)[b(d)]=c(d)}}else return function(d){var e=a(d);d=b(d);return e?e[d]:undefined}},functionCall:function(a){var b=[];if(this.peekToken().text!=")"){do b.push(this.expression());while(this.expect(","))}this.consume(")");return function(c){for(var d=[],e=0;e<b.length;e++)d.push(b[e](c));e=a(c);if(typeof e===
"function")return e.apply(c,d);else throw"Expression '"+a.isAssignable+"' is not a function.";}},arrayDeclaration:function(){var a=[];if(this.peekToken().text!="]"){do a.push(this.expression());while(this.expect(","))}this.consume("]");return function(b){for(var c=[],d=0;d<a.length;d++)c.push(a[d](b));return c}},object:function(){var a=[];if(this.peekToken().text!="}"){do{var b=this.expect().text;this.consume(":");var c=this.expression();a.push({key:b,value:c})}while(this.expect(","))}this.consume("}");
return function(d){for(var e={},f=0;f<a.length;f++){var g=a[f],h=g.value(d);e[g.key]=h}return e}},entityDeclaration:function(){for(var a=[];this.hasTokens();){a.push(this.entityDecl());this.expect(";")||this.assertAllConsumed()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}},entityDecl:function(){var a=this.expect().text,b,c;if(this.expect("=")){b=a;a=this.expect().text}if(this.expect(":"))c=this.primary()(null);return function(d){var e=d.datastore.entity(a,c);d.scope.set(a,
e);if(b){e=e();e.$$anchor=b;d.scope.set(b,e);return"$anchor."+b+":{"+b+"="+a+".load($anchor."+b+");"+b+".$$anchor="+m.String.quote(b)+";};"}else return""}},watch:function(){for(var a=[];this.hasTokens();){a.push(this.watchDecl());this.expect(";")||this.assertAllConsumed()}this.assertAllConsumed();return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.addListener(d.name,d.fn)}}},watchDecl:function(){var a=this.expect().text;this.consume(":");var b;if(this.peekToken().text=="{"){this.consume("{");
b=this.statements();this.consume("}")}else b=this.expression();return function(){return{name:a,fn:b}}}};x.expressionCache={};x.getter=function(a,b){if(!b)return a;for(var c=b.split("."),d,e=a,f=c.length,g=0;g<f;g++){d=c[g];if(!d.match(/^[\$\w][\$\w\d]*$/))throw"Expression '"+b+"' is not a valid expression for accesing variables.";if(a){e=a;a=a[d]}if(_.isUndefined(a)&&d.charAt(0)=="$"){var h=m.Global.typeOf(e);if(d=(h=m[h.charAt(0).toUpperCase()+h.substring(1)])?h[[d.substring(1)]]:undefined)return a=
_.bind(d,e,e)}}if(typeof a==="function"&&!a.$$factory)return Pa(e,a);return a};x.prototype={updateView:function(){var a=this;this.fireWatchers();_.each(this.widgets,function(b){a.evalWidget(b,"",{},function(){this.updateView(a)})})},addWidget:function(a){a&&this.widgets.push(a)},isProperty:function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!E.prototype.isIdent(c))return false}return true},get:function(a){return x.getter(this.state,a)},set:function(a,b){a=a.split(".");for(var c=this.state,
d=0;a.length>1;d++){var e=a.shift(),f=c[e];if(!f){f={};c[e]=f}c=f}return c[a.shift()]=b},setEval:function(a,b){this.eval(a+"="+v(b))},eval:function(a,b){var c=x.expressionCache[a];if(!c){var d=new D(a);c=d.statements();d.assertAllConsumed();x.expressionCache[a]=c}b=b||{};b.scope=this;b.self=this.state;return c(b)},evalWidget:function(a,b,c,d,e){try{var f=this.eval(b,c);if(a.hasError){a.hasError=false;k(a.view).removeClass("ng-exception").removeAttr("ng-error")}d&&d.apply(a,[f]);return true}catch(g){ba("Eval Widget Error:",
g);b=v(g,true);a.hasError=true;k(a.view).addClass("ng-exception").attr("ng-error",b);e&&e.apply(a,[g,b]);return false}},validate:function(a,b,c){var d=x.expressionCache[a];if(!d){d=(new D(a)).validator();x.expressionCache[a]=d}a={scope:this,self:this.state,$element:c};return d(a)(a,b)},entity:function(a,b){return(new D(a)).entityDeclaration()({scope:this,datastore:b})},clearInvalid:function(){for(var a=this.state.$invalidWidgets;a.length>0;)a.pop()},markInvalid:function(a){this.state.$invalidWidgets.push(a)},
watch:function(a){var b=this;(new D(a)).watch()({scope:this,addListener:function(c,d){b.addWatchListener(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})},addWatchListener:function(a,b){var c=this.watchListeners[a];if(!c){c={listeners:[],expression:a};this.watchListeners[a]=c}c.listeners.push(b)},fireWatchers:function(){var a=this,b=false;o(this.watchListeners,function(c){var d=a.eval(c.expression);if(d!==c.lastValue){o(c.listeners,function(e){e(d,c.lastValue);b=true});c.lastValue=
d}});return b}};pa.prototype={base64url:function(a){return fa.encode(a)},request:function(a,b,c,d){var e=this.uuid+this.nextId++;a=this.base64url(v({u:b,m:a,p:c}));b=Math.ceil(a.length/this.maxSize);c=this.url+"/$/"+e+"/"+b+"/";M[e]=function(h){delete M[e];d(200,h)};for(var f=0;f<b;f++){var g=a.substr(f*this.maxSize,this.maxSize);this.getScript(c+(f+1)+"?h="+g,n)}}};S.PREFIX="$DATASET:";S.prototype={read:function(){this.data=F(this.frame.name.substr(S.PREFIX.length))},write:function(){this.frame.name=
S.PREFIX+v(this.data)},request:function(){}};qa.prototype={request:function(a,b,c,d){var e=this;this.status.beginRequest(c);this.delegate.request(a,b,c,function(){e.status.endRequest();try{d.apply(this,arguments)}catch(f){alert(v(f))}e.update()})}};B(sa.prototype,{fetchCurrentUser:function(a){var b=this;this.server.request("GET","/account.json",{},function(c,d){b.current=d.user;a(d.user)})},logout:function(a){var b=this;this.controlBar.logout(function(){delete b.current;(a||n)()})},login:function(a){var b=
this;this.controlBar.login(function(){b.fetchCurrentUser(function(){(a||n)()})})},notAuthorized:function(){this.controlBar.notAuthorized()}});o({regexp:function(a,b,c){return a.match(b)?null:c||"Value does not match expected format "+b+"."},number:function(a,b,c){var d=1*a;if(d==a){if(typeof b!="undefined"&&d<b)return"Value can not be less than "+b+".";if(typeof b!="undefined"&&d>c)return"Value can not be greater than "+c+".";return null}else return"Value is not a number."},integer:function(a,b,c){if(b=
ga.number(a,b,c))return b;if(!(""+a).match(/^\s*[\d+]*\s*$/)||a!=Math.round(a))return"Value is not a whole number.";return null},date:function(a){if(a.match(/^\d\d?\/\d\d?\/\d\d\d\d$/))return null;return"Value is not a date. (Expecting format: 12/31/2009)."},ssn:function(a){if(a.match(/^\d\d\d-\d\d-\d\d\d\d$/))return null;return"SSN needs to be in 999-99-9999 format."},email:function(a){if(a.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/))return null;return"Email needs to be in username@host.com format."},
phone:function(a){if(a.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/))return null;if(a.match(/^\+\d{2,3} (\(\d{1,5}\))?[\d ]+\d$/))return null;return"Phone number needs to be in 1(987)654-3210 format in North America or +999 (123) 45678 906 internationaly."},url:function(a){if(a.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/))return null;return"URL needs to be in http://server[:port]/path format."},json:function(a){try{F(a);return null}catch(b){return b.toString()}},
asynchronous:function(a,b){var c=this.$element,d=c.$validateState=c.$validateState||{},e=d[a],f=this.$updateView;c.$lastKey=a;if(e===undefined){k(c).addClass("ng-input-indicator-wait");e=d[a]=null;b(a,function(g){e=d[a]=g?g:false;d[c.$lastKey]!==null&&k(c).removeClass("ng-input-indicator-wait");f()})}e===null&&this.$invalidWidgets.push(this.$element);return e}},function(a,b){ga[b]=a});oa.prototype={createController:function(a,b){var c,d=a.attr("type").toLowerCase(),e=a.attr("name");if(e)e=e.split(":").pop();
var f="change",g=true,h=ha[a.attr("ng-format")]||ha.noop;if(d=="button"||d=="submit"||d=="reset"||d=="image"){c=new Ya(a[0],e,h);f="click";g=false}else if(d=="text"||d=="textarea"||d=="hidden"||d=="password"){c=new ua(a[0],e,h);f="keyup change"}else if(d=="checkbox"){c=new va(a[0],e,h);f="click"}else if(d=="radio"){c=new ya(a[0],e,h);f="click"}else if(d=="select-one")c=new wa(a[0],e,h);else if(d=="select-multiple")c=new xa(a[0],e,h);else if(d=="file")c=this.createFileController(a,e,h);else throw"Unknown type: "+
d;a.data("controller",c);var i=b.get("$updateView");k(c.view,":input").bind(f,function(){if(c.updateModel(b)){var j=k(c.view).attr("ng-action")||"";b.evalWidget(c,j)&&i(b)}return g});return c},createFileController:function(a){var b="__uploadWidget_"+this.nextUploadId++,c=U.template(b);a.after(c);b=this.createSWF({data:this.serverUrl+"/admin/ServerAPI.swf",width:"95",height:"20",align:"top",wmode:"transparent"},{flashvars:"uploadWidgetId="+b,allowScriptAccess:"always"},b);a.remove();a=new U(c,a[0].name,
b,this.serverUrl+"/data/"+this.database);k(b).parent().data("controller",a);return a}};M.flashEvent=function(a,b,c){a=u.getElementById(a);a=k(a);var d=a.parent().data("controller");U.prototype[b].apply(d,c);_.defer(a.scope().get("$updateView"))};U.template=function(a){return k('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+a+'" /><a></a><span/></span>')};B(U.prototype,{cancel:n,complete:n,httpStatus:function(a){alert("httpStatus:"+this.scopeName+" status:"+
a)},ioError:function(){alert("ioError:"+this.scopeName)},open:function(){alert("open:"+this.scopeName)},progress:n,securityError:function(){alert("securityError:"+this.scopeName)},uploadCompleteData:function(a){a=F(a);a.url=this.attachmentsPath+"/"+a.id+"/"+a.text;this.view.find("input").attr("checked",true);var b=this.view.scope();this.value=a;this.updateModel(b);this.value=null},select:function(a,b){this.name=a;this.view.find("a").text(a).attr("href",a);this.view.find("span").text(m.filter.bytes(b));
this.upload()},updateModel:function(a){var b=this.view.find("input").attr("checked")?this.value:null;if(this.lastValue===b)return false;else{a.set(this.scopeName,b);return true}},updateView:function(a){if((a=a.get(this.scopeName))&&this.value!==a){this.value=a;this.view.find("a").attr("href",this.value.url).text(this.value.text);this.view.find("span").text(m.filter.bytes(this.value.size))}this.view.find("input").attr("checked",!!a)},upload:function(){this.name&&this.uploader.uploadFile(this.attachmentsPath)}});
Q.prototype={updateModel:function(){return true},updateView:n};Q.instance=new Q;var Ya=Q;ua.prototype={updateModel:function(a){var b=this.formatter.parse(this.view.value);if(this.lastValue===b)return false;else{a.setEval(this.exp,b);this.lastValue=b;return true}},updateView:function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.initialValue;a.setEval(this.exp,c)}c=c?c:"";if(!_(this.lastValue).isEqual(c)){b.value=this.formatter.format(c);this.lastValue=c}var d=false;b.removeAttribute("ng-error");
if(this.required)d=!(c&&$.trim(""+c).length>0);var e=d?"Required Value":null;if(!d&&this.validator&&c){e=a.validate(this.validator,c,b);d=!!e}if(this.lastErrorText!==e){this.lastErrorText=d;if(e&&Ka(b)){b.setAttribute("ng-error",e);a.markInvalid(this)}k(b).toggleClass("ng-validation-error",d)}}};va.prototype={updateModel:function(a){var b=this.view;b=b.checked?b.value:"";b=this.formatter.parse(b);b=this.formatter.format(b);if(this.lastValue===b)return false;else{a.setEval(this.exp,this.formatter.parse(b));
this.lastValue=b;return true}},updateView:function(a){var b=this.view,c=a.eval(this.exp);if(typeof c==="undefined"){c=this.initialValue;a.setEval(this.exp,c)}b.checked=this.formatter.parse(b.value)==c}};wa.prototype={updateModel:function(a){if(this.view.selectedIndex<0)a.setEval(this.exp,null);else{var b=this.view.value;if(this.lastValue===b)return false;else{a.setEval(this.exp,b);this.lastValue=b;return true}}},updateView:function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=
this.initialValue;a.setEval(this.exp,c)}if(c!==this.lastValue){b.value=c?c:"";this.lastValue=c}}};xa.prototype={selected:function(){for(var a=[],b=this.view.options,c=0;c<b.length;c++){var d=b[c];d.selected&&a.push(d.value)}return a},updateModel:function(a){var b=this.selected();if(this.lastValue===b)return false;else{a.setEval(this.exp,b);this.lastValue=b;return true}},updateView:function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.initialValue;a.setEval(this.exp,c)}if(c!==
this.lastValue){a=b.options;for(b=0;b<a.length;b++){var d=a[b];d.selected=_.include(c,d.value)}this.lastValue=c}}};ya.prototype={updateModel:function(a){var b=this.view;if(this.lastChecked)return false;else{b.checked=true;this.lastValue=a.setEval(this.exp,this.inputValue);return this.lastChecked=true}},updateView:function(a){var b=this.view,c=a.get(this.exp);if(this.initialValue&&typeof c==="undefined"){c=this.initialValue;a.setEval(this.exp,c)}if(this.lastValue!=c){this.lastChecked=b.checked=this.inputValue==
""+c;this.lastValue=c}}};L.toText=function(a){switch(typeof a){case "string":case "boolean":case "number":return C(a);case "function":return L.toText(a());case "object":if(ja(a))return ma(a);else if(a instanceof m.filter.Meta){switch(typeof a.html){case "string":case "number":return a.html;case "function":return a.html();case "object":if(ja(a.html))return ma(a.html);default:break}switch(typeof a.text){case "string":case "number":return C(a.text);case "function":return C(a.text());default:break}}if(a===
null)return"";return C(v(a,true));default:return""}};L.prototype={updateModel:n,updateView:function(a){for(var b=[],c=this.exp,d=c.length,e=0;e<d;e++){var f=c[e],g=w.binding(f);if(g){a.evalWidget(this,g,{$element:this.view},function(h){b.push(L.toText(h))},function(h,i){la(this.view,i)});if(this.hasError)return}else b.push(C(f))}la(this.view,b.join(""))}};za.prototype={updateModel:n,updateView:function(a){var b=k(this.view),c=this.attrs;if(this.hasError){this.hasError=false;b.removeClass("ng-exception").removeAttr("ng-error")}var d=
b.is("img");for(var e in c){for(var f=w.parseBindings(c[e]),g=[],h=0;h<f.length;h++){var i=w.binding(f[h]);if(i)try{var j=a.eval(i,{$element:b[0],attrName:e});if(j&&(j.constructor!==array||j.length!==0))g.push(j)}catch(l){this.hasError=true;ba("BindAttrUpdater",l);i=v(l,true);g.push("["+i+"]");b.addClass("ng-exception").attr("ng-error",i)}else g.push(f[h])}f=g.length?g.join(""):null;if(d&&e=="src"&&!f)f=a.get("$config.blankImage");b.attr(e,f)}}};Aa.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,
this.exp)}};Ba.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,this.exp,{},function(b){var c=k(this.view);P(b)?c.hide():c.show()})}};Ca.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,this.exp,{},function(b){var c=k(this.view);P(b)?c.show():c.hide()})}};Da.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,this.exp,{},function(b){if(b!==null&&b!==undefined)this.view.className=b})}};Ea.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,
this.exp,{},function(b){var c=a.get("$index");k(this.view).toggleClass(b,c%2===1)})}};Fa.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,this.exp,{},function(b){var c=a.get("$index");k(this.view).toggleClass(b,c%2===0)})}};Ga.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,this.exp,{},function(b){k(this.view).attr("style","").css(b)})}};Ha.prototype={updateModel:n,updateView:function(a){a.evalWidget(this,this.iteratorExp,{},function(b){var c=this;if(!b){b=[];a.isProperty(this.iteratorExp)&&
a.set(this.iteratorExp,b)}var d=b.length,e=this.children.length,f=this.view,g=0,h=null,i=this.keyExp,j=this.valueExp,l=0;o(b,function(q,N){if(l<e){h=c.children[l];h.scope.set(j,q)}else{var s=new x(a.state,c.prefix+j+" in "+c.iteratorExp+"["+l+"]");s.set("$index",l);i&&s.set(i,N);s.set(j,q);h={scope:s,element:c.template(s,c.prefix,l)};f.after(h.element);c.children.push(h)}f=h.element;q=(new Date).getTime();h.scope.updateView();g+=(new Date).getTime()-q;l++});for(b=e;b>d;--b)this.children.pop().element.remove();
if(h&&h.element[0].nodeName==="OPTION")if(d=k(h.element[0].parentNode).data("controller")){d.lastValue=undefined;d.updateView(a)}})}};A.OUT_EVENT="mouseleave mouseout click dblclick keypress keyup";A.onOver=function(){A.onOut();var a=k(this);a.bind(A.OUT_EVENT,A.onOut);var b=a.position(),c=u.documentElement,d=(self.innerWidth||c&&c.clientWidth||u.body.clientWidth)-b.left;c=a.hasClass("ng-exception")?"EXCEPTION:":"Validation error...";a=a.attr("ng-error");d=d>375?"left":"right";c=k("<div id='ng-callout' style='width:300px'><div class='ng-arrow-"+
d+"'/><div class='ng-title'>"+c+"</div><div class='ng-content'>"+a+"</div></div>");k("body").append(c);if(d==="left")a=b.left+this.offsetWidth+11;else{a=b.left-315;c.find(".ng-arrow-right").css({left:301})}c.css({left:a+"px",top:b.top-3+"px"});return true};A.onOut=function(){k("#ng-callout").unbind(A.OUT_EVENT,A.onOut).remove();return true};A.prototype={bind:function(){this.doc.find(".ng-validation-error,.ng-exception").live("mouseover",A.onOver)}};ra.prototype={beginRequest:function(){},endRequest:function(){}};
ea.DOM='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';ea.prototype={beginRequest:function(){if(this.requestCount===0)(this.loader=this.loader||this.body.append(ea.DOM).find("#ng-loading")).show();this.requestCount++},endRequest:function(){this.requestCount--;this.requestCount===0&&this.loader.hide("fold")}};var Na=/^(.*)\/angular-(.+)\.js(\?([^#]*))?(\#(.*))?$/;Ia.prototype={load:function(a,b){this.parseConfig(this.getOurScriptTag().src);this.loadCss("/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css");
this.loadCss("/stylesheets/angular.css");this.config.location=a;var c=this.findDocumentRoot();if(c){var d=this.angular.compile(c,this.config).init(),e=d.get("$users");k(this._document).find("body").show();e.fetchCurrentUser(function(f){!f&&k(c).find("[ng-auth=eager]").length&&e.login()})}b(d)},getOurScriptTag:function(){var a;o(this._document.getElementsByTagName("script"),function(b){if((b.src||"").match(Na)){a=b;_.breakLoop()}});return a},parseConfig:function(a){var b=this.config;a=a.match(Na);
var c=b.server=a[1];b.version=a[2];b.database=b.library=(c.match(/^https?:\/\/(\w+)/)||["",""])[1];b.blankImage=c+"/images/blank.png";o((a[6]||"").split("&"),function(d){var e=d.split("=")[0];(value=d.split("=")[1])||(value=true);P(value)||(value=false);b[e]=value})},loadCss:function(a){var b=this._document.createElement("link");b.rel="stylesheet";b.type="text/css";a.match(/^https?:/)||(a=this.config.server+a);b.href=a;this._document.getElementsByTagName("head")[0].appendChild(b)},findDocumentRoot:function(){var a=
this.config.bindRootId,b,c=this._document;if(a){o(a.split("|"),function(d){d=d.split("?");if((b=c.getElementById(d[0]))&&d[1])b=c.getElementById(d[1])?b:undefined;b&&_.breakLoop()});return b}else return this._document}}})(window,document);
