// lib/handlebars/parser.js
/* Jison generated parser */
var handlebars = (function(){
var parser = {trace: function trace() { },
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 anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {

var $0 = $$.length - 1;
switch (yystate) {
case 1: return $$[$0-1] 
break;
case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]) 
break;
case 3: this.$ = new yy.ProgramNode($$[$0]) 
break;
case 4: this.$ = new yy.ProgramNode([]) 
break;
case 5: this.$ = [$$[$0]] 
break;
case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1] 
break;
case 7: this.$ = new yy.InverseNode($$[$0-2], $$[$0-1], $$[$0]) 
break;
case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0]) 
break;
case 9: this.$ = $$[$0] 
break;
case 10: this.$ = $$[$0] 
break;
case 11: this.$ = new yy.ContentNode($$[$0]) 
break;
case 12: this.$ = new yy.CommentNode($$[$0]) 
break;
case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]) 
break;
case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]) 
break;
case 15: this.$ = $$[$0-1] 
break;
case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]) 
break;
case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true) 
break;
case 18: this.$ = new yy.PartialNode($$[$0-1]) 
break;
case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]) 
break;
case 20: 
break;
case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]] 
break;
case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null] 
break;
case 23: this.$ = [[$$[$0-1]], $$[$0]] 
break;
case 24: this.$ = [[$$[$0]], null] 
break;
case 25: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; 
break;
case 26: this.$ = [$$[$0]] 
break;
case 27: this.$ = $$[$0] 
break;
case 28: this.$ = new yy.StringNode($$[$0]) 
break;
case 29: this.$ = new yy.IntegerNode($$[$0]) 
break;
case 30: this.$ = new yy.BooleanNode($$[$0]) 
break;
case 31: this.$ = new yy.HashNode($$[$0]) 
break;
case 32: $$[$0-1].push($$[$0]); this.$ = $$[$0-1] 
break;
case 33: this.$ = [$$[$0]] 
break;
case 34: this.$ = [$$[$0-2], $$[$0]] 
break;
case 35: this.$ = [$$[$0-2], new yy.StringNode($$[$0])] 
break;
case 36: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])] 
break;
case 37: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])] 
break;
case 38: this.$ = new yy.IdNode($$[$0]) 
break;
case 39: $$[$0-2].push($$[$0]); this.$ = $$[$0-2]; 
break;
case 40: this.$ = [$$[$0]] 
break;
}
},
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 parseError(str, hash) {
    throw new Error(str);
},
parse: function parse(input) {
    var self = this,
        stack = [0],
        vstack = [null], // semantic value stack
        lstack = [], // location stack
        table = this.table,
        yytext = '',
        yylineno = 0,
        yyleng = 0,
        recovering = 0,
        TERROR = 2,
        EOF = 1;

    //this.reductionCount = this.shiftCount = 0;

    this.lexer.setInput(input);
    this.lexer.yy = this.yy;
    this.yy.lexer = this.lexer;
    if (typeof this.lexer.yylloc == 'undefined')
        this.lexer.yylloc = {};
    var yyloc = this.lexer.yylloc;
    lstack.push(yyloc);

    if (typeof this.yy.parseError === 'function')
        this.parseError = this.yy.parseError;

    function popStack (n) {
        stack.length = stack.length - 2*n;
        vstack.length = vstack.length - n;
        lstack.length = lstack.length - n;
    }

    function lex() {
        var token;
        token = self.lexer.lex() || 1; // $end = 1
        // if token isn't its numeric value, convert
        if (typeof token !== 'number') {
            token = self.symbols_[token] || token;
        }
        return token;
    };

    var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
    while (true) {
        // retreive state number from top of stack
        state = stack[stack.length-1];

        // use default actions if available
        if (this.defaultActions[state]) {
            action = this.defaultActions[state];
        } else {
            if (symbol == null)
                symbol = lex();
            // read action for current state and first input
            action = table[state] && table[state][symbol];
        }

        // handle parse error
        if (typeof action === 'undefined' || !action.length || !action[0]) {

            if (!recovering) {
                // Report error
                expected = [];
                for (p in table[state]) if (this.terminals_[p] && p > 2) {
                    expected.push("'"+this.terminals_[p]+"'");
                }
                var errStr = '';
                if (this.lexer.showPosition) {
                    errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+'\nExpecting '+expected.join(', ');
                } else {
                    errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
                                  (symbol == 1 /*EOF*/ ? "end of input" :
                                              ("'"+(this.terminals_[symbol] || symbol)+"'"));
                }
                this.parseError(errStr,
                    {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
            }

            // just recovered from another error
            if (recovering == 3) {
                if (symbol == EOF) {
                    throw new Error(errStr || 'Parsing halted.');
                }

                // discard current lookahead and grab another
                yyleng = this.lexer.yyleng;
                yytext = this.lexer.yytext;
                yylineno = this.lexer.yylineno;
                yyloc = this.lexer.yylloc;
                symbol = lex();
            }

            // try to recover from error
            while (1) {
                // check for error recovery rule in this state
                if ((TERROR.toString()) in table[state]) {
                    break;
                }
                if (state == 0) {
                    throw new Error(errStr || 'Parsing halted.');
                }
                popStack(1);
                state = stack[stack.length-1];
            }

            preErrorSymbol = symbol; // save the lookahead token
            symbol = TERROR;         // insert generic error symbol as new lookahead
            state = stack[stack.length-1];
            action = table[state] && table[state][TERROR];
            recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
        }

        // this shouldn't happen, unless resolve defaults are off
        if (action[0] instanceof Array && action.length > 1) {
            throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
        }

        switch (action[0]) {

            case 1: // shift
                //this.shiftCount++;

                stack.push(symbol);
                vstack.push(this.lexer.yytext);
                lstack.push(this.lexer.yylloc);
                stack.push(action[1]); // push state
                symbol = null;
                if (!preErrorSymbol) { // normal execution/no error
                    yyleng = this.lexer.yyleng;
                    yytext = this.lexer.yytext;
                    yylineno = this.lexer.yylineno;
                    yyloc = this.lexer.yylloc;
                    if (recovering > 0)
                        recovering--;
                } else { // error just occurred, resume old lookahead f/ before error
                    symbol = preErrorSymbol;
                    preErrorSymbol = null;
                }
                break;

            case 2: // reduce
                //this.reductionCount++;

                len = this.productions_[action[1]][1];

                // perform semantic action
                yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
                // default location, uses first token for firsts, last for lasts
                yyval._$ = {
                    first_line: lstack[lstack.length-(len||1)].first_line,
                    last_line: lstack[lstack.length-1].last_line,
                    first_column: lstack[lstack.length-(len||1)].first_column,
                    last_column: lstack[lstack.length-1].last_column
                };
                r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);

                if (typeof r !== 'undefined') {
                    return r;
                }

                // pop off stack
                if (len) {
                    stack = stack.slice(0,-1*len*2);
                    vstack = vstack.slice(0, -1*len);
                    lstack = lstack.slice(0, -1*len);
                }

                stack.push(this.productions_[action[1]][0]);    // push nonterminal (reduce)
                vstack.push(yyval.$);
                lstack.push(yyval._$);
                // goto new state = table[STATE][NONTERMINAL]
                newState = table[stack[stack.length-2]][stack[stack.length-1]];
                stack.push(newState);
                break;

            case 3: // accept
                return true;
        }

    }

    return true;
}};/* Jison generated lexer */
var lexer = (function(){var lexer = ({EOF:1,
parseError:function parseError(str, hash) {
        if (this.yy.parseError) {
            this.yy.parseError(str, hash);
        } else {
            throw new Error(str);
        }
    },
setInput:function (input) {
        this._input = input;
        this._more = this._less = this.done = false;
        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 ch = this._input[0];
        this.yytext+=ch;
        this.yyleng++;
        this.match+=ch;
        this.matched+=ch;
        var lines = ch.match(/\n/);
        if (lines) this.yylineno++;
        this._input = this._input.slice(1);
        return ch;
    },
unput:function (ch) {
        this._input = ch + this._input;
        return this;
    },
more:function () {
        this._more = true;
        return this;
    },
pastInput:function () {
        var past = this.matched.substr(0, this.matched.length - this.match.length);
        return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
    },
upcomingInput:function () {
        var next = this.match;
        if (next.length < 20) {
            next += this._input.substr(0, 20-next.length);
        }
        return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
    },
showPosition:function () {
        var pre = this.pastInput();
        var c = new Array(pre.length + 1).join("-");
        return pre + this.upcomingInput() + "\n" + c+"^";
    },
next:function () {
        if (this.done) {
            return this.EOF;
        }
        if (!this._input) this.done = true;

        var token,
            match,
            col,
            lines;
        if (!this._more) {
            this.yytext = '';
            this.match = '';
        }
        var rules = this._currentRules();
        for (var i=0;i < rules.length; i++) {
            match = this._input.match(this.rules[rules[i]]);
            if (match) {
                lines = match[0].match(/\n.*/g);
                if (lines) this.yylineno += lines.length;
                this.yylloc = {first_line: this.yylloc.last_line,
                               last_line: this.yylineno+1,
                               first_column: this.yylloc.last_column,
                               last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
                this.yytext += match[0];
                this.match += match[0];
                this.matches = match;
                this.yyleng = this.yytext.length;
                this._more = false;
                this._input = this._input.slice(match[0].length);
                this.matched += match[0];
                token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]);
                if (token) return token;
                else return;
            }
        }
        if (this._input === "") {
            return this.EOF;
        } else {
            this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), 
                    {text: "", token: null, line: this.yylineno});
        }
    },
lex:function lex() {
        var r = this.next();
        if (typeof r !== 'undefined') {
            return r;
        } else {
            return this.lex();
        }
    },
begin:function begin(condition) {
        this.conditionStack.push(condition);
    },
popState:function popState() {
        return this.conditionStack.pop();
    },
_currentRules:function _currentRules() {
        return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
    }});
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {

var YYSTATE=YY_START
switch($avoiding_name_collisions) {
case 0: this.begin("mu"); if (yy_.yytext) return 14; 
break;
case 1: return 14; 
break;
case 2: return 24; 
break;
case 3: return 16; 
break;
case 4: return 20; 
break;
case 5: return 19; 
break;
case 6: return 19; 
break;
case 7: return 23; 
break;
case 8: return 23; 
break;
case 9: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.begin("INITIAL"); return 15; 
break;
case 10: return 22; 
break;
case 11: return 34; 
break;
case 12: return 33; 
break;
case 13: return 33; 
break;
case 14: return 36; 
break;
case 15: /*ignore whitespace*/ 
break;
case 16: this.begin("INITIAL"); return 18; 
break;
case 17: this.begin("INITIAL"); return 18; 
break;
case 18: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 28; 
break;
case 19: return 30; 
break;
case 20: return 30; 
break;
case 21: return 29; 
break;
case 22: return 33; 
break;
case 23: return 'INVALID'; 
break;
case 24: return 5; 
break;
}
};
lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s/.])/,/^./,/^$/];
lexer.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":false},"INITIAL":{"rules":[0,1,24],"inclusive":true}};return lexer;})()
parser.lexer = lexer;
return parser;
})();
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.parser = handlebars;
exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); }
exports.main = function commonjsMain(args) {
    if (!args[1])
        throw new Error('Usage: '+args[0]+' FILE');
    if (typeof process !== 'undefined') {
        var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
    } else {
        var cwd = require("file").path(require("file").cwd());
        var source = cwd.join(args[1]).read({charset: "utf-8"});
    }
    return exports.parser.parse(source);
}
if (typeof module !== 'undefined' && require.main === module) {
  exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
}
};
;
// lib/handlebars/base.js
var Handlebars = {};

Handlebars.VERSION = "1.0.beta.2";

Handlebars.Parser = handlebars;

Handlebars.parse = function(string) {
  Handlebars.Parser.yy = Handlebars.AST;
  return Handlebars.Parser.parse(string);
};

Handlebars.print = function(ast) {
  return new Handlebars.PrintVisitor().accept(ast);
};

Handlebars.helpers  = {};
Handlebars.partials = {};

Handlebars.registerHelper = function(name, fn, inverse) {
  if(inverse) { fn.not = inverse; }
  this.helpers[name] = fn;
};

