var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)d=rep[c],typeof d=="string"&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a){return a<10?"0"+a:a}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(b&&typeof b!="function"&&(typeof b!="object"||typeof b.length!="number"))throw new Error("JSON.stringify");return str("",{"":a})}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")})}();try{console.log("testing for console")}catch(e){window.console={log:function(){}}}var handlebars=function(){var a={trace:function(){},yy:{},symbols_:{error:2,root:3,program:4,EOF:5,statements:6,simpleInverse:7,statement:8,openInverse:9,closeBlock:10,openBlock:11,mustache:12,partial:13,CONTENT:14,COMMENT:15,OPEN_BLOCK:16,inMustache:17,CLOSE:18,OPEN_INVERSE:19,OPEN_ENDBLOCK:20,path:21,OPEN:22,OPEN_UNESCAPED:23,OPEN_PARTIAL:24,params:25,hash:26,param:27,STRING:28,INTEGER:29,BOOLEAN:30,hashSegments:31,hashSegment:32,ID:33,EQUALS:34,pathSegments:35,SEP:36,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",28:"STRING",29:"INTEGER",30:"BOOLEAN",33:"ID",34:"EQUALS",36:"SEP"},productions_:[0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[25,2],[25,1],[27,1],[27,1],[27,1],[27,1],[26,1],[31,2],[31,1],[32,3],[32,3],[32,3],[32,3],[21,1],[35,3],[35,1]],performAction:function(a,b,c,d,e,f,g){var h=f.length-1;switch(e){case 1:return f[h-1];case 2:this.$=new d.ProgramNode(f[h-2],f[h]);break;case 3:this.$=new d.ProgramNode(f[h]);break;case 4:this.$=new d.ProgramNode([]);break;case 5:this.$=[f[h]];break;case 6:f[h-1].push(f[h]),this.$=f[h-1];break;case 7:this.$=new d.InverseNode(f[h-2],f[h-1],f[h]);break;case 8:this.$=new d.BlockNode(f[h-2],f[h-1],f[h]);break;case 9:this.$=f[h];break;case 10:this.$=f[h];break;case 11:this.$=new d.ContentNode(f[h]);break;case 12:this.$=new d.CommentNode(f[h]);break;case 13:this.$=new d.MustacheNode(f[h-1][0],f[h-1][1]);break;case 14:this.$=new d.MustacheNode(f[h-1][0],f[h-1][1]);break;case 15:this.$=f[h-1];break;case 16:this.$=new d.MustacheNode(f[h-1][0],f[h-1][1]);break;case 17:this.$=new d.MustacheNode(f[h-1][0],f[h-1][1],!0);break;case 18:this.$=new d.PartialNode(f[h-1]);break;case 19:this.$=new d.PartialNode(f[h-2],f[h-1]);break;case 20:break;case 21:this.$=[[f[h-2]].concat(f[h-1]),f[h]];break;case 22:this.$=[[f[h-1]].concat(f[h]),null];break;case 23:this.$=[[f[h-1]],f[h]];break;case 24:this.$=[[f[h]],null];break;case 25:f[h-1].push(f[h]),this.$=f[h-1];break;case 26:this.$=[f[h]];break;case 27:this.$=f[h];break;case 28:this.$=new d.StringNode(f[h]);break;case 29:this.$=new d.IntegerNode(f[h]);break;case 30:this.$=new d.BooleanNode(f[h]);break;case 31:this.$=new d.HashNode(f[h]);break;case 32:f[h-1].push(f[h]),this.$=f[h-1];break;case 33:this.$=[f[h]];break;case 34:this.$=[f[h-2],f[h]];break;case 35:this.$=[f[h-2],new d.StringNode(f[h])];break;case 36:this.$=[f[h-2],new d.IntegerNode(f[h])];break;case 37:this.$=[f[h-2],new d.BooleanNode(f[h])];break;case 38:this.$=new d.IdNode(f[h]);break;case 39:f[h-2].push(f[h]),this.$=f[h-2];break;case 40:this.$=[f[h]]}},table:[{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,33:[1,25],35:24},{17:26,21:23,33:[1,25],35:24},{17:27,21:23,33:[1,25],35:24},{17:28,21:23,33:[1,25],35:24},{21:29,33:[1,25],35:24},{1:[2,1]},{6:30,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,31],21:23,33:[1,25],35:24},{10:32,20:[1,33]},{10:34,20:[1,33]},{18:[1,35]},{18:[2,24],21:40,25:36,26:37,27:38,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,38],28:[2,38],29:[2,38],30:[2,38],33:[2,38],36:[1,46]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],36:[2,40]},{18:[1,47]},{18:[1,48]},{18:[1,49]},{18:[1,50],21:51,33:[1,25],35:24},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:52,33:[1,25],35:24},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:40,26:53,27:54,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,23]},{18:[2,26],28:[2,26],29:[2,26],30:[2,26],33:[2,26]},{18:[2,31],32:55,33:[1,56]},{18:[2,27],28:[2,27],29:[2,27],30:[2,27],33:[2,27]},{18:[2,28],28:[2,28],29:[2,28],30:[2,28],33:[2,28]},{18:[2,29],28:[2,29],29:[2,29],30:[2,29],33:[2,29]},{18:[2,30],28:[2,30],29:[2,30],30:[2,30],33:[2,30]},{18:[2,33],33:[2,33]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],34:[1,57],36:[2,40]},{33:[1,58]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,59]},{18:[1,60]},{18:[2,21]},{18:[2,25],28:[2,25],29:[2,25],30:[2,25],33:[2,25]},{18:[2,32],33:[2,32]},{34:[1,57]},{21:61,28:[1,62],29:[1,63],30:[1,64],33:[1,25],35:24},{18:[2,39],28:[2,39],29:[2,39],30:[2,39],33:[2,39],36:[2,39]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{18:[2,34],33:[2,34]},{18:[2,35],33:[2,35]},{18:[2,36],33:[2,36]},{18:[2,37],33:[2,37]}],defaultActions:{16:[2,1],37:[2,23],53:[2,21]},parseError:function(a,b){throw new Error(a)},parse:function(a){function o(){var a;a=b.lexer.lex()||1,typeof a!="number"&&(a=b.symbols_[a]||a);return a}function n(a){c.length=c.length-2*a,d.length=d.length-a,e.length=e.length-a}var b=this,c=[0],d=[null],e=[],f=this.table,g="",h=0,i=0,j=0,k=2,l=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var m=this.lexer.yylloc;e.push(m),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var p,q,r,s,t,u,v={},w,x,y,z;for(;;){r=c[c.length-1],this.defaultActions[r]?s=this.defaultActions[r]:(p==null&&(p=o()),s=f[r]&&f[r][p]);if(typeof s=="undefined"||!s.length||!s[0]){if(!j){z=[];for(w in f[r])this.terminals_[w]&&w>2&&z.push("'"+this.terminals_[w]+"'");var A="";this.lexer.showPosition?A="Parse error on line "+(h+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+z.join(", "):A="Parse error on line "+(h+1)+": Unexpected "+(p==1?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(A,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:m,expected:z})}if(j==3){if(p==l)throw new Error(A||"Parsing halted.");i=this.lexer.yyleng,g=this.lexer.yytext,h=this.lexer.yylineno,m=this.lexer.yylloc,p=o()}for(;;){if(k.toString()in f[r])break;if(r==0)throw new Error(A||"Parsing halted.");n(1),r=c[c.length-1]}q=p,p=k,r=c[c.length-1],s=f[r]&&f[r][k],j=3}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:c.push(p),d.push(this.lexer.yytext),e.push(this.lexer.yylloc),c.push(s[1]),p=null,q?(p=q,q=null):(i=this.lexer.yyleng,g=this.lexer.yytext,h=this.lexer.yylineno,m=this.lexer.yylloc,j>0&&j--);break;case 2:x=this.productions_[s[1]][1],v.$=d[d.length-x],v._$={first_line:e[e.length-(x||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(x||1)].first_column,last_column:e[e.length-1].last_column},u=this.performAction.call(v,g,i,h,this.yy,s[1],d,e);if(typeof u!="undefined")return u;x&&(c=c.slice(0,-1*x*2),d=d.slice(0,-1*x),e=e.slice(0,-1*x)),c.push(this.productions_[s[1]][0]),d.push(v.$),e.push(v._$),y=f[c[c.length-2]][c[c.length-1]],c.push(y);break;case 3:return!0}}return!0}},f=function(){var a={EOF:1,parseError:function(a,b){if(this.yy.parseError)this.yy.parseError(a,b);else throw new Error(a)},setInput:function(a){this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};return this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.match+=a,this.matched+=a;var b=a.match(/\n/);b&&this.yylineno++,this._input=this._input.slice(1);return a},unput:function(a){this._input=a+this._input;return this},more:function(){this._more=!0;return this},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;a.length<20&&(a+=this._input.substr(0,20-a.length));return(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");var e=this._currentRules();for(var f=0;f<e.length;f++){b=this._input.match(this.rules[e[f]]);if(b){d=b[0].match(/\n.*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-1:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.matches=b,this.yyleng=this.yytext.length,this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,e[f],this.conditionStack[this.conditionStack.length-1]);if(a)return a;return}}if(this._input==="")return this.EOF;this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return typeof a!="undefined"?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules}};a.performAction=function(a,b,c,d){var e=d;switch(c){case 0:this.begin("mu");if(b.yytext)return 14;break;case 1:return 14;case 2:return 24;case 3:return 16;case 4:return 20;case 5:return 19;case 6:return 19;case 7:return 23;case 8:return 23;case 9:b.yytext=b.yytext.substr(3,b.yyleng-5),this.begin("INITIAL");return 15;case 10:return 22;case 11:return 34;case 12:return 33;case 13:return 33;case 14:return 36;case 15:break;case 16:this.begin("INITIAL");return 18;case 17:this.begin("INITIAL");return 18;case 18:b.yytext=b.yytext.substr(1,b.yyleng-2).replace(/\\"/g,'"');return 28;case 19:return 30;case 20:return 30;case 21:return 29;case 22:return 33;case 23:return"INVALID";case 24:return 5}},a.rules=[/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s/.])/,/^./,/^$/],a.conditions={mu:{rules:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],inclusive:!1},INITIAL:{rules:[0,1,24],inclusive:!0}};return a}();a.lexer=f;return a}();typeof require!="undefined"&&typeof exports!="undefined"&&(exports.parser=handlebars,exports.parse=function(){return handlebars.parse.apply(handlebars,arguments)},exports.main=function(a){if(!a[1])throw new Error("Usage: "+a[0]+" FILE");if(typeof process!="undefined")var b=require("fs").readFileSync(require("path").join(process.cwd(),a[1]),"utf8");else var c=require("file").path(require("file").cwd()),b=c.join(a[1]).read({charset:"utf-8"});return exports.parser.parse(b)},typeof module!="undefined"&&require.main===module&&exports.main(typeof process!="undefined"?process.argv.slice(1):require("system").args));var Handlebars={};Handlebars.VERSION="1.0.beta.2",Handlebars.Parser=handlebars,Handlebars.parse=function(a){Handlebars.Parser.yy=Handlebars.AST;return Handlebars.Parser.parse(a)},Handlebars.print=function(a){return(new Handlebars.PrintVisitor).accept(a)},Handlebars.helpers={},Handlebars.partials={},Handlebars.registerHelper=function(a,b,c){c&&(b.not=c),this.helpers[a]=b},Handlebars.registerPartial=function(a,b){this.partials[a]=b},Handlebars.registerHelper("helperMissing",function(a){if(arguments.length===2)return undefined;throw new Error("Could not find property '"+a+"'")}),Handlebars.registerHelper("blockHelperMissing",function(a,b,c){c=c||function(){};var d="",e=Object.prototype.toString.call(a);e==="[object Function]"&&(a=a());if(a===!0)return b(this);if(a===!1||a==null)return c(this);if(e==="[object Array]"){if(a.length>0)for(var f=0,g=a.length;f<g;f++)d=d+b(a[f]);else d=c(this);return d}return b(a)},function(a,b){return b(a)}),Handlebars.registerHelper("each",function(a,b,c){var d="";if(a&&a.length>0)for(var e=0,f=a.length;e<f;e++)d=d+b(a[e]);else d=c(this);return d}),Handlebars.registerHelper("if",function(a,b,c){return!a||a==[]?c(this):b(this)}),Handlebars.registerHelper("unless",function(a,b,c){return Handlebars.helpers["if"].call(this,a,c,b)}),Handlebars.registerHelper("with",function(a,b){return b(a)}),Handlebars.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(a,b){}},Handlebars.log=function(a,b){Handlebars.logger.log(a,b)},function(){Handlebars.AST={},Handlebars.AST.ProgramNode=function(a,b){this.type="program",this.statements=a,b&&(this.inverse=new Handlebars.AST.ProgramNode(b))},Handlebars.AST.MustacheNode=function(a,b,c){this.type="mustache",this.id=a[0],this.params=a.slice(1),this.hash=b,this.escaped=!c},Handlebars.AST.PartialNode=function(a,b){this.type="partial",this.id=a,this.context=b};var a=function(a,b){if(a.original!==b.original)throw new Handlebars.Exception(a.original+" doesn't match "+b.original)};Handlebars.AST.BlockNode=function(b,c,d){a(b.id,d),this.type="block",this.mustache=b,this.program=c},Handlebars.AST.InverseNode=function(b,c,d){a(b.id,d),this.type="inverse",this.mustache=b,this.program=c},Handlebars.AST.ContentNode=function(a){this.type="content",this.string=a},Handlebars.AST.HashNode=function(a){this.type="hash",this.pairs=a},Handlebars.AST.IdNode=function(a){this.type="ID",this.original=a.join(".");var b=[],c=0;for(var d=0,e=a.length;d<e;d++){var f=a[d];if(f==="..")c++;else{if(f==="."||f==="this")continue;b.push(f)}}this.parts=b,this.string=b.join("."),this.depth=c,this.isSimple=b.length===1&&c===0},Handlebars.AST.StringNode=function(a){this.type="STRING",this.string=a},Handlebars.AST.IntegerNode=function(a){this.type="INTEGER",this.integer=a},Handlebars.AST.BooleanNode=function(a){this.type="BOOLEAN",this.boolean=a},Handlebars.AST.CommentNode=function(a){this.type="comment",this.comment=a}}(),Handlebars.Visitor=function(){},Handlebars.Visitor.prototype={accept:function(a){return this[a.type](a)}},Handlebars.Exception=function(a){this.message=a},Handlebars.SafeString=function(a){this.string=a},Handlebars.SafeString.prototype.toString=function(){return this.string.toString()},function(){var a={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},b=/&(?!\w+;)|[<>"'`]/g,c=/[&<>"'`]/,d=function(b){return a[b]||"&amp;"};Handlebars.Utils={escapeExpression:function(a){if(a instanceof Handlebars.SafeString)return a.toString();if(a==null||a===!1)return"";if(!c.test(a))return a;return a.replace(b,d)},isEmpty:function(a){return typeof a=="undefined"?!0:a===null?!0:a===!1?!0:Object.prototype.toString.call(a)==="[object Array]"&&a.length===0?!0:!1}}}(),Handlebars.Compiler=function(){},Handlebars.JavaScriptCompiler=function(){},function(a,b){a.OPCODE_MAP={appendContent:1,getContext:2,lookupWithHelpers:3,lookup:4,append:5,invokeMustache:6,appendEscaped:7,pushString:8,truthyOrFallback:9,functionOrFallback:10,invokeProgram:11,invokePartial:12,push:13,invokeInverse:14,assignToHash:15,pushStringParam:16},a.MULTI_PARAM_OPCODES={appendContent:1,getContext:1,lookupWithHelpers:1,lookup:1,invokeMustache:2,pushString:1,truthyOrFallback:1,functionOrFallback:1,invokeProgram:2,invokePartial:1,push:1,invokeInverse:1,assignToHash:1,pushStringParam:1},a.DISASSEMBLE_MAP={};for(var c in a.OPCODE_MAP){var d=a.OPCODE_MAP[c];a.DISASSEMBLE_MAP[d]=c}a.multiParamSize=function(b){return a.MULTI_PARAM_OPCODES[a.DISASSEMBLE_MAP[b]]},a.prototype={compiler:a,disassemble:function(){var b=this.opcodes,c,d,e=[],f,g,h;for(var i=0,j=b.length;i<j;i++){c=b[i];if(c==="DECLARE")g=b[++i],h=b[++i],e.push("DECLARE "+g+" = "+h);else{f=a.DISASSEMBLE_MAP[c];var k=a.multiParamSize(c),l=[];for(var m=0;m<k;m++)d=b[++i],typeof d=="string"&&(d='"'+d.replace("\n","\\n")+'"'),l.push(d);f=f+" "+l.join(" "),e.push(f)}}return e.join("\n")},guid:0,compile:function(a,b){this.children=[],this.depths={list:[]},this.options=b||{};return this.program(a)},accept:function(a){return this[a.type](a)},program:function(a){var b=a.statements,c;this.opcodes=[];for(var d=0,e=b.length;d<e;d++)c=b[d],this[c.type](c);this.depths.list=this.depths.list.sort(function(a,b){return a-b});return this},compileProgram:function(a){var b=(new this.compiler).compile(a,this.options),c=this.guid++;this.usePartial=this.usePartial||b.usePartial,this.children[c]=b;for(var d=0,e=b.depths.list.length;d<e;d++){depth=b.depths.list[d];if(depth<2)continue;this.addDepth(depth-1)}return c},block:function(a){var b=a.mustache,c,d,e,f,g=this.setupStackForMustache(b),h=this.compileProgram(a.program);a.program.inverse&&(f=this.compileProgram(a.program.inverse),this.declare("inverse",f)),this.opcode("invokeProgram",h,g.length),this.declare("inverse",null),this.opcode("append")},inverse:function(a){this.ID(a.mustache.id);var b=this.compileProgram(a.program);this.opcode("invokeInverse",b),this.opcode("append")},hash:function(a){var b=a.pairs,c,d;this.opcode("push","{}");for(var e=0,f=b.length;e<f;e++)c=b[e],d=c[1],this.accept(d),this.opcode("assignToHash",c[0])},partial:function(a){var b=a.id;this.usePartial=!0,a.context?this.ID(a.context):this.opcode("push","context"),this.opcode("invokePartial",b.original),this.opcode("append")},content:function(a){this.opcode("appendContent",a.string)},mustache:function(a){var b=this.setupStackForMustache(a);this.opcode("invokeMustache",b.length,a.id.original),a.escaped?this.opcode("appendEscaped"):this.opcode("append")},ID:function(a){this.addDepth(a.depth),this.opcode("getContext",a.depth),this.opcode("lookupWithHelpers",a.parts[0]||null);for(var b=1,c=a.parts.length;b<c;b++)this.opcode("lookup",a.parts[b])},STRING:function(a){this.opcode("pushString",a.string)},INTEGER:function(a){this.opcode("push",a.integer)},BOOLEAN:function(a){this.opcode("push",a.boolean)},comment:function(){},pushParams:function(a){var b=a.length,c;while(b--)c=a[b],this.options.stringParams?(c.depth&&this.addDepth(c.depth),this.opcode("getContext",c.depth||0),this.opcode("pushStringParam",c.string)):this[c.type](c)},opcode:function(b,c,d){this.opcodes.push(a.OPCODE_MAP[b]),c!==undefined&&this.opcodes.push(c),d!==undefined&&this.opcodes.push(d)},declare:function(a,b){this.opcodes.push("DECLARE"),this.opcodes.push(a),this.opcodes.push(b)},addDepth:function(a){a!==0&&(this.depths[a]||(this.depths[a]=!0,this.depths.list.push(a)))},setupStackForMustache:function(a){var b=a.params;this.pushParams(b),a.hash?this.hash(a.hash):this.opcode("push","{}"),this.ID(a.id);return b}},b.prototype={nameLookup:function(a,c,d){return b.RESERVED_WORDS[c]||c.indexOf("-")!==-1||!isNaN(c)?a+"['"+c+"']":/^[0-9]+$/.test(c)?a+"["+c+"]":a+"."+c},appendToBuffer:function(a){return"buffer = buffer + "+a+";"},initializeBuffer:function(){return this.quotedString("")},compile:function(a,b){this.environment=a,this.options=b||{},this.preamble(),this.stackSlot=0,this.stackVars=[],this.registers={list:[]},this.compileChildren(a,b),Handlebars.log(Handlebars.logger.DEBUG,a.disassemble()+"\n\n");var c=a.opcodes,d,e,f,h;this.i=0;for(g=c.length;this.i<g;this.i++)d=this.nextOpcode(0),d[0]==="DECLARE"?(this.i=this.i+2,this[d[1]]=d[2]):(this.i=this.i+d[1].length,this[d[0]].apply(this,d[1]));return this.createFunction()},nextOpcode:function(b){var c=this.environment.opcodes,d=c[this.i+b],e,f,g,h;if(d==="DECLARE"){e=c[this.i+1],f=c[this.i+2];return["DECLARE",e,f]}e=a.DISASSEMBLE_MAP[d],g=a.multiParamSize(d),h=[];for(var i=0;i<g;i++)h.push(c[this.i+i+1+b]);return[e,h]},eat:function(a){this.i=this.i+a.length},preamble:function(){var a=[];a.push("var buffer = "+this.initializeBuffer()+", currentContext = context");var b="helpers = helpers || Handlebars.helpers;";this.environment.usePartial&&(b=b+" partials = partials || Handlebars.partials;"),a.push(b),this.lastContext=0,this.source=a},createFunction:function(){var a={escapeExpression:Handlebars.Utils.escapeExpression,invokePartial:Handlebars.VM.invokePartial,programs:[],program:function(a,b,c,d){var e=this.programs[a];if(d)return Handlebars.VM.program(this.children[a],b,c,d);if(e)return e;e=this.programs[a]=Handlebars.VM.program(this.children[a],b,c);return e},programWithDepth:Handlebars.VM.programWithDepth,noop:Handlebars.VM.noop},b=this.stackVars.concat(this.registers.list);b.length>0&&(this.source[0]=this.source[0]+", "+b.join(", ")),this.source[0]=this.source[0]+";",this.source.push("return buffer;");var c=["Handlebars","context","helpers","partials"];this.options.data&&c.push("data");for(var d=0,e=this.environment.depths.list.length;d<e;d++)c.push("depth"+this.environment.depths.list[d]);c.length===4&&!this.environment.usePartial&&c.pop(),c.push(this.source.join("\n"));var f=Function.apply(this,c);f.displayName="Handlebars.js",Handlebars.log(Handlebars.logger.DEBUG,f.toString()+"\n\n"),a.render=f,a.children=this.environment.children;return function(b,c,d){try{c=c||{};var e=[Handlebars,b,c.helpers,c.partials,c.data],f=Array.prototype.slice.call(arguments,2);e=e.concat(f);return a.render.apply(a,e)}catch(g){throw g}}},appendContent:function(a){this.source.push(this.appendToBuffer(this.quotedString(a)))},append:function(){var a=this.popStack();this.source.push("if("+a+" || "+a+" === 0) { "+this.appendToBuffer(a)+" }")},appendEscaped:function(){var a=this.nextOpcode(1),b="";a[0]==="appendContent"&&(b=" + "+this.quotedString(a[1][0]),this.eat(a)),this.source.push(this.appendToBuffer("this.escapeExpression("+this.popStack()+")"+b))},getContext:function(a){this.lastContext!==a&&(this.lastContext=a,a===0?this.source.push("currentContext = context;"):this.source.push("currentContext = depth"+a+";"))},lookupWithHelpers:function(a){if(a){var b=this.nextStack(),c="if('"+a+"' in helpers) { "+b+" = "+this.nameLookup("helpers",a,"helper")+"; } else { "+b+" = "+this.nameLookup("currentContext",a,"context")+"; }";this.source.push(c)}else this.pushStack("currentContext")},lookup:function(a){var b=this.topStack();this.source.push(b+" = "+this.nameLookup(b,a,"context")+";")},pushStringParam:function(a){this.pushStack("currentContext"),this.pushString(a)},pushString:function(a){this.pushStack(this.quotedString(a))},push:function(a){this.pushStack(a)},invokeMustache:function(a,b){this.populateParams(a,this.quotedString(b),"{}",null,function(a,b,c){this.source.push("else if("+c+"=== undefined) { "+a+" = helpers.helperMissing.call("+b+"); }"),this.source.push("else { "+a+" = "+c+"; }")})},invokeProgram:function(a,b){var c=this.programExpression(this.inverse),d=this.programExpression(a);this.populateParams(b,null,d,c,function(a,b,c){this.source.push("else { "+a+" = helpers.blockHelperMissing.call("+b+"); }")})},populateParams:function(a,b,c,d,e){var f=this.popStack(),g,h=[],i,j,k=this.popStack();this.register("tmp1",c),this.source.push("tmp1.hash = "+k+";"),this.options.stringParams&&this.source.push("tmp1.contexts = [];");for(var l=0;l<a;l++)i=this.popStack(),h.push(i),this.options.stringParams&&this.source.push("tmp1.contexts.push("+this.popStack()+");");d&&(this.source.push("tmp1.fn = tmp1;"),this.source.push("tmp1.inverse = "+d+";")),this.options.data&&this.source.push("tmp1.data = data;"),h.push("tmp1"),d&&h.push(d),this.populateCall(h,f,b||f,e)},populateCall:function(a,b,c,d){var e=["context"].concat(a).join(", "),f=["context"].concat(c).concat(a).join(", ");nextStack=this.nextStack(),this.source.push("if(typeof "+b+" === 'function') { "+nextStack+" = "+b+".call("+e+"); }"),d.call(this,nextStack,f,b)},invokeInverse:function(a){var b=this.programExpression(a),c=["context",this.topStack(),"this.noop",b];this.pushStack("helpers.blockHelperMissing.call("+c.join(", ")+")")},invokePartial:function(a){this.pushStack("this.invokePartial("+this.nameLookup("partials",a,"partial")+", '"+a+"', "+this.popStack()+", helpers, partials);")},assignToHash:function(a){var b=this.popStack(),c=this.topStack();this.source.push(c+"['"+a+"'] = "+b+";")},compiler:b,compileChildren:function(a,b){var c=a.children,d,e,f=[];for(var g=0,h=c.length;g<h;g++)d=c[g],e=new this.compiler,f[g]=e.compile(d,b);a.rawChildren=c,a.children=f},programExpression:function(a){if(a==null)return"this.noop";var b=[a,"helpers","partials"],c=this.environment.rawChildren[a].depths.list;this.options.data&&b.push("data");for(var d=0,e=c.length;d<e;d++)depth=c[d],depth===1?b.push("context"):b.push("depth"+(depth-1));this.environment.usePartial||(b[3]?b[2]="null":b.pop());if(c.length===0)return"this.program("+b.join(", ")+")";b[0]="this.children["+a+"]";return"this.programWithDepth("+b.join(", ")+")"},register:function(a,b){this.useRegister(a),this.source.push(a+" = "+b+";")},useRegister:function(a){this.registers[a]||(this.registers[a]=!0,this.registers.list.push(a))},pushStack:function(a){this.source.push(this.nextStack()+" = "+a+";");return"stack"+this.stackSlot},nextStack:function(){this.stackSlot++,this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot);return"stack"+this.stackSlot},popStack:function(){return"stack"+this.stackSlot--},topStack:function(){return"stack"+this.stackSlot},quotedString:function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")+'"'}};var e="break case catch continue default delete do else finally for function if in instanceof new return switch this throw try typeof var void while with null true false".split(" ");compilerWords=b.RESERVED_WORDS={};for(var f=0,g=e.length;f<g;f++)compilerWords[e[f]]=!0}(Handlebars.Compiler,Handlebars.JavaScriptCompiler),Handlebars.VM={programWithDepth:function(a,b,c,d,e){var f=Array.prototype.slice.call(arguments,4);return function(e,g){g=g||{},g={helpers:g.helpers||b,partials:g.partials||c,data:g.data||d};return a.apply(this,[e,g].concat(f))}},program:function(a,b,c,d){return function(e,f){f=f||{};return a(e,{helpers:f.helpers||b,partials:f.partials||c,data:f.data||d})}},noop:function(){return""},compile:function(a,b){var c=Handlebars.parse(a),d=(new Handlebars.Compiler).compile(c,b);return(new Handlebars.JavaScriptCompiler).compile(d,b)},invokePartial:function(a,b,c,d,e){if(a===undefined)throw new Handlebars.Exception("The partial "+b+" could not be found");if(a instanceof Function)return a(c,{helpers:d,partials:e});e[b]=Handlebars.VM.compile(a);return e[b](c,{helpers:d,partials:e})}},Handlebars.compile=Handlebars.VM.compile,Template={cache:{}},Template.get=function(a,b){b(null,Template.cache[a])},Template.getSync=function(a,b){return Template.cache[a]},Template.addTemplate=function(a,b){if(Template[a])throw"Can't add a template with reserved name: "+a+".";if(Template.cache.hasOwnProperty(a))throw"You've already got a template by the name: \""+a+'"';Template.cache[a]=Handlebars.compile(b)},Template.cacheTemplates=function(){$('script[type="text/html"]').each(function(){var a=$(this),b=a.attr("id"),c=$.trim(a.html()),d=a.attr("class").toLowerCase()==="partial";d?Handlebars.addPartial(b,c):Template.addTemplate(b,c)})},$(function(){Template.cacheTemplates()}),Handlebars.registerHelper("view",function(a,b){var c=b.hash;c.parent=this.parent;var d=new a(c);c.parent.children.push(d);return new Handlebars.SafeString(d.getHTML())}),function(){var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=d.slice,g=d.unshift,h=e.toString,i=e.hasOwnProperty,j=d.forEach,k=d.map,l=d.reduce,m=d.reduceRight,n=d.filter,o=d.every,p=d.some,q=d.indexOf,r=d.lastIndexOf,s=Array.isArray,t=Object.keys,u=function(a){return new z(a)};typeof module!="undefined"&&module.exports?(module.exports=u,u._=u):a._=u,u.VERSION="1.1.3";var v=u.each=u.forEach=function(a,b,d){var e;if(a!=null)if(j&&a.forEach===j)a.forEach(b,d);else if(u.isNumber(a.length)){for(var f=0,g=a.length;f<g;f++)if(b.call(d,a[f],f,a)===c)return}else for(var h in a)if(i.call(a,h)&&b.call(d,a[h],h,a)===c)return};u.map=function(a,b,c){var d=[];if(a==null)return d;if(k&&a.map===k)return a.map(b,c);v(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)});return d},u.reduce=u.foldl=u.inject=function(a,b,c,d){var e=c!==void 0;a==null&&(a=[]);if(l&&a.reduce===l){d&&(b=u.bind(b,d));return e?a.reduce(b,c):a.reduce(b)}v(a,function(a,f,g){!e&&f===0?(c=a,e=!0):c=b.call(d,c,a,f,g)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},u.reduceRight=u.foldr=function(a,b,c,d){a==null&&(a=[]);if(m&&a.reduceRight===m){d&&(b=u.bind(b,d));return c!==void 0?a.reduceRight(b,c):a.reduceRight(b)}var e=(u.isArray(a)?a.slice():u.toArray(a)).reverse();return u.reduce(e,b,c,d)},u.find=u.detect=function(a,b,c){var d;w(a,function(a,e,f){if(b.call(c,a,e,f)){d=a;return!0}});return d},u.filter=u.select=function(a,b,c){var d=[];if(a==null)return d;if(n&&a.filter===n)return a.filter(b,c);v(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)});return d},u.reject=function(a,b,c){var d=[];if(a==null)return d;v(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)});return d},u.every=u.all=function(a,b,d){b=b||u.identity;var e=!0;if(a==null)return e;if(o&&a.every===o)return a.every(b,d);v(a,function(a,f,g){if(!(e=e&&b.call(d,a,f,g)))return c});return e};var w=u.some=u.any=function(a,b,d){b=b||u.identity;var e=!1;if(a==null)return e;if(p&&a.some===p)return a.some(b,d);v(a,function(a,f,g){if(e=b.call(d,a,f,g))return c});return e};u.include=u.contains=function(a,b){var c=!1;if(a==null)return c;if(q&&a.indexOf===q)return a.indexOf(b)!=-1;w(a,function(a){if(c=a===b)return!0});return c},u.invoke=function(a,b){var c=f.call(arguments,2);return u.map(a,function(a){return(b?a[b]:a).apply(a,c)})},u.pluck=function(a,b){return u.map(a,function(a){return a[b]})},u.max=function(a,b,c){if(!b&&u.isArray(a))return Math.max.apply(Math,a);var d={computed:-Infinity};v(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})});return d.value},u.min=function(a,b,c){if(!b&&u.isArray(a))return Math.min.apply(Math,a);var d={computed:Infinity};v(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g<d.computed&&(d={value:a,computed:g})});return d.value},u.sortBy=function(a,b,c){return u.pluck(u.map(a,function(a,d,e){return{value:a,criteria:b.call(c,a,d,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")},u.sortedIndex=function(a,b,c){c=c||u.identity;var d=0,e=a.length;while(d<e){var f=d+e>>1;c(a[f])<c(b)?d=f+1:e=f}return d},u.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(u.isArray(a))return a;if(u.isArguments(a))return f.call(a);return u.values(a)},u.size=function(a){return u.toArray(a).length},u.first=u.head=function(a,b,c){return b&&!c?f.call(a,0,b):a[0]},u.rest=u.tail=function(a,b,c){return f.call(a,u.isUndefined(b)||c?1:b)},u.last=function(a){return a[a.length-1]},u.compact=function(a){return u.filter(a,function(a){return!!a})},u.flatten=function(a){return u.reduce(a,function(a,b){if(u.isArray(b))return a.concat(u.flatten(b));a[a.length]=b;return a},[])},u.without=function(a){var b=f.call(arguments,1);return u.filter(a,function(a){return!u.include(b,a)})},u.uniq=u.unique=function(a,b){return u.reduce(a,function(a,c,d){if(0==d||(b===!0?u.last(a)!=c:!u.include(a,c)))a[a.length]=c;return a},[])},u.intersect=function(a){var b=f.call(arguments,1);return u.filter(u.uniq(a),function(a){return u.every(b,function(b){return u.indexOf(b,a)>=0})})},u.zip=function(){var a=f.call(arguments),b=u.max(u.pluck(a,"length")),c=Array(b);for(var d=0;d<b;d++)c[d]=u.pluck(a,""+d);return c},u.indexOf=function(a,b){if(a==null)return-1;if(q&&a.indexOf===q)return a.indexOf(b);for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},u.lastIndexOf=function(a,b){if(a==null)return-1;if(r&&a.lastIndexOf===r)return a.lastIndexOf(b);var c=a.length;while(c--)if(a[c]===b)return c;return-1},u.range=function(a,b,c){var d=f.call(arguments),e=d.length<=1,a=e?0:d[0],b=e?d[0]:d[1],c=d[2]||1,g=Math.max(Math.ceil((b-a)/c),0),h=0,i=Array(g);while(h<g)i[h++]=a,a+=c;return i},u.bind=function(a,b){var c=f.call(arguments,2);return function(){return a.apply(b||{},c.concat(f.call(arguments)))}},u.bindAll=function(a){var b=f.call(arguments,1);b.length==0&&(b=u.functions(a)),v(b,function(b){a[b]=u.bind(a[b],a)});return a},u.memoize=function(a,b){var c={};b=b||u.identity;return function(){var d=b.apply(this,arguments);return d in c?c[d]:c[d]=a.apply(this,arguments)}},u.delay=function(a,b){var c=f.call(arguments,2);return setTimeout(function(){return a.apply(a,c)},b)},u.defer=function(a){return u.delay.apply(u,[a,1].concat(f.call(arguments,1)))};var x=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d);if(c||!d)d=setTimeout(g,b)}};u.throttle=function(a,b){return x(a,b,!1)},u.debounce=function(a,b){return x(a,b,!0)},u.wrap=function(a,b){return function(){var c=[a].concat(f.call(arguments));return b.apply(b,c)}},u.compose=function(){var a=f.call(arguments);return function(){var b=f.call(arguments);for(var c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},u.keys=t||function(a){if(u.isArray(a))return u.range(0,a.length);var b=[];for(var c in a)i.call(a,c)&&(b[b.length]=c);return b},u.values=function(a){return u.map(a,u.identity)},u.functions=u.methods=function(a){return u.filter(u.keys(a),function(b){return u.isFunction(a[b])}).sort()},u.extend=function(a){v(f.call(arguments,1),function(b){for(var c in b)a[c]=b[c]});return a},u.clone=function(a){return u.isArray(a)?a.slice():u.extend({},a)},u.tap=function(a,b){b(a);return a},u.isEqual=function(a,b){if(a===b)return!0;var c=typeof a,d=typeof b;if(c!=d)return!1;if(a==b)return!0;if(!a&&b||a&&!b)return!1;a._chain&&(a=a._wrapped),b._chain&&(b=b._wrapped);if(a.isEqual)return a.isEqual(b);if(u.isDate(a)&&u.isDate(b))return a.getTime()===b.getTime();if(u.isNaN(a)&&u.isNaN(b))return!1;if(u.isRegExp(a)&&u.isRegExp(b))return a.source===b.source&&a.global===b.global&&a.ignoreCase===b.ignoreCase&&a.multiline===b.multiline;if(c!=="object")return!1;if(a.length&&a.length!==b.length)return!1;var e=u.keys(a),f=u.keys(b);if(e.length!=f.length)return!1;for(var g in a)if(!(g in b)||!u.isEqual(a[g],b[g]))return!1;return!0},u.isEmpty=function(a){if(u.isArray(a)||u.isString(a))return a.length===0;for(var b in a)if(i.call(a,b))return!1;return!0},u.isElement=function(a){return!!a&&a.nodeType==1},u.isArray=s||function(a){return!!(a&&a.concat&&a.unshift&&!a.callee)},u.isArguments=function(a){return!!a&&!!a.callee},u.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},u.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},u.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)},u.isNaN=function(a){return h.call(a)==="[object Number]"&&isNaN(a)},u.isBoolean=function(a){return a===!0||a===!1},u.isDate=function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)},u.isRegExp=function(a){return!(!(a&&a.test&&a.exec)||!a.ignoreCase&&a.ignoreCase!==!1)},u.isNull=function(a){return a===null},u.isUndefined=function(a){return a===void 0},u.noConflict=function(){a._=b;return this},u.identity=function(a){return a},u.times=function(a,b,c){for(var d=0;d<a;d++)b.call(c,d)},u.mixin=function(a){v(u.functions(a),function(b){B(b,u[b]=a[b])})};var y=0;u.uniqueId=function(a){var b=y++;return a?a+b:b},u.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g},u.template=function(a,b){var c=u.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(c.interpolate,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(c.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj",d);return b?e(b):e};var z=function(a){this._wrapped=a};u.prototype=z.prototype;var A=function(a,b){return b?u(a).chain():a},B=function(a,b){z.prototype[a]=function(){var a=f.call(arguments);g.call(a,this._wrapped);return A(b.apply(u,a),this._chain)}};u.mixin(u),v(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];z.prototype[a]=function(){b.apply(this._wrapped,arguments);return A(this._wrapped,this._chain)}}),v(["concat","join","slice"],function(a){var b=d[a];z.prototype[a]=function(){return A(b.apply(this._wrapped,arguments),this._chain)}}),z.prototype.chain=function(){this._chain=!0;return this},z.prototype.value=function(){return this._wrapped}}(),function(){var a=this,b=a.Backbone,c;typeof exports!="undefined"?c=exports:c=a.Backbone={},c.VERSION="0.5.1";var d=a._;!d&&typeof require!="undefined"&&(d=require("underscore")._);var e=a.jQuery||a.Zepto;c.noConflict=function(){a.Backbone=b;return this},c.emulateHTTP=!1,c.emulateJSON=!1,c.Events={bind:function(a,b){var c=this._callbacks||(this._callbacks={}),d=c[a]||(c[a]=[]);d.push(b);return this},unbind:function(a,b){var c;if(!a)this._callbacks={};else if(c=this._callbacks)if(!b)c[a]=[];else{var d=c[a];if(!d)return this;for(var e=0,f=d.length;e<f;e++)if(b===d[e]){d[e]=null;break}}return this},trigger:function(a){var b,c,d,e,f,g=2;if(!(c=this._callbacks))return this;while(g--){d=g?a:"all";if(b=c[d])for(var h=0,i=b.length;h<i;h++)(e=b[h])?(f=g?Array.prototype.slice.call(arguments,1):arguments,e.apply(this,f)):(b.splice(h,1),h--,i--)}return this}},c.Model=function(a,b){var c;a||(a={});if(c=this.defaults)d.isFunction(c)&&(c=c.call(this)),a=d.extend({},c,a);this.attributes={},this._escapedAttributes={},this.cid=d.uniqueId("c"),this.set(a,{silent:!0}),this._changed=!1,this._previousAttributes=d.clone(this.attributes),b&&b.collection&&(this.collection=b.collection),this.initialize(a,b)},d.extend(c.Model.prototype,c.Events,{_previousAttributes:null,_changed:!1,idAttribute:"id",initialize:function(){},toJSON:function(){return d.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;var c=this.attributes[a];return this._escapedAttributes[a]=w(c==null?"":""+c)},has:function(a){return this.attributes[a]!=null},set:function(a,b){b||(b={});if(!a)return this;a.attributes&&(a=a.attributes);var c=this.attributes,e=this._escapedAttributes;if(!b.silent&&this.validate&&!this._performValidation(a,b))return!1;this.idAttribute in a&&(this.id=a[this.idAttribute]);var f=this._changing;this._changing=!0;for(var g in a){var h=a[g];d.isEqual(c[g],h)||(c[g]=h,delete e[g],this._changed=!0,b.silent||this.trigger("change:"+g,this,h,b))}!f&&!b.silent&&this._changed&&this.change(b),this._changing=!1;return this},unset:function(a,b){if(!(a in this.attributes))return this;b||(b={});var c=this.attributes[a],d={};d[a]=void 0;if(!b.silent&&this.validate&&!this._performValidation(d,b))return!1;delete this.attributes[a],delete this._escapedAttributes[a],a==this.idAttribute&&delete this.id,this._changed=!0,b.silent||(this.trigger("change:"+a,this,void 0,b),this.change(b));return this},clear:function(a){a||(a={});var b,c=this.attributes,d={};for(b in c)d[b]=void 0;if(!a.silent&&this.validate&&!this._performValidation(d,a))return!1;this.attributes={},this._escapedAttributes={},this._changed=!0;if(!a.silent){for(b in c)this.trigger("change:"+b,this,void 0,a);this.change(a)}return this},fetch:function(a){a||(a={});var b=this,d=a.success;a.success=function(c,e,f){if(!b.set(b.parse(c,f),a))return!1;d&&d(b,c)},a.error=v(a.error,b,a);return(this.sync||c.sync).call(this,"read",this,a)},save:function(a,b){b||(b={});if(a&&!this.set(a,b))return!1;var d=this,e=b.success;b.success=function(a,c,f){if(!d.set(d.parse(a,f),b))return!1;e&&e(d,a,f)},b.error=v(b.error,d,b);var f=this.isNew()?"create":"update";return(this.sync||c.sync).call(this,f,this,b)},destroy:function(a){a||(a={});if(this.isNew())return this.trigger("destroy",this,this.collection,a);var b=this,d=a.success;a.success=function(c){b.trigger("destroy",b,b.collection,a),d&&d(b,c)},a.error=v(a.error,b,a);return(this.sync||c.sync).call(this,"delete",this,a)},url:function(){var a=t(this.collection)||this.urlRoot||u();if(this.isNew())return a;return a+(a.charAt(a.length-1)=="/"?"":"/")+encodeURIComponent(this.id)},parse:function(a,b){return a},clone:function(){return new this.constructor(this)},isNew:function(){return this[this.idAttribute]==null},change:function(a){this.trigger("change",this,a),this._previousAttributes=d.clone(this.attributes),this._changed=!1},hasChanged:function(a){if(a)return this._previousAttributes[a]!=this.attributes[a];return this._changed},changedAttributes:function(a){a||(a=this.attributes);var b=this._previousAttributes,c=!1;for(var e in a)d.isEqual(b[e],a[e])||(c=c||{},c[e]=a[e]);return c},previous:function(a){if(!a||!this._previousAttributes)return null;return this._previousAttributes[a]},previousAttributes:function(){return d.clone(this._previousAttributes)},_performValidation:function(a,b){var c=this.validate(a);if(c){b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}return!0}}),c.Collection=function(a,b){b||(b={}),b.comparator&&(this.comparator=b.comparator),d.bindAll(this,"_onModelEvent","_removeReference"),this._reset(),a&&this.reset(a,{silent:!0}),this.initialize.apply(this,arguments)},d.extend(c.Collection.prototype,c.Events,{model:c.Model,initialize:function(){},toJSON:function(){return this.map(function(a){return a.toJSON()})},add:function(a,b){if(d.isArray(a))for(var c=0,e=a.length;c<e;c++)this._add(a[c],b);else this._add(a,b);return this},remove:function(a,b){if(d.isArray(a))for(var c=0,e=a.length;c<e;c++)this._remove(a[c],b);else this._remove(a,b);return this},get:function(a){if(a==null)return null;return this._byId[a.id!=null?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},sort:function(a){a||(a={});if(!this.comparator)throw new Error("Cannot sort a set without a comparator");this.models=this.sortBy(this.comparator),a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return d.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]),b||(b={}),this.each(this._removeReference),this._reset(),this.add(a,{silent:!0}),b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a||(a={});var b=this,d=a.success;a.success=function(c,e,f){b[a.add?"add":"reset"](b.parse(c,f),a),d&&d(b,c)},a.error=v(a.error,b,a);return(this.sync||c.sync).call(this,"read",this,a)},create:function(a,b){var c=this;b||(b={}),a=this._prepareModel(a,b);if(!a)return!1;var d=b.success;b.success=function(a,e,f){c.add(a,b),d&&d(a,e,f)},a.save(null,b);return a},parse:function(a,b){return a},chain:function(){return d(this.models).chain()},_reset:function(a){this.length=0,this.models=[],this._byId={},this._byCid={}},_prepareModel:function(a,b){if(a instanceof c.Model)a.collection||(a.collection=this);else{var d=a;a=new this.model(d,{collection:this}),a.validate&&!a._performValidation(d,b)&&(a=!1)}return a},_add:function(a,b){b||(b={}),a=this._prepareModel(a,b);if(!a)return!1;var c=this.getByCid(a);if(c)throw new Error(["Can't add the same model to a set twice",c.id]);this._byId[a.id]=a,this._byCid[a.cid]=a;var d=b.at!=null?b.at:this.comparator?this.sortedIndex(a,this.comparator):this.length;this.models.splice(d,0,a),a.bind("all",this._onModelEvent),this.length++,b.silent||a.trigger("add",a,this,b);return a},_remove:function(a,b){b||(b={}),a=this.getByCid(a)||this.get(a);if(!a)return null;delete this._byId[a.id],delete this._byCid[a.cid],this.models.splice(this.indexOf(a),1),this.length--,b.silent||a.trigger("remove",a,this,b),this._removeReference(a);return a},_removeReference:function(a){this==a.collection&&delete a.collection,a.unbind("all",this._onModelEvent)},_onModelEvent:function(a,b,c,d){if(a!="add"&&a!="remove"||c==this)a=="destroy"&&this._remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,arguments)}});var f=["forEach","each","map","reduce","reduceRight","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","sortBy","sortedIndex","toArray","size","first","rest","last","without","indexOf","lastIndexOf","isEmpty"];d.each(f,function(a){c.Collection.prototype[a]=function(){return d[a].apply(d,[this.models].concat(d.toArray(arguments)))}}),c.Router=function(a){a||(a={}),a.routes&&(this.routes=a.routes),this._bindRoutes(),this.initialize.apply(this,arguments)};var g=/:([\w\d]+)/g,h=/\*([\w\d]+)/g,i=/[-[\]{}()+?.,\\^$|#\s]/g;d.extend(c.Router.prototype,c.Events,{initialize:function(){},route:function(a,b,e){c.history||(c.history=new c.History),d.isRegExp(a)||(a=this._routeToRegExp(a)),c.history.route(a,d.bind(function(c){var d=this._extractParameters(a,c);e.apply(this,d),this.trigger.apply(this,["route:"+b].concat(d))},this))},navigate:function(a,b){c.history.navigate(a,b)},_bindRoutes:function(){if(!!this.routes){var a=[];for(var b in this.routes)a.unshift([b,this.routes[b]]);for(var c=0,d=a.length;c<d;c++)this.route(a[c][0],a[c][1],this[a[c][1]])}},_routeToRegExp:function(a){a=a.replace(i,"\\$&").replace(g,"([^/]*)").replace(h,"(.*?)");return new RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}}),c.History=function(){this.handlers=[],d.bindAll(this,"checkUrl")};var j=/^#*/,k=/msie [\w.]+/,l=!1;d.extend(c.History.prototype,{interval:50,getFragment:function(a,b){if(a==null)if(this._hasPushState||b){a=window.location.pathname;var c=window.location.search;c&&(a+=c),a.indexOf(this.options.root)==0&&(a=a.substr(this.options.root.length))}else a=window.location.hash;return a.replace(j,"")},start:function(a){if(l)throw new Error("Backbone.history has already been started");this.options=d.extend({},{root:"/"},this.options,a),this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&window.history&&window.history.pushState);var b=this.getFragment(),c=document.documentMode,f=k.exec(navigator.userAgent.toLowerCase())&&(!c||c<=7);f&&(this.iframe=e('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(b)),this._hasPushState?e(window).bind("popstate",this.checkUrl):"onhashchange"in window&&!f?e(window).bind("hashchange",this.checkUrl):setInterval(this.checkUrl,this.interval),this.fragment=b,l=!0;var g=window.location,h=g.pathname==this.options.root||g.pathname==this.options.root+"/";if(this._wantsPushState&&!this._hasPushState&&!h){this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment);return!0}this._wantsPushState&&this._hasPushState&&h&&g.hash&&(this.fragment=g.hash.replace(j,""),window.history.replaceState({},document.title,g.protocol+"//"+g.host+this.options.root+this.fragment));return this.loadUrl()},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(a){var b=this.getFragment();b==this.fragment&&this.iframe&&(b=this.getFragment(this.iframe.location.hash));if(b==this.fragment||b==decodeURIComponent(this.fragment))return!1;this.iframe&&this.navigate(b),this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(a){var b=this.fragment=this.getFragment(a),c=d.any(this.handlers,function(a){if(a.route.test(b)){a.callback(b);return!0}});return c},navigate:function(a,b){var c=(a||"").replace(j,"");if(this.fragment!=c&&this.fragment!=decodeURIComponent(c)){if(this._hasPushState){var d=window.location;c.indexOf(this.options.root)!=0&&(c=this.options.root+c),this.fragment=c,window.history.pushState({},document.title,d.protocol+"//"+d.host+c)}else window.location.hash=this.fragment=c,this.iframe&&c!=this.getFragment(this.iframe.location.hash)&&(this.iframe.document.open().close(),this.iframe.location.hash=c);b&&this.loadUrl(a)}}}),c.View=function(a){this.cid=d.uniqueId("view"),this._configure(a||{}),this._ensureElement(),this.delegateEvents(),this.initialize.apply(this,arguments)};var m=function(a){return e(a,this.el)},n=/^(\S+)\s*(.*)$/,o=["model","collection","el","id","attributes","className","tagName"];d.extend(c.View.prototype,c.Events,{tagName:"div",$:m,initialize:function(){},render:function(){return this},remove:function(){e(this.el).remove();return this},make:function(a,b,c){var d=document.createElement(a);b&&e(d).attr(b),c&&e(d).html(c);return d},delegateEvents:function(a){if(!!a||!!(a=this.events)){e(this.el).unbind(".delegateEvents"+this.cid);for(var b in a){var c=this[a[b]];if(!c)throw new Error('Event "'+a[b]+'" does not exist');var f=b.match(n),g=f[1],h=f[2];c=d.bind(c,this),g+=".delegateEvents"+this.cid,h===""?e(this.el).bind(g,c):e(this.el).delegate(h,g,c)}}},_configure:function(a){this.options&&(a=d.extend({},this.options,a));for(var b=0,c=o.length;b<c;b++){var e=o[b];a[e]&&(this[e]=a[e])}this.options=a},_ensureElement:function(){if(!this.el){var a=this.attributes||{};this.id&&(a.id=this.id),this.className&&(a["class"]=this.className),this.el=this.make(this.tagName,a)}else d.isString(this.el)&&(this.el=e(this.el).get(0))}});var p=function(a,b){var c=s(this,a,b);c.extend=this.extend;return c};c.Model.extend=c.Collection.extend=c.Router.extend=c.View.extend=p;var q={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};c.sync=function(a,b,f){var g=q[a],h=d.extend({type:g,dataType:"json"},f);h.url||(h.url=t(b)||u()),!h.data&&b&&(a=="create"||a=="update")&&(h.contentType="application/json",h.data=JSON.stringify(b.toJSON())),c.emulateJSON&&(h.contentType="application/x-www-form-urlencoded",h.data=h.data?{model:h.data}:{}),c.emulateHTTP&&(g==="PUT"||g==="DELETE")&&(c.emulateJSON&&(h.data._method=g),h.type="POST",h.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",g)}),h.type!=="GET"&&(h.processData=!1);return e.ajax(h)};var r=function(){},s=function(a,b,c){var e;b&&b.hasOwnProperty("constructor")?e=b.constructor:e=function(){return a.apply(this,arguments)},d.extend(e,a),r.prototype=a.prototype,e.prototype=new r,b&&d.extend(e.prototype,b),c&&d.extend(e,c),e.prototype.constructor=e,e.__super__=a.prototype;return e},t=function(a){if(!a||!a.url)return null;return d.isFunction(a.url)?a.url():a.url},u=function(){throw new Error('A "url" property or function must be specified')},v=function(a,b,c){return function(d){a?a(b,d,c):b.trigger("error",b,d,c)}},w=function(a){return a.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")}}.call(this),function(a){function l(a){out="",a.replace(/\\s*[a-z\-]+\\s*=\\s*(?:\042|\047)(?:[^\\1]*?)\\1/gi,function(a){$out+=a.replace(/\/\*.*?\*\//g,"")});return out}function k(a){return a.replace(">","&gt;").replace("<","&lt;").replace("\\","\\\\")}function j(){return"!*$^#(@*#&"}function i(a){for(var b in g)a=a.replace(g[b],"");return a}var b={"&nbsp;":" ","&iexcl;":"¡","&cent;":"¢","&pound;":"£","&curren;":"€","&yen;":"¥","&brvbar;":"Š","&sect;":"§","&uml;":"š","&copy;":"©","&ordf;":"ª","&laquo;":"«","&not;":"¬","&shy;":"­","&reg;":"®","&macr;":"¯","&deg;":"°","&plusmn;":"±","&sup2;":"²","&sup3;":"³","&acute;":"Ž","&micro;":"µ","&para;":"¶","&middot;":"·","&cedil;":"ž","&sup1;":"¹","&ordm;":"º","&raquo;":"»","&frac14;":"Œ","&frac12;":"œ","&frac34;":"Ÿ","&iquest;":"¿","&Agrave;":"À","&Aacute;":"Á","&Acirc;":"Â","&Atilde;":"Ã","&Auml;":"Ä","&Aring;":"Å","&AElig;":"Æ","&Ccedil;":"Ç","&Egrave;":"È","&Eacute;":"É","&Ecirc;":"Ê","&Euml;":"Ë","&Igrave;":"Ì","&Iacute;":"Í","&Icirc;":"Î","&Iuml;":"Ï","&ETH;":"Ð","&Ntilde;":"Ñ","&Ograve;":"Ò","&Oacute;":"Ó","&Ocirc;":"Ô","&Otilde;":"Õ","&Ouml;":"Ö","&times;":"×","&Oslash;":"Ø","&Ugrave;":"Ù","&Uacute;":"Ú","&Ucirc;":"Û","&Uuml;":"Ü","&Yacute;":"Ý","&THORN;":"Þ","&szlig;":"ß","&agrave;":"à","&aacute;":"á","&acirc;":"â","&atilde;":"ã","&auml;":"ä","&aring;":"å","&aelig;":"æ","&ccedil;":"ç","&egrave;":"è","&eacute;":"é","&ecirc;":"ê","&euml;":"ë","&igrave;":"ì","&iacute;":"í","&icirc;":"î","&iuml;":"ï","&eth;":"ð","&ntilde;":"ñ","&ograve;":"ò","&oacute;":"ó","&ocirc;":"ô","&otilde;":"õ","&ouml;":"ö","&divide;":"÷","&oslash;":"ø","&ugrave;":"ù","&uacute;":"ú","&ucirc;":"û","&uuml;":"ü","&yacute;":"ý","&thorn;":"þ","&yuml;":"ÿ","&quot;":'"',"&lt;":"<","&gt;":">","&apos;":"'","&minus;":"−","&circ;":"ˆ","&tilde;":"˜","&Scaron;":"Š","&lsaquo;":"‹","&OElig;":"Œ","&lsquo;":"‘","&rsquo;":"’","&ldquo;":"“","&rdquo;":"”","&bull;":"•","&ndash;":"–","&mdash;":"—","&trade;":"™","&scaron;":"š","&rsaquo;":"›","&oelig;":"œ","&Yuml;":"Ÿ","&fnof;":"ƒ","&Alpha;":"Α","&Beta;":"Β","&Gamma;":"Γ","&Delta;":"Δ","&Epsilon;":"Ε","&Zeta;":"Ζ","&Eta;":"Η","&Theta;":"Θ","&Iota;":"Ι","&Kappa;":"Κ","&Lambda;":"Λ","&Mu;":"Μ","&Nu;":"Ν","&Xi;":"Ξ","&Omicron;":"Ο","&Pi;":"Π","&Rho;":"Ρ","&Sigma;":"Σ","&Tau;":"Τ","&Upsilon;":"Υ","&Phi;":"Φ","&Chi;":"Χ","&Psi;":"Ψ","&Omega;":"Ω","&alpha;":"α","&beta;":"β","&gamma;":"γ","&delta;":"δ","&epsilon;":"ε","&zeta;":"ζ","&eta;":"η","&theta;":"θ","&iota;":"ι","&kappa;":"κ","&lambda;":"λ","&mu;":"μ","&nu;":"ν","&xi;":"ξ","&omicron;":"ο","&pi;":"π","&rho;":"ρ","&sigmaf;":"ς","&sigma;":"σ","&tau;":"τ","&upsilon;":"υ","&phi;":"φ","&chi;":"χ","&psi;":"ψ","&omega;":"ω","&thetasym;":"ϑ","&upsih;":"ϒ","&piv;":"ϖ","&ensp;":" ","&emsp;":" ","&thinsp;":" ","&zwnj;":"‌","&zwj;":"‍","&lrm;":"‎","&rlm;":"‏","&sbquo;":"‚","&bdquo;":"„","&dagger;":"†","&Dagger;":"‡","&hellip;":"…","&permil;":"‰","&prime;":"′","&Prime;":"″","&oline;":"‾","&frasl;":"⁄","&euro;":"€","&image;":"ℑ","&weierp;":"℘","&real;":"ℜ","&alefsym;":"ℵ","&larr;":"←","&uarr;":"↑","&rarr;":"→","&darr;":"↓","&harr;":"↔","&crarr;":"↵","&lArr;":"⇐","&uArr;":"⇑","&rArr;":"⇒","&dArr;":"⇓","&hArr;":"⇔","&forall;":"∀","&part;":"∂","&exist;":"∃","&empty;":"∅","&nabla;":"∇","&isin;":"∈","&notin;":"∉","&ni;":"∋","&prod;":"∏","&sum;":"∑","&lowast;":"∗","&radic;":"√","&prop;":"∝","&infin;":"∞","&ang;":"∠","&and;":"∧","&or;":"∨","&cap;":"∩","&cup;":"∪","&int;":"∫","&there4;":"∴","&sim;":"∼","&cong;":"≅","&asymp;":"≈","&ne;":"≠","&equiv;":"≡","&le;":"≤","&ge;":"≥","&sub;":"⊂","&sup;":"⊃","&nsub;":"⊄","&sube;":"⊆","&supe;":"⊇","&oplus;":"⊕","&otimes;":"⊗","&perp;":"⊥","&sdot;":"⋅","&lceil;":"⌈","&rceil;":"⌉","&lfloor;":"⌊","&rfloor;":"⌋","&lang;":"〈","&rang;":"〉","&loz;":"◊","&spades;":"♠","&clubs;":"♣","&hearts;":"♥","&diams;":"♦"},c=function(a){if(!~a.indexOf("&"))return a;for(var c in b)a=a.replace(new RegExp(c,"g"),b[c]);a=a.replace(/&#x(0*[0-9a-f]{2,5});?/gi,function(a,b){return String.fromCharCode(parseInt(+b,16))}),a=a.replace(/&#([0-9]{2,4});?/gi,function(a,b){return String.fromCharCode(+b)}),a=a.replace(/&amp;/g,"&");return a},d=function(a){a=a.replace(/&/g,"&amp;");for(var c in b)a=a.replace(new RegExp(b[c],"g"),c);return a};a.entities={encode:d,decode:c};var e={"document.cookie":"[removed]","document.write":"[removed]",".parentNode":"[removed]",".innerHTML":"[removed]","window.location":"[removed]","-moz-binding":"[removed]","<!--":"&lt;!--","-->":"--&gt;","<![CDATA[":"&lt;![CDATA["},f={"javascript\\s*:":"[removed]","expression\\s*(\\(|&\\#40;)":"[removed]","vbscript\\s*:":"[removed]","Redirect\\s+302":"[removed]"},g=[/%0[0-8bcef]/g,/%1[0-9a-f]/g,/[\x00-\x08]/g,/\x0b/g,/\x0c/g,/[\x0e-\x1f]/g],h=["javascript","expression","vbscript","script","applet","alert","document","write","cookie","window"];a.xssClean=function(b,c){if(b instanceof Array||typeof b=="object"){for(var d in b)b[d]=a.xssClean(b[d]);return b}b=i(b),b=b.replace(/\&([a-z\_0-9]+)\=([a-z\_0-9]+)/i,j()+"$1=$2"),b=b.replace(/(&\#?[0-9a-z]{2,})([\x00-\x20])*;?/i,"$1;$2"),b=b.replace(/(&\#x?)([0-9A-F]+);?/i,"$1;$2"),b=b.replace(j(),"&"),b=decodeURIComponent(b),b=b.replace(/[a-z]+=([\'\"]).*?\\1/gi,function(a,b){return a.replace(b,k(b))}),b=b.replace(/<\w+.*?(?=>|<|$)/gi,function(a,b){}),b=i(b),b=b.replace("\t"," ");var g=b;for(var d in e)b=b.replace(d,e[d]);for(var d in f)b=b.replace(new RegExp(d,"i"),f[d]);for(var d in h){var m=h[d].split("").join("\\s*")+"\\s*";b=b.replace(new RegExp("("+m+")(\\W)","ig"),function(a,b,c){return b.replace(/\s+/g,"")+c})}do{var n=b;b.match(/<a/i)&&(b=b.replace(/<a\\s+([^>]*?)(>|$)/gi,function(a,b,c){b=l(b.replace("<","").replace(">",""));return a.replace(b,b.replace(/href=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\\s*,)/gi,""))})),b.match(/<img/i)&&(b=b.replace(/<img\\s+([^>]*?)(\\s?\/?>|$)/gi,function(a,b,c){b=l(b.replace("<","").replace(">",""));return a.replace(b,b.replace(/src=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\\s*,)/gi,""))}));if(b.match(/script/i)||b.match(/xss/i))b=b.replace(/<(\/*)(script|xss)(.*?)\>/gi,"[removed]")}while(n!=b);event_handlers=["[^a-z_-]onw*"],c||event_handlers.push("xmlns"),b=b.replace(new RegExp("<([^><]+?)("+event_handlers.join("|")+")(\\s*=\\s*[^><]*)([><]*)","i"),"<$1$4"),naughty="alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss",b=b.replace(new RegExp("<(/*\\s*)("+naughty+")([^><]*)([><]*)","gi"),function(a,b,c,d,e){return"&lt;"+b+c+d+e.replace(">","&gt;").replace("<","&lt;")}),b=b.replace(/(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\\s*)\((.*?)\)/gi,"$1$2&#40;$3&#41;");for(var d in e)b=b.replace(d,e[d]);for(var d in f)b=b.replace(new RegExp(d,"i"),f[d]);if(c&&b!==g)throw"Image may contain XSS";return b};var m=a.Validator=function(){};m.prototype.check=function(a,b){this.str=String(a||""),this.msg=b;return this},m.prototype.validate=m.prototype.check,m.prototype.assert=m.prototype.check,m.prototype.error=function(a){throw a},m.prototype.isEmail=function(){this.str.match(/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/)||this.error(this.msg||"Invalid email");return this},m.prototype.isUrl=function(){this.str.match(/^(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?:\w+:\w+@)?((?:(?:[-\w\d{1-3}]+\.)+(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|edu|co\.uk|ac\.uk|it|fr|tv|museum|asia|local|travel|[a-z]{2}))|((\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)(\.(\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)){3}))(?::[\d]{1,5})?(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?:#(?:[-\w~!$ |\/.,*:;=]|%[a-f\d]{2})*)?$/)||this.error(this.msg||"Invalid URL");return this},m.prototype.isIP=function(){this.str.match(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/)||this.error(this.msg||"Invalid IP");return this},m.prototype.isAlpha=function(){this.str.match(/^[a-zA-Z]*$/)||this.error(this.msg||"Invalid characters");return this},m.prototype.isAlphanumeric=function(){this.str.match(/^[a-zA-Z0-9]*$/)===null&&this.error(this.msg||"Invalid characters");return this},m.prototype.isNumeric=function(){this.str.match(/^-?[0-9]*$/)===null&&this.error(this.msg||"Invalid number");return this},m.prototype.isLowercase=function(){this.str.match(/^[a-z0-9]*$/)||this.error(this.msg||"Invalid characters");return this},m.prototype.isUppercase=function(){this.str.match(/^[A-Z0-9]*$/)||this.error(this.msg||"Invalid characters");return this},m.prototype.isInt=function(){this.str.match(/^(?:-?(?:0|[1-9][0-9]*))$/)||this.error(this.msg||"Invalid integer");return this},m.prototype.isDecimal=function(){this.str.match(/^(?:-?(?:0|[1-9][0-9]*))?(?:\.[0-9]*)?$/)||this.error(this.msg||"Invalid decimal");return this},m.prototype.isFloat=function(){return this.isDecimal()},m.prototype.notNull=function(){this.str===""&&this.error(this.msg||"Invalid characters");return this},m.prototype.isNull=function(){this.str!==""&&this.error(this.msg||"Invalid characters");return this},m.prototype.notEmpty=function(){this.str.match(/^[\s\t\r\n]*$/)&&this.error(this.msg||"String is whitespace");return this},m.prototype.equals=function(a){this.str!=a&&this.error(this.msg||"Not equal");return this},m.prototype.contains=function(a){this.str.indexOf(a)===-1&&this.error(this.msg||"Invalid characters");return this},m.prototype.notContains=function(a){this.str.indexOf(a)>=0&&this.error(this.msg||"Invalid characters");return this},m.prototype.regex=m.prototype.is=function(a,b){typeof a!="function"&&(a=new RegExp(a,b)),this.str.match(a)||this.error(this.msg||"Invalid characters");return this},m.prototype.notRegex=m.prototype.not=function(a,b){typeof a!="function"&&(a=new RegExp(a,b)),this.str.match(a)&&this.error(this.msg||"Invalid characters");return this},m.prototype.len=function(a,b){this.str.length<a&&this.error(this.msg||"String is too small"),typeof b!==undefined&&this.str.length>b&&this.error(this.msg||"String is too large");return this},m.prototype.isUUID=function(a){a==3||a=="v3"?pattern=/[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i:a==4||a=="v4"?pattern=/[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i:pattern=/[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,this.str.match(pattern)||this.error(this.msg||"Not a UUID");return this};var n=a.Filter=function(){},o="\\r\\n\\t\\s";n.prototype.modify=function(a){this.str=a},n.prototype.convert=n.prototype.sanitize=function(a){this.str=a;return this},n.prototype.xss=function(a){this.modify(xssClean(this.str,a));return this.str},n.prototype.entityDecode=function(){this.modify(c(this.str));return this.str},n.prototype.entityEncode=function(){this.modify(d(this.str));return this.str},n.prototype.ltrim=function(a){a=a||o,this.modify(this.str.replace(new RegExp("^["+a+"]+","g"),""));return this.str},n.prototype.rtrim=function(a){a=a||o,this.modify(this.str.replace(new RegExp("["+a+"]+$","g"),""));return this.str},n.prototype.trim=function(a){a=a||o,this.modify(this.str.replace(new RegExp("^["+a+"]+|["+a+"]+$","g"),""));return this.str},n.prototype.ifNull=function(a){(!this.str||this.str==="")&&this.modify(a);return this.str},n.prototype.toFloat=function(){this.modify(parseFloat(this.str));return this.str},n.prototype.toInt=function(){this.modify(parseInt(this.str));return this.str},n.prototype.toBoolean=function(){!this.str||this.str=="0"||this.str=="false"||this.str==""?this.modify(!1):this.modify(!0);return this.str},n.prototype.toBooleanStrict=function(){this.str=="1"||this.str=="true"?this.modify(!0):this.modify(!1);return this.str},a.sanitize=a.convert=function(b){var c=new a.Filter;return c.sanitize(b)},a.check=a.validate=a.assert=function(b,c){var d=new a.Validator;return d.check(b,c)}}(this),function(a,b){function c(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.10",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){function h(b,c,d,f){a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)});return c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){if(c===b)return g["inner"+d].call(this);return this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){if(typeof b!="number")return g["outer"+d].call(this,b);return this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){var d=b.nodeName.toLowerCase(),e=a.attr(b,"tabindex");if("area"===d){var f=b.parentNode,g=f.name,h;if(!b.href||!g||f.nodeName.toLowerCase()!=="map")return!1;h=a("img[usemap=#"+g+"]")[0];return!!h&&c(h)}return(/input|select|textarea|button|object/.test(d)?!b.disabled:"a"==d?b.href||!isNaN(e):!isNaN(e))&&c(b)},tabbable:function(b){var c=a.attr(b,"tabindex");return(isNaN(c)||c>=0)&&a(b).is(":focusable")}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!!d&&!!a.element[0].parentNode)for(var e=0;e<d.length;e++)a.options[d[e][0]]&&d[e][1].apply(a.element,c)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(b,c){if(a(b).css("overflow")==="hidden")return!1;var d=c&&c==="left"?"scrollLeft":"scrollTop",e=!1;if(b[d]>0)return!0;b[d]=1,e=b[d]>0,b[d]=0;return e},isOverAxis:function(a,b,c){return a>b&&a<b+c},isOver:function(b,c,d,e,f,g){return a.ui.isOverAxis(b,d,f)&&a.ui.isOverAxis(c,e,g)}}))}(jQuery),function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b){for(var d=0,e;(e=b[d])!=null;d++)a(e).triggerHandler("remove");c(b)}}else{var d=a.fn.remove;a.fn.remove=function(b,c){return this.each(function(){c||(!b||a.filter(b,[this]).length)&&a("*",this).add([this]).each(function(){a(this).triggerHandler("remove")});return d.call(a(this),b,c)})}}a.widget=function(b,c,d){var e=b.split(".")[0],f;b=b.split(".")[1],f=e+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][f]=function(c){return!!a.data(c,b)},a[e]=a[e]||{},a[e][b]=function(a,b){arguments.length&&this._createWidget(a,b)};var g=new c;g.options=a.extend(!0,{},g.options),a[e][b].prototype=a.extend(!0,g,{namespace:e,widgetName:b,widgetEventPrefix:a[e][b].prototype.widgetEventPrefix||b,widgetBaseClass:f},d),a.widget.bridge(b,a[e][b])},a.widget.bridge=function(c,d){a.fn[c]=function(e){var f=typeof e=="string",g=Array.prototype.slice.call(arguments,1),h=this;e=!f&&g.length?a.extend.apply(null,[!0,e].concat(g)):e;if(f&&e.charAt(0)==="_")return h;f?this.each(function(){var d=a.data(this,c),f=d&&a.isFunction(d[e])?d[e].apply(d,g):d;if(f!==d&&f!==b){h=f;return!1}}):this.each(function(){var b=a.data(this,c);b?b.option(e||{})._init():a.data(this,c,new d(e,this))});return h}},a.Widget=function(a,b){arguments.length&&this._createWidget(a,b)},a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(b,c){a.data(c,this.widgetName,this),this.element=a(c),this.options=a.extend(!0,{},this.options,this._getCreateOptions(),b);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled")},widget:function(){return this.element},option:function(c,d){var e=c;if(arguments.length===0)return a.extend({},this.options);if(typeof c=="string"){if(d===b)return this.options[c];e={},e[c]=d}this._setOptions(e);return this},_setOptions:function(b){var c=this;a.each(b,function(a,b){c._setOption(a,b)});return this},_setOption:function(a,b){this.options[a]=b,a==="disabled"&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",b);return this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(b,c,d){var e=this.options[b];c=a.Event(c),c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase(),d=d||{};if(c.originalEvent)for(var f=a.event.props.length,g;f;)g=a.event.props[--f],c[g]=c.originalEvent[g];this.element.trigger(c,d);return!(a.isFunction(e)&&e.call(this.element[0],c,d)===!1||c.isDefaultPrevented())}}}(jQuery),function(a,b){a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(a){return b._mouseDown(a)}).bind("click."+this.widgetName,function(c){if(!0===a.data(c.target,b.widgetName+".preventClickEvent")){a.removeData(c.target,b.widgetName+".preventClickEvent"),c.stopImmediatePropagation();return!1}}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(b){b.originalEvent=b.originalEvent||{};if(!b.originalEvent.mouseHandled){this._mouseStarted&&this._mouseUp(b),this._mouseDownEvent=b;var c=this,d=b.which==1,e=typeof this.options.cancel=="string"?a(b.target).parents().add(b.target).filter(this.options.cancel).length:!1;if(!d||e||!this._mouseCapture(b))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=this._mouseStart(b)!==!1;if(!this._mouseStarted){b.preventDefault();return!0}}this._mouseMoveDelegate=function(a){return c._mouseMove(a)},this._mouseUpDelegate=function(a){return c._mouseUp(a)},a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),b.preventDefault(),b.originalEvent.mouseHandled=!0;return!0}},_mouseMove:function(b){if(a.browser.msie&&!(document.documentMode>=9)&&!b.button)return this._mouseUp(b);if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b));return!this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b));return!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})}(jQuery),function(a,b){var c=5;a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var b=this,d=this.options;this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"),d.disabled&&this.element.addClass("ui-slider-disabled ui-disabled"),this.range=a([]),d.range&&(d.range===!0?(this.range=a("<div></div>"),d.values||(d.values=[this._valueMin(),this._valueMin()]),d.values.length&&d.values.length!==2&&(d.values=[d.values[0],d.values[0]])):this.range=a("<div></div>"),this.range.appendTo(this.element).addClass("ui-slider-range"),(d.range==="min"||d.range==="max")&&this.range.addClass("ui-slider-range-"+d.range),this.range.addClass("ui-widget-header")),a(".ui-slider-handle",this.element).length===0&&a("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle-left").addClass("ui-slider-handle");if(d.values&&d.values.length)while(a(".ui-slider-handle",this.element).length<d.values.length)a("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle-right").addClass("ui-slider-handle");this.handles=a(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all"),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(a){a.preventDefault()}).hover(function(){d.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){d.disabled?a(this).blur():(a(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),a(this).addClass("ui-state-focus"))}).blur(function(){a(this).removeClass("ui-state-focus")}),this.handles.each(function(b){a(this).data("index.ui-slider-handle",b)}),this.handles.keydown(function(d){var e=!0,f=a(this).data("index.ui-slider-handle"),g,h,i,j;if(!b.options.disabled){switch(d.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:e=!1;if(!b._keySliding){b._keySliding=!0,a(this).addClass("ui-state-active"),g=b._start(d,f);if(g===!1)return}}j=b.options.step,b.options.values&&b.options.values.length?h=i=b.values(f):h=i=b.value();switch(d.keyCode){case a.ui.keyCode.HOME:i=b._valueMin();break;case a.ui.keyCode.END:i=b._valueMax();break;case a.ui.keyCode.PAGE_UP:i=b._trimAlignValue(h+(b._valueMax()-b._valueMin())/c);break;case a.ui.keyCode.PAGE_DOWN:i=b._trimAlignValue(h-(b._valueMax()-b._valueMin())/c);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(h===b._valueMax())return;i=b._trimAlignValue(h+j);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(h===b._valueMin())return;i=b._trimAlignValue(h-j)}b._slide(d,f,i);return e}}).keyup(function(c){var d=a(this).data("index.ui-slider-handle");b._keySliding&&(b._keySliding=!1,b._stop(c,d),b._change(c,d),a(this).removeClass("ui-state-active"))}),this._refreshValue(),this._animateOff=!1},destroy:function(){this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider"),this._mouseDestroy();return this},_mouseCapture:function(b){var c=this.options,d,e,f,g,h,i,j,k,l;if(c.disabled)return!1;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),d={x:b.pageX,y:b.pageY},e=this._normValueFromMouse(d),f=this._valueMax()-this._valueMin()+1,h=this,this.handles.each(function(b){var c=Math.abs(e-h.values(b));f>c&&(f=c,g=a(this),i=b)}),c.range===!0&&this.values(1)===c.min&&(i+=1,g=a(this.handles[i])),j=this._start(b,i);if(j===!1)return!1;this._mouseSliding=!0,h._handleIndex=i,g.addClass("ui-state-active").focus(),k=g.offset(),l=!a(b.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:b.pageX-k.left-g.width()/2,top:b.pageY-k.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(b,i,e),this._animateOff=!0;return!0},_mouseStart:function(a){return!0},_mouseDrag:function(a){var b={x:a.pageX,y:a.pageY},c=this._normValueFromMouse(b);this._slide(a,this._handleIndex,c);return!1},_mouseStop:function(a){this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1;return!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,d,e,f;this.orientation==="horizontal"?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),d=c/b,d>1&&(d=1),d<0&&(d=0),this.orientation==="vertical"&&(d=1-d),e=this._valueMax()-this._valueMin(),f=this._valueMin()+d*e;return this._trimAlignValue(f)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values());return this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,f;this.options.values&&this.options.values.length?(d=this.values(b?0:1),this.options.values.length===2&&this.options.range===!0&&(b===0&&c>d||b===1&&c<d)&&(c=d),c!==this.values(b)&&(e=this.values(),e[b]=c,f=this._trigger("slide",a,{handle:this.handles[b],value:c,values:e}),d=this.values(b?0:1),f!==!1&&this.values(b,c,!0))):c!==this.value()&&(f=this._trigger("slide",a,{handle:this.handles[b],value:c}),f!==!1&&this.value(c))},_stop:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("stop",a,c)},_change:function(a,b){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("change",a,c)}},value:function(a){arguments.length&&(this.options.value=this._trimAlignValue(a),this._refreshValue(),this._change(null,0));return this._value()},values:function(b,c){var d,e,f;arguments.length>1&&(this.options.values[b]=this._trimAlignValue(c),this._refreshValue(),this._change(null,b));if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(b):this.value();d=this.options.values,e=arguments[0];for(f=0;f<d.length;f+=1)d[f]=this._trimAlignValue(e[f]),this._change(null,f);this._refreshValue()},_setOption:function(b,c){var d,e=0;a.isArray(this.options.values)&&(e=this.options.values.length),a.Widget.prototype._setOption.apply(this,arguments);switch(b){case"disabled":c?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.attr("disabled","disabled"),this.element.addClass("ui-disabled")):(this.handles.removeAttr("disabled"),this.element.removeClass("ui-disabled"));break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":this._animateOff=!0,this._refreshValue();for(d=0;d<e;d+=1)this._change(null,d);this._animateOff=!1}},_value:function(){var a=this.options.value;a=this._trimAlignValue(a);return a},_values:function(a){var b,c,d;if(arguments.length){b=this.options.values[a],b=this._trimAlignValue(b);return b}c=this.options.values.slice();for(d=0;d<c.length;d+=1)c[d]=this._trimAlignValue(c[d]);return c},_trimAlignValue:function(a){if(a<=this._valueMin())return this._valueMin();if(a>=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b;alignValue=a-c,Math.abs(c)*2>=b&&(alignValue+=c>0?b:-b);return parseFloat(alignValue.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b=this.options.range,c=this.options,d=this,e=this._animateOff?!1:c.animate,f,g={},h,i,j,k;this.options.values&&this.options.values.length?this.handles.each(function(b,i){f=(d.values(b)-d._valueMin())/(d._valueMax()-d._valueMin())*100,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",a(this).stop(1,1)[e?"animate":"css"](g,c.animate),d.options.range===!0&&(d.orientation==="horizontal"?(b===0&&d.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({width:f-h+"%"},{queue:!1,duration:c.animate})):(b===0&&d.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({height:f-h+"%"},{queue:!1,duration:c.animate}))),h=f}):(i=this.value(),j=this._valueMin(),k=this._valueMax(),f=k!==j?(i-j)/(k-j)*100:0,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",this.handle.stop(1,1)[e?"animate":"css"](g,c.animate),b==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[e?"animate":"css"]({width:f+"%"},c.animate),b==="max"&&this.orientation==="horizontal"&&this.range[e?"animate":"css"]({width:100-f+"%"},{queue:!1,duration:c.animate}),b==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},c.animate),b==="max"&&this.orientation==="vertical"&&this.range[e?"animate":"css"]({height:100-f+"%"},{queue:!1,duration:c.animate}))}}),a.extend(a.ui.slider,{version:"1.8.10"})}(jQuery),jQuery.url=function(){function g(a){a=a||window.location.toString();return b(unescape(a.replace(/\+/g," ")))}function f(a){return encodeURIComponent(a)}function e(a){if(a.source)return encodeURI(a.source);var b=[];a.protocol&&(a.protocol=="file"?b.push("file:///"):a.protocol=="mailto"?b.push("mailto:"):b.push(a.protocol+"://")),a.authority?b.push(a.authority):(a.userInfo?b.push(a.userInfo+"@"):a.user&&(b.push(a.user),a.password&&b.push(":"+a.password),b.push("@")),a.host&&(b.push(a.host),a.port&&b.push(":"+a.port))),a.path?b.push(a.path):(a.directory&&b.push(a.directory),a.file&&b.push(a.file)),a.query?b.push("?"+a.query):a.params&&b.push("?"+$.param(a.params)),a.anchor&&b.push("#"+a.anchor);return b.join("")}function d(a){a=a||window.location;var b=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],e=b.exec(a),f={},g=d.length;while(g--)f[d[g]]=e[g]||"";f.query&&(f.params=c(f.query,!0));return f}function c(a,b){var c={},d={"true":!0,"false":!1,"null":null};$.each(a.replace(/\+/g," ").split("&"),function(a,e){var f=e.split("="),h=g(f[0]),i,j=c,k=0,l=h.split("]["),m=l.length-1;/\[/.test(l[0])&&/\]$/.test(l[m])?(l[m]=l[m].replace(/\]$/,""),l=l.shift().split("[").concat(l),m=l.length-1):m=0;if(f.length===2){i=g(f[1]),b&&(i=i&&!isNaN(i)?+i:i==="undefined"?undefined:d[i]!==undefined?d[i]:i);if(m)for(;k<=m;k++)h=l[k]===""?j.length:l[k],j=j[h]=k<m?j[h]||(l[k+1]&&isNaN(l[k+1])?{}:[]):i;else $.isArray(c[h])?c[h].push(i):c[h]!==undefined?c[h]=[c[h],i]:c[h]=i}else h&&(c[h]=b?undefined:"")});return c}function b(a){var b="",c=0,d=0,e=0;while(c<a.length)d=a.charCodeAt(c),d<128?(b+=String.fromCharCode(d),c++):d>191&&d<224?(e=a.charCodeAt(c+1),b+=String.fromCharCode((d&31)<<6|e&63),c+=2):(e=a.charCodeAt(c+1),c3=a.charCodeAt(c+2),b+=String.fromCharCode((d&15)<<12|(e&63)<<6|c3&63),c+=3);return b}function a(a){a=a.replace(/\r\n/g,"\n");var b="";for(var c=0;c<a.length;c++){var d=a.charCodeAt(c);d<128?b+=String.fromCharCode(d):d>127&&d<2048?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(d&63|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(d&63|128))}return b}return{encode:f,decode:g,parse:d,build:e}}(),function(a){a.fn.incrementor=function(b){b=a.extend(!0,{wrapClass:"incrementor",incClass:"bttn inc",decClass:"bttn dec",incText:"▲",decText:"▼",step:1,min:undefined,max:undefined},b);return this.each(function(){function d(a){var d=parseInt(c.val(),10),e=d+a;(isNaN(b.min)||b.min<=e)&&(isNaN(b.max)||b.max>=e)&&c.val(d+a),c.change()}var c=a(this),e=a(this).wrap("<div/>").parent().addClass(b.wrapClass),f=a("<a/>",{"class":b.incClass,href:"#",text:b.incText}).click(function(){d(b.step);return!1}).appendTo(e),g=a("<a/>",{"class":b.decClass,href:"#",text:b.decText}).click(function(){d(-b.step);return!1}).appendTo(e)})}}(jQuery),function(){_.extend(Backbone.Router.prototype,{route:function(a,b,c){Backbone.history||(Backbone.history=new Backbone.History),_.isRegExp(a)||(a=this._routeToRegExp(a)),Backbone.history.route(a,_.bind(function(d,e){e=e||{};var f=this._extractParameters(a,d);f.push(e),c.apply(this,f),this.trigger.apply(this,["route:"+b].concat(f))},this))}});var a=/^#*/;_.extend(Backbone.History.prototype,{checkUrl:function(a){var b=this.getFragment();b==this.fragment&&this.iframe&&(b=this.getFragment(this.iframe.location.hash));if(b==this.fragment)return!1;this.iframe&&this.navigate(b),this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(a){var b=this.fragment=this.getFragment(),c=$.url.parse(b),d=_.any(this.handlers,function(a){if(a.route.test(c.path)){a.callback(c.path,c.params);return!0}});return d},navigate:function(b,c){var d=(b||"").replace(a,"");if(this.fragment!=d){if(this._hasPushState){var e=window.location;d.indexOf(this.options.root)!=0&&(d=this.options.root+d),this.fragment=d,window.history.pushState({},document.title,e.protocol+"//"+e.host+d)}else window.location.hash=this.fragment=d,this.iframe&&d!=this.getFragment(this.iframe.location.hash)&&(this.iframe.document.open().close(),this.iframe.location.hash=d);c&&this.loadUrl(b)}},addParam:function(a,b,c){var d=$.url.parse(this.getFragment()),e=d.path,f=d.params||{};a in f?_.isArray(f[a])?f[a].push(b):f[a]=[f[a],b]:f[a]=b,this.navigate($.url.build({path:e,params:f}),c)},setParams:function(a,b){var c=$.url.parse(this.getFragment()),d=c.path,e=c.params||{};_.each(a,function(a,b){e[b]=a}),this.navigate($.url.build({path:d,params:e}),b)},removeParams:function(a,b){var c=$.url.parse(this.getFragment()),d=c.path,e=c.params||{},f=function(a){a in e&&delete e[a]};_.isArray(a)?_.each(a,f):f(a),this.navigate($.url.build({path:d,params:e}),b)}}),_.extend(Backbone.Model.prototype,{getNext:function(){var a=this.collection.at(this.collection.indexOf(this)+1);return a},getPrevious:function(){var a=this.collection.at(this.collection.indexOf(this)-1);return a},idAttribute:"_id",isNew:function(){return this.id==null}})}(),_.templateSettings={interpolate:/\{\{(.+?)\}\}/g},Utils={resolve:function(a,b){if(_.isString(b)){var c=b.split(".");while(c.length){var d=c.shift();if(d in a)a=a[d];else return}return a}},imageLoaded:function(a){if(!a||!a.complete)return!1;if(typeof a.naturalWidth!="undefined"&&a.naturalWidth===0)return!1;return!0},csvToArr:function(a){var b=[];_.each(a.split(","),function(a){a=$.trim(a),console.log(a),a&&b.push(a)}),console.log("arr",b);return b},arrToCSV:function(a){var b="",c;_.each(a,function(a){c=$.trim(a),c&&(b+=c+", ")});return b},toTitleCase:function(a){function g(a,b,c){return b+e(c)}function f(a){return/[A-Za-z]\.[A-Za-z]/.test(a)?a:e(a)}function e(a){return a.substr(0,1).toUpperCase()+a.substr(1)}function d(a){return a.toLowerCase()}var b="(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)",c="([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)",h=[],i=/[:.;?!] |(?: |^)["Ò]/g,j=0;for(;;){var k=i.exec(a),l=a.substring(j,k?k.index:a.length).replace(/\b([A-Za-z][a-z.'Õ]*)\b/g,f).replace(RegExp("\\b"+b+"\\b","ig"),d).replace(RegExp("^"+c+b+"\\b","ig"),g).replace(RegExp("\\b"+b+c+"$","ig"),e);h.push(l),j=i.lastIndex;if(k)h.push(k[0]);else break}return h.join("").replace(/ V(s?)\. /ig," v$1. ").replace(/(['Õ])S\b/ig,"$1s").replace(/\b(AT&T|Q&A)\b/ig,function(a){return a.toUpperCase()})},humanizeList:function(a,b){function c(c){return b?"<"+b+">"+a[c]+"</"+b+">":a[c]}for(var d=0;d<a.length;d++)d===0?text=c(d):d==a.length-1?text+=" and "+c(d):text+=", "+c(d);return text},isoDateRE:/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/,stringToDate:function(a){var b=Utils.isoDateRE.exec(a);if(b)return new Date(Date.UTC(+b[1],+b[2]-1,+b[3],+b[4],+b[5],+b[6]));return null},zeroFill:function(a,b){b-=a.toString().length;if(b>0)return Array(b+(/\./.test(a)?2:1)).join("0")+a;return a}},$.fn.serializeObj=function(){var a={};jQuery.map($(this).serializeArray(),function(b,c){a[b.name]=b.value});return a},jQuery.ajaxSetup({statusCode:{404:function(){alert("Resouce could not be found.")},401:function(){alert("You are not logged in!"),window.location="/login/"},500:function(a,b,c){console.log("a b c",a,b,c);var d=confirm("Server Error!\n\nClick okay to refresh the page (recommeded).");d&&window.location.reload(!0)},502:function(a,b,c){console.log("a b c",a,b,c);var d=confirm("Server Not Found!\n\nClick okay to refresh the page (recommeded).");d&&window.location.reload(!0)}}}),Shared={setStatusDisplay:function(a,b){this.hideStatusTimeoutId&&clearTimeout(this.hideStatusTimeoutId);var c={status:"info",sticky:!1};_.extend(c,b);var d=this.$("span.status");d.text(a),c.status=="error"?d.addClass("error"):d.removeClass("error"),d.fadeIn("fast"),c.sticky||(this.hideStatusTimeoutId=setTimeout(function(){d.fadeOut()},2500))}},Validator.prototype.len=function(a,b){this.str.length<a&&this.error(this.msg||"Too small (min "+a+" characters)"),typeof b!==undefined&&this.str.length>b&&this.error(this.msg||"Too long (max "+b+" characters)");return this},Validator.prototype.notEmpty=function(){this.str.match(/^[\s\t\r\n]*$/)&&this.error(this.msg||"Required");return this},function(){var a=this.Backbone||require("backbone"),b=this._||require("underscore"),c=a.Model.extend({idAttribute:"_id",defaults:{quantity:1},set:function(b,c){"item_id"in b&&delete this.item,"variation_id"in b&&delete this.variation,"purchase_option_id"in b&&delete this.purchase_option,"item"in b&&(this.item=b.item,b.item_id=this.item.id,b.item_title=this.item.get("title"),b.item_stock_id=this.item.get("stock_id"),delete b.item),"variation"in b&&(this.variation=b.variation,b.variation_id=this.variation.id,b.variation_title=this.variation.get("title"),b.variation_stock_id=this.variation.get("stock_id"),b.thumb=this.variation.imgSrc("thumb"),delete b.variation),"purchase_option"in b&&(this.purchase_option=b.purchase_option,b.purchase_option_id=this.purchase_option.id,b.purchase_option_title=this.purchase_option.get("title"),b.purchase_option_price=this.purchase_option.get("price"),delete b.purchase_option);return a.Model.prototype.set.call(this,b,c)},getItem:function(){return this.item},getVariation:function(){this.variation||(this.variation=this.item.getVariations().get(this.get("variation_id")));return this.variation},getPurchaseOption:function(){this.purchase_option||(this.purchase_option=this.item.getPurchaseOptions().get(this.get("purchase_option_id")));return this.purchase_option},getTitle:function(){var a=this.get("item_title");this.get("variation_title")&&(a+=" - "+this.get("variation_title"));return a},getTotal:function(){return(this.get("purchase_option_price")*this.get("quantity")).toFixed(2)}}),d=a.Collection.extend({model:c,url:"/data/order/items",getTotal:function(a){return this.reduce(function(a,b){return a+b.get("purchase_option_price")*b.get("quantity")},0)},getTotalDisplay:function(){return this.getTotal().toFixed(2)}});typeof exports!="undefined"?(exports.CartItem=c,exports.CartItemCollection=d):(this.CartItem=c,this.CartItemCollection=d)}.call(this);var Category=Backbone.Model.extend({initialize:function(a){},defaults:{title:"new"}}),CategoryCollection=Backbone.Collection.extend({model:Category,url:"/data/admin/categories",comparator:function(a){return a.get("order")}}),Color=Backbone.Model.extend({defaults:{title:"new",hex:"ffffff"}}),ColorCollection=Backbone.Collection.extend({model:Color,url:"/data/admin/colors",comparator:function(a){return a.get("order")}});(function(){var a=this.Backbone||require("backbone"),b=this._||require("underscore"),c=a.Model.extend({defaults:{code:"",name:"",group:"ROW"}}),d=a.Collection.extend({model:c,url:"/data/admin/countries",getNameForCode:function(a){var b=this.detect(function(b){return b.get("code")==a});if(b)return b.get("name")}});typeof exports!="undefined"?(exports.Country=c,exports.CountryCollection=d):(this.Country=c,this.CountryCollection=d)}).call(this),function(){var a=this.Backbone||require("backbone"),b=this._||require("underscore"),c=this.sanitize||require("validator").sanitize,d=this.check||require("validator").check,e=a.Model.extend({defaults:{cost:0,threshold:0},set:function(d,e){b.each(d,function(a,b,e){switch(b){case"cost":case"threshold":d[b]=c(a).toFloat();break;default:}},this);return a.Model.prototype.set.call(this,d,e)},validate:function(a){var c;b.each(a,function(a,b,e){try{switch(b){case"cost":d(a,"Must be a number").isDecimal();break;case"threshold":d(a,"Must be a number").isDecimal();break;default:}}catch(f){c||(c={}),c[b]=f}},this);if(c)return c}}),f=a.Collection.extend({model:e,comparator:function(a){return-a.get("threshold")}}),g=a.Model.extend({initialize:function(a){},defaults:{code:"ROW",title:"Rest of the World"},getFreeDeliveryThreshold:function(){var a=new f(this.get("price_brackets")),b=a.detect(function(a){return a.get("cost")===0});if(b)return b.get("threshold")},getCostForTotal:function(a){var b=new f(this.get("price_brackets")),c=b.detect(function(b){return b.get("threshold")<=a});return c.get("cost")},getCostForTotalDisplay:function(a){return this.getCostForTotal(a).toFixed(2)}}),h=a.Collection.extend({model:g,url:"/data/admin/delivery-groups",comparator:function(a){return a.get("order")}});typeof exports!="undefined"?(exports.PriceBracket=e,exports.DeliveryGroup=g,exports.PriceBracketCollection=f,exports.DeliveryGroupCollection=h):(this.PriceBracket=e,this.DeliveryGroup=g,this.PriceBracketCollection=f,this.DeliveryGroupCollection=h)}.call(this);var FeaturedItem=Backbone.Model.extend({initialize:function(){}}),FeaturedItemCollection=Backbone.Collection.extend({model:FeaturedItem,url:"/data/admin/featured-items",comparator:function(a){return a.get("order")}}),HoleSize=Backbone.Model.extend({}),HoleSizeCollection=Backbone.Collection.extend({model:HoleSize,comparator:function(a){return a.get("sumcount")}}),Size=Backbone.Model.extend({}),SizeCollection=Backbone.Collection.extend({model:Size,comparator:function(a){return a.get("sumcount")}}),Variation=Backbone.Model.extend({defaults:{colors:[]},validate:function(a){var b;_.each(a,function(a,c,d){try{switch(c){case"stock_id":check(a,"Requried. No spaces or strange characters please").is(/^[\w\-]+$/);break;default:}}catch(e){b||(b={}),b[c]=e}},this);if(b){console.log("variation errors",b);return b}},imgSrc:function(a,b){b=_.extend({noParent:!1},b);return this.get("image_version")?"/gen/"+this.id+"/"+a+".jpg?v="+this.get("image_version"):!b.noParent&&this.collection.parent.get("image_version")?this.collection.parent.imgSrc(a):"/images/site/no_image_thumb.jpg"},detailURL:function(){return _.template("/{{category}}/{{item_title}}/{{variation_title}}",{category:this.collection.parent.get("category"),item_title:this.collection.parent.get("slug"),variation_title:this.get("slug")}).toLowerCase()}}),VariationCollection=Backbone.Collection.extend({model:Variation,initialize:function(a,b){this.parent=b.parent},url:function(){return"/data/admin/variations/"+this.parent.id}});(function(){var a=this.Backbone||require("backbone"),b=this._||require("underscore"),c=this.CartItemCollection||require("./cart_items.js").CartItemCollection;if(typeof window=="undefined"){var d=require("../../../app"),e=require("view_helpers"),f=require("./countries.js").CountryCollection,g=require("./delivery_groups.js").DeliveryGroupCollection;e.getCountries(function(a,b){BBCountries=new f(b)}),e.getDeliveryGroups(function(a,b){BBDeliveryGroups=new g(b)})}var h=a.Model.extend({defaults:{delivery:null,dispatched:!1,BillingCountry:"GB",DeliveryCountry:"GB"},stages:["billing","delivery","confirm"],initialize:function(){this.items||(this.items=new c)},set:function(b,d){b&&"items"in b&&(this.items||(this.items=new c),this.items.reset(b.items),delete b.items),b&&"BillingPostCode"in b&&(b.BillingPostCode=b.BillingPostCode.toUpperCase()),b&&"DeliveryPostCode"in b&&(b.DeliveryPostCode=b.DeliveryPostCode.toUpperCase());return a.Model.prototype.set.call(this,b,d)},stageIsComplete:function(a){var c,d,e;switch(a){case"billing":c=["CustomerEMail","BillingSurname","BillingFirstnames","BillingAddress1","BillingAddress2","BillingCity","BillingPostCode","BillingPhone","BillingCountry"],d={},b.map(c,function(a){d[a]=this.get(a)},this),e=this.validate(d);return!e;case"delivery":var f=this.get("delivery");if(!f)return!1;if(b.contains(["collect","billing"],f))return!0;c=["DeliverySurname","DeliveryFirstnames","DeliveryAddress1","DeliveryAddress2","DeliveryCity","DeliveryPostCode","DeliveryPhone","DeliveryCountry"],d={},b.map(c,function(a){d[a]=this.get(a)},this),e=this.validate(d);return!e;default:return!1}},getCompletedStages:function(){return b.select(this.stages,function(a){return this.stageIsComplete(stage)},this)},getNextStage:function(){var a=b.detect(this.stages,function(a){return!this.stageIsComplete(a)},this);return a},getAllowedStages:function(){var a=!0;return b.select(this.stages,function(b){var c=this.stageIsComplete(b);if(c)return!0;if(a){a=!1;return!0}return!1},this)},getDeliveryGroup:function(){if(this.get("delivery")!="collect"){var a=this.get("delivery")=="billing"?this.get("BillingCountry"):this.get("DeliveryCountry"),b=BBCountries.detect(function(b){return b.get("code")==a});return BBDeliveryGroups.detect(function(a){return a.get("code")==b.get("group")})}},getDeliveryCost:function(){return this.get("delivery")!="collect"?this.getDeliveryGroup().getCostForTotal(this.items.getTotal()):0},getDeliveryCostDisplay:function(){return this.getDeliveryCost().toFixed(2)},getGrandTotal:function(){return this.items.getTotal()+this.getDeliveryCost()},getGrandTotalDisplay:function(){return this.getGrandTotal().toFixed(2)},getOrderNumberDisplay:function(){var a=this.get("order_number");return a?Utils.zeroFill(a,6):""},getOptions:function(a){return a=="BillingCountry"||a=="DeliveryCountry"?BBCountries.map(function(a){return{value:a.get("code"),display:a.get("name")}}):{}},validate:function(a){var c;b.each(a,function(a,b,d){try{switch(b){case"CustomerEMail":a&&check(a).notEmpty().len(0,255).isEmail();break;case"BillingSurname":check(a).notEmpty().len(1,20);break;case"BillingFirstnames":check(a).notEmpty().len(1,20);break;case"BillingAddress1":check(a).notEmpty().len(1,100);break;case"BillingAddress2":check(a).len(0,100);break;case"BillingCity":check(a).notEmpty().len(1,40);break;case"BillingPostCode":check(a).notEmpty().len(1,10).is(/[a-zA-Z0-9 ]+/);break;case"BillingPhone":check(a).len(0,20).is(/[a-zA-Z0-9 ]*/);break;case"BillingCountry":check(a).len(2,2);break;case"DeliverySurname":check(a).notEmpty().len(1,20);break;case"DeliveryFirstnames":check(a).notEmpty().len(1,20);break;case"DeliveryAddress1":check(a).notEmpty().len(1,100);break;case"DeliveryAddress2":check(a).len(0,100);break;case"DeliveryCity":check(a).notEmpty().len(1,40);break;case"DeliveryPostCode":check(a).notEmpty().len(1,10).is(/[a-zA-Z0-9 ]+/);break;case"DeliveryPhone":check(a).len(0,20);break;default:}}catch(e){c||(c={}),c[b]=e}},this);if(c)return c}}),i=a.Collection.extend({model:h,url:"/data/admin/orders"});typeof exports!="undefined"?(exports.Order=h,exports.OrderCollection=i):(this.Order=h,this.OrderCollection=i)}).call(this);var PurchaseOption=Backbone.Model.extend({initialize:function(a){},defaults:{title:"new",price:0},validate:function(a){var b;_.each(a,function(a,c,d){try{switch(c){case"price":check(a,"Price must be a number").isDecimal();break;case"title":check(a,"A title is required").notEmpty();break;default:}}catch(e){b||(b={}),b[c]=e}},this);if(b){console.log("puchase option errors",b);return b}}}),PurchaseOptionCollection=Backbone.Collection.extend({model:PurchaseOption,initialize:function(a,b){this.parent=b.parent},comparator:function(a){return a.get("order")},url:function(){return"/data/admin/purchase-options/"+this.parent.id}}),Item=Backbone.Model.extend({collectionDef:{variations:{cls:VariationCollection},purchase_options:{cls:PurchaseOptionCollection}},initialize:function(a){this.collections={},this.bind("change",function(){console.log("item.change",arguments)})},getVariations:function(){if(!this.variations){var a=this.collection.variations[this.id];this.variations=new VariationCollection(a,{parent:this})}return this.variations},getPurchaseOptions:function(){if(!this.purchaseOptions){var a=this.collection.purchase_options[this.id];this.purchaseOptions=new PurchaseOptionCollection(a,{parent:this})}return this.purchaseOptions},validate:function(a){var b;_.each(a,function(a,c,d){try{switch(c){case"title":check(a,"A title is required").notEmpty();break;case"category":check(a,"A category is required").notEmpty();break;case"description":break;case"key_words":break;case"size":check(a,"Size must be a number").isDecimal();break;case"hole_size":check(a,"Hole size must be a number").isDecimal();break;case"materials":break;default:}}catch(e){b||(b={}),b[c]=e}},this);if(b)return b},imgSrc:function(a){return this.get("image_version")?"/gen/"+this.id+"/"+a+".jpg?v="+this.get("image_version"):"/images/site/no_image_thumb.jpg"}}),ItemCollection=Backbone.Collection.extend({model:Item,url:"/data/admin/items",comparator:function(a){return a.get("order")},parse:function(a){_.isArray(a)||(a=a.items),this.extractSubCollections(a);return a},extractSubCollections:function(a){this.variations||(this.variations={}),this.purchase_options||(this.purchase_options={}),_.each(a,function(a){this.variations[a._id]=a.variations,delete a.variations,this.purchase_options[a._id]=a.purchase_options,delete a.purchase_options},this)}}),Tag=Backbone.Model.extend({}),TagCollection=Backbone.Collection.extend({model:Tag,comparator:function(a){return-a.get("count")}}),FormView=Backbone.View.extend({tagName:"form",options:{template:""},events:{"click input[type=submit]":"submit"},render:function(){var a=this,b=this.model;this.children=[];var c=a.getContext(),d=Template.getSync(this.options.template)(c);$(a.el).append(d),_.each(this.children,function(a){a.bind()});return this},getContext:function(){var a={LabelAsPlaceholderTextField:LabelAsPlaceholderTextField,SelectField:SelectField};return{parent:this,Views:a,test:12}},submit:function(a){a&&a.preventDefault();var b=!0;_.each(this.children,function(a){a.isValid||(b=!1),a.displayErrors(!0)}),b?(this.complete=!0,this.onComplete()):$(".field.invalid input").eq(0).focus()},onComplete:function(){this.trigger("complete")}}),BaseView=Backbone.View.extend({initialize:function(a){_.bindAll(this,"getContext","getHTML","render","bind"),this.id=this.options.id||this.id||this.cid},options:{template:""},getContext:function(){return{tag:this.options.tag||this.tagName,id:this.id,className:this.className}},getHTML:function(){return Template.cache[this.options.template](this.getContext())},enhance:function(){},render:function(){$(this.el).append(this.getHTML()),this.enhance();return this},bind:function(){this.$el=this.options.parent.$("#"+this.id).eq(0),this.el=this.$el[0],this.delegateEvents(),this.enhance()}}),Field=BaseView.extend({className:"field",inputSelector:"input",isValid:!0,_displayErrors:!1,initialize:function(a){BaseView.prototype.initialize.call(this,a),_.bindAll(this,"getContext","val","onChange","validate","onError","displayErrors","showError","hideError","formatError"),this.options.inputId=this.options.inputId||this.options.attr},getContext:function(){return _.extend(BaseView.prototype.getContext.call(this),{inputId:this.options.inputId,value:this.model.get(this.options.attr),label:this.options.label,name:this.options.attr,autocomplete:this.options.autocomplete})},val:function(a){if(a)this.$(this.inputSelector).val(a);else return this.$(this.inputSelector).val()},onChange:function(){var a={};a[this.options.attr]=this.val();var b=this.model.set(a,{error:this.onError});if(b){this.isValid=!0,this.errors=undefined,this.hideError();return b}},validate:function(){var a={};a[this.options.attr]=this.val(),this.errors=this.model.validate(a),this.errors?(this.isValid=!1,this.showError()):(this.isValid=!0,this.hideError())},onError:function(a,b){this.isValid=!1,this.errors=b,this.showError()},displayErrors:function(a){this._displayErrors=a,a?this.isValid||this.showError():this.hideError()},showError:function(a){},hideError:function(){},formatError:function(a){return"<strong>"+this.options.label+"</strong><br>"+a}}),BillingForm=FormView.extend({tagName:"div",options:{template:"billing_form"}}),SelectDelivery=Backbone.View.extend({tagName:"div",className:"select-delivery",initialize:function(){_.bindAll(this,"render","setDeliveryOption"),this.model.bind("change:delivery",this.render)},events:{"click a":"setDeliveryOption"},render:function(){$(this.el).html("");var a={options:[{id:"billing",display:_.template("Your Billing Address<br>({{fname}} {{sname}}, {{add}}).",{fname:this.model.get("BillingFirstnames"),sname:this.model.get("BillingSurname"),add:this.model.get("BillingAddress1")})},{id:"new",display:"A different address..."}]};BBShop.collect_in_shop&&a.options.push({id:"collect",display:"I'll collect from the shop."}),_.each(a.options,function(a){a.selected=a.id==this.model.get("delivery")},this),$(this.el).append(Template.cache.select_delivery(a));return this},setDeliveryOption:function(a){a.preventDefault(),a.stopImmediatePropagation(),this.model.set({delivery:$(a.currentTarget).attr("id")})}}),DeliveryForm=FormView.extend({id:"delivery-form",className:"label-as-placeholder",attributes:{method:"post"},options:{template:"delivery_form"}}),CheckoutView=Backbone.View.extend({id:"checkout",initialize:function(){_.bindAll(this,"onStageComplete"),this.stages={billing:{view:BillingForm,title:"Billing Address"},delivery:{view:CheckoutDelivery,title:"Delivery Details"},confirm:{view:CheckoutConfirm,title:"Confirm"}}},render:function(){$(this.el).html("");var a=this.model.getAllowedStages(),b={stages:_.map(this.stages,function(b,c){b.url="/checkout/"+c,b.allowed=_.include(a,c);return b})};$(this.el).append(Template.cache.checkout(b)),this.view=new this.stages[this.options.stage].view({model:this.model,collection:this.collection}),this.view.render(),$(this.view.el).addClass("sub-view"),this.$(".sub-view").replaceWith(this.view.el),this.view.bind("complete",this.onStageComplete);return this},setStage:function(a){this.options.stage=a,this.render()},onStageComplete:function(){var a=this.model.getNextStage();this.model.save(),BBShop.navigate("/checkout/"+a,!0)},updateLayout:function(){}}),CheckoutConfirm=Backbone.View.extend({id:"checkout-confirm",initialize:function(){},events:{"click .without-message a":"showMessageInput","change textarea":"saveMessage"},render:function(){var a={total:this.model.items.getTotalDisplay(),delivery_cost:this.model.getDeliveryCostDisplay(),grand_total:this.model.getGrandTotalDisplay(),order:this.model.toJSON(),deliver_to_billing:this.model.get("delivery")=="billing",deliver_to_new:this.model.get("delivery")=="new",collect:this.model.get("delivery")=="collect",billing_country_name:BBCountries.getNameForCode(this.model.get("BillingCountry"))};this.model.get("delivery")=="new"&&(a.delivery_country_name=this.model.get("DeliveryCountry")?BBCountries.getNameForCode(this.model.get("DeliveryCountry")):"");var b=BBShop.order.get("transactions");if(b&&b.length){var c=b[b.length-1];c.RegistrationStatus=="INVALID"&&(a.error=c.RegistrationStatusDetail)}$(this.el).append(Template.cache.checkout_confirm(a));return this},showMessageInput:function(a){this.$(".without-message").hide(),this.$(".with-message").show();return!1},saveMessage:function(a){this.model.set({message:$(a.currentTarget).val()})}}),CheckoutDelivery=Backbone.View.extend({id:"checkout-delivery",initialize:function(a){_.bindAll(this,"updateEnterDeliveryAddress","onComplete"),this.model.bind("change:delivery",this.updateEnterDeliveryAddress)},events:{"click input[type=submit]":"onSubmit"},render:function(){$(this.el).append(Template.cache.checkout_delivery()),this.select_delivery=new SelectDelivery({model:this.model}),this.$(".select-delivery").replaceWith(this.select_delivery.render().el),this.enter_delivery_address=new DeliveryForm({model:this.model}),this.enter_delivery_address.bind("complete",this.onComplete),this.$("#delivery-form").replaceWith(this.enter_delivery_address.render().el),this.updateEnterDeliveryAddress();return this},updateEnterDeliveryAddress:function(){this.model.get("delivery")=="new"?this.$("#delivery-form").show():this.$("#delivery-form").hide()},onSubmit:function(){console.log("CheckoutDeliveryonSUbmit"),this.model.get("delivery")=="new"?this.enter_delivery_address.submit():this.trigger("complete")},onComplete:function(){this.trigger("complete")}}),CheckoutReturn=Backbone.View.extend({id:"checkout-return",className:"main-view body-text",initialize:function(){},events:{},render:function(){var a=this.model.toJSON();a.Status||(a.NOSTATUS=!0),_.each(["OK","NOTAUTHED","TAMPER","ABORT","ERROR"],function(b){a[b]=a.Status==b}),$(this.el).append(Template.cache.checkout_return(a));return this}}),BasketDeliveryPanel=Backbone.View.extend({id:"delivery-options",initialize:function(){_.bindAll(this,"render","setDeliveryOption"),this.model.items.bind("change:quantity",this.render),this.model.items.bind("remove",this.render),this.model.bind("change:collect_in_shop",this.render)},events:{"click a":"setDeliveryOption"},render:function(){$(this.el).html("");var a=BBDeliveryGroups.detect(function(a){return a.get("code")=="GB"}),b=BBDeliveryGroups.detect(function(a){return a.get("code")=="EU"}),c={total:this.model.items.getTotalDisplay(),collect_in_shop:BBShop.collect_in_shop,free_delivery_threshold:a.getFreeDeliveryThreshold(),delivery_cost:a.getCostForTotalDisplay(this.model.items.getTotal()),eu_delivery_cost:b.getCostForTotalDisplay(this.model.items.getTotal())};console.log(b.getCostForTotal(this.model.items.getTotal())),$(this.el).append(Template.cache.basket_delivery_panel(c));return this},setDeliveryOption:function(a){a.preventDefault(),a.stopImmediatePropagation(),this.model.set({collect_in_shop:$(a.currentTarget).attr("id")=="collect-in-shop"})}}),CartItemView=Backbone.View.extend({initialize:function(){_.bindAll(this,"handleQuantityChange","onQuantityChange","handleRemove","onRemove"),this.model.bind("change:quantity",this.onQuantityChange),this.model.bind("remove",this.onRemove)},tagName:"tr",events:{"change input":"handleQuantityChange","click a.remove":"destroy"},render:function(){var a=this.model.toJSON();a.total=this.model.getTotal(),$(this.el).append(Template.cache.cart_item(a)),this.$("input").incrementor({min:1});return this},handleQuantityChange:function(a){this.model.save({quantity:$(a.target).val()})},destroy:function(){this.model.destroy();return!1},onRemove:function(){$(this.el).remove()},onQuantityChange:function(a){this.$(".sub-total").html("&pound;"+this.model.getTotal())},updateLayout:function(){}}),CartView=Backbone.View.extend({id:"basket",initialize:function(){_.bindAll(this,"updateTotal","checkout"),this.model.items.bind("change:quantity",this.updateTotal),this.model.items.bind("remove",this.updateTotal),this.model.bind("change:collect_in_shop",this.updateTotal)},events:{"click #proceed-to-checkout a":"navigateToCheckout"},render:function(){$(this.el).html("");var a={empty:this.model.items.length===0};$(this.el).append(Template.cache.cart(a)),this.model.items.each(function(a){var b=new CartItemView({model:a});this.$("tbody").append(b.render().el)},this),this.delivery_options=new BasketDeliveryPanel({model:this.model}),this.$("#delivery-options").replaceWith(this.delivery_options.render().el),this.model.items.length&&this.updateTotal();return this},updateTotal:function(){this.model.items.length===0?this.render():this.$(".total").html("&pound;"+this.model.items.getTotalDisplay())},navigateToCheckout:function(a){BBShop.navigateToCurrentCheckoutRoute();return!1},updateLayout:function(){}}),ColorSelector=Backbone.View.extend({initialize:function(){_.bindAll(this,"render","update"),this.collection.bind("reset",this.render)},render:function(){$(this.el).html(""),this.views=[],this.collection.each(function(a){var b=new ColorThumb({model:a,selected:this.modelIsSelected(a)});this.views.push(b),b.bind("colorselect",this.onColorSelect),$(this.el).append(b.render().el)},this);return this},update:function(){_.each(this.views,function(a){a.setSelected(this.modelIsSelected(a.model))},this)},modelIsSelected:function(a){return!1},onColorSelect:function(a){}}),ColorFiltersView=ColorSelector.extend({onColorSelect:function(a){var b=a.model.get("title");BBShop.state.color==b?(this.$("a").removeClass("current"),Backbone.history.removeParams("color",!0)):(this.$("a").addClass("current"),Backbone.history.setParams({color:b},!0))},modelIsSelected:function(a){return BBShop.state.color==a.get("title")}}),ColorThumb=Backbone.View.extend({tagName:"a",className:"color-thumb",initialize:function(){_.bindAll(this,"onClick","setColor")},events:{click:"onClick"},render:function(){$(this.el).html(""),$(this.el).attr("href","?color="+this.model.get("title")),$(this.el).attr("title",this.model.get("title"));var a={hex:this.model.get("hex"),title:this.model.get("title")};$(this.el).append(Template.cache.color_thumb(a)),this.updateSelected();return this},setColor:function(a){this.$(".color-thumb-wrap").css("background-color","#"+a)},setSelected:function(a){this.options.selected=a,this.updateSelected()},updateSelected:function(){this.options.selected?$(this.el).addClass("current"):$(this.el).removeClass("current")},onClick:function(a){a.preventDefault(),a.stopPropagation(),this.trigger("colorselect",this)}}),FilterPanel=Backbone.View.extend({id:"filters",options:{tagsPerColumn:6},views:{},initialize:function(a){$(this.el).append(Template.cache.filter_panel()),this.colorFilters=new ColorFiltersView({el:this.$(".color-filters"),collection:BBShop.collections.colors}),this.sizeFilter=new SizeFilterView({el:this.$("#size-filter"),collection:BBShop.collections.sizes,minParam:"size-min",maxParam:"size-max"}),this.holeSizeFilter=new SizeFilterView({el:this.$("#hole-size-filter"),collection:BBShop.collections.holesizes,minParam:"hole-size-min",maxParam:"hole-size-max"})},render:function(){this.colorFilters.collection.length?(this.colorFilters.render(),this.$("#color-filters").show()):this.$("#color-filters").hide(),this.sizeFilter.collection.length>1?(this.sizeFilter.render(),this.$("#size-filter").show()):this.$("#size-filter").hide(),this.holeSizeFilter.collection.length>1?(this.holeSizeFilter.render(),this.$("#hole-size-filter").show()):this.$("#hole-size-filter").hide();if(BBShop.collections.tags.length){this.$(".tag-columns ").show(),this.$(".tag-filters").remove(),this.views.tagLists=[];for(var a=0;a<BBShop.collections.tags.length;a+=this.options.tagsPerColumn){var b=new TagListView({count:this.options.tagsPerColumn,offset:a,collection:BBShop.collections.tags});this.views.tagLists.push(b),this.$(".tag-columns").append(b.render().el)}}else this.$(".tag-columns").hide();return this},update:function(){this.colorFilters.update(),_.each(this.views.tagLists,function(a){a.update()})}}),HomeView=Backbone.View.extend({events:{"submit #mailing-list form":"joinList"},joinList:function(a){a.preventDefault(),a.stopPropagation();if(!d){var b=this.$("form"),c=b.find("input[type=submit]");c.replaceWith('<img class="spinner" src="/images/site/loading_indicator.gif">');var d=!0;$.ajax({type:"POST",url:b.attr("action"),data:b.serialize(),success:function(a,e,f){d=!1,b.find("img.spinner").replaceWith(c),b.replaceWith("<p>Thanks! A confirmation email has been sent to your address. Please click on the link within to confirm your subscription.</p>")},error:function(a,e,f){d=!1,b.find("img.spinner").replaceWith(c),b.find("p.error").remove(),b.prepend('<p class="error">'+a.responseText+"</p>")}})}}}),ItemDetail=Backbone.View.extend({tagName:"article",className:"detail",initialize:function(){_.bindAll(this,"onQuantityChange","onVariationChange","handlePurchaseOptionClick","onPurchaseOptionChange","handleQuantityChange","addToCart","updateSummary","updateTitle"),this.cartItem=new CartItem({item:this.model,variation:this.getVariationFromSlug(this.options.variation_slug),purchase_option:this.model.getPurchaseOptions().first()}),this.cartItem.bind("change:quantity",this.onQuantityChange),this.cartItem.bind("change:variation_id",this.onVariationChange),this.cartItem.bind("change:purchase_option_id",this.onPurchaseOptionChange)},getVariationFromSlug:function(a){return this.model.getVariations().detect(function(b){return b.get("slug")==a},this)},setVariation:function(a){this.cartItem.set({variation:this.getVariationFromSlug(a)})},events:{"click a.zoom":"zoom","click .purchase-options a":"handlePurchaseOptionClick","click .add-to-basket a.bttn":"addToCart","change input[name=quantity]":"handleQuantityChange","mouseover .add-to-basket a":"showSummary","mouseout .add-to-basket a":"hideSummary"},render:function(){var a=this.model.getNext(),b=this.model.getPrevious(),c,d;a&&(BBShop.state.color?d=a.getVariations().detect(function(a){return _.include(a.get("colors"),BBShop.state.color)}):d=a.getVariations().at(0),a=d.detailURL()),b&&(BBShop.state.color?d=b.getVariations().detect(function(a){return _.include(a.get("colors"),BBShop.state.color)}):d=b.getVariations().at(0),b=d.detailURL()),BBShop.state.category&&(c=BBShop.getListURL());var e=this.model.getVariations().map(function(a){return{id:a.id,img_src:a.imgSrc("thumb"),url:a.detailURL(),title:a.get("title"),slug:a.get("slug"),current:a.get("slug")==this.options.variation_slug}},this),f=this.model.getPurchaseOptions().map(function(a){return{id:a.id,price:a.get("price"),title:a.get("title"),current:a.id==this.cartItem.get("purchase_option_id")}},this),g={_id:this.model.id,title:this.model.get("title"),category:this.model.get("category"),description:this.model.get("description"),main_img:this.cartItem.variation.imgSrc("main"),variation_title:this.cartItem.variation.get("title"),variation_description:this.cartItem.variation.get("description"),showVariations:this.model.getVariations().length>1,variationsAsList:this.model.get("image_version"),purchaseOptions:f,variations:e,next:a,previous:b,list:c},h=Template.cache.item_detail(g);$(this.el).append(h),this.imageLoaded()||(this.$("img.main").hide(),this.$("img.main").bind("load",function(){$(this).unbind("load"),$(this).fadeIn()})),this.$("input[name=quantity]").incrementor({min:1});return this},updateVariation:function(){this.model.get("image_version")?($(".variation-list a").removeClass("current"),$(".variation-list li#"+this.cartItem.get("variation_id")+" a").addClass("current")):(this.$("img.main").attr("src",this.cartItem.variation.imgSrc("main")),$(".variation-thumbs li").removeClass("current"),$(".variation-thumbs li#"+this.cartItem.get("variation_id")).addClass("current"))},updatePurchaseOptions:function(){$(".purchase-options a").removeClass("current"),$(".purchase-options a#"+this.cartItem.get("purchase_option_id")).addClass("current")},updateSummary:function(){var a=this.cartItem.toJSON();a.title=this.cartItem.getTitle();var b=_.template("{{quantity}} x {{title}} @ &pound;{{purchase_option_price}} {{purchase_option_title}}",a);this.$(".summary .description").html(b),this.$(".summary .total").html("&pound;"+this.cartItem.getTotal())},updateQuantity:function(){this.$("input[name=quantity]").val(this.cartItem.get("quantity"))},updateTitle:function(){var a=this.model.get("title");this.cartItem.variation.get("title")&&(a+=" - "+this.cartItem.variation.get("title")),this.$("h1").text(a)},onQuantityChange:function(a){this.updateQuantity()},onVariationChange:function(a){this.updateVariation(),this.updateTitle()},onPurchaseOptionChange:function(a){this.updatePurchaseOptions()},zoom:function(a){this.$(".wrap").hasClass("zoomed")?(this.$(".wrap").removeClass("zoomed"),this.$(".left").delay(200).fadeIn(200),this.$(".right").animate({width:"48%"},400)):(this.$(".wrap").addClass("zoomed"),this.$(".left").fadeOut(200),this.$(".right").animate({width:"100%"},400));return!1},handleQuantityChange:function(a){this.cartItem.set({quantity:$(a.target).val()})},handlePurchaseOptionClick:function(a){this.model.getPurchaseOptions().get($(a.currentTarget).attr("id")),this.cartItem.set({purchase_option:this.model.getPurchaseOptions().get($(a.currentTarget).attr("id"))})},addToCart:function(a){a.preventDefault(),this.hideSummary(),BBShop.order.items.create(this.cartItem.toJSON(),{success:function(a,b){a.set({_id:b.item_id});if(BBShop.order.id){if(BBShop.order.id!==b.order_id){var c=confirm("Somethings not right...!\n\nClick okay to refresh the page (recommeded)");c&&window.location.reload(!0)}}else BBShop.order.set({_id:b.order_id})}})},showSummary:function(){var a=this.cartItem.toJSON();a.title=this.cartItem.getTitle(),a.total="&pound;"+this.cartItem.getTotal();var b=_.template("{{quantity}} x {{title}} @ &pound;{{purchase_option_price}} {{purchase_option_title}} = {{total}}",a);$("<div/>",{"class":"summary",html:b}).hide().appendTo(".add-to-basket").fadeIn()},hideSummary:function(){this.$(".summary").fadeOut(function(){$(this).remove()})},imageLoaded:function(a){return Utils.imageLoaded(this.$("img.main")[0])},updateLayout:function(){}}),ItemList=Backbone.View.extend({tagName:"div",id:"item-list",initialize:function(a){this.thumbGrid=new ThumbGrid,this.filterPanel=new FilterPanel},render:function(a){$(this.el).append(this.thumbGrid.render().el),a||!this.$("#filters").length?$(this.el).append(this.filterPanel.render().el):this.filterPanel.update(),this.updateLayout();return this},updateLayout:function(){$(this.thumbGrid.el).height($(window).height()-165),this.thumbGrid.updateLayout()}}),QView=Backbone.View.extend({el:$("input.search"),initialize:function(){_.bind(this.onQChange,this)},events:{cut:"onQChange",paste:"onQChange",input:"onQChange",keyup:"onQChange",change:"onQChange"},onQChange:_.debounce(function(){$(this.el).val()&&this.q!=$(this.el).val()&&(this.q=$(this.el).val(),BBShop.navigate($.url.build({path:"/search",params:{q:this.q}}),!0))},200),update:function(){$(this.el).val(BBShop.state.q)},clear:function(){$(this.el).val("")}}),NavView=Backbone.View.extend({initialize:function(a){this.order=a.order,_.bindAll(this,"onAddToCart","updateCart","updateTotal"),this.order.items.bind("add",this.onAddToCart),this.order.items.bind("remove",this.updateTotal),this.order.items.bind("change:quantity",this.updateTotal)},events:{"click .notice":"clearNotice"},render:function(){this.qview=new QView,this.updateCart();return this},onAddToCart:function(a){this.updateCart();var b=$(_.template('<div class="notice">{{quantity}} x {{title}} has been added to your basket.</div>',{quantity:a.get("quantity"),title:a.getTitle()})).hide().fadeIn();this.$("#notices").append(b),setTimeout(function(){b&&b.fadeOut(function(){b.remove()})},3500)},clearNotice:function(a){$(a.currentTarget).fadeOut(function(){$(this).remove()});return!1},updateCart:function(){this.order.items.length&&!this.$("span.count").length&&this.$(".basket-icon").after($("<span/>",{"class":"count"})),this.$("span.count").text(this.order.items.length),this.updateTotal()},updateTotal:function(){this.$("span.grand-total").text(this.order.items.getTotalDisplay())},updateCategory:function(){this.$("li").removeClass("current"),BBShop.state.category&&$("li.cat-"+BBShop.state.category).addClass("current")},clearQ:function(){this.qview.clear()}}),NotFound=Backbone.View.extend({id:"not-found",className:"main-view",render:function(){$(this.el).html("<h1>Not Found</h1><p>"+this.options.message+"</p>");return this}});SizeFilterView=Backbone.View.extend({initialize:function(){_.bindAll(this,"onSlide")},onSlide:_.debounce(function(a,b){var c=this.indexToSize(b.values[0]),d=this.indexToSize(b.values[1]);console.log("onSLide");if(c==this.collection.at(0).get("size")&&d==this.collection.at(this.collection.length-1).get("size"))Backbone.history.removeParams([this.options.minParam,this.options.maxParam],!0);else{var e={};e[this.options.maxParam]=d,e[this.options.minParam]=c,Backbone.history.setParams(e,!0)}this.updateDisplay(!0)},100),render:function(){var a=this.$("span.current"),b=this.collection.at(this.collection.length-1).get("sumcount");this.$(".slider").slider({range:!0,min:0,max:b,values:[BBShop.state[this.options.minParam]?this.sizeToIndex(BBShop.state[this.options.minParam]):0,BBShop.state[this.options.maxParam]?this.sizeToIndex(BBShop.state[this.options.maxParam]):b],slide:this.onSlide}),this.updateDisplay();return this},indexToSize:function(a){var b=this.collection.detect(function(b){return b.get("sumcount")>=a});if(b)return b.get("size")},sizeToIndex:function(a){var b=this.collection.detect(function(b){return b.get("size")==a});if(b)return b.get("sumcount")},updateDisplay:function(a){BBShop.state[this.options.minParam]&&BBShop.state[this.options.maxParam]?this.$("span.current").text(BBShop.state[this.options.minParam]+" - "+BBShop.state[this.options.maxParam]+"mm"):this.$("span.current").text("all")}});var TagListView=Backbone.View.extend({tagName:"ul",className:"tag-filters",render:function(){$(this.el).html(""),this.views=[],this.collection.each(function(a,b){if(b>=this.options.offset&&b<this.options.offset+this.options.count){var c=new TagView({model:a});this.views.push(c),$(this.el).append(c.render().el)}},this);return this},update:function(){this.$("a").removeClass("current"),_.each(this.views,function(a){BBShop.state.tag==a.model.get("name")&&a.$("a").addClass("current"),a.delegateEvents()})}}),TagView=Backbone.View.extend({tagName:"li",events:{"click a":"selectCategory"},render:function(){$(this.el).append(Template.cache.tag_filter({name:this.model.get("name"),count:this.model.get("count"),isCurrent:BBShop.state.tag==this.model.get("name")}));return this},selectCategory:function(a){this.$("a").hasClass("current")?(this.$("a").removeClass("current"),Backbone.history.removeParams("tag",!0)):(this.$("a").addClass("current"),Backbone.history.setParams({tag:this.model.get("name")},!0));return!1}}),TextField=Field.extend({className:"field text-field",options:{template:"text_field"}}),LabelAsPlaceholderTextField=TextField.extend({initialize:function(a){TextField.prototype.initialize.call(this,a),_.bindAll(this,"enhance","showError","hideError","onFocus","onBlur","onChange","setFilled"),this.options.inputId||(this.options.inputId=this.options.attr),this.id||(this.id=this.cid)},events:{"keyup input":"onChange","cut input":"onChange","paste input":"onChange","change input":"onChange","focus input":"onFocus","blur input":"onBlur"},enhance:function(){this.validate(),this.setFilled()},onChange:function(){Field.prototype.onChange.call(this),this.setFilled()},setFilled:function(a){this.val().length?$(this.el).addClass("filled"):$(this.el).removeClass("filled")},showError:function(){if(this._displayErrors&&this.errors){var a=this.errors[this.options.attr];$(this.el).addClass("invalid"),this.$err?this.$err.html(this.formatError(a)):this.$err=$("<div/>",{"class":"popup-error",html:this.formatError(a)}).css({opacity:0,bottom:$(this.el).outerHeight()+7}).appendTo($(this.el)).hide()}},hideError:function(){$(this.el).removeClass("invalid"),this.$err&&(this.$err.animate({opacity:0,bottom:"-=3"},150,function(){$(this).remove()}),this.$err=null)},onFocus:function(){$(this.el).addClass("focus"),$(this.el).hasClass("invalid")&&this.$err&&this.$err.show().animate({opacity:1,bottom:"+=3"},150)},onBlur:function(){$(this.el).removeClass("focus"),this.$err&&this.$err.animate({opacity:0,bottom:"-=3"},150,function(){$(this).hide()})}}),SelectField=Field.extend({className:"field select-field",inputSelector:"select",options:{template:"select_field"},events:{"change select":"onChange"},initialize:function(a){Field.prototype.initialize.call(this,a),_.bindAll(this,"getContext")},getContext:function(){var a=this.model.get(this.options.attr),b=this.model.getOptions(this.options.attr);_.each(b,function(b){b.selected=b.value==a});return _.extend(Field.prototype.getContext.call(this),{options:b,label:this.options.label,name:this.options.attr})}}),ThumbGrid=Backbone.View.extend({id:"thumb-grid",className:"thumb-grid",views:{},initialize:function(){_.bindAll(this,"addThumb","render","renderThumbs"),this.collection=BBShop.collections.items},addThumb:function(a,b){if(_.isArray(this.views.thumbs)){var c=new ThumbView({model:a});this.views.thumbs.push(c),$(this.el).append(c.el)}},render:function(){$(this.el).html(""),this.views.thumbs=[],$(this.el).scroll(_.throttle(this.renderThumbs,500));if(this.collection.length)this.collection.each(function(a,b){this.addThumb(a,b<16)},this),$(this.el).append('<div class="spacer">&nbsp;</div>'),this.updateLayout();else{var a="Sorry, we could find";BBShop.state.color?a+=" any <strong>"+BBShop.state.color+"</strong> items":a+=" anything";if(BBShop.state.q){var b=BBShop.state.q.split(" ");a+=" labelled "+Utils.humanizeList(BBShop.state.q.split(" "),"strong")}else BBShop.state.category&&(a+=" in the <strong>"+BBShop.state.category+"</strong> section");BBShop.state.tag&&(a+=", tagged <strong>"+BBShop.state.tag+"</strong>"),$(this.el).append('<p class="no-results">'+a+"</p>")}return this},renderThumbs:function(){if($(this.el).height()){var a=!1,b=this.el.scrollTop-this.thumb_width-this.spacing_y,c=this.el.scrollTop+$(this.el).height(),d=_.filter(this.views.thumbs,function(d){d.rendered||(a=!0);return!d.rendered&&b<d.position.top&&d.position.top<c});d.length&&_.each(d,function(a,b){_.delay(a.render,b*50)}),a||$(this.el).unbind("scroll")}},min_margin:15,thumb_width:136,spacing_y:60,updateLayout:function(){if(this.collection.length){var a=$(window).width()-$("header").outerWidth()-15,b=a-this.min_margin*2,c=this.thumb_width+this.min_margin*2,d=Math.floor(b/c),e=b%c,f=e/(2*d+2),g=this.min_margin+f,h=this.spacing_y+Math.ceil(this.collection.length/d)*(this.thumb_width+this.spacing_y);_.each(this.views.thumbs,function(a,b){var c=b%d,e=Math.floor(b/d);a.setPosition({left:(2*c+1)*g+c*this.thumb_width,top:15+(this.thumb_width+this.spacing_y)*e})},this),this.$(".spacer").css("top",h),this.renderThumbs()}}}),ThumbView=Backbone.View.extend({className:"thumb",initialize:function(){_.bindAll(this,"render","getCurrentVersion","onMouseMove","startSlideShow","stopSlideShow","nextVariation"),this.variations=this.model.getVariations(),BBShop.state.color&&(this.variations=this.variations.select(function(a){return _.include(a.get("colors"),BBShop.state.color)},this))},currentVariationIndex:0,width:140,events:{"mouseover a.img-wrap":"startSlideShow","mouseout a.img-wrap":"stopSlideShow","click li a":"setVariation"},render:function(){var a=this;$(this.el).html("");var b=this.getCurrentVariation();if(b){var c={_id:b.id,href:b.detailURL(),img_src:b.imgSrc("thumb"),title:this.model.get("title")};this.model.get("image_version")||(c.variations=_.range(this.variations.length)),$(this.el).append(Template.cache.thumb(c)),!this.imageLoaded()&&!($.browser.msie&&parseInt($.browser.version,10)<8)?($(this.el).addClass("loading"),this.$("a.img-wrap").hide(),this.$("img.img").bind("load",function(){$(a).unbind("load"),a.$("a.img-wrap").fadeIn(),$(a.el).removeClass("loading")})):a.$("a.img-wrap").hide().fadeIn(),this.$("li."+this.currentVariationIndex+" a").addClass("cur")}this.rendered=!0;return this},changeVariationImage:function(){this.$("li a").removeClass("cur"),this.$("li."+this.currentVariationIndex+" a").addClass("cur");var a=this.getCurrentVariation();if(a){var b=this,c=$('<img class="img" width="135" height="135"/>');c.bind("load",function(){b.$("img.img").after(c).remove(),b.$("a.img-wrap").add("a.title").attr("href",a.detailURL())}),c.attr("src",a.imgSrc("thumb"))}},getCurrentVariation:function(){return this.variations instanceof Backbone.Collection?this.variations.at(this.currentVariationIndex):this.variations[this.currentVariationIndex]},onMouseMove:function(a){var b=a.clientX-$(a.currentTarget).offset().left,c=Math.floor(b*this.variations.length/this.width);_.isNumber(c)&&c!=this.currentVariationIndex&&c!=this.variations.length&&(this.currentVariationIndex=c,this.changeVariationImage())},startSlideShow:function(){this.stopSlideShow();var a=this,b=function(){a.nextVariation(),a.slideShowInterval=setTimeout(b,800)};!this.model.get("image_version")&&this.variations.length>1&&(a.slideShowInterval=setTimeout(b,400))},stopSlideShow:function(){clearTimeout(this.slideShowInterval)},nextVariation:function(){this.currentVariationIndex++,this.currentVariationIndex>=this.variations.length&&(this.currentVariationIndex=0),this.changeVariationImage()},setVariation:function(a){a.preventDefault(),this.currentVariationIndex=parseInt($(a.currentTarget).closest("li").attr("class"),10),this.changeVariationImage()},imageLoaded:function(a){return Utils.imageLoaded(this.$("img.img")[0])},updateCurrent:function(){var a=_.any(this.model.get("variations"),function(a){return a.stock_id==BBShop.stock_id});if(a){$(this.el).addClass("current");return!0}return!1},setPosition:function(a){this.position=a,$(this.el).css(a)}}),VariationColorThumb=Backbone.View.extend({className:"color-thumb",options:{width:16,diagonal:16},events:{click:"selectVariation"},render:function(){var a={colors:[]};_.each(this.options.colors,function(b){a.colors.push({hex:Utils.hexForColor(b),height:this.options.diagonal/this.options.colors.length})},this),$(this.el).append(Template.cache.multi_color_thumb(a)),this.options.isCurrent&&$(this.el).addClass("current");return this},selectVariation:function(){BBShop.setItem(this.options.stock_id)}}),ShopController=Backbone.Router.extend({initialize:function(a){BBShop=this,a.order.get("Status")==="OK"?(this.order=new Order,this.previous_order=a.order):this.order=a.order,_.bindAll(this,"updateLayout","parse"),this.collections.categories=new CategoryCollection,this.collections.items=new ItemCollection,this.collections.tags=new TagCollection,this.collections.colors=new ColorCollection,this.collections.sizes=new HoleSizeCollection,this.collections.holesizes=new HoleSizeCollection,this.navView=(new NavView({el:$("header"),order:this.order})).render(),this.itemList=new ItemList,$(window).resize(_.debounce(this.updateLayout,100)),this.updateLayout(),$("a.push-state").live("click",function(a){a.preventDefault(),BBShop.navigate($(a.currentTarget).attr("href"),!0)}),typeof _gaq!="undefined"&&this.bind("all",function(){var a=window.location.pathname;window.location.hash&&(a=window.location.hash.slice(1)),_gaq.push(["_trackPageview",a])});return this},collections:{},view:undefined,state:{},routes:{"/":"homeRoute","/help":"helpRoute","/contact":"contactRoute","/delivery":"deliveryRoute","/privacy":"privacyRoute","/terms":"termsRoute","/shop":"shopRoute","/basket":"basketRoute","/checkout":"checkoutRoute","/checkout/return":"checkoutReturn","/checkout/:stage":"checkoutStageRoute","/search":"searchRoute","/:category/":"categoryRoute","/:category/:item_slug":"itemRoute","/:category/:item_slug/:variation_slug":"variationRoute","/:notfound":"notFound"},staticRoute:function(a,b,c){$("[data-view=static][data-view-name="+a+"]").length?c&&new c({el:$("#main")[0]}):(delete this.state.category,this.removeCurrentView(),this.view=null,this.navView.updateCategory(),$.get("/"+(a==="home"?"":a)+"?contentonly=1",{},function(a){if(c){var d=new c({el:$(a)[0]});$("#main").html(d.el)}else $("#main").html(a);b&&(document.title=b)},"html"))},homeRoute:function(){this.staticRoute("home","Welcome to The Birmingham Bead Shop",HomeView)},helpRoute:function(){this.staticRoute("help","Help @ The Birmingham Bead Shop")},contactRoute:function(){this.staticRoute("contact","Contact The Birmingham Bead Shop")},deliveryRoute:function(){this.staticRoute("delivery","About Delivery From The Birmingham Bead Shop")},privacyRoute:function(){this.staticRoute("privacy","Your Privacy @ The Birmingham Bead Shop")},termsRoute:function(){this.staticRoute("terms","Terms and Conditions @ The Birmingham Bead Shop")},shopRoute:function(){this.staticRoute("shop","The Bricks & Mortar Birmingham Bead Shop")},basketRoute:function(a){delete this.state.category,this.removeCurrentView(),this.view=new CartView({model:this.order}),$("#main").append(this.view.render().el),this.navView.updateCategory(),document.title="Your Basket @ The Birmingham Bead Shop"},checkoutRoute:function(a){this.navigateToCurrentCheckoutRoute()},checkoutStageRoute:function(a,b){this.doCheckoutRoute(a)},doCheckoutRoute:function(a){(!a||!_.include(this.order.getAllowedStages(),a))&&this.navigateToCurrentCheckoutRoute(),delete this.state.category,this.view instanceof CheckoutView?this.view.setStage(a):(this.removeCurrentView(),this.view=new CheckoutView({model:this.order,stage:a}),$("#main").append(this.view.render().el),document.title="Checkout @ The Birmingham Bead Shop"),this.navView.updateCategory()},checkoutReturn:function(){delete this.state.category,this.removeCurrentView(),this.view=new CheckoutReturn({model:this.previous_order||this.order}),$("#main").append(this.view.render().el),this.navView.updateCategory()},navigateToCurrentCheckoutRoute:function(){this.navigate("/checkout/"+this.order.getNextStage(),!0)},_addListRouteParams:function(a,b){"color"in a&&(b.color=a.color),"tag"in a&&(b.tag=a.tag),"hole-size-min"in a&&(b["hole-size-min"]=parseFloat(a["hole-size-min"])),"hole-size-max"in a&&(b["hole-size-max"]=parseFloat(a["hole-size-max"])),"size-min"in a&&(b["size-min"]=parseFloat(a["size-min"])),"size-max"in a&&(b["size-max"]=parseFloat(a["size-max"]))},searchRoute:function(a){var b=this,c={q:a.q},d=e!=this.state.query;this._addListRouteParams(a,c);var e=_.clone(c);d&&(e.loadStats=!0),_.isEqual(c,this.state)?this.showListView(d):this.loadItems(e,function(){b.showListView(d)}),this.state=c,this.navView.updateCategory(),document.title='Searching for "'+a.q+'" @ The Birmingham Bead Shop'},categoryRoute:function(a,b){var c=this,d=a!=this.state.category,e={category:a},f=this.collections.categories.detect(function(b){return b.get("slug")==a});if(!f)this.showNotFound("The category you requested does not seem to exist...");else{this._addListRouteParams(b,e);var g=_.clone(e);d&&(g.loadStats=!0),this.navView.clearQ(),_.isEqual(e,this.state)?this.showListView(d):this.loadItems(g,function(){c.showListView(d)}),this.state=e,document.title=Utils.toTitleCase(f.get("title"))+" @ The Birmingham Bead Shop"}},showListView:function(a){this.view!==this.itemList?(this.removeCurrentView(),this.view=this.itemList,$("#main").addClass("no-scroll"),$("#main").append(this.view.render(a).el)):this.view.render(a),this.navView.updateCategory()},itemRoute:function(a,b){this.showNotFound()},variationRoute:function(a,b,c){this.view instanceof ItemDetail&&this.view.model.get("slug")==b?(this.view.setVariation(c),document.title=this.view.cartItem.getTitle()+" @ The Birmingham Bead Shop"):(this.removeCurrentView(),this.getItem(b,function(a){a?(this.view=new ItemDetail({model:a,item_slug:b,variation_slug:c}),$("#main").append(this.view.render().el),document.title=this.view.cartItem.getTitle()+" @ The Birmingham Bead Shop"):(this.showNotFound("The item you are looking for could not be found..."),document.title="Not Found @ The Birmingham Bead Shop")}))},notFound:function(a){this.showNotFound()},showNotFound:function(a){a=a||"The page you requested could not be found",this.removeCurrentView(),this.view=new NotFound({message:a}),$("#main").append(this.view.render().el)},removeCurrentView:function(){$(".main-view").remove(),this.view&&$(this.view.el).remove(),$("#main").removeClass("no-scroll")},getListURL:function(){var a=_.clone(this.state);delete a.item,delete a.variation;var b="";a.q?b="/search":(b="/"+a.category+"/",delete a.category);return _.isEmpty(a)?b:$.url.build({path:b,params:a})},loadItems:function(a,b){function e(a,b,c){console.log(a,b,c)}function d(a,d,e){c.parse(a),b&&b.apply(c)}var c=this;$.ajax({url:"/data/items",traditional:!0,data:a,dataType:"json",success:d,error:e})},parse:function(a){_.each(a,function(b,c,d){switch(c){case"items":this.collections.items.extractSubCollections(b),this.collections.items.reset(a.items);break;case"colors":this.collections.colors.reset(b);break;case"tags":this.collections.tags.reset(b);break;case"sizes":this.collections.sizes.reset(b);break;case"hole_sizes":this.collections.holesizes.reset(b);break;default:}},this)},getItem:function(a,b){var c=this.collections.items.detect(function(b){return b.get("slug")==a});c?b.apply(this,[c]):this.loadItems({slug:a},function(){b.apply(this,[this.collections.items.at(0)])})},updateLayout:function(a){$.browser.msie&&$.browser.version<8&&$("#main").width($(window).width()-$("header").outerWidth(!0)),this.view&&this.view.updateLayout&&this.view.updateLayout()}})
