(function(){var u=this;
var r=u._;
var b={};
var i=Array.prototype,B=Object.prototype,D=Function.prototype;
var s=i.slice,w=i.unshift,v=B.toString,o=B.hasOwnProperty;
var m=i.forEach,h=i.map,z=i.reduce,e=i.reduceRight,l=i.filter,a=i.every,y=i.some,t=i.indexOf,f=i.lastIndexOf,c=Array.isArray,A=Object.keys,j=D.bind;
var C=function(E){return new g(E)
};
if(typeof module!=="undefined"&&module.exports){module.exports=C;
C._=C
}else{u._=C
}C.VERSION="1.1.5";
var d=C.each=C.forEach=function(J,I,H){if(J==null){return
}if(m&&J.forEach===m){J.forEach(I,H)
}else{if(C.isNumber(J.length)){for(var G=0,E=J.length;
G<E;
G++){if(I.call(H,J[G],G,J)===b){return
}}}else{for(var F in J){if(o.call(J,F)){if(I.call(H,J[F],F,J)===b){return
}}}}}};
C.map=function(H,G,F){var E=[];
if(H==null){return E
}if(h&&H.map===h){return H.map(G,F)
}d(H,function(K,I,J){E[E.length]=G.call(F,K,I,J)
});
return E
};
C.reduce=C.foldl=C.inject=function(I,H,E,G){var F=E!==void 0;
if(I==null){I=[]
}if(z&&I.reduce===z){if(G){H=C.bind(H,G)
}return F?I.reduce(H,E):I.reduce(H)
}d(I,function(L,J,K){if(!F&&J===0){E=L;
F=true
}else{E=H.call(G,E,L,J,K)
}});
if(!F){throw new TypeError("Reduce of empty array with no initial value")
}return E
};
C.reduceRight=C.foldr=function(H,G,E,F){if(H==null){H=[]
}if(e&&H.reduceRight===e){if(F){G=C.bind(G,F)
}return E!==void 0?H.reduceRight(G,E):H.reduceRight(G)
}var I=(C.isArray(H)?H.slice():C.toArray(H)).reverse();
return C.reduce(I,G,E,F)
};
C.find=C.detect=function(H,G,F){var E;
p(H,function(K,I,J){if(G.call(F,K,I,J)){E=K;
return true
}});
return E
};
C.filter=C.select=function(H,G,F){var E=[];
if(H==null){return E
}if(l&&H.filter===l){return H.filter(G,F)
}d(H,function(K,I,J){if(G.call(F,K,I,J)){E[E.length]=K
}});
return E
};
C.reject=function(H,G,F){var E=[];
if(H==null){return E
}d(H,function(K,I,J){if(!G.call(F,K,I,J)){E[E.length]=K
}});
return E
};
C.every=C.all=function(H,G,F){G||(G=C.identity);
var E=true;
if(H==null){return E
}if(a&&H.every===a){return H.every(G,F)
}d(H,function(K,I,J){if(!(E=E&&G.call(F,K,I,J))){return b
}});
return E
};
var p=C.some=C.any=function(H,G,F){G||(G=C.identity);
var E=false;
if(H==null){return E
}if(y&&H.some===y){return H.some(G,F)
}d(H,function(K,I,J){if(E=G.call(F,K,I,J)){return b
}});
return E
};
C.include=C.contains=function(G,F){var E=false;
if(G==null){return E
}if(t&&G.indexOf===t){return G.indexOf(F)!=-1
}p(G,function(H){if(E=H===F){return true
}});
return E
};
C.invoke=function(F,G){var E=s.call(arguments,2);
return C.map(F,function(H){return(G?H[G]:H).apply(H,E)
})
};
C.pluck=function(F,E){return C.map(F,function(G){return G[E]
})
};
C.max=function(H,G,F){if(!G&&C.isArray(H)){return Math.max.apply(Math,H)
}var E={computed:-Infinity};
d(H,function(L,I,K){var J=G?G.call(F,L,I,K):L;
J>=E.computed&&(E={value:L,computed:J})
});
return E.value
};
C.min=function(H,G,F){if(!G&&C.isArray(H)){return Math.min.apply(Math,H)
}var E={computed:Infinity};
d(H,function(L,I,K){var J=G?G.call(F,L,I,K):L;
J<E.computed&&(E={value:L,computed:J})
});
return E.value
};
C.sortBy=function(G,F,E){return C.pluck(C.map(G,function(J,H,I){return{value:J,criteria:F.call(E,J,H,I)}
}).sort(function(K,J){var I=K.criteria,H=J.criteria;
return I<H?-1:I>H?1:0
}),"value")
};
C.sortedIndex=function(J,I,G){G||(G=C.identity);
var E=0,H=J.length;
while(E<H){var F=(E+H)>>1;
G(J[F])<G(I)?E=F+1:H=F
}return E
};
C.toArray=function(E){if(!E){return[]
}if(E.toArray){return E.toArray()
}if(C.isArray(E)){return E
}if(C.isArguments(E)){return s.call(E)
}return C.values(E)
};
C.size=function(E){return C.toArray(E).length
};
C.first=C.head=function(G,F,E){return(F!=null)&&!E?s.call(G,0,F):G[0]
};
C.rest=C.tail=function(G,E,F){return s.call(G,(E==null)||F?1:E)
};
C.last=function(E){return E[E.length-1]
};
C.compact=function(E){return C.filter(E,function(F){return !!F
})
};
C.flatten=function(E){return C.reduce(E,function(F,G){if(C.isArray(G)){return F.concat(C.flatten(G))
}F[F.length]=G;
return F
},[])
};
C.without=function(F){var E=s.call(arguments,1);
return C.filter(F,function(G){return !C.include(E,G)
})
};
C.uniq=C.unique=function(F,E){return C.reduce(F,function(G,I,H){if(0==H||(E===true?C.last(G)!=I:!C.include(G,I))){G[G.length]=I
}return G
},[])
};
C.intersect=function(F){var E=s.call(arguments,1);
return C.filter(C.uniq(F),function(G){return C.every(E,function(H){return C.indexOf(H,G)>=0
})
})
};
C.zip=function(){var E=s.call(arguments);
var H=C.max(C.pluck(E,"length"));
var G=new Array(H);
for(var F=0;
F<H;
F++){G[F]=C.pluck(E,""+F)
}return G
};
C.indexOf=function(I,G,H){if(I==null){return -1
}var F,E;
if(H){F=C.sortedIndex(I,G);
return I[F]===G?F:-1
}if(t&&I.indexOf===t){return I.indexOf(G)
}for(F=0,E=I.length;
F<E;
F++){if(I[F]===G){return F
}}return -1
};
C.lastIndexOf=function(G,F){if(G==null){return -1
}if(f&&G.lastIndexOf===f){return G.lastIndexOf(F)
}var E=G.length;
while(E--){if(G[E]===F){return E
}}return -1
};
C.range=function(J,H,I){if(arguments.length<=1){H=J||0;
J=0
}I=arguments[2]||1;
var F=Math.max(Math.ceil((H-J)/I),0);
var E=0;
var G=new Array(F);
while(E<F){G[E++]=J;
J+=I
}return G
};
C.bind=function(F,G){if(F.bind===j&&j){return j.apply(F,s.call(arguments,1))
}var E=s.call(arguments,2);
return function(){return F.apply(G,E.concat(s.call(arguments)))
}
};
C.bindAll=function(F){var E=s.call(arguments,1);
if(E.length==0){E=C.functions(F)
}d(E,function(G){F[G]=C.bind(F[G],F)
});
return F
};
C.memoize=function(G,F){var E={};
F||(F=C.identity);
return function(){var H=F.apply(this,arguments);
return o.call(E,H)?E[H]:(E[H]=G.apply(this,arguments))
}
};
C.delay=function(F,G){var E=s.call(arguments,2);
return setTimeout(function(){return F.apply(F,E)
},G)
};
C.defer=function(E){return C.delay.apply(C,[E,1].concat(s.call(arguments,1)))
};
var x=function(F,H,E){var G;
return function(){var J=this,I=arguments;
var K=function(){G=null;
F.apply(J,I)
};
if(E){clearTimeout(G)
}if(E||!G){G=setTimeout(K,H)
}}
};
C.throttle=function(E,F){return x(E,F,false)
};
C.debounce=function(E,F){return x(E,F,true)
};
C.once=function(G){var E=false,F;
return function(){if(E){return F
}E=true;
return F=G.apply(this,arguments)
}
};
C.wrap=function(E,F){return function(){var G=[E].concat(s.call(arguments));
return F.apply(this,G)
}
};
C.compose=function(){var E=s.call(arguments);
return function(){var F=s.call(arguments);
for(var G=E.length-1;
G>=0;
G--){F=[E[G].apply(this,F)]
}return F[0]
}
};
C.keys=A||function(G){if(G!==Object(G)){throw new TypeError("Invalid object")
}var F=[];
for(var E in G){if(o.call(G,E)){F[F.length]=E
}}return F
};
C.values=function(E){return C.map(E,C.identity)
};
C.functions=C.methods=function(E){return C.filter(C.keys(E),function(F){return C.isFunction(E[F])
}).sort()
};
C.extend=function(E){d(s.call(arguments,1),function(F){for(var G in F){E[G]=F[G]
}});
return E
};
C.defaults=function(E){d(s.call(arguments,1),function(F){for(var G in F){if(E[G]==null){E[G]=F[G]
}}});
return E
};
C.clone=function(E){return C.isArray(E)?E.slice():C.extend({},E)
};
C.tap=function(F,E){E(F);
return F
};
C.isEqual=function(F,E){if(F===E){return true
}var I=typeof(F),K=typeof(E);
if(I!=K){return false
}if(F==E){return true
}if((!F&&E)||(F&&!E)){return false
}if(F._chain){F=F._wrapped
}if(E._chain){E=E._wrapped
}if(F.isEqual){return F.isEqual(E)
}if(C.isDate(F)&&C.isDate(E)){return F.getTime()===E.getTime()
}if(C.isNaN(F)&&C.isNaN(E)){return false
}if(C.isRegExp(F)&&C.isRegExp(E)){return F.source===E.source&&F.global===E.global&&F.ignoreCase===E.ignoreCase&&F.multiline===E.multiline
}if(I!=="object"){return false
}if(F.length&&(F.length!==E.length)){return false
}var G=C.keys(F),J=C.keys(E);
if(G.length!=J.length){return false
}for(var H in F){if(!(H in E)||!C.isEqual(F[H],E[H])){return false
}}return true
};
C.isEmpty=function(F){if(C.isArray(F)||C.isString(F)){return F.length===0
}for(var E in F){if(o.call(F,E)){return false
}}return true
};
C.isElement=function(E){return !!(E&&E.nodeType==1)
};
C.isArray=c||function(E){return v.call(E)==="[object Array]"
};
C.isArguments=function(E){return !!(E&&o.call(E,"callee"))
};
C.isFunction=function(E){return !!(E&&E.constructor&&E.call&&E.apply)
};
C.isString=function(E){return !!(E===""||(E&&E.charCodeAt&&E.substr))
};
C.isNumber=function(E){return !!(E===0||(E&&E.toExponential&&E.toFixed))
};
C.isNaN=function(E){return E!==E
};
C.isBoolean=function(E){return E===true||E===false
};
C.isDate=function(E){return !!(E&&E.getTimezoneOffset&&E.setUTCFullYear)
};
C.isRegExp=function(E){return !!(E&&E.test&&E.exec&&(E.ignoreCase||E.ignoreCase===false))
};
C.isNull=function(E){return E===null
};
C.isUndefined=function(E){return E===void 0
};
C.noConflict=function(){u._=r;
return this
};
C.identity=function(E){return E
};
C.times=function(H,G,F){for(var E=0;
E<H;
E++){G.call(F,E)
}};
C.mixin=function(E){d(C.functions(E),function(F){q(F,C[F]=E[F])
})
};
var k=0;
C.uniqueId=function(E){var F=k++;
return E?E+F:F
};
C.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g};
C.template=function(H,G){var I=C.templateSettings;
var E="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+H.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(I.interpolate,function(J,K){return"',"+K.replace(/\\'/g,"'")+",'"
}).replace(I.evaluate||null,function(J,K){return"');"+K.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"
}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";
var F=new Function("obj",E);
return G?F(G):F
};
var g=function(E){this._wrapped=E
};
C.prototype=g.prototype;
var n=function(F,E){return E?C(F).chain():F
};
var q=function(E,F){g.prototype[E]=function(){var G=s.call(arguments);
w.call(G,this._wrapped);
return n(F.apply(C,G),this._chain)
}
};
C.mixin(C);
d(["pop","push","reverse","shift","sort","splice","unshift"],function(E){var F=i[E];
g.prototype[E]=function(){F.apply(this._wrapped,arguments);
return n(this._wrapped,this._chain)
}
});
d(["concat","join","slice"],function(E){var F=i[E];
g.prototype[E]=function(){return n(F.apply(this._wrapped,arguments),this._chain)
}
});
g.prototype.chain=function(){this._chain=true;
return this
};
g.prototype.value=function(){return this._wrapped
}
})();(function(){var n=this;
var m=n.Backbone;
var b;
if(typeof exports!=="undefined"){b=exports
}else{b=n.Backbone={}
}b.VERSION="0.3.3";
var v=n._;
if(!v&&(typeof require!=="undefined")){v=require("underscore")._
}var e=n.jQuery||n.Zepto;
b.noConflict=function(){n.Backbone=m;
return this
};
b.emulateHTTP=false;
b.emulateJSON=false;
b.Events={bind:function(x,z){var w=this._callbacks||(this._callbacks={});
var y=this._callbacks[x]||(this._callbacks[x]=[]);
y.push(z);
return this
},unbind:function(z,B){var y;
if(!z){this._callbacks={}
}else{if(y=this._callbacks){if(!B){y[z]=[]
}else{var A=y[z];
if(!A){return this
}for(var x=0,w=A.length;
x<w;
x++){if(B===A[x]){A.splice(x,1);
break
}}}}}return this
},trigger:function(z){var A,y,x,w;
if(!(y=this._callbacks)){return this
}if(y[z]){A=y[z].slice(0);
for(x=0,w=A.length;
x<w;
x++){A[x].apply(this,Array.prototype.slice.call(arguments,1))
}}if(y.all){A=y.all.slice(0);
for(x=0,w=A.length;
x<w;
x++){A[x].apply(this,arguments)
}}return this
}};
b.Model=function(w,x){var y;
w||(w={});
if(y=this.defaults){if(v.isFunction(y)){y=y()
}w=v.extend({},y,w)
}this.attributes={};
this._escapedAttributes={};
this.cid=v.uniqueId("c");
this.set(w,{silent:true});
this._changed=false;
this._previousAttributes=v.clone(this.attributes);
if(x&&x.collection){this.collection=x.collection
}this.initialize(w,x)
};
v.extend(b.Model.prototype,b.Events,{_previousAttributes:null,_changed:false,idAttribute:"id",initialize:function(){},toJSON:function(){return v.clone(this.attributes)
},get:function(w){return this.attributes[w]
},escape:function(w){var x;
if(x=this._escapedAttributes[w]){return x
}var y=this.attributes[w];
return this._escapedAttributes[w]=l(y==null?"":""+y)
},has:function(w){return this.attributes[w]!=null
},set:function(z,y){y||(y={});
if(!z){return this
}if(z.attributes){z=z.attributes
}var x=this.attributes,A=this._escapedAttributes;
if(!y.silent&&this.validate&&!this._performValidation(z,y)){return false
}if(this.idAttribute in z){this.id=z[this.idAttribute]
}for(var w in z){var B=z[w];
if(!v.isEqual(x[w],B)){x[w]=B;
delete A[w];
this._changed=true;
if(!y.silent){this.trigger("change:"+w,this,B,y)
}}}if(!y.silent&&this._changed){this.change(y)
}return this
},unset:function(w,x){if(!(w in this.attributes)){return this
}x||(x={});
var z=this.attributes[w];
var y={};
y[w]=void 0;
if(!x.silent&&this.validate&&!this._performValidation(y,x)){return false
}delete this.attributes[w];
delete this._escapedAttributes[w];
if(w==this.idAttribute){delete this.id
}this._changed=true;
if(!x.silent){this.trigger("change:"+w,this,void 0,x);
this.change(x)
}return this
},clear:function(x){x||(x={});
var w=this.attributes;
var y={};
for(attr in w){y[attr]=void 0
}if(!x.silent&&this.validate&&!this._performValidation(y,x)){return false
}this.attributes={};
this._escapedAttributes={};
this._changed=true;
if(!x.silent){for(attr in w){this.trigger("change:"+attr,this,void 0,x)
}this.change(x)
}return this
},fetch:function(x){x||(x={});
var w=this;
var y=x.success;
x.success=function(z){if(!w.set(w.parse(z),x)){return false
}if(y){y(w,z)
}};
x.error=c(x.error,w,x);
(this.sync||b.sync).call(this,"read",this,x);
return this
},save:function(y,x){x||(x={});
if(y&&!this.set(y,x)){return false
}var w=this;
var z=x.success;
x.success=function(B){if(!w.set(w.parse(B),x)){return false
}if(z){z(w,B)
}};
x.error=c(x.error,w,x);
var A=this.isNew()?"create":"update";
(this.sync||b.sync).call(this,A,this,x);
return this
},destroy:function(x){x||(x={});
var w=this;
var y=x.success;
x.success=function(z){w.trigger("destroy",w,w.collection,x);
if(y){y(w,z)
}};
x.error=c(x.error,w,x);
(this.sync||b.sync).call(this,"delete",this,x);
return this
},url:function(){var w=o(this.collection)||this.urlRoot||q();
if(this.isNew()){return w
}return w+(w.charAt(w.length-1)=="/"?"":"/")+encodeURIComponent(this.id)
},parse:function(w){return w
},clone:function(){return new this.constructor(this)
},isNew:function(){return !this.id
},change:function(w){this.trigger("change",this,w);
this._previousAttributes=v.clone(this.attributes);
this._changed=false
},hasChanged:function(w){if(w){return this._previousAttributes[w]!=this.attributes[w]
}return this._changed
},changedAttributes:function(y){y||(y=this.attributes);
var x=this._previousAttributes;
var z=false;
for(var w in y){if(!v.isEqual(x[w],y[w])){z=z||{};
z[w]=y[w]
}}return z
},previous:function(w){if(!w||!this._previousAttributes){return null
}return this._previousAttributes[w]
},previousAttributes:function(){return v.clone(this._previousAttributes)
},_performValidation:function(y,x){var w=this.validate(y);
if(w){if(x.error){x.error(this,w)
}else{this.trigger("error",this,w,x)
}return false
}return true
}});
b.Collection=function(x,w){w||(w={});
if(w.comparator){this.comparator=w.comparator;
delete w.comparator
}v.bindAll(this,"_onModelEvent","_removeReference");
this._reset();
if(x){this.refresh(x,{silent:true})
}this.initialize(x,w)
};
v.extend(b.Collection.prototype,b.Events,{model:b.Model,initialize:function(){},toJSON:function(){return this.map(function(w){return w.toJSON()
})
},add:function(z,x){if(v.isArray(z)){for(var y=0,w=z.length;
y<w;
y++){this._add(z[y],x)
}}else{this._add(z,x)
}return this
},remove:function(z,x){if(v.isArray(z)){for(var y=0,w=z.length;
y<w;
y++){this._remove(z[y],x)
}}else{this._remove(z,x)
}return this
},get:function(w){if(w==null){return null
}return this._byId[w.id!=null?w.id:w]
},getByCid:function(w){return w&&this._byCid[w.cid||w]
},at:function(w){return this.models[w]
},sort:function(w){w||(w={});
if(!this.comparator){throw new Error("Cannot sort a set without a comparator")
}this.models=this.sortBy(this.comparator);
if(!w.silent){this.trigger("refresh",this,w)
}return this
},pluck:function(w){return v.map(this.models,function(x){return x.get(w)
})
},refresh:function(x,w){x||(x=[]);
w||(w={});
this.each(this._removeReference);
this._reset();
this.add(x,{silent:true});
if(!w.silent){this.trigger("refresh",this,w)
}return this
},fetch:function(w){w||(w={});
var y=this;
var x=w.success;
w.success=function(z){y[w.add?"add":"refresh"](y.parse(z),w);
if(x){x(y,z)
}};
w.error=c(w.error,y,w);
(this.sync||b.sync).call(this,"read",this,w);
return this
},create:function(y,x){var z=this;
x||(x={});
if(!(y instanceof b.Model)){var w=y;
y=new this.model(null,{collection:z});
if(!y.set(w)){return false
}}else{y.collection=z
}var A=x.success;
x.success=function(B,C){z.add(B);
if(A){A(B,C)
}};
return y.save(null,x)
},parse:function(w){return w
},chain:function(){return v(this.models).chain()
},_reset:function(w){this.length=0;
this.models=[];
this._byId={};
this._byCid={}
},_add:function(y,x){x||(x={});
if(!(y instanceof b.Model)){y=new this.model(y,{collection:this})
}var z=this.getByCid(y);
if(z){throw new Error(["Can't add the same model to a set twice",z.id])
}this._byId[y.id]=y;
this._byCid[y.cid]=y;
if(!y.collection){y.collection=this
}var w=this.comparator?this.sortedIndex(y,this.comparator):this.length;
this.models.splice(w,0,y);
y.bind("all",this._onModelEvent);
this.length++;
if(!x.silent){y.trigger("add",y,this,x)
}return y
},_remove:function(x,w){w||(w={});
x=this.getByCid(x)||this.get(x);
if(!x){return null
}delete this._byId[x.id];
delete this._byCid[x.cid];
this.models.splice(this.indexOf(x),1);
this.length--;
if(!w.silent){x.trigger("remove",x,this,w)
}this._removeReference(x);
return x
},_removeReference:function(w){if(this==w.collection){delete w.collection
}w.unbind("all",this._onModelEvent)
},_onModelEvent:function(y,x,z,w){if((y=="add"||y=="remove")&&z!=this){return
}if(y=="destroy"){this._remove(x,w)
}if(y==="change:"+x.idAttribute){delete this._byId[x.previous(x.idAttribute)];
this._byId[x.id]=x
}this.trigger.apply(this,arguments)
}});
var t=["forEach","each","map","reduce","reduceRight","find","detect","filter","select","reject","every","all","some","any","include","invoke","max","min","sortBy","sortedIndex","toArray","size","first","rest","last","without","indexOf","lastIndexOf","isEmpty"];
v.each(t,function(w){b.Collection.prototype[w]=function(){return v[w].apply(v,[this.models].concat(v.toArray(arguments)))
}
});
b.Controller=function(w){w||(w={});
if(w.routes){this.routes=w.routes
}this._bindRoutes();
this.initialize(w)
};
var g=/:([\w\d]+)/g;
var u=/\*([\w\d]+)/g;
var d=/[-[\]{}()+?.,\\^$|#\s]/g;
v.extend(b.Controller.prototype,b.Events,{initialize:function(){},route:function(w,x,y){b.history||(b.history=new b.History);
if(!v.isRegExp(w)){w=this._routeToRegExp(w)
}b.history.route(w,v.bind(function(A){var z=this._extractParameters(w,A);
y.apply(this,z);
this.trigger.apply(this,["route:"+x].concat(z))
},this))
},saveLocation:function(w){b.history.saveLocation(w)
},_bindRoutes:function(){if(!this.routes){return
}var x=[];
for(var y in this.routes){x.unshift([y,this.routes[y]])
}for(var z=0,w=x.length;
z<w;
z++){this.route(x[z][0],x[z][1],this[x[z][1]])
}},_routeToRegExp:function(w){w=w.replace(d,"\\$&").replace(g,"([^/]*)").replace(u,"(.*?)");
return new RegExp("^"+w+"$")
},_extractParameters:function(w,x){return w.exec(x).slice(1)
}});
b.History=function(){this.handlers=[];
this.fragment=this.getFragment();
v.bindAll(this,"checkUrl")
};
var k=/^#*/;
var i=false;
v.extend(b.History.prototype,{interval:50,getFragment:function(w){return(w||window.location).hash.replace(k,"")
},start:function(){if(i){throw new Error("Backbone.history has already been started")
}var w=document.documentMode;
var x=(e.browser.msie&&(!w||w<=7));
if(x){this.iframe=e('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow
}if("onhashchange" in window&&!x){e(window).bind("hashchange",this.checkUrl)
}else{setInterval(this.checkUrl,this.interval)
}i=true;
return this.loadUrl()
},route:function(w,x){this.handlers.unshift({route:w,callback:x})
},checkUrl:function(){var w=this.getFragment();
if(w==this.fragment&&this.iframe){w=this.getFragment(this.iframe.location)
}if(w==this.fragment||w==decodeURIComponent(this.fragment)){return false
}if(this.iframe){window.location.hash=this.iframe.location.hash=w
}this.loadUrl()
},loadUrl:function(){var x=this.fragment=this.getFragment();
var w=v.any(this.handlers,function(y){if(y.route.test(x)){y.callback(x);
return true
}});
return w
},saveLocation:function(w){w=(w||"").replace(k,"");
if(this.fragment==w){return
}window.location.hash=this.fragment=w;
if(this.iframe&&(w!=this.getFragment(this.iframe.location))){this.iframe.document.open().close();
this.iframe.location.hash=w
}}});
b.View=function(w){this.cid=v.uniqueId("view");
this._configure(w||{});
this._ensureElement();
this.delegateEvents();
this.initialize(w)
};
var j=function(w){return e(w,this.el)
};
var a=/^(\w+)\s*(.*)$/;
var r=["model","collection","el","id","attributes","className","tagName"];
v.extend(b.View.prototype,b.Events,{tagName:"div",$:j,initialize:function(){},render:function(){return this
},remove:function(){e(this.el).remove();
return this
},make:function(x,w,z){var y=document.createElement(x);
if(w){e(y).attr(w)
}if(z){e(y).html(z)
}return y
},delegateEvents:function(B){if(!(B||(B=this.events))){return
}e(this.el).unbind(".delegateEvents"+this.cid);
for(var A in B){var y=B[A];
var z=A.match(a);
var x=z[1],w=z[2];
var C=v.bind(this[y],this);
x+=".delegateEvents"+this.cid;
if(w===""){e(this.el).bind(x,C)
}else{e(this.el).delegate(w,x,C)
}}},_configure:function(y){if(this.options){y=v.extend({},this.options,y)
}for(var z=0,x=r.length;
z<x;
z++){var w=r[z];
if(y[w]){this[w]=y[w]
}}this.options=y
},_ensureElement:function(){if(!this.el){var w=this.attributes||{};
if(this.id){w.id=this.id
}if(this.className){w["class"]=this.className
}this.el=this.make(this.tagName,w)
}else{if(v.isString(this.el)){this.el=e(this.el).get(0)
}}}});
var s=function(w,x){var y=h(this,w,x);
y.extend=this.extend;
return y
};
b.Model.extend=b.Collection.extend=b.Controller.extend=b.View.extend=s;
var p={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};
b.sync=function(A,x,w){var y=p[A];
var z=v.extend({type:y,contentType:"application/json",dataType:"json",processData:false},w);
if(!z.url){z.url=o(x)||q()
}if(!z.data&&x&&(A=="create"||A=="update")){z.data=JSON.stringify(x.toJSON())
}if(b.emulateJSON){z.contentType="application/x-www-form-urlencoded";
z.processData=true;
z.data=z.data?{model:z.data}:{}
}if(b.emulateHTTP){if(y==="PUT"||y==="DELETE"){if(b.emulateJSON){z.data._method=y
}z.type="POST";
z.beforeSend=function(B){B.setRequestHeader("X-HTTP-Method-Override",y)
}
}}e.ajax(z)
};
var f=function(){};
var h=function(x,w,y){var z;
if(w&&w.hasOwnProperty("constructor")){z=w.constructor
}else{z=function(){return x.apply(this,arguments)
}
}v.extend(z,x);
f.prototype=x.prototype;
z.prototype=new f();
if(w){v.extend(z.prototype,w)
}if(y){v.extend(z,y)
}z.prototype.constructor=z;
z.__super__=x.prototype;
return z
};
var o=function(w){if(!(w&&w.url)){return null
}return v.isFunction(w.url)?w.url():w.url
};
var q=function(){throw new Error("A 'url' property or function must be specified")
};
var c=function(y,x,w){return function(z){if(y){y(x,z,w)
}else{x.trigger("error",x,z,w)
}}
};
var l=function(w){return w.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")
}
}).call(this);(function(b){var a={};
b.publish=function(d,c){a[d]&&b.each(a[d],function(){this.apply(b,c||[])
})
};
b.subscribe=function(c,d){if(!a[c]){a[c]=[]
}a[c].push(d);
return[c,d]
};
b.unsubscribe=function(d){var c=d[0];
a[c]&&b.each(a[c],function(e){if(this==d[1]){a[c].splice(e,1)
}})
}
})(jQuery);