Handlebars.registerPartial = function(name, str) {
  this.partials[name] = str;
};

Handlebars.registerHelper('helperMissing', function(arg) {
  if(arguments.length === 2) {
    return undefined;
  } else {
    throw new Error("Could not find property '" + arg + "'");
  }
});

Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
  inverse = inverse || function() {};

  var ret = "";
  var type = Object.prototype.toString.call(context);

  if(type === "[object Function]") {
    context = context();
  }

  if(context === true) {
    return fn(this);
  } else if(context === false || context == null) {
    return inverse(this);
  } else if(type === "[object Array]") {
    if(context.length > 0) {
      for(var i=0, j=context.length; i<j; i++) {
        ret = ret + fn(context[i]);
      }
    } else {
      ret = inverse(this);
    }
    return ret;
  } else {
    return fn(context);
  }
}, function(context, fn) {
  return fn(context);
});

Handlebars.registerHelper('each', function(context, fn, inverse) {
  var ret = "";

  if(context && context.length > 0) {
    for(var i=0, j=context.length; i<j; i++) {
      ret = ret + fn(context[i]);
    }
  } else {
    ret = inverse(this);
  }
  return ret;
});

Handlebars.registerHelper('if', function(context, fn, inverse) {
  if(!context || context == []) {
    return inverse(this);
  } else {
    return fn(this);
  }
});

Handlebars.registerHelper('unless', function(context, fn, inverse) {
  return Handlebars.helpers['if'].call(this, context, inverse, fn);
});

Handlebars.registerHelper('with', function(context, fn) {
  return fn(context);
});

Handlebars.logger = {
  DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,

  // override in the host environment
  log: function(level, str) {}
};

Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
;
// lib/handlebars/ast.js
(function() {

  Handlebars.AST = {};

  Handlebars.AST.ProgramNode = function(statements, inverse) {
    this.type = "program";
    this.statements = statements;
    if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
  };

  Handlebars.AST.MustacheNode = function(params, hash, unescaped) {
    this.type = "mustache";
    this.id = params[0];
    this.params = params.slice(1);
    this.hash = hash;
    this.escaped = !unescaped;
  };

  Handlebars.AST.PartialNode = function(id, context) {
    this.type    = "partial";

    // TODO: disallow complex IDs

    this.id      = id;
    this.context = context;
  };

  var verifyMatch = function(open, close) {
    if(open.original !== close.original) {
      throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
    }
  };

  Handlebars.AST.BlockNode = function(mustache, program, close) {
    verifyMatch(mustache.id, close);
    this.type = "block";
    this.mustache = mustache;
    this.program  = program;
  };

  Handlebars.AST.InverseNode = function(mustache, program, close) {
    verifyMatch(mustache.id, close);
    this.type = "inverse";
    this.mustache = mustache;
    this.program  = program;
  };

  Handlebars.AST.ContentNode = function(string) {
    this.type = "content";
    this.string = string;
  };

  Handlebars.AST.HashNode = function(pairs) {
    this.type = "hash";
    this.pairs = pairs;
  };

  Handlebars.AST.IdNode = function(parts) {
    this.type = "ID";
    this.original = parts.join(".");

    var dig = [], depth = 0;

    for(var i=0,l=parts.length; i<l; i++) {
      var part = parts[i];

      if(part === "..") { depth++; }
      else if(part === "." || part === "this") { continue; }
      else { dig.push(part); }
    }

    this.parts    = dig;
    this.string   = dig.join('.');
    this.depth    = depth;
    this.isSimple = (dig.length === 1) && (depth === 0);
  };

  Handlebars.AST.StringNode = function(string) {
    this.type = "STRING";
    this.string = string;
  };

  Handlebars.AST.IntegerNode = function(integer) {
    this.type = "INTEGER";
    this.integer = integer;
  };

  Handlebars.AST.BooleanNode = function(boolean) {
    this.type = "BOOLEAN";
    this.boolean = boolean;
  };

  Handlebars.AST.CommentNode = function(comment) {
    this.type = "comment";
    this.comment = comment;
  };

})();;
// lib/handlebars/visitor.js

Handlebars.Visitor = function() {};

Handlebars.Visitor.prototype = {
  accept: function(object) {
    return this[object.type](object);
  }
};;
// lib/handlebars/utils.js
Handlebars.Exception = function(message) {
  this.message = message;
};

// Build out our basic SafeString type
Handlebars.SafeString = function(string) {
  this.string = string;
};
Handlebars.SafeString.prototype.toString = function() {
  return this.string.toString();
};

(function() {
  var escape = {
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&#x27;",
    "`": "&#x60;"
  };

  var badChars = /&(?!\w+;)|[<>"'`]/g;
  var possible = /[&<>"'`]/;

  var escapeChar = function(chr) {
    return escape[chr] || "&amp;"
  };

  Handlebars.Utils = {
    escapeExpression: function(string) {
      // don't escape SafeStrings, since they're already safe
      if (string instanceof Handlebars.SafeString) {
        return string.toString();
      } else if (string == null || string === false) {
        return "";
      }

      if(!possible.test(string)) { return string; }
      return string.replace(badChars, escapeChar);
    },

    isEmpty: function(value) {
      if (typeof value === "undefined") {
        return true;
      } else if (value === null) {
        return true;
      } else if (value === false) {
        return true;
      } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
        return true;
      } else {
        return false;
      }
    }
  };
})();;
// lib/handlebars/compiler.js
Handlebars.Compiler = function() {};
Handlebars.JavaScriptCompiler = function() {};

(function(Compiler, JavaScriptCompiler) {
  Compiler.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
  };

  Compiler.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
  };

  Compiler.DISASSEMBLE_MAP = {};

  for(var prop in Compiler.OPCODE_MAP) {
    var value = Compiler.OPCODE_MAP[prop];
    Compiler.DISASSEMBLE_MAP[value] = prop;
  }

  Compiler.multiParamSize = function(code) {
    return Compiler.MULTI_PARAM_OPCODES[Compiler.DISASSEMBLE_MAP[code]];
  };

  Compiler.prototype = {
    compiler: Compiler,

    disassemble: function() {
      var opcodes = this.opcodes, opcode, nextCode;
      var out = [], str, name, value;

      for(var i=0, l=opcodes.length; i<l; i++) {
        opcode = opcodes[i];

        if(opcode === 'DECLARE') {
          name = opcodes[++i];
          value = opcodes[++i];
          out.push("DECLARE " + name + " = " + value);
        } else {
          str = Compiler.DISASSEMBLE_MAP[opcode];

          var extraParams = Compiler.multiParamSize(opcode);
          var codes = [];

          for(var j=0; j<extraParams; j++) {
            nextCode = opcodes[++i];

            if(typeof nextCode === "string") {
              nextCode = "\"" + nextCode.replace("\n", "\\n") + "\"";
            }

            codes.push(nextCode);
          }

          str = str + " " + codes.join(" ");

          out.push(str);
        }
      }

      return out.join("\n");
    },

    guid: 0,

    compile: function(program, options) {
      this.children = [];
      this.depths = {list: []};
      this.options = options || {};
      return this.program(program);
    },

    accept: function(node) {
      return this[node.type](node);
    },

    program: function(program) {
      var statements = program.statements, statement;
      this.opcodes = [];

      for(var i=0, l=statements.length; i<l; i++) {
        statement = statements[i];
        this[statement.type](statement);
      }

      this.depths.list = this.depths.list.sort(function(a, b) {
        return a - b;
      });

      return this;
    },

    compileProgram: function(program) {
      var result = new this.compiler().compile(program, this.options);
      var guid = this.guid++;

      this.usePartial = this.usePartial || result.usePartial;

      this.children[guid] = result;

      for(var i=0, l=result.depths.list.length; i<l; i++) {
        depth = result.depths.list[i];

        if(depth < 2) { continue; }
        else { this.addDepth(depth - 1); }
      }

      return guid;
    },

    block: function(block) {
      var mustache = block.mustache;
      var depth, child, inverse, inverseGuid;

      var params = this.setupStackForMustache(mustache);

      var programGuid = this.compileProgram(block.program);

      if(block.program.inverse) {
        inverseGuid = this.compileProgram(block.program.inverse);
        this.declare('inverse', inverseGuid);
      }

      this.opcode('invokeProgram', programGuid, params.length);
      this.declare('inverse', null);
      this.opcode('append');
    },

    inverse: function(block) {
      this.ID(block.mustache.id);
      var programGuid = this.compileProgram(block.program);

      this.opcode('invokeInverse', programGuid);
      this.opcode('append');
    },

    hash: function(hash) {
      var pairs = hash.pairs, pair, val;

      this.opcode('push', '{}');

      for(var i=0, l=pairs.length; i<l; i++) {
        pair = pairs[i];
        val  = pair[1];

        this.accept(val);
        this.opcode('assignToHash', pair[0]);
      }
    },

    partial: function(partial) {
      var id = partial.id;
      this.usePartial = true;

      if(partial.context) {
        this.ID(partial.context);
      } else {
        this.opcode('push', 'context');
      }

      this.opcode('invokePartial', id.original);
      this.opcode('append');
    },

    content: function(content) {
      this.opcode('appendContent', content.string);
    },

    mustache: function(mustache) {
      var params = this.setupStackForMustache(mustache);

      this.opcode('invokeMustache', params.length, mustache.id.original);

      if(mustache.escaped) {
        this.opcode('appendEscaped');
      } else {
        this.opcode('append');
      }
    },

    ID: function(id) {
      this.addDepth(id.depth);

      this.opcode('getContext', id.depth);

      this.opcode('lookupWithHelpers', id.parts[0] || null);

      for(var i=1, l=id.parts.length; i<l; i++) {
        this.opcode('lookup', id.parts[i]);
      }
    },

    STRING: function(string) {
      this.opcode('pushString', string.string);
    },

    INTEGER: function(integer) {
      this.opcode('push', integer.integer);
    },

    BOOLEAN: function(boolean) {
      this.opcode('push', boolean.boolean);
    },

    comment: function() {},

    // HELPERS
    pushParams: function(params) {
      var i = params.length, param;

      while(i--) {
        param = params[i];

        if(this.options.stringParams) {
          if(param.depth) {
            this.addDepth(param.depth);
          }

          this.opcode('getContext', param.depth || 0);
          this.opcode('pushStringParam', param.string);
        } else {
          this[param.type](param);
        }
      }
    },

    opcode: function(name, val1, val2) {
      this.opcodes.push(Compiler.OPCODE_MAP[name]);
      if(val1 !== undefined) { this.opcodes.push(val1); }
      if(val2 !== undefined) { this.opcodes.push(val2); }
    },

    declare: function(name, value) {
      this.opcodes.push('DECLARE');
      this.opcodes.push(name);
      this.opcodes.push(value);
    },

    addDepth: function(depth) {
      if(depth === 0) { return; }

      if(!this.depths[depth]) {
        this.depths[depth] = true;
        this.depths.list.push(depth);
      }
    },

    setupStackForMustache: function(mustache) {
      var params = mustache.params;

      this.pushParams(params);

      if(mustache.hash) {
        this.hash(mustache.hash);
      } else {
        this.opcode('push', '{}');
      }

      this.ID(mustache.id);

      return params;
    }
  };

  JavaScriptCompiler.prototype = {
    // PUBLIC API: You can override these methods in a subclass to provide
    // alternative compiled forms for name lookup and buffering semantics
    nameLookup: function(parent, name, type) {
      if(JavaScriptCompiler.RESERVED_WORDS[name] || name.indexOf('-') !== -1 || !isNaN(name)) {
        return parent + "['" + name + "']";
      } else if (/^[0-9]+$/.test(name)) {
        return parent + "[" + name + "]";
      } else {
        return parent + "." + name;
      }
    },

    appendToBuffer: function(string) {
      return "buffer = buffer + " + string + ";";
    },

    initializeBuffer: function() {
      return this.quotedString("");
    },
    // END PUBLIC API

    compile: function(environment, options) {
      this.environment = environment;
      this.options = options || {};

      this.preamble();

      this.stackSlot = 0;
      this.stackVars = [];
      this.registers = {list: []};

      this.compileChildren(environment, options);

      Handlebars.log(Handlebars.logger.DEBUG, environment.disassemble() + "\n\n");

      var opcodes = environment.opcodes, opcode, name, declareName, declareVal;

      this.i = 0;

      for(l=opcodes.length; this.i<l; this.i++) {
        opcode = this.nextOpcode(0);

        if(opcode[0] === 'DECLARE') {
          this.i = this.i + 2;
          this[opcode[1]] = opcode[2];
        } else {
          this.i = this.i + opcode[1].length;
          this[opcode[0]].apply(this, opcode[1]);
        }
      }

      return this.createFunction();
    },

    nextOpcode: function(n) {
      var opcodes = this.environment.opcodes, opcode = opcodes[this.i + n], name, val;
      var extraParams, codes;

      if(opcode === 'DECLARE') {
        name = opcodes[this.i + 1];
        val  = opcodes[this.i + 2];
        return ['DECLARE', name, val];
      } else {
        name = Compiler.DISASSEMBLE_MAP[opcode];

        extraParams = Compiler.multiParamSize(opcode);
        codes = [];

        for(var j=0; j<extraParams; j++) {
          codes.push(opcodes[this.i + j + 1 + n]);
        }

        return [name, codes];
      }
    },

    eat: function(opcode) {
      this.i = this.i + opcode.length;
    },

    preamble: function() {
      var out = [];
      out.push("var buffer = " + this.initializeBuffer() + ", currentContext = context");

      var copies = "helpers = helpers || Handlebars.helpers;";
      if(this.environment.usePartial) { copies = copies + " partials = partials || Handlebars.partials;"; }
      out.push(copies);

      // track the last context pushed into place to allow skipping the
      // getContext opcode when it would be a noop
      this.lastContext = 0;
      this.source = out;
    },

    createFunction: function() {
      var container = {
        escapeExpression: Handlebars.Utils.escapeExpression,
        invokePartial: Handlebars.VM.invokePartial,
        programs: [],
        program: function(i, helpers, partials, data) {
          var programWrapper = this.programs[i];
          if(data) {
            return Handlebars.VM.program(this.children[i], helpers, partials, data);
          } else if(programWrapper) {
            return programWrapper;
          } else {
            programWrapper = this.programs[i] = Handlebars.VM.program(this.children[i], helpers, partials);
            return programWrapper;
          }
        },
        programWithDepth: Handlebars.VM.programWithDepth,
        noop: Handlebars.VM.noop
      };
      var locals = this.stackVars.concat(this.registers.list);

      if(locals.length > 0) {
        this.source[0] = this.source[0] + ", " + locals.join(", ");
      }

      this.source[0] = this.source[0] + ";";

      this.source.push("return buffer;");

      var params = ["Handlebars", "context", "helpers", "partials"];

      if(this.options.data) { params.push("data"); }

      for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
        params.push("depth" + this.environment.depths.list[i]);
      }

      if(params.length === 4 && !this.environment.usePartial) { params.pop(); }

      params.push(this.source.join("\n"));

      var fn = Function.apply(this, params);
      fn.displayName = "Handlebars.js";

      Handlebars.log(Handlebars.logger.DEBUG, fn.toString() + "\n\n");

      container.render = fn;

      container.children = this.environment.children;

      return function(context, options, $depth) {
        try {
          options = options || {};
          var args = [Handlebars, context, options.helpers, options.partials, options.data];
          var depth = Array.prototype.slice.call(arguments, 2);
          args = args.concat(depth);
          return container.render.apply(container, args);
        } catch(e) {
          throw e;
        }
      };
    },

    appendContent: function(content) {
      this.source.push(this.appendToBuffer(this.quotedString(content)));
    },

    append: function() {
      var local = this.popStack();
      this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
    },

    appendEscaped: function() {
      var opcode = this.nextOpcode(1), extra = "";

      if(opcode[0] === 'appendContent') {
        extra = " + " + this.quotedString(opcode[1][0]);
        this.eat(opcode);
      }

      this.source.push(this.appendToBuffer("this.escapeExpression(" + this.popStack() + ")" + extra));
    },

    getContext: function(depth) {
      if(this.lastContext !== depth) {
        this.lastContext = depth;

        if(depth === 0) {
          this.source.push("currentContext = context;");
        } else {
          this.source.push("currentContext = depth" + depth + ";");
        }
      }
    },

    lookupWithHelpers: function(name) {
      if(name) {
        var topStack = this.nextStack();

        var toPush =  "if('" + name + "' in helpers) { " + topStack +
                      " = " + this.nameLookup('helpers', name, 'helper') +
                      "; } else { " + topStack + " = " +
                      this.nameLookup('currentContext', name, 'context') +
                      "; }";

        this.source.push(toPush);
      } else {
        this.pushStack("currentContext");
      }
    },

    lookup: function(name) {
      var topStack = this.topStack();
      this.source.push(topStack + " = " + this.nameLookup(topStack, name, 'context') + ";");
    },

    pushStringParam: function(string) {
      this.pushStack("currentContext");
      this.pushString(string);
    },

    pushString: function(string) {
      this.pushStack(this.quotedString(string));
    },

    push: function(name) {
      this.pushStack(name);
    },

    invokeMustache: function(paramSize, original) {
      this.populateParams(paramSize, this.quotedString(original), "{}", null, function(nextStack, helperMissingString, id) {
        this.source.push("else if(" + id + "=== undefined) { " + nextStack + " = helpers.helperMissing.call(" + helperMissingString + "); }");
        this.source.push("else { " + nextStack + " = " + id + "; }");
      });
    },

    invokeProgram: function(guid, paramSize) {
      var inverse = this.programExpression(this.inverse);
      var mainProgram = this.programExpression(guid);

      this.populateParams(paramSize, null, mainProgram, inverse, function(nextStack, helperMissingString, id) {
        this.source.push("else { " + nextStack + " = helpers.blockHelperMissing.call(" + helperMissingString + "); }");
      });
    },

    populateParams: function(paramSize, helperId, program, inverse, fn) {
      var id = this.popStack(), nextStack;
      var params = [], param, stringParam;

      var hash = this.popStack();

      this.register('tmp1', program);
      this.source.push('tmp1.hash = ' + hash + ';');

      if(this.options.stringParams) {
        this.source.push('tmp1.contexts = [];');
      }

      for(var i=0; i<paramSize; i++) {
        param = this.popStack();
        params.push(param);

        if(this.options.stringParams) {
          this.source.push('tmp1.contexts.push(' + this.popStack() + ');');
        }
      }

      if(inverse) {
        this.source.push('tmp1.fn = tmp1;');
        this.source.push('tmp1.inverse = ' + inverse + ';');
      }

      if(this.options.data) {
        this.source.push('tmp1.data = data;');
      }

      params.push('tmp1');

      // TODO: This is legacy behavior. Deprecate and remove.
      if(inverse) {
        params.push(inverse);
      }

      this.populateCall(params, id, helperId || id, fn);
    },

    populateCall: function(params, id, helperId, fn) {
      var paramString = ["context"].concat(params).join(", ");
      var helperMissingString = ["context"].concat(helperId).concat(params).join(", ");

      nextStack = this.nextStack();

      this.source.push("if(typeof " + id + " === 'function') { " + nextStack + " = " + id + ".call(" + paramString + "); }");
      fn.call(this, nextStack, helperMissingString, id);
    },

    invokeInverse: function(guid) {
      var program = this.programExpression(guid);

      var blockMissingParams = ["context", this.topStack(), "this.noop", program];
      this.pushStack("helpers.blockHelperMissing.call(" + blockMissingParams.join(", ") + ")");
    },

    invokePartial: function(context) {
      this.pushStack("this.invokePartial(" + this.nameLookup('partials', context, 'partial') + ", '" + context + "', " + this.popStack() + ", helpers, partials);");
    },

    assignToHash: function(key) {
      var value = this.popStack();
      var hash = this.topStack();

      this.source.push(hash + "['" + key + "'] = " + value + ";");
    },

    // HELPERS

    compiler: JavaScriptCompiler,

    compileChildren: function(environment, options) {
      var children = environment.children, child, compiler;
      var compiled = [];

      for(var i=0, l=children.length; i<l; i++) {
        child = children[i];
        compiler = new this.compiler();

        compiled[i] = compiler.compile(child, options);
      }

      environment.rawChildren = children;
      environment.children = compiled;
    },

    programExpression: function(guid) {
      if(guid == null) { return "this.noop"; }

      var programParams = [guid, "helpers", "partials"];

      var depths = this.environment.rawChildren[guid].depths.list;

      if(this.options.data) { programParams.push("data"); }

      for(var i=0, l = depths.length; i<l; i++) {
        depth = depths[i];

        if(depth === 1) { programParams.push("context"); }
        else { programParams.push("depth" + (depth - 1)); }
      }

      if(!this.environment.usePartial) {
        if(programParams[3]) {
          programParams[2] = "null";
        } else {
          programParams.pop();
        }
      }

      if(depths.length === 0) {
        return "this.program(" + programParams.join(", ") + ")";
      } else {
        programParams[0] = "this.children[" + guid + "]";
        return "this.programWithDepth(" + programParams.join(", ") + ")";
      }
    },

    register: function(name, val) {
      this.useRegister(name);
      this.source.push(name + " = " + val + ";");
    },

    useRegister: function(name) {
      if(!this.registers[name]) {
        this.registers[name] = true;
        this.registers.list.push(name);
      }
    },

    pushStack: function(item) {
      this.source.push(this.nextStack() + " = " + item + ";");
      return "stack" + this.stackSlot;
    },

    nextStack: function() {
      this.stackSlot++;
      if(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(str) {
      return '"' + str
        .replace(/\\/g, '\\\\')
        .replace(/"/g, '\\"')
        .replace(/\n/g, '\\n')
        .replace(/\r/g, '\\r') + '"';
    }
  };

  var reservedWords = ("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 = JavaScriptCompiler.RESERVED_WORDS = {};

  for(var i=0, l=reservedWords.length; i<l; i++) {
    compilerWords[reservedWords[i]] = true;
  }

})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);

Handlebars.VM = {
  programWithDepth: function(fn, helpers, partials, data, $depth) {
    var args = Array.prototype.slice.call(arguments, 4);

    return function(context, options) {
      options = options || {};

      options = {
        helpers: options.helpers || helpers,
        partials: options.partials || partials,
        data: options.data || data
      };

      return fn.apply(this, [context, options].concat(args));
    };
  },
  program: function(fn, helpers, partials, data) {
    return function(context, options) {
      options = options || {};

      return fn(context, {
        helpers: options.helpers || helpers,
        partials: options.partials || partials,
        data: options.data || data
      });
    };
  },
  noop: function() { return ""; },
  compile: function(string, options) {
    var ast = Handlebars.parse(string);
    var environment = new Handlebars.Compiler().compile(ast, options);
    return new Handlebars.JavaScriptCompiler().compile(environment, options);
  },
  invokePartial: function(partial, name, context, helpers, partials) {
    if(partial === undefined) {
      throw new Handlebars.Exception("The partial " + name + " could not be found");
    } else if(partial instanceof Function) {
      return partial(context, {helpers: helpers, partials: partials});
    } else {
      partials[name] = Handlebars.VM.compile(partial);
      return partials[name](context, {helpers: helpers, partials: partials});
    }
  }
};

Handlebars.compile = Handlebars.VM.compile;;

// jQuery is loaded from a CDN

// jQuery Tools is loaded from a CDN


/*
 * flowplayer.js 3.2.2. The Flowplayer API
 *
 * Copyright 2010 Flowplayer Oy
 *
 * This file is part of Flowplayer.
 *
 * Flowplayer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Flowplayer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Flowplayer.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Date: 2010-05-20 17:15:38 +0000 (Thu, 20 May 2010)
 * Revision: 480
 */
(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,G,t){var w=this,v=null,D=false,u,s,F=[],y={},x={},E,r,p,C,o,A;i(w,{id:function(){return E},isLoaded:function(){return(v!==null&&v.fp_play!=undefined&&!D)},getParent:function(){return q},hide:function(H){if(H){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=A+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(J){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var H=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(G.version)){q.innerHTML=""}flashembed(q,G,{config:t});if(J){J.cached=true;j(x,"onLoad",J)}};var I=0;m(a,function(){this.unload(function(K){if(++I==a.length){H()}})})}return w},unload:function(J){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(J){J(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(J){J(false)}return w}D=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(H){}var I=function(){v=null;q.innerHTML=u;D=false;if(J){J(true)}};setTimeout(I,50)}else{if(J){J(false)}}return w},getClip:function(H){if(H===undefined){H=C}return F[H]},getCommonClip:function(){return s},getPlaylist:function(){return F},getPlugin:function(H){var J=y[H];if(!J&&w.isLoaded()){var I=w._api().fp_getPlugin(H);if(I){J=new l(H,I,w);y[H]=J}}return J},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(H){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(H){return H?k(t):t},getFlashParams:function(){return G},loadPlugin:function(K,J,M,L){if(typeof M=="function"){L=M;M={}}var I=L?e():"_";w._api().fp_loadPlugin(K,J,M,I);var H={};H[I]=L;var N=new l(K,null,w,H);y[K]=N;return N},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(I,H){var J=function(){if(I!==undefined){w._api().fp_play(I,H)}else{w._api().fp_play()}};if(w.isLoaded()){J()}else{if(D){setTimeout(function(){w.play(I,H)},50)}else{w.load(function(){J()})}}return w},getVersion:function(){var I="flowplayer.js 3.2.2";if(w.isLoaded()){var H=v.fp_getVersion();H.push(I);return H}return I},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(H){w.setPlaylist([H]);return w},getIndex:function(){return p}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var H="on"+this;if(H.indexOf("*")!=-1){H=H.slice(0,H.length-1);var I="onBefore"+H.slice(2);w[I]=function(J){j(x,I,J);return w}}w[H]=function(J){j(x,H,J);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var H=this;w[H]=function(J,I){if(!w.isLoaded()){return w}var K=null;if(J!==undefined&&I!==undefined){K=v["fp_"+H](J,I)}else{K=(J===undefined)?v["fp_"+H]():v["fp_"+H](J)}return K==="undefined"||K===undefined?w:K}});w._fireEvent=function(Q){if(typeof Q=="string"){Q=[Q]}var R=Q[0],O=Q[1],M=Q[2],L=Q[3],K=0;if(t.debug){g(Q)}if(!w.isLoaded()&&R=="onLoad"&&O=="player"){v=v||c(r);o=v.clientHeight;m(F,function(){this._fireEvent("onLoad")});m(y,function(S,T){T._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(R=="onLoad"&&O!="player"){return}if(R=="onError"){if(typeof O=="string"||(typeof O=="number"&&typeof M=="number")){O=M;M=L}}if(R=="onContextMenu"){m(t.contextMenu[O],function(S,T){T.call(w)});return}if(R=="onPluginEvent"||R=="onBeforePluginEvent"){var H=O.name||O;var I=y[H];if(I){I._fireEvent("onUpdate",O);return I._fireEvent(M,Q.slice(3))}return}if(R=="onPlaylistReplace"){F=[];var N=0;m(O,function(){F.push(new h(this,N++,w))})}if(R=="onClipAdd"){if(O.isInStream){return}O=new h(O,M,w);F.splice(M,0,O);for(K=M+1;K<F.length;K++){F[K].index++}}var P=true;if(typeof O=="number"&&O<F.length){C=O;var J=F[O];if(J){P=J._fireEvent(R,M,L)}if(!J||P!==false){P=s._fireEvent(R,M,L,J)}}m(x[R],function(){P=this.call(w,O,M);if(this.cached){x[R].splice(K,1)}if(P===false){return false}K++});return P};function B(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}A=parseInt(q.style.height,10)||q.clientHeight;E=q.id||"fp"+e();r=G.id||E+"_api";G.id=r;t.playerId=E;if(typeof t=="string"){t={clip:{url:t}}}if(typeof t.clip=="string"){t.clip={url:t.clip}}t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var H=0;m(t.playlist,function(){var J=this;if(typeof J=="object"&&J.length){J={url:""+J}}m(t.clip,function(K,L){if(L!==undefined&&J[K]===undefined&&typeof L!="function"){J[K]=L}});t.playlist[H]=J;J=new h(J,H,w);F.push(J);H++});m(t,function(J,K){if(typeof K=="function"){if(s[J]){s[J](K)}else{j(x,J,K)}delete t[J]}});m(t.plugins,function(J,K){if(K){y[J]=new l(J,K,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);function I(J){if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(J)}u=q.innerHTML;if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",I,false)}else{if(q.attachEvent){q.attachEvent("onclick",I)}}}else{if(q.addEventListener){q.addEventListener("click",f,false)}w.load()}}if(typeof q=="string"){var z=c(q);if(!z){throw"Flowplayer cannot access element: "+q}else{q=z;B()}}else{B()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:true},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(l,f){if(f){for(key in f){if(f.hasOwnProperty(key)){l[key]=f[key]}}}return l}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(n){try{var l=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=l&&l.GetVariable("$version")}catch(m){}}f=e.exec(f);return f?[f[1],f[3]]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n='<object width="'+o.width+'" height="'+o.height+'" id="'+o.id+'" name="'+o.id+'"';if(o.cachebusting){o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(o.w3c||!h){n+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(o.w3c||h){n+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+='<param name="'+m+'" value="'+o[m]+'" />'}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='<param name="flashvars" value=\''+p+"' />"}n+="</object>";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="<h2>Flash version "+n.version+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(f.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+j+"'>here</a></p>");if(f.tagName=="A"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.2"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})();


/*
 * flowplayer.playlist 3.0.8. Flowplayer JavaScript plugin.
 *
 * This file is part of Flowplayer, http://flowplayer.org
 *
 * Author: Tero Piirainen, <info@flowplayer.org>
 * Copyright (c) 2008-2010 Flowplayer Ltd
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * SEE: http://www.opensource.org/licenses
 *
 * Date: 2010-05-04 05:33:23 +0000 (Tue, 04 May 2010)
 * Revision: 3405
 */
(function(a){$f.addPlugin("playlist",function(d,q){var o=this;var b={playingClass:"playing",pausedClass:"paused",progressClass:"progress",template:'<a href="${url}">${title}</a>',loop:false,playOnClick:true,manual:false};a.extend(b,q);d=a(d);var j=o.getPlaylist().length<=1||b.manual;var k=null;function e(s){var r=n;a.each(s,function(t,u){if(!a.isFunction(u)){r=r.replace("${"+t+"}",u).replace("$%7B"+t+"%7D",u)}});return r}function i(){k=p().unbind("click.playlist").bind("click.playlist",function(){return h(a(this),k.index(this))})}function c(){d.empty();a.each(o.getPlaylist(),function(){d.append(e(this))});i()}function h(r,s){if(r.hasClass(b.playingClass)||r.hasClass(b.pausedClass)){o.toggle()}else{r.addClass(b.progressClass);o.play(s)}return false}function m(){if(j){k=p()}k.removeClass(b.playingClass);k.removeClass(b.pausedClass);k.removeClass(b.progressClass)}function f(r){return(j)?k.filter("[href="+r.originalUrl+"]"):k.eq(r.index)}function p(){var r=d.find("a");return r.length?r:d.children()}if(!j){var n=d.is(":empty")?b.template:d.html();c()}else{k=p();if(a.isFunction(k.live)){var l=a(d.selector+" a");if(!l.length){l=a(d.selector+" > *")}l.live("click",function(){var r=a(this);return h(r,r.attr("href"))})}else{k.click(function(){var r=a(this);return h(r,r.attr("href"))})}var g=o.getClip(0);if(!g.url&&b.playOnClick){g.update({url:k.eq(0).attr("href")})}}o.onBegin(function(r){m();f(r).addClass(b.playingClass)});o.onPause(function(r){f(r).removeClass(b.playingClass).addClass(b.pausedClass)});o.onResume(function(r){f(r).removeClass(b.pausedClass).addClass(b.playingClass)});if(!b.loop&&!j){o.onBeforeFinish(function(r){if(!r.isInStream&&r.index<k.length-1){return false}})}if(j&&b.loop){o.onBeforeFinish(function(s){var r=f(s);if(r.next().length){r.next().click()}else{k.eq(0).click()}return false})}o.onUnload(function(){m()});if(!j){o.onPlaylistReplace(function(){c()})}o.onClipAdd(function(s,r){k.eq(r).before(e(s));i()});return o})})(jQuery);


/*
 * jQuery Address Plugin v1.2.1
 * http://www.asual.com/jquery/address/
 *
 * Copyright (c) 2009-2010 Rostislav Hristov
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Date: 2010-05-20 09:39:26 +0300 (Thu, 20 May 2010)
 */
(function(c){c.address=function(){var v=function(a){c(c.address).trigger(c.extend(c.Event(a),function(){for(var b={},g=c.address.parameterNames(),h=0,q=g.length;h<q;h++)b[g[h]]=c.address.parameter(g[h]);return{value:c.address.value(),path:c.address.path(),pathNames:c.address.pathNames(),parameterNames:g,parameters:b,queryString:c.address.queryString()}}.call(c.address)))},w=function(a,b,g){c(c.address).bind(a,b,g);return c.address},p=function(){var a=d.href.indexOf("#");return a!=-1?W(J(t(d.href.substr(a+
1),j))):""},X=function(){return"javascript"},Y=function(a,b){if(i.strict)a=b?a.substr(0,1)!="/"?"/"+a:a:a==""?"/":a;return a},K=function(a,b){return u&&d.protocol=="file:"?b?f.replace(/\?/,"%3F"):f.replace(/%253F/,"?"):a},t=function(a,b){if(i.crawlable&&b)return(a!=""?"!":"")+a;return a.replace(/^\!/,"")},x=function(a,b){return parseInt(a.css(b),10)},Z=function(a){for(var b,g,h=0,q=a.childNodes.length;h<q;h++){if(a.childNodes[h].src)b=String(a.childNodes[h].src);if(g=Z(a.childNodes[h]))b=g}return b},
H=function(){if(!L){var a=p(),b=f!=a;if(y&&m<523){if(D!=F.length){D=F.length;if(typeof z[D-1]!=A)f=z[D-1];G(j)}}else if(u&&m<7&&b)d.reload();else if(b){f=a;G(j)}}},G=function(a){v($);v(a?aa:ba);E(ca,10)},ca=function(){var a=(d.pathname+(/\/$/.test(d.pathname)?"":"/")+(c.address?c.address.value():"")).replace(/\/\//,"/").replace(/^\/$/,""),b=n[i.tracker];if(typeof b==M)b(a);else if(typeof urchinTracker==M)urchinTracker(a);else if(typeof pageTracker!=A&&typeof pageTracker._trackPageview==M)pageTracker._trackPageview(a);
else typeof _gaq!=A&&typeof _gaq.push==M&&_gaq.push(["_trackPageview",a])},da=function(){var a=l.contentWindow.document;a.open();a.write("<html><head><title>"+k.title+"</title><script>var "+o+' = "'+p()+'";<\/script></head></html>');a.close()},fa=function(){if(!ea){ea=e;var a=c("body").ajaxComplete(function(){ja.call(this)}).trigger("ajaxComplete");if(i.wrap){c("body > *").wrapAll('<div style="padding:'+(x(a,"marginTop")+x(a,"paddingTop"))+"px "+(x(a,"marginRight")+x(a,"paddingRight"))+"px "+(x(a,
"marginBottom")+x(a,"paddingBottom"))+"px "+(x(a,"marginLeft")+x(a,"paddingLeft"))+'px;" />').parent().wrap('<div id="'+o+'" style="height:100%; overflow:auto;'+(y?window.statusbar.visible&&!/chrome/i.test(O)?"":" resize:both;":"")+'" />');c("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"});y&&c('<style type="text/css" />').appendTo("head").text("#"+o+"::-webkit-resizer { background-color: #fff; }")}if(u&&m<8){a=k.getElementsByTagName("frameset")[0];l=k.createElement((a?"":"i")+
"frame");if(a){a.insertAdjacentElement("beforeEnd",l);a[a.cols?"cols":"rows"]+=",0";l.src=X()+":"+j;l.noResize=e;l.frameBorder=l.frameSpacing=0}else{l.src=X()+":"+j;l.style.display="none";k.body.insertAdjacentElement("afterBegin",l)}E(function(){c(l).bind("load",function(){var b=l.contentWindow;f=typeof b[o]!=A?b[o]:"";if(f!=p()){G(j);d.hash=K(t(f,e),e)}});typeof l.contentWindow[o]==A&&da()},50)}else if(y){if(m<418){c(k.body).append('<form id="'+o+'" style="position:absolute;top:-9999px;" method="get"></form>');
P=k.getElementById(o)}if(typeof d[o]==A)d[o]={};if(typeof d[o][d.pathname]!=A)z=d[o][d.pathname].split(",")}E(function(){v("init");G(j)},1);if(u&&m>7||!u&&"on"+I in n)if(n.addEventListener)n.addEventListener(I,H,false);else n.attachEvent&&n.attachEvent("on"+I,H);else ka(H,50);c("a").filter("[rel*='address:']").address()}},la=function(){if(n.removeEventListener)n.removeEventListener(I,H,false);else n.detachEvent&&n.detachEvent("on"+I,H)},ja=function(){var a=d.pathname.replace(/\/$/,"");c("body").html().indexOf("_escaped_fragment_")!=
-1&&c("a[href]:not([href^=http])",this).each(function(){var b=c(this).attr("href").replace(new RegExp(a+"/?$"),"");if(b==""||b.indexOf("_escaped_fragment_")!=-1)c(this).attr("href","#"+decodeURIComponent(b.replace(/\/(.*)\?_escaped_fragment_=(.*)$/,"!$2")))})},o="jQueryAddress",M="function",A="undefined",I="hashchange",$="change",aa="internalChange",ba="externalChange",e=true,j=false,i={autoUpdate:e,crawlable:j,history:e,strict:e,wrap:j},r=c.browser,m=parseFloat(c.browser.version),ga=r.mozilla,u=
r.msie,s=r.opera,y=r.safari,Q=j,n=function(){try{return top.document!==undefined?top:window}catch(a){return window}}(),k=n.document,F=n.history,d=n.location,ka=setInterval,E=setTimeout,J=decodeURI,W=encodeURI,O=navigator.userAgent,l,P,B=Z(document),ha=B?B.indexOf("?"):-1,R=k.title,D=F.length,L=j,ea=j,S=e,ia=e,N=j,z=[],f=p();if(u){m=parseFloat(O.substr(O.indexOf("MSIE")+4));if(k.documentMode&&k.documentMode!=m)m=k.documentMode!=8?7:8;c(document).bind("propertychange",function(){if(k.title!=R&&k.title.indexOf("#"+
p())!=-1)k.title=R})}if(Q=ga&&m>=1||u&&m>=6||s&&m>=9.5||y&&m>=312){for(r=1;r<D;r++)z.push("");z.push(f);if(u&&d.hash!=f)d.hash="#"+K(t(f,e),e);if(s)history.navigationMode="compatible";if(B&&ha!=-1){B=B.substr(ha+1).split("&");for(r=0;r<B.length;r++){s=B[r].split("=");if(/^(autoUpdate|crawlable|history|strict|wrap)$/.test(s[0]))i[s[0]]=isNaN(s[1])?/^(true|yes)$/i.test(s[1]):parseInt(s[1],10)!==0;if(/^tracker$/.test(s[0]))i[s[0]]=s[1]}}document.readyState=="complete"&&fa();c(fa);c(window).bind("unload",
la)}else if(!Q&&p()!=""||y&&m<418&&p()!=""&&d.search!=""){k.open();k.write('<html><head><meta http-equiv="refresh" content="0;url='+encodeURI(d.href.substr(0,d.href.indexOf("#")))+'" /></head></html>');k.close()}else ca();return{bind:function(a,b,g){return w(a,b,g)},init:function(a){return w("init",a)},change:function(a){return w($,a)},internalChange:function(a){return w(aa,a)},externalChange:function(a){return w(ba,a)},baseURL:function(){var a=d.href;if(a.indexOf("#")!=-1)a=a.substr(0,a.indexOf("#"));
if(/\/$/.test(a))a=a.substr(0,a.length-1);return a},autoUpdate:function(a){if(a!==undefined){i.autoUpdate=a;return this}return i.autoUpdate},crawlable:function(a){if(a!==undefined){i.crawlable=a;return this}return i.crawlable},history:function(a){if(a!==undefined){i.history=a;return this}return i.history},strict:function(a){if(a!==undefined){i.strict=a;return this}return i.strict},tracker:function(a){if(a!==undefined){i.tracker=a;return this}return i.tracker},wrap:function(a){if(a!==undefined){i.wrap=
a;return this}return i.wrap},update:function(){N=e;this.value(f);N=j;return this},title:function(a){if(a!==undefined){a=J(a);E(function(){R=k.title=a;if(ia&&l&&l.contentWindow&&l.contentWindow.document){l.contentWindow.document.title=a;ia=j}if(!S&&ga)d.replace(d.href.indexOf("#")!=-1?d.href:d.href+"#");S=j},50);return this}return k.title},value:function(a){if(a!==undefined){a=W(J(Y(a,e)));if(a=="/")a="";if(f==a&&!N)return;S=e;f=a;if(i.autoUpdate||N){L=e;G(e);z[F.length]=f;if(y)if(i.history){d[o][d.pathname]=
z.toString();D=F.length+1;if(m<418){if(d.search==""){P.action="#"+t(f,e);P.submit()}}else if(m<523||f==""){a=k.createEvent("MouseEvents");a.initEvent("click",e,e);var b=k.createElement("a");b.href="#"+t(f,e);b.dispatchEvent(a)}else d.hash="#"+t(f,e)}else d.replace("#"+t(f,e));else if(f!=p())if(i.history)d.hash="#"+K(t(f,e),e);else d.replace("#"+t(f,e));u&&m<8&&i.history&&E(da,50);if(y)E(function(){L=j},1);else L=j}return this}if(!Q)return null;return J(Y(K(f,j),j))},path:function(a){if(a!==undefined){var b=
this.queryString(),g=this.hash();this.value(a+(b?"?"+b:"")+(g?"#"+g:""));return this}return this.value().split("#")[0].split("?")[0]},queryString:function(a){if(a!==undefined){var b=this.hash();this.value(this.path()+(a?"?"+a:"")+(b?"#"+b:""));return this}a=this.value().split("?");return a.slice(1,a.length).join("?").split("#")[0]},parameter:function(a,b,g){var h,q;if(b!==undefined){var T=this.parameterNames();q=[];for(h=0;h<T.length;h++){var U=T[h],C=this.parameter(U);if(typeof C=="string")C=[C];
if(U==a)C=b===null||b===""?[]:g?C.concat([b]):[b];for(var V=0;V<C.length;V++)q.push(U+"="+C[V])}c.inArray(a,T)==-1&&b!==null&&b!==""&&q.push(a+"="+b);this.queryString(q.join("&"));return this}if(b=this.queryString()){q=b.split("&");b=[];for(h=0;h<q.length;h++){g=q[h].split("=");g[0]==a&&b.push(g[1])}if(b.length!==0)return b.length!=1?b:b[0]}},pathNames:function(){var a=this.path(),b=a.replace(/\/{2,9}/g,"/").split("/");if(a.substr(0,1)=="/"||a.length===0)b.splice(0,1);a.substr(a.length-1,1)=="/"&&
b.splice(b.length-1,1);return b},parameterNames:function(){var a=this.queryString(),b=[];if(a&&a.indexOf("=")!=-1){a=a.split("&");for(var g=0;g<a.length;g++){var h=a[g].split("=")[0];c.inArray(h,b)==-1&&b.push(h)}}return b},hash:function(a){if(a!==undefined){this.value(this.value().split("#")[0]+(a?"#"+a:""));return this}a=this.value().split("#");return a.slice(1,a.length).join("#")}}}();c.fn.address=function(v){var w=function(){if(c(this).is("a")){var p=v?v.call(this):/address:/.test(c(this).attr("rel"))?
c(this).attr("rel").split("address:")[1].split(" ")[0]:c(this).attr("href").replace(/^#\!?/,"");c.address.value(p);return false}};c(this).click(w).live("click",w);c(this).live("submit",function(){if(c(this).is("form")){var p=v?v.call(this):c(this).attr("action")+"?"+c(this).serialize();c.address.value(p);return false}});return this}})(jQuery);

////////////////////////////////////////////////////
// Crockford JS framework v1.0
////////////////////////////////////////////////////

/// Define "create" method on Object type as a static method which allows easy inheritence between objects.
if( typeof Object.create !== "function" )
{
	Object.create = function( instance )
	{
		var F = function() {};
		F.prototype = instance;
		return new F();
	}
}

/// Define "method" method on Function as an instance method which provides syntactic sugar for declaring instance methods on a function
/// (useful for constructor functions to augment types) and also ensures that instance method cannot be overriden.
Function.prototype.method = function( name, func )
{
	if( !this.prototype[ name ] )
	{
		this.prototype[ name ] = func;
		return this;
	}
};

/// Define the "curry" method on Function as an instance method which provides a technique for wrapping a method and specifying default values for parameters.
/// Example: var add1 = add.curry(1);	// will always add 1 + number
/// add1(2);	// this will result in 3
Function.method( "curry", function()
{
	var slice = Array.prototype.slice;
	args = slice.apply( arguments );
	that = this;
	return function()
	{
		return that.apply( null, args.concat( slice.apply( arguments ) ) );
	};
});

/// Determines if the value specified refers to an array.
function isArray( value )
{
	var isValueAnArray = value &&
						 typeof value === "object" &&
						 typeof value.length === "number" &&
						 !value.propertyIsEnumerable( "length" );
	return isValueAnArray;
}

/// Helper method to dispose an array and to optionally call a callback on each item after being removed from the array.
function disposeArray( array, callback )
{
	if( isArray( array ) )
	{
		var item;
		while( array.length !== 0 )
		{
			item = array.pop();
			if( callback && typeof callback === "function" )
			{
				callback( item );
			}
		}
	}
}

/// Ensure that the Array type has an "indexOf" method like other languages.
if( typeof Array.prototype.indexOf !== "function" )
{
	Array.prototype.indexOf = function( item, index )
	{
		var count = this.length;
		index = ( isNaN( index ) || index < 0 || index >= count ) ? 0 : index;
		for( var i = 0; i < count; i++ )
		{
			if( this[ i ] === item )
			{
				return i;
			}
		}
		return -1;
	};
}

/// Ensure that the Array type has an "lastIndexOf" method like other languages.
if( typeof Array.prototype.lastIndexOf !== "function" )
{
	Array.prototype.lastIndexOf = function( item, index )
	{
		var count = this.length;
		index = ( isNaN( index ) || index < 0 || index >= count ) ? count - 1 : index;
		for( var i = 0; i < count; i-- )
		{
			if( this[ i ] === item )
			{
				return i;
			}
		}
		return -1;
	};
}

/// Represents a general purpose dictionary that can be used to associate a key of any kind to a value of any kind.
/// A key can only be associated to a single value.
function Dictionary()
{
	// private fields
	var keys = [];
	var values = [];

	this.get = function( key )
	{
		var index = keys.indexOf( key );
		if( index >= 0 )
		{
			return values[ index ];
		}
		else
		{
			return null;
		}
	};

	this.set = function( key, value )
	{
		var index = keys.indexOf( key );
		if( index >= 0 )
		{
			values[ index ] = value;
		}
		else
		{
			keys.push( key );
			values.push( value );
		}
	};

	this.containsKey = function( key )
	{
		var hasKey = keys.indexOf( key );
		return hasKey;
	};

	this.containsValue = function( value )
	{
		var hasValue = values.indexOf( value );
		return hasValue;
	};

	this.getKeys = function()
	{
		return keys.slice();
	};

	this.getValues = function()
	{
		return values.slice();
	};

	this.getKeysByValue = function( value )
	{
		var match = [];
		var count = values.length;
		var v;
		for( var i = 0; i < count; i++ )
		{
			v = values[ i ];
			if( v === value )
			{
				match.push( keys[ i ] );
			}
		}
		return match;
	};

	this.getCount = function()
	{
		return keys.length;
	};

	this.clear = function()
	{
		disposeArray( keys );
		disposeArray( values );
	};
}

/// Represents a general purpose map that can be used to associate a key of any kind to a value of any kind.
/// The difference between a dictionary and map is that a key can be associated to many values.
function Map()
{
	// private fields
	var keys = [];
	var values = [];

	/// Retrieves the values associated to the given key as an array.
	this.get = function( key )
	{
		var index = keys.indexOf( key );
		if( index >= 0 )
		{
			return values[ index ].slice();
		}
		else
		{
			return [];
		}
	};

	this.set = function( key, value )
	{
		var index = keys.indexOf( key );
		if( index >= 0 )
		{
			var array = values[ index ];
			if( array.indexOf( value ) >= 0 )
			{
				array.push( value );
			}
		}
		else
		{
			keys.push( key );
			values.push( [ value ] );
		}
	};

	this.containsKey = function( key )
	{
		var hasKey = keys.indexOf( key );
		return hasKey;
	};

	this.containsValue = function( value )
	{
		var count = values.length;
		var array;
		for( var i = 0; i < count; i++ )
		{
			array = values[ i ];
			if( array.indexOf( value ) >= 0 )
			{
				return true;
			}
		}
		return false;
	};

	this.getKeys = function()
	{
		return keys.slice();
	};

	this.getKeysByValue = function( value )
	{
		var match = [];
		var count = values.length;
		var array;
		for( var i = 0; i < count; i++ )
		{
			array = values[ i ];
			if( array.indexOf( value ) >= 0 )
			{
				match.push( keys[ i ] );
			}
		}
		return match;
	};

	this.getCount = function()
	{
		return keys.length;
	};

	this.clear = function()
	{
		disposeArray( keys );
		disposeArray( values, disposeArray );
	};
}

var CONSTRUCTORS = function()
{
	var constructors = {};

	var set = function( n, c )
	{
		if( !constructors[ n ] )
		{
			constructors[ n ] = c;
		}
	};

	var get = function( n )
	{
		if( constructors[ n ] )
		{
			return constructors[ n ];
		}

		return error( "Constructor " + n + " not defined" );
	};

	var error = function( message )
	{
		alert( message );
		throw( message );
		return false;
	};

	return {
		set: function( n, c ) { set( n, c ); },
		get: function( n ) { return get( n ); }
	};
};

////////////////////////////////////////////////////
// php.js methods
////////////////////////////////////////////////////

String.method( "urlencode", function()
{
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'

    var ret = this;

    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');

    return ret;
});

String.method( "urldecode", function()
{
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'

    var ret = this;

    ret = ret.replace(/\+/g, '%20');
    ret = decodeURIComponent(ret);
    ret = ret.toString();

    return ret;
});

String.method( "base64_encode", function()
{
    // http://kevin.vanzonneveld.net
    // +   original by: Tyler Akins (http://rumkin.com)
    // +   improved by: Bayron Guevara
    // +   improved by: Thunder.m
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: utf8_encode
    // *     example 1: base64_encode('Kevin van Zonneveld');
    // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='

    // mozilla has this native
    // - but breaks in 2.0.0.12!
    //if (typeof window['atob'] == 'function') {
    //    return atob(data);
    //}

    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, enc="", tmp_arr = [];
    var data = this.utf8_encode();

    do { // pack three octets into four hexets
        o1 = data.charCodeAt(i++);
        o2 = data.charCodeAt(i++);
        o3 = data.charCodeAt(i++);

        bits = o1<<16 | o2<<8 | o3;

        h1 = bits>>18 & 0x3f;
        h2 = bits>>12 & 0x3f;
        h3 = bits>>6 & 0x3f;
        h4 = bits & 0x3f;

        // use hexets to index into b64, and append result to encoded string
        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
    } while (i < data.length);

    enc = tmp_arr.join('');

    switch( data.length % 3 ){
        case 1:
            enc = enc.slice(0, -2) + '==';
        break;
        case 2:
            enc = enc.slice(0, -1) + '=';
        break;
    }

    return enc;
});

String.method( "utf8_encode", function()
{
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'

    var str_data = this.replace(/\r\n/g,"\n");
    var tmp_arr = [], ac = 0;

    for (var n = 0; n < str_data.length; n++) {
        var c = str_data.charCodeAt(n);
        if (c < 128) {
            tmp_arr[ac++] = String.fromCharCode(c);
        } else if((c > 127) && (c < 2048)) {
            tmp_arr[ac++] = String.fromCharCode((c >> 6) | 192);
            tmp_arr[ac++] = String.fromCharCode((c & 63) | 128);
        } else {
            tmp_arr[ac++] = String.fromCharCode((c >> 12) | 224);
            tmp_arr[ac++] = String.fromCharCode(((c >> 6) & 63) | 128);
            tmp_arr[ac++] = String.fromCharCode((c & 63) | 128);
        }
    }

    return tmp_arr.join('');
});

String.prototype.unescapeHtml = function () {
    var temp = document.createElement("div");
    temp.innerHTML = this;
    var result = temp.childNodes[0].nodeValue;
    temp.removeChild(temp.firstChild);
    return result;
}

////////////////////////////////////////////////////
// Inner message jQuery plugin
// Written by Mathieu Bouchard (c) 2010
////////////////////////////////////////////////////

var originalVal = jQuery.fn.val;

jQuery.fn.realval = function()
{
	return originalVal.apply( this, arguments );
};

jQuery.fn.val = function()
{
	if( jQuery( this ).length > 0 )
	{
		if( arguments.length == 0 )
		{
			if( jQuery( this ).get( 0 ).message == jQuery( this ).realval() )
			{
				return "";
			}
		}
	}

	return originalVal.apply( this, arguments );
};

jQuery.fn.innerMessage = function()
{
	if( jQuery( this ).length > 0 )
	{
		jQuery( this ).get( 0 ).message = jQuery( this ).realval();

		jQuery( this ).addClass( "inner-messaging" );

		var thisObj = this;

		jQuery( this ).focus( function()
		{
			if( jQuery( this ).realval() == jQuery( thisObj ).get( 0 ).message )
			{
				jQuery( this ).realval( "" );
				jQuery( this ).removeClass( "inner-messaging" );
			}
		});

		jQuery( this ).blur( function( event )
		{
			if( jQuery( this ).realval().length == 0 )
			{
				jQuery( this ).realval( jQuery( thisObj ).get( 0 ).message );
				jQuery( this ).addClass( "inner-messaging" );
			}
		});
	}

	return this;
};

////////////////////////////////////////////////////
// Javascript helpers
// Written by Mathieu Bouchard (c) 2010
////////////////////////////////////////////////////

jQuery( document ).ready( function()
{
	// Add hover class to navigation li's in IE
	if( jQuery.browser.msie )
	{
		jQuery( "ul.navigation li" ).hover(
			function() { jQuery( this ).addClass( "hover" ); },
			function() { jQuery( this ).removeClass( "hover" ); }
		);
	}

	if( window.parent.document != document )
	{
		// Make iframe links that target new windows open in a new window outside the iframe
		jQuery( "a[rel]" ).live( "click", function( e )
		{
			top.frames[ jQuery( this ).attr( "rel" ) ].location.href = jQuery( this ).attr( "href" );
			e.preventDefault();
		});
	}
	else
	{
		// Make rel anchors open in a new window
		jQuery( "a[rel]" ).live( "click", function()
		{
			jQuery( this ).attr( "target", jQuery( this ).attr( "rel" ) );
		});
	}
});

////////////////////////////////////////////////////
// ARIMODAL: auto-resizing iframe modal window
// Written by Mathieu Bouchard (c) 2010
////////////////////////////////////////////////////

var ARIMODAL = function()
{
	var modalCollection = new Dictionary();

	var innerModal = function()
	{
		// private fields
		var initialized = false;
		var myInstance = null;

		// private methods
		var initialize = function()
		{
			if( !initialized )
			{
				initialized = true;

				if( isInnerModal() )
				{
					myInstance = getMyInstance();
					myInstance.show();
					myInstance.resize( jQuery( document ).width(), jQuery( document ).height() );
				}
			}
		};

		var getMyInstance = function()
		{
			return top.ARIMODAL.getModalCollection().get( window.location.pathname );
		};

		var isInnerModal = function()
		{
			return window.parent.document != document;
		};

		var closeMe = function()
		{
			getMyInstance().close();
		};

		// public domain
		return {
			initialize: function()
			{
				initialize();
				return this;
			},
			closeMe: function()
			{
				initialize();
				closeMe();
				return this;
			}
		};
	}();

	var modal = function()
	{
		// private fields
		var initialized = false;
		var modalAPI = null;
		var modalContainer = null;
		var modalHref = null;
		var modalIframe = null;

		// private methods
		var initialize = function( containerID, href, that )
		{
			if( !initialized )
			{
				initialized = true;
				modalHref = href;
				modalCollection.set( href, that );
				initializeModalContainer( containerID );
			}
		};

		var launchModalWindow = function()
		{
			modalAPI = modalContainer.overlay(
			{
				api: true,
				onBeforeLoad: function( e )
				{
					e.stopPropagation();

					modalIframe = jQuery( "<iframe frameborder='0' scrolling='auto' style='width: 100%;' />" );
					modalContainer.append( modalIframe );
					modalIframe.attr( "src", modalHref );

					$( ".close", modalContainer ).css( {
						position: "absolute",
						cursor: "pointer",
						zIndex: 10001
					});
				},
				onClose: function( e )
				{
					modalIframe.remove();
					modalContainer.remove();
				},
				closeOnClick: true,
				expose:
				{
					color: "#000",
					loadSpeed: 200,
					opacity: 0.75
				}
			}).load();
		};

		var initializeModalContainer = function( containerID )
		{
			if( jQuery( "#" + containerID ).length == 0 )
			{
				jQuery( "body" ).append( "<div id='" + containerID + "' class='modal-box' style='display: none; z-index: 10000; padding: 0px; border: 0px;' />" );
			}

			modalContainer = jQuery( "#" + containerID );
		};

		var showIframe = function()
		{
			modalIframe.show();
			return this;
		};

		var resizeIframe = function( width, height )
		{
			var maxHeight = parseInt( modalIframe.css( "max-height" ) );
			var maxWidth = parseInt( modalIframe.css( "max-width" ) );
			var windowHeight = jQuery( window ).height();
			var windowWidth = jQuery( window ).width();

			maxHeight = maxHeight > windowHeight ? windowHeight : maxHeight;
			maxWidth = maxWidth > windowWidth ? windowWidth : maxWidth;

			height = height > maxHeight ? maxHeight : height;
			width = width > maxWidth ? maxWidth : width;

			//width += 17;	// scrollbar fix (except IE6)!

			var left = ( jQuery( window ).width() - width ) / 2;
			var top = ( jQuery( window ).height() - height ) / 2;

			modalIframe.animate( { height: height, width: width }, { duration: 250, queue: false } );
			modalContainer.animate( {  height: height, width: width, left: left, top: top }, { duration: 250, queue: false } );
		};

		var closeModal = function()
		{
			modalAPI.close();
			return this;
		};

		var showCloseIcon = function()
		{
			jQuery( ".close", modalContainer ).show();
		};

		// public domain
		return {
			initialize: function( containerID, href )
			{
				initialize( containerID, href, this );
				return this;
			},
			launch: function()
			{
				launchModalWindow();
				return this;
			},
			close: function()
			{
				closeModal();
				return this;
			},
			show: function()
			{
				showIframe();
				showCloseIcon();
				return this;
			},
			resize: function( width, height )
			{
				resizeIframe( width, height );
				return this;
			}
		};
	};

	return {
		initialize: function()
		{
			innerModal.initialize();
		},
		launch: function( containerID, href )
		{
			modal().initialize( containerID, href ).launch();
		},
		closeMe: function()
		{
			innerModal.closeMe();
		},
		getModalCollection: function()
		{
			return modalCollection;
		}
	};
}();

////////////////////////////////////////////////////
// jQuery plug-in
// Remove all attributes
////////////////////////////////////////////////////

jQuery.fn.removeAttributes = function()
{
	return this.each( function()
	{
		var attributes = jQuery.map( this.attributes, function( item )
		{
			return item.name;
		});

		var obj = $( this );

		jQuery.each( attributes, function( i, item )
		{
			obj.removeAttr( item );
		});
	});
};

////////////////////////////////////////////////////
// jQuery plug-in
// Find element using a selector and remove an
// attribute on it, but without changing scope
// to found element, retaining original scope.
// Written by Mathieu Bouchard (c) 2010
////////////////////////////////////////////////////

jQuery.fn.findAndRemoveAttribute = function( findSelector, attributeToRemove )
{
	this.find( findSelector ).each( function()
	{
		$( this ).removeAttr( attributeToRemove );
	});

	return this;
};

////////////////////////////////////////////////////
// jQuery plug-in
// Compare two DOM nodes for same HTML, which has
// the benefit of being able to compare two DOM
// nodes from different documents.
// Caveat: regexp was simplified to remove ALL
// spaces, therefore changes in spaces only will not
// be detected.
// Written by Mathieu Bouchard (c) 2010
////////////////////////////////////////////////////

jQuery.fn.compare = function( against )
{
	if( $( this ).length == 1 && against.length == 1 )
	{
		var html1 = $( this ).html().replace( /\s/g, "" );
		var html2 = against.html().replace( /\s/g, "" );

		return( html1 === html2 );
	}
}

////////////////////////////////////////////////////
// strips brackets from input names
////////////////////////////////////////////////////

String.method( "stripBrackets", function()
{
    return this.replace( "[", "" ).replace( "]", "" ).replace( "\\[", "" ).replace( "\\]", "" );
});

////////////////////////////////////////////////////
// escapes names from input fields
////////////////////////////////////////////////////

String.method( "escapeName", function()
{
    if( ! jQuery.browser.msie )
	{
		return this.replace( "[", "\\[" ).replace( "]", "\\]" );
	}

	return this;
});
( function( $, App )
{
	// Sanity checks
    if( typeof $ !== "function" ) throw new Error( "jQuery is not defined." );

	$( document ).ready( function()
	{
		$( "input#search" ).innerMessage();
		$( "input#catalogue-search-box" ).innerMessage();

		$( ".catalogue-items li a" ).modalIframe( { modalID: "modal-generic-box" } );
		$( ".johnson-box.mall-hours a" ).modalIframe( { modalID: "modal-hours-box" } );
		$( ".store-post-view a" ).modalIframe( { modalID: "modal-generic-box" } );
		$( ".long-hours a" ).modalIframe( { modalID: "modal-hours-box" } );

		$( "ul.month-nav" ).monthNav();

		App.CatalogueVisuals.Initialize();
		App.Modals.Initialize();
		App.Admin.Initialize();

		setupNewsletterSignup();
		pullLatestBlogTitles();

		if( App.Catalogue !== undefined )
		{
			App.Catalogue.Initialize( "/catalogue-" + $( "span.model" ).html() + "-#IMAGESIZE#-" + $( "span.items-per-page" ).html() + "-#CURRENTPAGE#-#SEARCH#-#CATEGORY#-#GROUP#.ajax" );
			App.Filters.Initialize();
		}
	});

	App.RotatingImagery = function()
	{
		var timePause = 8000;
		var timeFadeOut = 1000;
		var timeFadeIn = 1000;

		var imageryList = [];

		var Initialize = function( newImageryList )
		{
			if( $( ".rotating-imagery" ).length > 0 )
			{
				imageryList = newImageryList;
				InitializeImagery();
				Rotate();
			}
		};

		var InitializeImagery = function()
		{
			$( ".rotating-imagery" ).addClass( imageryList[ 0 ] );
		};

		var Rotate = function()
		{
			var currentImagery = GetCurrentImagery();
			var nextImagery = GetNextImagery();

			$( ".rotating-imagery" ).delay( timePause ).fadeOut( timeFadeOut, function()
			{
				$( this ).removeClass( currentImagery ).addClass( nextImagery ).fadeIn( timeFadeIn, function()
				{
					Rotate();
				})
			});
		};

		var GetCurrentImagery = function()
		{
			return $( ".rotating-imagery" ).attr( "class" ).split( " " )[ 1 ];
		};

		var GetNextImagery = function()
		{
			var tempImageryList = ( imageryList + "," + imageryList ).split( "," );
			var currentIndex = GetCurrentIndex();

			return tempImageryList[ currentIndex + 1 ];
		};

		var GetCurrentIndex = function()
		{
			var currentImagery = GetCurrentImagery();

			for( var key in imageryList )
			{
				if( currentImagery == imageryList[ key ] )
				{
					return parseInt( key );
				}
			}

			return -1;
		};

		return {
			Initialize: Initialize
		};
	}();

	App.CatalogueVisuals = function()
	{
		var findStoreHeight;
		var findStoreHasFocus;

		var Initialize = function()
		{
			$( "select#category-select" ).change( function()
			{
				if( $( this ).val().length > 0 )
				{
					$( "input#catalogue-search-box" ).val( "" );
					$( "input#catalogue-search-box" ).blur();
				}
			});

			$( "input#catalogue-search-box" ).keyup( function()
			{
				if( $( this ).val().length > 0 )
				{
					$( "select#category-select" ).val( "" );
					$( "select#category-select" ).blur();
				}
			});

			if( $( ".johnson-box.find-store" ).length > 0 )
			{
				findStoreHeight = $( ".johnson-box.find-store" ).height();
				findStoreHasFocus = false;

				$( "input#catalogue-search-box" ).focus( function( e )
				{
					FindStoreFocus();
				});

				$( "body" ).click( function( e )
				{
					if( findStoreHasFocus )
					{
						FindStoreBlur();
					}
				});

				$( ".johnson-box.find-store *" ).click( function( e )
				{
					if( !e ) var e = window.event;
					e.cancelBubble = true;
					e.stopPropagation();
					e.preventDefault();
				});

				$( ".johnson-box.find-store .catalogue-items" ).bind( "oncatalogueitemsupdated.catalogue", OnCatalogueItemsUpdated );
			}
		};

		var FindStoreFocus = function()
		{
			var box = $( ".johnson-box.find-store" );

			if( ! findStoreHasFocus )
			{
				$( ".results", box ).fadeIn();

				$( box ).animate( { height: findStoreHeight + 185 }, 250, "swing", function()
				{
					$( box ).css( "height", "auto" );
				});

				findStoreHasFocus = true;
			}
		};

		var FindStoreBlur = function()
		{
			var box = $( ".johnson-box.find-store" );

			if( findStoreHasFocus )
			{
				box.animate( { height: findStoreHeight }, 250, "swing" );
				$( ".results", box ).fadeOut();
				findStoreHasFocus = false;
			}
		};

		var OnCatalogueItemsUpdated = function()
		{
			var context = $( ".johnson-box.find-store" ).get( 0 );
			$( ".prev-page, .next-page", context ).height( $( ".catalogue", context ).height() );
		}

		return {
			Initialize: Initialize
		};
	}();

	App.Modals = function()
	{
		var Initialize = function()
		{
			if( $( ".modal-inside" ).length > 0 )
			{
				//window.setTimeout( ResizeWindow, 80 );
				FixOuterTargetLinks();
			}
		};

		var ResizeWindow = function()
		{
			var width = $( "body" ).width();
			var height = $( "body" ).height();
			var left = ( $( "body", window.parent.document ).width() - width ) / 2;
			var maxHeightGeneric = parseInt( $( ".modal-box iframe", window.parent.document ).css( "max-height" ) );

			if( maxHeightGeneric > 0 && height > maxHeightGeneric )
			{
				height = maxHeightGeneric;
			}

			$( ".modal-box, .modal-box iframe", window.parent.document ).animate( { height: height, width: width, left: left }, 150 );
		}

		var FixOuterTargetLinks = function()
		{
			$( "a[target]" ).click( function( e )
			{
				top.frames[ $( this ).attr( "target" ) ].location.href = $( this ).attr( "href" );

				e.preventDefault();
			});
		}

		return {
			Initialize: Initialize
		};
	}();

	App.Admin = function()
	{
		var Initialize = function()
		{
			if( $( "div.admin" ).length > 0 )
			{
				FadeStates();
				TinyMCE( ".hours textarea.short-hours" );
				TinyMCE( ".hours textarea.long-hours" );
				TinyMCE( ".blog-edit textarea.summary" );
				TinyMCE( ".blog-edit textarea.content" );
				TinyMCE( ".career-edit textarea.description" );
				SetupAlias( ".blog-edit input.alias", ".blog-edit input.title" );
				ConfirmDelete( "input.delete-store", "Checking this box means that when you click 'Save & update this store', this store will be deleted. Are you sure you want to do this?" );
				ConfirmDelete( "input.delete-blog", "Checking this box means that when you click 'Save & update this post', this blog post will be deleted. Are you sure you want to do this?" );
				ConfirmDelete( "input.delete-career", "Checking this box means that when you click 'Save & update this career', this career posting will be deleted. Are you sure you want to do this?" );

				if( $.fn.datepicker )
				{
					$( "#posteddate" ).datepicker(
					{
						inline: true,
						dateFormat: "yy-mm-dd"
					});
				}

				$( "form" ).submit( function()
				{
					if( $( "input.delete-store, input.delete-blog, input.delete-career" ).is( ":checked" ) )
					{
						return confirm( "Final warning: Are you sure you want to delete this record?" );
					}

					return true;
				});
			}
		};

		var FadeStates = function()
		{
			$( ".state-success, .state-neutral" ).delay( 1000 ).fadeOut( 2000 );
			$( ".state-fail" ).delay( 10000 ).fadeOut( 2000 );
		};

		var TinyMCE = function( selector )
		{
			if( $.isFunction( $.fn.tinymce ) )
			{
				$( selector ).tinymce(
				{
					script_url: '/inc/vendor/tiny_mce/tiny_mce.js',
					mode: "textareas",
					content_css: "/inc/styles/typography.css",
					entities: "",

					plugins: "paste,searchreplace,table,print",

					theme: "advanced",
					theme_advanced_buttons1: "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,pasteword,|,undo,redo,|,bullist,numlist,|,outdent,indent,|,search,replace,|,code",
					theme_advanced_buttons2: "link,unlink,anchor,image,cleanup,|,tablecontrols,|,hr,removeformat,|,sub,sup,|,print",
					theme_advanced_buttons3: "",
					theme_advanced_buttons4: "",
					theme_advanced_toolbar_location: "top",
					theme_advanced_toolbar_align: "left"
				});
			}
		};

		var SetupAlias = function( targetSelector, sourceSelector )
		{
			$( targetSelector ).focus( function()
			{
				if( $( this ).val().length == 0 )
				{
					$( this ).val( GenerateAlias( $( sourceSelector ).val() ) );
				}
			});

			$( targetSelector ).blur( function()
			{
				if( $( this ).val().length == 0 )
				{
					$( this ).val( GenerateAlias( $( sourceSelector ).val() ) );
				}
			});

			$( targetSelector ).change( function()
			{
				$( this ).val( GenerateAlias( $( targetSelector ).val() ) );
			});

			$( "form" ).submit( function()
			{
				if( $( targetSelector ).length > 0 )
				{
					if( $( targetSelector ).val().length == 0 )
					{
						$( targetSelector ).val( GenerateAlias( $( sourceSelector ).val() ) );
					}
				}

				return true;
			});
		};

		var GenerateAlias = function( value )
		{
			var alias = value.toLowerCase();

			alias = alias.replace( /[^a-z0-9- ]/g, "" );
			alias = alias.replace( / /g, "-" );

			return alias;
		};

		var ConfirmDelete = function( selector, message )
		{
			$( selector ).click( function()
			{
				if( $( this ).is( ":checked" ) )
				{
					if( !confirm( message ) )
					{
						$( this ).removeAttr( "checked" );
					}
				}
			});
		};

		return {
			Initialize: Initialize
		};
	}();

	/* setup style functions */

	var setupNewsletterSignup = function()
	{
		$( "form.newsletter-form" ).validator(
		{
			"position": "bottom center"

		}).submit( function( e )
		{
			var form = $( this );
			var emailInput = $( "input[name='newsletter-field']", this );
			var submitButton = $( "input[name='subscribe']", this );
			var message = $( ".msg", this );

			// client-side validation passed
			if( ! e.isDefaultPrevented() )
			{
				submitButton.hide();
				message.text( message.attr( "data-wait-message" ) ).fadeIn( 100 );

				// submit the data to the server with AJAX
				$.ajax(
				{
					"url": form.attr( "action" ).replace( "#EMAIL#", encodeURIComponent( emailInput.val() ) ),
					"async": true,
					"dataType": "xml",
					"success": function( data, textStatus )
					{
						var receivedProperResponse = ( textStatus === "success" );

						if( receivedProperResponse )
						{
							var success = $( "success", data ).text() === "1";
							submitButton.delay( 6000 ).fadeIn( 500 );
							message.text( message.attr( "data-done-message" ) ).fadeIn( 500 ).delay( 5000 ).fadeOut( 500 );
						}

						emailInput.val( "" );
					}
				});

				// prevent default form submission logic
				e.preventDefault();
			}
		});

		$( ".error" ).live( "click", function()
		{
			$( this ).fadeOut( 50, function() { $( this ).css( "visibility", "hidden" ); } );
		});
	};

	var pullLatestBlogTitles = function()
	{
		Handlebars.registerHelper( "list", function( items, max, fn )
		{
			var out = "";

			for( var i = 0, len = items.length; i < Math.min( max, len ); i++ )
			{
				out = out + "<li>" + fn( items[ i ] ) + "</li>";
			}

			return out;
		});

		if( $( "#blog-latest-titles" ).length > 0 )
		{
			$.getJSON( "http://www.stlblog.ca/?feed=json&jsonp=?", function( data )
			{
				var template = Handlebars.compile( $( "#blog-latest-titles-template" ).html() );

				for( var i = 0; i < data.length; i++ )
				{
					data[ i ].title = data[ i ].title.unescapeHtml();
				}

				var html = template( { posts: data } );

				$( "#blog-latest-titles" ).html( html );
			});
		}
	};

	/* jQuery plugins */

	$.fn.modalIframe = function( options )
	{
		var settings = {
			modalID: "modal-generic-box",
			eventName: "click"
		};

		return this.each( function( index, item )
		{
			if( options ) $.extend( settings, options );

			if( $( this ).closest( ".johnson-box.find-store" ).length > 0 )
			{
				settings.eventName = "mouseup";
			}

			$( this ).live( settings.eventName, function( e )
			{
				var href = $( this ).attr( "href" );

				$( "body" ).append( "<div id='" + settings.modalID + "' class='modal-box' />" );

				$( "#" + settings.modalID ).overlay(
				{
					api: true,
					onBeforeLoad: function( e )
					{
						e.stopPropagation();
						document.modalAPI = this;
						$( "#" + settings.modalID ).append( $( "<iframe frameborder='0' />" ) );
						$( "#" + settings.modalID + " iframe" ).attr( "src", href );
					},
					onClose: function( e )
					{
						$( "#" + settings.modalID + " iframe" ).remove();
						$( "#" + settings.modalID ).remove();
					},
					expose:
					{
						color: "#000",
						loadSpeed: 200,
						opacity: 0.5
					}
				}).load();

				e.preventDefault();
				return false;
			});
		});
	};

	$.fn.monthNav = function()
	{
		$( this ).each( function()
		{
			var globalSelectedCount = $( "li.selected", this ).length;

			if( globalSelectedCount > 0 )
			{
				$( this ).children( "li" ).each( function()
				{
					if( $( "ul li.selected", this ).length > 0 )
					{
						$( this ).addClass( "maximized" );
					}
					else
					{
						$( this ).addClass( "minimized" );
					}
				});
			}
			else
			{
				$( "li:first ul", this ).closest( "li:not( .navigation )" ).addClass( "maximized" );
				$( "li:not( :first ) ul", this ).closest( "li:not( .navigation )" ).addClass( "minimized" );
			}

			$( "li > span", this ).click( function()
			{
				$( this ).siblings( "ul, table" ).slideToggle( "fast", function()
				{
					$( this ).closest( "li:not( .navigation )" ).toggleClass( "maximized" ).toggleClass( "minimized" );
				});
			});
		});
	};

})( jQuery, window.STL || ( window.STL = {} ) );
( function( $, App )
{
	// Sanity checks
    if( typeof $ !== "function" ) throw new Error( "jQuery is not defined." );

	App.Filters = function()
	{
		var currentPage = null;
		var searchKeyUpDelay = 400;
		var pageKeyUpDelay = 400;

		var Initialize = function()
		{
			currentPage = GetCurrentPageInDOM();

			InitialLoad();
			BindFilterEvents();
			UpdatePaginationButtonStates();
			PreventFormSubmit();
		};

		var InitialLoad = function()
		{
			$( ".prev-page a" ).removeAttr( "href" );
			$( ".next-page a" ).removeAttr( "href" );
			$( ".current-page" ).removeAttr( "disabled" );
		};

		var BindFilterEvents = function()
		{
			BindPaginationEvents();
			BindSearchEvents();
			BindCategoryEvents();
		};

		var BindPaginationEvents = function()
		{
			$( ".prev-page a" ).click( function( e )
			{
				e.preventDefault();

				var projectedPage = GetCurrentPage() - 1;

				if( projectedPage >= 1 )
				{
					SetCurrentPage( projectedPage );
				}
			});

			$( ".next-page a" ).click( function( e )
			{
				e.preventDefault();

				var projectedPage = GetCurrentPage() + 1;
				var totalPages = GetTotalPages();

				if( projectedPage <= totalPages )
				{
					SetCurrentPage( projectedPage );
				}
			});

			$( ".current-page" ).keydown( function()
			{
				window.clearTimeout( $.data( this, "timeout" ) );

				$.data( this, "timeout",
					window.setTimeout(
						function()
						{
							if( TestCurrentPage() )
							{
								OnFilterChange();
							}
						},
						pageKeyUpDelay
					)
				);
			});
		};

		var BindSearchEvents = function()
		{
			$( "#catalogue-search-box" ).keyup( function()
			{
				var lastVal = $.data( this, "last-val" );
				var nowVal = $( this ).val();

				if( lastVal != nowVal )
				{
					$.data( this, "last-val", nowVal );

					window.clearTimeout( $.data( this, "timeout" ) );

					$.data( this, "timeout",
						window.setTimeout(
							function()
							{
								OnFilterChange();
							},
							searchKeyUpDelay
						)
					);
				}
			});
		};

		var BindCategoryEvents = function()
		{
			$( "#category-select" ).change( function( e )
			{
				e.preventDefault();

				OnFilterChange();
			});
		};

		var TestCurrentPage = function()
		{
			var pageNumberRequested = GetCurrentPageInDOM();
			var totalPages = GetTotalPages();

			if( totalPages > 0 )
			{
				if( pageNumberRequested > totalPages )
				{
					SetCurrentPage( totalPages );
				}
				else if( pageNumberRequested < 1 )
				{
					SetCurrentPage( 1 );
				}
				else
				{
					SetCurrentPage( pageNumberRequested );
					UpdatePaginationButtonStates();
					return true;
				}
			}
			else
			{
				UpdatePaginationButtonStates();
			}

			return false;
		};

		var UpdatePaginationButtonStates = function()
		{
			var currentPage = GetCurrentPage();
			var totalPages = GetTotalPages();

			if( currentPage == 1 || totalPages == 0 )
			{
				$( ".prev-page a" ).addClass( "disabled" );
			}
			else
			{
				$( ".prev-page a" ).removeClass( "disabled" );
			}

			if( currentPage == totalPages || totalPages == 0 )
			{
				$( ".next-page a" ).addClass( "disabled" );
			}
			else
			{
				$( ".next-page a" ).removeClass( "disabled" );
			}
		};

		var GetCurrentPage = function()
		{
			return currentPage;
		};

		var GetCurrentPageInDOM = function()
		{
			var currentPage = parseInt( $( ".current-page" ).html() );

			if( isNaN( currentPage ) )
			{
				currentPage = 1;
			}

			return currentPage;
		};

		var SetCurrentPage = function( page )
		{
			var newPage = parseInt( page );

			SetCurrentPageInDOM( newPage );

			if( newPage != GetCurrentPage() )
			{
				currentPage = newPage;

				if( TestCurrentPage() )
				{
					OnFilterChange();
				}
			}
		};

		var SetCurrentPageInDOM = function( page )
		{
			if( $( ".current-page" ).length > 0 )
			{
				$( ".current-page" ).html( parseInt( page ).toString() );
			}
		};

		var GetTotalPages = function()
		{
			var totalPages = 1;

			if( $( ".total-pages" ).length > 0 )
			{
				totalPages = parseInt( $( ".total-pages" ).html() );
			}

			return totalPages;
		};

		var SetTotalPages = function( totalPages )
		{
			if( $( ".total-pages" ).length > 0 )
			{
				$( ".total-pages" ).html( totalPages );
			}

			TestCurrentPage();
		};

		var SetTotalItems = function( totalItems )
		{
			if( $( ".total-items" ).length > 0 )
			{
				$( ".total-items" ).html( totalItems );
			}
		};

		var OnFilterChange = function()
		{
			var groupFinder = window.location.search.split( "?cg=" );
			var group = groupFinder.length > 1 ? parseInt( groupFinder[ 1 ] ) : "";

			var params = {
				currentPage: GetCurrentPage(),
				search: $( "#catalogue-search-box" ).length ? $( "#catalogue-search-box" ).val() : "",
				category: $( "#category-select" ).length ? $( "#category-select" ).val() : "",
				group: group,
				imageSize: parseInt( $( ".image-size" ).html() )
			};

			App.Catalogue.GetListFromServer( params );
		};

		var PreventFormSubmit = function()
		{
			$( "#catalogue-search-box" ).closest( "form" ).submit( function()
			{
				window.clearTimeout( $.data( this, "timeout" ) );
				OnFilterChange();
				return false;
			});
		};

		return {
			Initialize: Initialize,
			SetTotalPages: SetTotalPages,
			SetTotalItems: SetTotalItems
		};
	}();

	App.Catalogue = function()
	{
		var ajaxURL = null;

		var Initialize = function( newAjaxURL )
		{
			ajaxURL = newAjaxURL;
		};

		var GetListFromServer = function( params )
		{
			updatedItems = null;

			var uniqueAjaxURL = ajaxURL;

			uniqueAjaxURL = uniqueAjaxURL.replace( "#IMAGESIZE#", encodeURIComponent( params.imageSize ) );
			uniqueAjaxURL = uniqueAjaxURL.replace( "#CURRENTPAGE#", encodeURIComponent( params.currentPage ) );
			uniqueAjaxURL = uniqueAjaxURL.replace( "#SEARCH#", encodeURIComponent( params.search ) );
			uniqueAjaxURL = uniqueAjaxURL.replace( "#CATEGORY#", encodeURIComponent( params.category ) );
			uniqueAjaxURL = uniqueAjaxURL.replace( "#GROUP#", encodeURIComponent( params.group ) );

			$( "ul.catalogue-items" ).load( uniqueAjaxURL + " ul.catalogue-items > li", function( response, status, xhr )
			{
				if( status !== "error" )
				{
					UpdateTotalPages( $( ".total-pages", response ).html() );
					UpdateTotalItems( $( ".total-items", response ).html() );
					UpdateNoMatchesContent( $( ".total-items", response ).html() );
					$( ".catalogue-items" ).trigger( "oncatalogueitemsupdated.catalogue" );
				}
			});
		};

		var UpdateTotalPages = function( totalPages )
		{
			App.Filters.SetTotalPages( totalPages );
		};

		var UpdateTotalItems = function( totalItems )
		{
			App.Filters.SetTotalItems( totalItems );
		};

		var UpdateNoMatchesContent = function( totalItems )
		{
			if( totalItems > 0 )
			{
				$( ".no-matches" ).hide();
			}
			else
			{
				$( ".no-matches" ).show();
			}
		};

		return {
			Initialize: Initialize,
			GetListFromServer: GetListFromServer
		};
	}();

})( jQuery, window.STL || ( window.STL = {} ) );
( function( $, App )
{
	// Sanity checks
    if( typeof $ !== "function" ) throw new Error( "jQuery is not defined." );

	$( document ).ready( function()
	{
		App.RotatingImagery.Initialize( [
			"winter-2011-1",
			"winter-2011-2",
			"winter-2011-3"
		] );
	});

})( jQuery, window.STL || ( window.STL = {} ) );

