(function ($) {
    $.fn.scrollLoad = function (options) {

        var defaults = {
            url: '',
            data: '',
            ScrollAfterHeight: 90,
            onload: function (data, itsMe) {
                alert(data);
            },
            start: function (itsMe) { },
            continueWhile: function () {
                return true;
            },
            getData: function (itsMe) {
                return '';
            }
        };

        for (var eachProperty in defaults) {
            if (options[eachProperty]) {
                defaults[eachProperty] = options[eachProperty];
            }
        }

        return this.each(function () {
            this.scrolling = false;
            this.scrollPrev = this.onscroll ? this.onscroll : null;
            $(this).bind('scroll', function (e) {
                if (this.scrollPrev) {
                    this.scrollPrev();
                }
                if (this.scrolling) return;
                //var totalPixels = $( this ).attr( 'scrollHeight' ) - $( this ).attr( 'clientHeight' );
                if (Math.round($(this).attr('scrollTop') / ($(this).attr('scrollHeight') - $(this).attr('clientHeight')) * 100) > defaults.ScrollAfterHeight) {
                    defaults.start.call(this, this);
                    this.scrolling = true;
                    $this = $(this);
                    $.ajax({ url: defaults.url, data: defaults.getData.call(this, this), type: 'post', success: function (data) {
                        $this[0].scrolling = false;
                        defaults.onload.call($this[0], data, $this[0]);
                        if (!defaults.continueWhile.call($this[0], data)) {
                            $this.unbind('scroll');
                        }
                    }
                    });
                }
            }).bind('jsp-scroll-y', function (event, scrollPositionY, isAtTop, isAtBottom) {
                if (this.scrollPrev) {
                    this.scrollPrev();
                }
                if (this.scrolling) return;
                if (isAtBottom) {
                    defaults.start.call(this, this);
                    this.scrolling = true;
                    $this = $(this);
                    $.ajax({ url: defaults.url, data: defaults.getData.call(this, this), type: 'post', success: function (data) {
                        $this[0].scrolling = false;
                        defaults.onload.call($this[0], data, $this[0]);
                        if (!defaults.continueWhile.call($this[0], data)) {
                            $this.unbind('jsp-scroll-y');
                        }
                    }
                    });
                }
            });
        });
    }
})(jQuery);

/*
      #infinite_scroll{height:200px;overflow-y:scroll;margin-top:50px;border:1px solid #ccc;padding:10px;}
       #infinite_scroll a{font-weight:bold;}
       #infinite_scroll p{margin-bottom:20px;width:90%}
       .loading{text-align:right;margin-top:-100px}


<script type="text/javascript">
$(document).ready(function(){
 
$( '#infinite_scroll' ).scrollLoad({
 
url : 'my_scroll_ajax_file.php', //your ajax file to be loaded when scroll breaks ScrollAfterHeight
 
getData : function() {
//you can post some data along with ajax request
},
 
start : function() {
$('<div class="loading"><img src="ajax-loader.gif"/></div>').appendTo(this);
// you can add your effect before loading data
},
 
ScrollAfterHeight : 95,			//this is the height in percentage after which ajax stars
 
onload : function( data ) {
$(this).append( data );
$('.loading').remove();
}, // this event fires on ajax success
 
continueWhile : function( resp ) {
if( $(this).children('li').length >= 100 ) { // stops when number of 'li' reaches 100
return false;
}
return true; 
}
});
 
});
 
</script>*/
/* jTemplates 0.7.8 (http://jtemplates.tpython.com) Copyright (c) 2009 Tomasz Gloc */
eval(function(p, a, c, k, e, r) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace( /^/ , String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] }]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }('a(37.b&&!37.b.38){(9(b){6 m=9(s,A,f){5.1M=[];5.1u={};5.2p=E;5.1N={};5.1c={};5.f=b.1m({1Z:1f,3a:1O,2q:1f,2r:1f,3b:1O,3c:1O},f);5.1v=(5.f.1v!==F)?(5.f.1v):(13.20);5.Y=(5.f.Y!==F)?(5.f.Y):(13.3d);5.3e(s,A);a(s){5.1w(5.1c[\'21\'],A,5.f)}5.1c=E};m.y.2s=\'0.7.8\';m.R=1O;m.y.3e=9(s,A){6 2t=/\\{#14 *(\\w*?)( .*)*\\}/g;6 22,1x,M;6 1y=E;6 2u=[];2v((22=2t.3N(s))!=E){1y=2t.1y;1x=22[1];M=s.2w(\'{#/14 \'+1x+\'}\',1y);a(M==-1){C j Z(\'15: m "\'+1x+\'" 2x 23 3O.\');}5.1c[1x]=s.2y(1y,M);2u[1x]=13.2z(22[2])}a(1y===E){5.1c[\'21\']=s;c}N(6 i 24 5.1c){a(i!=\'21\'){5.1N[i]=j m()}}N(6 i 24 5.1c){a(i!=\'21\'){5.1N[i].1w(5.1c[i],b.1m({},A||{},5.1N||{}),b.1m({},5.f,2u[i]));5.1c[i]=E}}};m.y.1w=9(s,A,f){a(s==F){5.1M.B(j 1g(\'\',1,5));c}s=s.U(/[\\n\\r]/g,\'\');s=s.U(/\\{\\*.*?\\*\\}/g,\'\');5.2p=b.1m({},5.1N||{},A||{});5.f=j 2A(f);6 p=5.1M;6 1P=s.1h(/\\{#.*?\\}/g);6 16=0,M=0;6 e;6 1i=0;6 25=0;N(6 i=0,l=(1P)?(1P.V):(0);i<l;++i){6 17=1P[i];a(1i){M=s.2w(\'{#/1z}\');a(M==-1){C j Z("15: 3P 1Q 3f 1z.");}a(M>16){p.B(j 1g(s.2y(16,M),1,5))}16=M+11;1i=0;i=b.3Q(\'{#/1z}\',1P);1R}M=s.2w(17,16);a(M>16){p.B(j 1g(s.2y(16,M),1i,5))}6 3R=17.1h(/\\{#([\\w\\/]+).*?\\}/);6 26=I.$1;2B(26){q\'3S\':++25;p.27();q\'a\':e=j 1A(17,p);p.B(e);p=e;D;q\'J\':p.27();D;q\'/a\':2v(25){p=p.28();--25}q\'/N\':q\'/29\':p=p.28();D;q\'29\':e=j 1n(17,p,5);p.B(e);p=e;D;q\'N\':e=2a(17,p,5);p.B(e);p=e;D;q\'1R\':q\'D\':p.B(j 18(26));D;q\'2C\':p.B(j 2D(17,5.2p));D;q\'h\':p.B(j 2E(17));D;q\'2F\':p.B(j 2G(17));D;q\'3T\':p.B(j 1g(\'{\',1,5));D;q\'3U\':p.B(j 1g(\'}\',1,5));D;q\'1z\':1i=1;D;q\'/1z\':a(m.R){C j Z("15: 3V 2H 3f 1z.");}D;2I:a(m.R){C j Z(\'15: 3W 3X: \'+26+\'.\');}}16=M+17.V}a(s.V>16){p.B(j 1g(s.3Y(16),1i,5))}};m.y.K=9(d,h,z,H){++H;6 $T=d,2b,2c;a(5.f.3b){$T=5.1v(d,{2d:(5.f.3a&&H==1),1S:5.f.1Z},5.Y)}a(!5.f.3c){2b=5.1u;2c=h}J{2b=5.1v(5.1u,{2d:(5.f.2q),1S:1f},5.Y);2c=5.1v(h,{2d:(5.f.2q&&H==1),1S:1f},5.Y)}6 $P=b.1m({},2b,2c);6 $Q=(z!=F)?(z):({});$Q.2s=5.2s;6 19=\'\';N(6 i=0,l=5.1M.V;i<l;++i){19+=5.1M[i].K($T,$P,$Q,H)}--H;c 19};m.y.2J=9(1T,1o){5.1u[1T]=1o};13=9(){};13.3d=9(3g){c 3g.U(/&/g,\'&3Z;\').U(/>/g,\'&3h;\').U(/</g,\'&3i;\').U(/"/g,\'&40;\').U(/\'/g,\'&#39;\')};13.20=9(d,1B,Y){a(d==E){c d}2B(d.2K){q 2A:6 o={};N(6 i 24 d){o[i]=13.20(d[i],1B,Y)}a(!1B.1S){a(d.41("2L"))o.2L=d.2L}c o;q 42:6 o=[];N(6 i=0,l=d.V;i<l;++i){o[i]=13.20(d[i],1B,Y)}c o;q 2M:c(1B.2d)?(Y(d)):(d);q 43:a(1B.1S){a(m.R)C j Z("15: 44 45 23 46.");J c F}2I:c d}};13.2z=9(2e){a(2e===E||2e===F){c{}}6 o=2e.47(/[= ]/);a(o[0]===\'\'){o.48()}6 2N={};N(6 i=0,l=o.V;i<l;i+=2){2N[o[i]]=o[i+1]}c 2N};6 1g=9(2O,1i,14){5.2f=2O;5.3j=1i;5.1d=14};1g.y.K=9(d,h,z,H){6 2g=5.2f;a(!5.3j){6 2P=5.1d;6 $T=d;6 $P=h;6 $Q=z;2g=2g.U(/\\{(.*?)\\}/g,9(49,3k){1C{6 1D=10(3k);a(1E 1D==\'9\'){a(2P.f.1Z||!2P.f.2r){c\'\'}J{1D=1D($T,$P,$Q)}}c(1D===F)?(""):(2M(1D))}1F(e){a(m.R){a(e 1G 18)e.1j="4a";C e;}c""}})}c 2g};6 1A=9(L,1H){5.2h=1H;L.1h(/\\{#(?:J)*a (.*?)\\}/);5.3l=I.$1;5.1p=[];5.1q=[];5.1I=5.1p};1A.y.B=9(e){5.1I.B(e)};1A.y.28=9(){c 5.2h};1A.y.27=9(){5.1I=5.1q};1A.y.K=9(d,h,z,H){6 $T=d;6 $P=h;6 $Q=z;6 19=\'\';1C{6 2Q=(10(5.3l))?(5.1p):(5.1q);N(6 i=0,l=2Q.V;i<l;++i){19+=2Q[i].K(d,h,z,H)}}1F(e){a(m.R||(e 1G 18))C e;}c 19};2a=9(L,1H,14){a(L.1h(/\\{#N (\\w+?) *= *(\\S+?) +4b +(\\S+?) *(?:12=(\\S+?))*\\}/)){L=\'{#29 2a.3m 3n \'+I.$1+\' 2H=\'+(I.$2||0)+\' 1Q=\'+(I.$3||-1)+\' 12=\'+(I.$4||1)+\' u=$T}\';c j 1n(L,1H,14)}J{C j Z(\'15: 4c 4d "3o": \'+L);}};2a.3m=9(i){c i};6 1n=9(L,1H,14){5.2h=1H;5.1d=14;L.1h(/\\{#29 (.+?) 3n (\\w+?)( .+)*\\}/);5.3p=I.$1;5.x=I.$2;5.W=I.$3||E;5.W=13.2z(5.W);5.1p=[];5.1q=[];5.1I=5.1p};1n.y.B=9(e){5.1I.B(e)};1n.y.28=9(){c 5.2h};1n.y.27=9(){5.1I=5.1q};1n.y.K=9(d,h,z,H){1C{6 $T=d;6 $P=h;6 $Q=z;6 1r=10(5.3p);6 1U=[];6 1J=1E 1r;a(1J==\'3q\'){6 2R=[];b.1e(1r,9(k,v){1U.B(k);2R.B(v)});1r=2R}6 u=(5.W.u!==F)?(10(5.W.u)):(($T!=E)?($T):({}));6 s=1V(10(5.W.2H)||0),e;6 12=1V(10(5.W.12)||1);a(1J!=\'9\'){e=1r.V}J{a(5.W.1Q===F||5.W.1Q===E){e=1V.4e}J{e=1V(10(5.W.1Q))+((12>0)?(1):(-1))}}6 19=\'\';6 i,l;a(5.W.1W){6 2S=s+1V(10(5.W.1W));e=(2S>e)?(e):(2S)}a((e>s&&12>0)||(e<s&&12<0)){6 1K=0;6 3r=(1J!=\'9\')?(4f.4g((e-s)/12)):F;6 1s,1k;N(;((12>0)?(s<e):(s>e));s+=12,++1K){1s=1U[s];a(1J!=\'9\'){1k=1r[s]}J{1k=1r(s);a(1k===F||1k===E){D}}a((1E 1k==\'9\')&&(5.1d.f.1Z||!5.1d.f.2r)){1R}a((1J==\'3q\')&&(1s 24 2A)){1R}6 3s=u[5.x];u[5.x]=1k;u[5.x+\'$3t\']=s;u[5.x+\'$1K\']=1K;u[5.x+\'$3u\']=(1K==0);u[5.x+\'$3v\']=(s+12>=e);u[5.x+\'$3w\']=3r;u[5.x+\'$1U\']=(1s!==F&&1s.2K==2M)?(5.1d.Y(1s)):(1s);u[5.x+\'$1E\']=1E 1k;N(i=0,l=5.1p.V;i<l;++i){1C{19+=5.1p[i].K(u,h,z,H)}1F(2T){a(2T 1G 18){2B(2T.1j){q\'1R\':i=l;D;q\'D\':i=l;s=e;D;2I:C e;}}J{C e;}}}1l u[5.x+\'$3t\'];1l u[5.x+\'$1K\'];1l u[5.x+\'$3u\'];1l u[5.x+\'$3v\'];1l u[5.x+\'$3w\'];1l u[5.x+\'$1U\'];1l u[5.x+\'$1E\'];1l u[5.x];u[5.x]=3s}}J{N(i=0,l=5.1q.V;i<l;++i){19+=5.1q[i].K($T,h,z,H)}}c 19}1F(e){a(m.R||(e 1G 18))C e;c""}};6 18=9(1j){5.1j=1j};18.y=Z;18.y.K=9(d){C 5;};6 2D=9(L,A){L.1h(/\\{#2C (.*?)(?: 4h=(.*?))?\\}/);5.1d=A[I.$1];a(5.1d==F){a(m.R)C j Z(\'15: 4i 3o 2C: \'+I.$1);}5.3x=I.$2};2D.y.K=9(d,h,z,H){6 $T=d;6 $P=h;1C{c 5.1d.K(10(5.3x),h,z,H)}1F(e){a(m.R||(e 1G 18))C e;}c\'\'};6 2E=9(L){L.1h(/\\{#h 1T=(\\w*?) 1o=(.*?)\\}/);5.x=I.$1;5.2f=I.$2};2E.y.K=9(d,h,z,H){6 $T=d;6 $P=h;6 $Q=z;1C{h[5.x]=10(5.2f)}1F(e){a(m.R||(e 1G 18))C e;h[5.x]=F}c\'\'};6 2G=9(L){L.1h(/\\{#2F 4j=(.*?)\\}/);5.2U=10(I.$1);5.2V=5.2U.V;a(5.2V<=0){C j Z(\'15: 2F 4k 4l 4m\');}5.2W=0;5.2X=-1};2G.y.K=9(d,h,z,H){6 2Y=b.O(z,\'1X\');a(2Y!=5.2X){5.2X=2Y;5.2W=0}6 i=5.2W++%5.2V;c 5.2U[i]};b.1a.1w=9(s,A,f){a(s.2K===m){c b(5).1e(9(){b.O(5,\'2i\',s);b.O(5,\'1X\',0)})}J{c b(5).1e(9(){b.O(5,\'2i\',j m(s,A,f));b.O(5,\'1X\',0)})}};b.1a.4n=9(1L,A,f){6 s=b.2Z({1t:1L,1Y:1f}).3y;c b(5).1w(s,A,f)};b.1a.4o=9(30,A,f){6 s=b(\'#\'+30).2O();a(s==E){s=b(\'#\'+30).3z();s=s.U(/&3i;/g,"<").U(/&3h;/g,">")}s=b.4p(s);s=s.U(/^<\\!\\[4q\\[([\\s\\S]*)\\]\\]>$/3A,\'$1\');s=s.U(/^<\\!--([\\s\\S]*)-->$/3A,\'$1\');c b(5).1w(s,A,f)};b.1a.4r=9(){6 1W=0;b(5).1e(9(){a(b.2j(5)){++1W}});c 1W};b.1a.4s=9(){b(5).3B();c b(5).1e(9(){b.3C(5,\'2i\')})};b.1a.2J=9(1T,1o){c b(5).1e(9(){6 t=b.2j(5);a(t===F){a(m.R)C j Z(\'15: m 2x 23 3D.\');J c}t.2J(1T,1o)})};b.1a.31=9(d,h){c b(5).1e(9(){6 t=b.2j(5);a(t===F){a(m.R)C j Z(\'15: m 2x 23 3D.\');J c}b.O(5,\'1X\',b.O(5,\'1X\')+1);b(5).3z(t.K(d,h,5,0))})};b.1a.4t=9(1L,h,G){6 X=5;G=b.1m({1j:\'4u\',1Y:1O,32:1f},G);b.2Z({1t:1L,1j:G.1j,O:G.O,3E:G.3E,1Y:G.1Y,32:G.32,3F:G.3F,4v:\'4w\',4x:9(d){6 r=b(X).31(d,h);a(G.2k){G.2k(r)}},4y:G.4z,4A:G.4B});c 5};6 2l=9(1t,h,2m,2n,1b,G){5.3G=1t;5.1u=h;5.3H=2m;5.3I=2n;5.1b=1b;5.3J=E;5.33=G||{};6 X=5;b(1b).1e(9(){b.O(5,\'34\',X)});5.35()};2l.y.35=9(){5.3K();a(5.1b.V==0){c}6 X=5;b.4C(5.3G,5.3I,9(d){6 r=b(X.1b).31(d,X.1u);a(X.33.2k){X.33.2k(r)}});5.3J=4D(9(){X.35()},5.3H)};2l.y.3K=9(){5.1b=b.3L(5.1b,9(o){a(b.4E.4F){6 n=o.36;2v(n&&n!=4G){n=n.36}c n!=E}J{c o.36!=E}})};b.1a.4H=9(1t,h,2m,2n,G){c j 2l(1t,h,2m,2n,5,G)};b.1a.3B=9(){c b(5).1e(9(){6 2o=b.O(5,\'34\');a(2o==E){c}6 X=5;2o.1b=b.3L(2o.1b,9(o){c o!=X});b.3C(5,\'34\')})};b.1m({38:9(s,A,f){c j m(s,A,f)},4I:9(1L,A,f){6 s=b.2Z({1t:1L,1Y:1f}).3y;c j m(s,A,f)},2j:9(z){c b.O(z,\'2i\')},4J:9(14,O,3M){c 14.K(O,3M,F,0)},4K:9(1o){m.R=1o}})})(b)}', 62, 295, '|||||this|var|||function|if|jQuery|return|||settings||param||new|||Template|||node|case||||extData|||_name|prototype|element|includes|push|throw|break|null|undefined|options|deep|RegExp|else|get|oper|se|for|data|||DEBUG_MODE|||replace|length|_option|that|f_escapeString|Error|eval||step|TemplateUtils|template|jTemplates|ss|this_op|JTException|ret|fn|objs|_templates_code|_template|each|false|TextNode|match|literalMode|type|cval|delete|extend|opFOREACH|value|_onTrue|_onFalse|fcount|ckey|url|_param|f_cloneData|setTemplate|tname|lastIndex|literal|opIF|filter|try|__tmp|typeof|catch|instanceof|par|_currentState|mode|iteration|url_|_tree|_templates|true|op|end|continue|noFunc|name|key|Number|count|jTemplateSID|async|disallow_functions|cloneData|MAIN|iter|not|in|elseif_level|op_|switchToElse|getParent|foreach|opFORFactory|_param1|_param2|escapeData|optionText|_value|__t|_parent|jTemplate|getTemplate|on_success|Updater|interval|args|updater|_includes|filter_params|runnable_functions|version|reg|_template_settings|while|indexOf|is|substring|optionToObject|Object|switch|include|Include|UserParam|cycle|Cycle|begin|default|setParam|constructor|toString|String|obj|val|__template|tab|arr|tmp|ex|_values|_length|_index|_lastSessionID|sid|ajax|elementName|processTemplate|cache|_options|jTemplateUpdater|run|parentNode|window|createTemplate||filter_data|clone_data|clone_params|escapeHTML|splitTemplates|of|txt|gt|lt|_literalMode|__1|_cond|funcIterator|as|find|_arg|object|_total|prevValue|index|first|last|total|_root|responseText|html|im|processTemplateStop|removeData|defined|dataFilter|timeout|_url|_interval|_args|timer|detectDeletedNodes|grep|parameter|exec|closed|No|inArray|ppp|elseif|ldelim|rdelim|Missing|unknown|tag|substr|amp|quot|hasOwnProperty|Array|Function|Functions|are|allowed|split|shift|__0|subtemplate|to|Operator|failed|MAX_VALUE|Math|ceil|root|Cannot|values|has|no|elements|setTemplateURL|setTemplateElement|trim|CDATA|hasTemplate|removeTemplate|processTemplateURL|GET|dataType|json|success|error|on_error|complete|on_complete|getJSON|setTimeout|browser|msie|document|processTemplateStart|createTemplateURL|processTemplateToText|jTemplatesDebugMode'.split('|'), 0, {  }));
eval(function(p, a, c, k, e, d) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace( /^/ , String)) { while (c--) { d[e(c)] = k[c] || e(c) } k = [function(e) { return d[e] }]; e = function() { return '\\w+' }; c = 1 }; while (c--) { if (k[c]) { p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]) } } return p }('"6j 6l";(h($){$(3O).3U(h(){R i;$(2f).1K(\'3t 3r\',h(q){1T(i=0;i<$.19.g.N.Q;i++){R V=$.19.g.N[i];c(V&&V.U&&V.U.1c&&V.8.o.17!==\'27\'&&(V.8.o.1f.3r&&q.17===\'3r\'||V.8.o.1f.3t&&q.17===\'3t\')){V.29(q,G)}}});$(3O).1K(\'5p.g\',h(q){c($(q.w).5l(\'Y.g\').Q===0){$(\'.g[3M]\').1F(h(){R V=$(u).g(\'V\');c($(u).37(\':2I\')&&V&&V.U&&!V.U.1Z&&$(q.w).2n(V.d.w).Q>1){V.C(q)}})}})});h 2K(s){c(!s){B p}u.x=5P(s).3l(/60/i,\'1i\').5U(/M|25|1i/i)[0].2M();u.y=5P(s).3l(/60/i,\'1i\').5U(/K|23|1i/i)[0].2M();u.1s={M:0,K:0};u.2u=(s.2J(0).6W(/^(t|b)/)>-1)?\'y\':\'x\';u.1A=h(){B(u.2u===\'y\')?u.y+u.x:u.x+u.y}}h 4m(s,k,F){R 1N={5Y:[[0,0],[k,F],[k,0]],5L:[[0,0],[k,0],[0,F]],5J:[[0,F],[k,0],[k,F]],5M:[[0,0],[0,F],[k,F]],6O:[[0,F],[k/2,0],[k,F]],6M:[[0,0],[k,0],[k/2,F]],6P:[[0,0],[k,F/2],[0,F]],6u:[[k,0],[k,F],[0,F/2]]};1N.6V=1N.5Y;1N.6U=1N.5L;1N.6S=1N.5J;1N.6J=1N.5M;B 1N[s]}h 42(D){R 2q;c($(\'<1e />\').1r(0).1E){2q={3n:[D,D],4o:[0,D],4t:[D,0],3z:[0,0]}}E c($.16.1d){2q={3n:[-2E,2E,0],4o:[-2E,2E,-D],4t:[2E,62,0],3z:[2E,62,-D]}}B 2q}h 2G(e,4l){R 2N,i;2N=$.2k(G,{},e);1T(i 67 2N){c(4l===G&&(/(f|1g)/i).24(i)){3P 2N[i]}E c(!4l&&(/(k|J|f|T|1g|4z)/i).24(i)){3P 2N[i]}}B 2N}h 4G(e){c(P e.f!==\'1a\'){e.f={s:e.f}}c(P e.f.O!==\'1a\'){e.f.O={k:e.f.O,F:e.f.O}}c(P e.J!==\'1a\'){e.J={k:e.J}}c(P e.k!==\'1a\'){e.k={30:e.k}}c(P e.k.1L===\'1A\'){e.k.1L=1x(e.k.1L.3l(/([0-9]+)/i,"$1"),10)}c(P e.k.2c===\'1A\'){e.k.2c=1x(e.k.2c.3l(/([0-9]+)/i,"$1"),10)}c(P e.f.O.x===\'2o\'){e.f.O.k=e.f.O.x;3P e.f.O.x}c(P e.f.O.y===\'2o\'){e.f.O.F=e.f.O.y;3P e.f.O.y}B e}h 4E(){R 7,i,3q,2s,1B,1P;7=u;3q=[G,{}];1T(i=0;i<2Y.Q;i++){3q.6c(2Y[i])}2s=[$.2k.4K($,3q)];6B(P 2s[0].22===\'1A\'){2s.64(4G($.19.g.2Z[2s[0].22]))}2s.64(G,{1g:{j:\'g-\'+(2Y[0].22||\'2W\')}},$.19.g.2Z.2W);1B=$.2k.4K($,2s);1P=($.16.1d)?1:0;1B.f.O.k+=1P;1B.f.O.F+=1P;c(1B.f.O.k%2>0){1B.f.O.k+=1}c(1B.f.O.F%2>0){1B.f.O.F+=1}c(1B.f.s===G){c(7.8.o.s.j===\'1i\'&&7.8.o.s.w===\'1i\'){1B.f.s=p}E{1B.f.s=7.8.o.s.j}}B 1B}h 41(1e,X,D,I){R 1k=1e.1r(0).1E(\'2d\');1k.5E=I;1k.5C();1k.3R(X[0],X[1],D,0,1v.6C*2,p);1k.5s()}h 5G(){R 7,i,k,D,I,X,1R,O,43,2p,3j,3h,4s,4p,4r;7=u;7.d.1u.1J(\'.g-3h, .g-3j\').3D();k=7.8.e.J.k;D=7.8.e.J.D;I=7.8.e.J.I||7.8.e.f.I;X=42(D);1R={};1T(i 67 X){1R[i]=\'<Y 1Q="\'+i+\'" e="\'+((/6H/).24(i)?\'M\':\'25\')+\':0; \'+\'o:33; F:\'+D+\'18; k:\'+D+\'18; 2t:1G; 2F-F:0.1H; 3d-O:1H">\';c($(\'<1e />\').1r(0).1E){1R[i]+=\'<1e F="\'+D+\'" k="\'+D+\'" e="4e-3Q: K"></1e>\'}E c($.16.1d){O=D*2+3;1R[i]+=\'<v:3R 5g="p" 3I="\'+I+\'" 6G="\'+X[i][0]+\'" 6F="\'+X[i][1]+\'" \'+\'e="k:\'+O+\'18; F:\'+O+\'18; 2i-K:\'+((/23/).24(i)?-2:-1)+\'18; \'+\'2i-M:\'+((/6E/).24(i)?X[i][2]-3.5:-1)+\'18; \'+\'4e-3Q:K; 28:5q-4a; 3s:1w(#2C#3u)"></v:3R>\'}1R[i]+=\'</Y>\'}43=7.38().k-(1v.1L(k,D)*2);2p=\'<Y 1I="g-2p" e="F:\'+D+\'18; k:\'+43+\'18; \'+\'2t:1G; 1p-I:\'+I+\'; 2F-F:0.1H; 3d-O:1H;">\';3j=\'<Y 1I="g-3j" 44="45" e="F:\'+D+\'18; \'+\'2i-M:\'+D+\'18; 2F-F:0.1H; 3d-O:1H; 2A:0;">\'+1R.3n+1R.4o+2p;7.d.1u.3S(3j);3h=\'<Y 1I="g-3h" 44="45" e="F:\'+D+\'18; \'+\'2i-M:\'+D+\'18; 2F-F:0.1H; 3d-O:1H; 2A:0;">\'+1R.4t+1R.3z+2p;7.d.1u.5e(3h);c($(\'<1e />\').1r(0).1E){7.d.1u.1J(\'1e\').1F(h(){4s=X[$(u).3L(\'[1Q]:1O\').W(\'1Q\')];41.S(7,$(u),4s,D,I)})}E c($.16.1d){7.d.j.5e(\'<v:3Y e="3s:1w(#2C#3u);"></v:3Y>\')}4p=1v.1L(D,(D+(k-D)));4r=1v.1L(k-D,0);7.d.1z.H({J:\'6R 3N \'+I,6T:4r+\'18 \'+4p+\'18\'})}h 4u(1e,X,I){R 1k=1e.1r(0).1E(\'2d\');1k.5E=I;1k.5C();1k.6N(X[0][0],X[0][1]);1k.5D(X[1][0],X[1][1]);1k.5D(X[2][0],X[2][1]);1k.5s()}h 3Z(s){R 7,1P,1X,47,46,3V;7=u;c(7.8.e.f.s===p||!7.d.f){B}c(!s){s=2B 2K(7.d.f.W(\'1Q\'))}1P=1X=($.16.1d)?1:0;7.d.f.H(s[s.2u],0);c(s.2u===\'y\'){c($.16.1d){c(1x($.16.3a.2J(0),10)===6){1X=s.y===\'K\'?-3:1}E{1X=s.y===\'K\'?1:2}}c(s.x===\'1i\'){7.d.f.H({M:\'50%\',6m:-(7.8.e.f.O.k/2)})}E c(s.x===\'M\'){7.d.f.H({M:7.8.e.J.D-1P})}E{7.d.f.H({25:7.8.e.J.D+1P})}c(s.y===\'K\'){7.d.f.H({K:-1X})}E{7.d.f.H({23:1X})}}E{c($.16.1d){1X=(1x($.16.3a.2J(0),10)===6)?1:(s.x===\'M\'?1:2)}c(s.y===\'1i\'){7.d.f.H({K:\'50%\',4c:-(7.8.e.f.O.F/2)})}E c(s.y===\'K\'){7.d.f.H({K:7.8.e.J.D-1P})}E{7.d.f.H({23:7.8.e.J.D+1P})}c(s.x===\'M\'){7.d.f.H({M:-1X})}E{7.d.f.H({25:1X})}}47=\'2A-\'+s[s.2u];46=7.8.e.f.O[s.2u===\'x\'?\'k\':\'F\'];7.d.j.H(\'2A\',0).H(47,46);c($.16.1d&&1x($.16.3a.2J(0),6)===6){3V=1x(7.d.f.H(\'2i-K\'),10)||0;3V+=1x(7.d.A.H(\'2i-K\'),10)||0;7.d.f.H({4c:3V})}}h 4j(s){R 7,I,X,3X,2l,f;7=u;c(7.d.f!==1y){7.d.f.3D()}I=7.8.e.f.I||7.8.e.J.I;c(7.8.e.f.s===p){B}E c(!s){s=2B 2K(7.8.e.f.s)}X=4m(s.1A(),7.8.e.f.O.k,7.8.e.f.O.F);7.d.f=\'<Y 1I="\'+7.8.e.1g.f+\'" 44="45" 1Q="\'+s.1A()+\'" e="o:33; \'+\'F:\'+7.8.e.f.O.F+\'18; k:\'+7.8.e.f.O.k+\'18; \'+\'2i:0 5R; 2F-F:0.1H; 3d-O:1H;"></Y>\';7.d.j.3S(7.d.f);c($(\'<1e />\').1r(0).1E){f=\'<1e F="\'+7.8.e.f.O.F+\'" k="\'+7.8.e.f.O.k+\'"></1e>\'}E c($.16.1d){3X=7.8.e.f.O.k+\',\'+7.8.e.f.O.F;2l=\'m\'+X[0][0]+\',\'+X[0][1];2l+=\' l\'+X[1][0]+\',\'+X[1][1];2l+=\' \'+X[2][0]+\',\'+X[2][1];2l+=\' 6q\';f=\'<v:3C 3I="\'+I+\'" 5g="p" 6s="G" 2l="\'+2l+\'" 3X="\'+3X+\'" \'+\'e="k:\'+7.8.e.f.O.k+\'18; F:\'+7.8.e.f.O.F+\'18; \'+\'2F-F:0.1H; 28:5q-4a; 3s:1w(#2C#3u); \'+\'4e-3Q:\'+(s.y===\'K\'?\'23\':\'K\')+\'"></v:3C>\';f+=\'<v:3Y e="3s:1w(#2C#3u);"></v:3Y>\';7.d.1z.H(\'o\',\'49\')}7.d.f=7.d.j.1J(\'.\'+7.8.e.1g.f).6g(0);7.d.f.2j(f);c($(\'<1e  />\').1r(0).1E){4u.S(7,7.d.f.1J(\'1e:1O\'),X,I)}c(s.y===\'K\'&&$.16.1d&&1x($.16.3a.2J(0),10)===6){7.d.f.H({4c:-4})}3Z.S(7,s)}h 5v(){R 7=u;c(7.d.T!==1y){7.d.T.3D()}7.d.j.W(\'3F-6Q\',\'g-\'+7.12+\'-T\');7.d.T=$(\'<Y 12="g-\'+7.12+\'-T" 1I="\'+7.8.e.1g.T+\'"></Y>\').H(2G(7.8.e.T,G)).H({2e:($.16.1d)?1:0}).5o(7.d.1z);c(7.8.A.T.1o){7.5Z.S(7,7.8.A.T.1o)}c(7.8.A.T.1j!==p&&P 7.8.A.T.1j===\'1A\'){7.d.1j=$(\'<a 1I="\'+7.8.e.1g.1j+\'" 5t="1j" e="7d:25; o: 49"></a>\').H(2G(7.8.e.1j,G)).2j(7.8.A.T.1j).5o(7.d.T).5n(h(q){c(!7.U.1Z){7.C(q)}})}}h 5u(){R 7,36,2r,3T;7=u;36=7.8.r.L.w;2r=7.8.C.L.w;c(7.8.C.3i){2r=2r.2n(7.d.j)}3T=[\'5n\',\'7P\',\'5p\',\'7M\',\'4x\',\'4O\',\'7A\',\'7y\',\'39\'];h 3H(q){c(7.U.1Z===G){B}2g(7.1D.1Y);7.1D.1Y=4b(h(){$(3T).1F(h(){2r.1S(u+\'.g-1Y\');7.d.A.1S(u+\'.g-1Y\')});7.C(q)},7.8.C.2P)}c(7.8.C.3i===G){7.d.j.1K(\'39.g\',h(){c(7.U.1Z===G){B}2g(7.1D.C)})}h 4d(q){c(7.U.1Z===G){B}c(7.8.C.L.q===\'1Y\'){$(3T).1F(h(){2r.1K(u+\'.g-1Y\',3H);7.d.A.1K(u+\'.g-1Y\',3H)});3H()}2g(7.1D.r);2g(7.1D.C);c(7.8.r.2P>0){7.1D.r=4b(h(){7.r(q)},7.8.r.2P)}E{7.r(q)}}h 4f(q){c(7.U.1Z===G){B}c(7.8.C.3i===G&&(/1M(7G|7I)/i).24(7.8.C.L.q)&&$(q.7J).5l(\'Y.g[12^="g"]\').Q>0){q.7F();q.7E();2g(7.1D.C);B p}2g(7.1D.r);2g(7.1D.C);7.d.j.3W(G,G);7.1D.C=4b(h(){7.C(q)},7.8.C.2P)}c(7.8.o.w===\'1M\'&&7.8.o.17!==\'27\'){36.1K(\'4x.g\',h(q){7.1t.1M={M:q.3y,K:q.4y};c(7.U.1Z===p&&7.8.o.1f.1M===G&&7.8.o.17!==\'27\'&&7.d.j.H(\'28\')!==\'35\'){7.29(q)}})}c((7.8.r.L.w.2n(7.8.C.L.w).Q===1&&7.8.r.L.q===7.8.C.L.q&&7.8.C.L.q!==\'1Y\')||7.8.C.L.q===\'3M\'){7.1t.2x=0;36.1K(7.8.r.L.q+\'.g\',h(q){c(7.1t.2x===0){4d(q)}E{4f(q)}})}E{36.1K(7.8.r.L.q+\'.g\',4d);c(7.8.C.L.q!==\'1Y\'){2r.1K(7.8.C.L.q+\'.g\',4f)}}c((/(3i|33)/).24(7.8.o.17)){7.d.j.1K(\'39.g\',7.2D)}}h 1V(){R 7,2j,2h;7=u;2h=7.38();2j=\'<7U 1I="g-1V" 7O="0" 7N="-1" 4v="7R:p" \'+\'e="28:4a; o:33; z-3x:-1; 5w:7Q(3A=\\\'0\\\'); J: 1H 3N 4C; \'+\'F:\'+2h.F+\'18; k:\'+2h.k+\'18" />\';7.d.1V=7.d.1u.3S(2j).2H(\'.g-1V:1O\')}h 4L(){R 7,A,1w,14,2T;7=u;7.4U.S(7);7.U.1c=2;7.d.j=\'<Y g="\'+7.12+\'" 12="g-\'+7.12+\'" 5t="j" \'+\'3F-7X="g-\'+7.12+\'-A" 1I="g \'+(7.8.e.1g.j||7.8.e)+\'" \'+\'e="28:35; -6X-J-D:0; -7W-J-D:0; J-D:0; o:\'+7.8.o.17+\';"> \'+\'  <Y 1I="g-1u" e="o:49; 2t:1G; 1o-3Q:M;"> \'+\'    <Y 1I="g-1z" e="2t:1G;"> \'+\'       <Y 12="g-\'+7.12+\'-A" 1I="g-A \'+7.8.e.1g.A+\'"></Y> \'+\'</Y></Y></Y>\';7.d.j=$(7.d.j);7.d.j.6b(7.8.o.3o);7.d.j.14(\'g\',{3f:0,N:[7]});7.d.1u=7.d.j.2H(\'Y:1O\');7.d.1z=7.d.1u.2H(\'Y:1O\');7.d.A=7.d.1z.2H(\'Y:1O\').H(2G(7.8.e));c($.16.1d){7.d.1u.2n(7.d.A).H({2e:1})}c(7.8.C.L.q===\'3M\'){7.d.j.W(\'3M\',G)}c(P 7.8.e.k.30===\'2o\'){7.40()}c($(\'<1e />\').1r(0).1E||$.16.1d){c(7.8.e.J.D>0){5G.S(7)}E{7.d.1z.H({J:7.8.e.J.k+\'18 3N \'+7.8.e.J.I})}c(7.8.e.f.s!==p){4j.S(7)}}E{7.d.1z.H({J:7.8.e.J.k+\'18 3N \'+7.8.e.J.I});7.8.e.J.D=0;7.8.e.f.s=p}c((P 7.8.A.1o===\'1A\'&&7.8.A.1o.Q>0)||(7.8.A.1o.4H&&7.8.A.1o.Q>0)){A=7.8.A.1o}E{A=\' \'}c(7.8.A.T.1o!==p){5v.S(7)}7.4P(A,p);5u.S(7);c(7.8.r.3U===G){7.r()}c(7.8.A.1w!==p){1w=7.8.A.1w;14=7.8.A.14;2T=7.8.A.2T||\'1r\';7.5Q(1w,14,2T)}7.U.1c=G;7.52.S(7)}h 61(w,8,12){R 7=u;7.12=12;7.8=8;7.U={4k:p,1c:p,1Z:p,3v:p};7.d={w:w.5y(7.8.e.1g.w),j:1y,1u:1y,A:1y,1z:1y,T:1y,1j:1y,f:1y,1V:1y};7.1t={W:p,1M:{},2x:0,2t:{M:p,K:p}};7.1D={};$.2k(7,7.8.V,{r:h(q){R 1b,1W;c(!7.U.1c){B p}c(7.d.j.H(\'28\')!==\'35\'){B 7}7.d.j.3W(G,p);1b=7.5a.S(7,q);c(1b===p){B 7}h 2O(){7.d.j.W(\'3F-1G\',G);c(7.8.o.17!==\'27\'){7.2D()}7.4Z.S(7,q);c($.16.1d){7.d.j.1r(0).e.79(\'5w\')}7.d.j.H({3A:\'\'})}7.1t.2x=1;c(7.8.o.17!==\'27\'){7.29(q,(7.8.r.11.Q>0&&7.1c!==2))}c(P 7.8.r.1W===\'1a\'){1W=$(7.8.r.1W)}E c(7.8.r.1W===G){1W=$(\'Y.g\').5V(7.d.j)}c(1W){1W.1F(h(){c($(u).g(\'V\').U.1c===G){$(u).g(\'V\').C()}})}c(P 7.8.r.11.17===\'h\'){7.8.r.11.17.S(7.d.j,7.8.r.11.Q);7.d.j.4T(h(){2O();$(u).4V()})}E{4q(7.8.r.11.17.2M()){26\'3J\':7.d.j.78(7.8.r.11.Q,2O);1C;26\'53\':7.d.j.77(7.8.r.11.Q,h(){2O();c(7.8.o.17!==\'27\'){7.29(q,G)}});1C;26\'59\':7.d.j.r(7.8.r.11.Q,2O);1C;2C:7.d.j.r(1y,2O);1C}7.d.j.5y(7.8.e.1g.3B)}B 7},C:h(q){R 1b;c(!7.U.1c){B p}E c(7.d.j.H(\'28\')===\'35\'){B 7}2g(7.1D.r);7.d.j.3W(G,p);1b=7.5c.S(7,q);c(1b===p){B 7}h 2w(){7.d.j.W(\'3F-1G\',G);7.d.j.H({3A:\'\'});7.4S.S(7,q)}7.1t.2x=0;c(P 7.8.C.11.17===\'h\'){7.8.C.11.17.S(7.d.j,7.8.C.11.Q);7.d.j.4T(h(){2w();$(u).4V()})}E{4q(7.8.C.11.17.2M()){26\'3J\':7.d.j.7a(7.8.C.11.Q,2w);1C;26\'53\':7.d.j.7b(7.8.C.11.Q,2w);1C;26\'59\':7.d.j.C(7.8.C.11.Q,2w);1C;2C:7.d.j.C(1y,2w);1C}7.d.j.7x(7.8.e.1g.3B)}B 7},2x:h(q,31){R 56=/7c|2o/.24(P 31)?31:!7.d.j.37(\':2I\');7[56?\'r\':\'C\'](q);B 7},29:h(q,4i){c(!7.U.1c){B p}R 21=8.o,w=$(21.w),2y=7.d.j.4J(),2z=7.d.j.4I(),1l,1n,o,1m=21.s.j,2L=21.s.w,1b,Z,i,4h,2b,4n={M:h(){R 3k=$(2f).4g(),3b=$(2f).k()+$(2f).4g(),2Q=1m.x===\'1i\'?2y/2:2y,2R=1m.x===\'1i\'?1l/2:1l,2S=(1m.x===\'1i\'?1:2)*7.8.e.J.D,1s=-2*21.1f.x,3e=o.M+2y,1h;c(3e>3b){1h=1s-2Q-2R+2S;c(o.M+1h>3k||3k-(o.M+1h)<3e-3b){B{1f:1h,f:\'25\'}}}c(o.M<3k){1h=1s+2Q+2R-2S;c(3e+1h<3b||3e+1h-3b<3k-o.M){B{1f:1h,f:\'M\'}}}B{1f:0,f:1m.x}},K:h(){R 2V=$(2f).48(),3c=$(2f).F()+$(2f).48(),2Q=1m.y===\'1i\'?2z/2:2z,2R=1m.y===\'1i\'?1n/2:1n,2S=(1m.y===\'1i\'?1:2)*7.8.e.J.D,1s=-2*21.1f.y,3g=o.K+2z,1h;c(3g>3c){1h=1s-2Q-2R+2S;c(o.K+1h>2V||2V-(o.K+1h)<3g-3c){B{1f:1h,f:\'23\'}}}c(o.K<2V){1h=1s+2Q+2R-2S;c(3g+1h<3c||3g+1h-3c<2V-o.K){B{1f:1h,f:\'K\'}}}B{1f:0,f:1m.y}}};c(q&&8.o.w===\'1M\'){2L={x:\'M\',y:\'K\'};1l=1n=0;c(!q.3y){o=7.1t.1M}E{o={K:q.4y,M:q.3y}}}E{c(w[0]===3O){1l=w.k();1n=w.F();o={K:0,M:0}}E c(w[0]===2f){1l=w.k();1n=w.F();o={K:w.48(),M:w.4g()}}E c(w.37(\'75\')){Z=7.8.o.w.W(\'Z\').70(\',\');1T(i=0;i<Z.Q;i++){Z[i]=1x(Z[i],10)}4h=7.8.o.w.3L(\'6Z\').W(\'22\');2b=$(\'4N[6Y="#\'+4h+\'"]:1O\').1s();w.o={M:1v.3K(2b.M+Z[0]),K:1v.3K(2b.K+Z[1])};4q(7.8.o.w.W(\'3C\').2M()){26\'71\':1l=1v.66(1v.65(Z[2]-Z[0]));1n=1v.66(1v.65(Z[3]-Z[1]));1C;26\'72\':1l=Z[2]+1;1n=Z[2]+1;1C;26\'74\':1l=Z[0];1n=Z[1];1T(i=0;i<Z.Q;i++){c(i%2===0){c(Z[i]>1l){1l=Z[i]}c(Z[i]<Z[0]){o.M=1v.3K(2b.M+Z[i])}}E{c(Z[i]>1n){1n=Z[i]}c(Z[i]<Z[1]){o.K=1v.3K(2b.K+Z[i])}}}1l=1l-(o.M-2b.M);1n=1n-(o.K-2b.K);1C}1l-=2;1n-=2}E{1l=w.4J();1n=w.4I();o=w.1s()}o.M+=2L.x===\'25\'?1l:2L.x===\'1i\'?1l/2:0;o.K+=2L.y===\'23\'?1n:2L.y===\'1i\'?1n/2:0}o.M+=21.1f.x+(1m.x===\'25\'?-2y:1m.x===\'1i\'?-2y/2:0);o.K+=21.1f.y+(1m.y===\'23\'?-2z:1m.y===\'1i\'?-2z/2:0);c(7.8.e.J.D>0){c(1m.x===\'M\'){o.M-=7.8.e.J.D}E c(1m.x===\'25\'){o.M+=7.8.e.J.D}c(1m.y===\'K\'){o.K-=7.8.e.J.D}E c(1m.y===\'23\'){o.K+=7.8.e.J.D}}c(21.1f.4Y){(h(){R 2X={x:0,y:0},2m={x:4n.M(),y:4n.K()},f=2B 2K(8.e.f.s);c(7.d.f&&f){c(2m.y.1f!==0){o.K+=2m.y.1f;f.y=2X.y=2m.y.f}c(2m.x.1f!==0){o.M+=2m.x.1f;f.x=2X.x=2m.x.f}7.1t.2t={M:2X.x===p,K:2X.y===p};c(7.d.f.W(\'1Q\')!==f.1A()){4j.S(7,f)}}}())}c(!7.d.1V&&$.16.1d&&1x($.16.3a.2J(0),10)===6){1V.S(7)}1b=7.5b.S(7,q);c(1b===p){B 7}c(8.o.w!==\'1M\'&&4i===G){7.U.4k=G;7.d.j.3W().4i(o,7t,\'7v\',h(){7.U.4k=p})}E{7.d.j.H(o)}7.55.S(7,q);B 7},40:h(1q){c(!7.U.1c||(1q&&P 1q!==\'2o\')){B p}R 1G=7.d.1z.7u().2n(7.d.f).2n(7.d.1j),2e=7.d.1u.2n(7.d.1z.2H()),j=7.d.j,1L=7.8.e.k.1L,2c=7.8.e.k.2c;c(!1q){c(P 7.8.e.k.30===\'2o\'){1q=7.8.e.k.30}E{7.d.j.H({k:\'5R\'});1G.C();j.k(1q);c($.16.1d){2e.H({2e:\'\'})}1q=7.38().k;c(!7.8.e.k.30){1q=1v.2c(1v.1L(1q,2c),1L)}}}c(1q%2){1q+=1}7.d.j.k(1q);1G.r();c(7.8.e.J.D){7.d.j.1J(\'.g-2p\').1F(h(i){$(u).k(1q-(7.8.e.J.D*2))})}c($.16.1d){2e.H({2e:1});7.d.1u.k(1q);c(7.d.1V){7.d.1V.k(1q).F(7.38.F)}}B 7},7i:h(22){R f,2q,1k,s,X;c(!7.U.1c||P 22!==\'1A\'||!$.19.g.2Z[22]){B p}7.8.e=4E.S(7,$.19.g.2Z[22],7.8.4z.e);7.d.A.H(2G(7.8.e));c(7.8.A.T.1o!==p){7.d.T.H(2G(7.8.e.T,G))}7.d.1z.H({7h:7.8.e.J.I});c(7.8.e.f.s!==p){c($(\'<1e />\').1r(0).1E){f=7.d.j.1J(\'.g-f 1e:1O\');1k=f.1r(0).1E(\'2d\');1k.5S(0,0,3m,3m);s=f.3L(\'Y[1Q]:1O\').W(\'1Q\');X=4m(s,7.8.e.f.O.k,7.8.e.f.O.F);4u.S(7,f,X,7.8.e.f.I||7.8.e.J.I)}E c($.16.1d){f=7.d.j.1J(\'.g-f [5O="3C"]\');f.W(\'3I\',7.8.e.f.I||7.8.e.J.I)}}c(7.8.e.J.D>0){7.d.j.1J(\'.g-2p\').H({7g:7.8.e.J.I});c($(\'<1e />\').1r(0).1E){2q=42(7.8.e.J.D);7.d.j.1J(\'.g-1u 1e\').1F(h(){1k=$(u).1r(0).1E(\'2d\');1k.5S(0,0,3m,3m);s=$(u).3L(\'Y[1Q]:1O\').W(\'1Q\');41.S(7,$(u),2q[s],7.8.e.J.D,7.8.e.J.I)})}E c($.16.1d){7.d.j.1J(\'.g-1u [5O="3R"]\').1F(h(){$(u).W(\'3I\',7.8.e.J.I)})}}B 7},4P:h(A,6a){R 34,32,4Q;h 4M(){7.40();c(6a!==p){c(7.8.o.17!==\'27\'){7.29(7.d.j.37(\':2I\'),G)}c(7.8.e.f.s!==p){3Z.S(7)}}}c(!7.U.1c||!A){B p}34=7.57.S(7,A);c(P 34===\'1A\'){A=34}E c(34===p){B}c($.16.1d){7.d.1z.2H().H({2e:\'7Y\'})}c(A.4H&&A.Q>0){A.5T(G).6b(7.d.A).r()}E{7.d.A.2j(A)}32=7.d.A.1J(\'4N[7l=p]\');c(32.Q>0){4Q=0;32.1F(h(i){$(\'<4N 4v="\'+$(u).W(\'4v\')+\'" />\').7k(h(){c(++4Q===32.Q){4M()}})})}E{4M()}7.54.S(7);B 7},5Q:h(1w,14,2T){R 1b;h 4R(A){7.4W.S(7);7.4P(A)}c(!7.U.1c){B p}1b=7.58.S(7);c(1b===p){B 7}c(2T===\'5K\'){$.5K(1w,14,4R)}E{$.1r(1w,14,4R)}B 7},5Z:h(A){R 1b;c(!7.U.1c||!A){B p}1b=7.4X.S(7);c(1b===p){B 7}c(7.d.1j){7.d.1j=7.d.1j.5T(G)}7.d.T.2j(A);c(7.d.1j){7.d.T.3S(7.d.1j)}7.5H.S(7);B 7},2D:h(q){R 4B,3w,3p,1b;c(!7.U.1c||7.8.o.17===\'27\'){B p}4B=1x(7.d.j.H(\'z-3x\'),10);3w=7j+$(\'Y.g[12^="g"]\').Q-1;c(!7.U.3v&&4B!==3w){1b=7.5B.S(7,q);c(1b===p){B 7}$(\'Y.g[12^="g"]\').5V(7.d.j).1F(h(){c($(u).g(\'V\').U.1c===G){3p=1x($(u).H(\'z-3x\'),10);c(P 3p===\'2o\'&&3p>-1){$(u).H({5W:1x($(u).H(\'z-3x\'),10)-1})}$(u).g(\'V\').U.3v=p}});7.d.j.H({5W:3w});7.U.3v=G;7.5F.S(7,q)}B 7},3G:h(31){7.U.1Z=31?G:p;B 7},2U:h(){R i,1b,N,4D=7.d.w.14(\'4A\'+7.1t.W[0]);1b=7.5z.S(7);c(1b===p){B 7}c(7.U.1c){7.8.r.L.w.1S(\'4x.g\',7.29);7.8.r.L.w.1S(\'4O.g\',7.C);7.8.r.L.w.1S(7.8.r.L.q+\'.g\');7.8.C.L.w.1S(7.8.C.L.q+\'.g\');7.d.j.1S(7.8.C.L.q+\'.g\');7.d.j.1S(\'39.g\',7.2D);7.d.j.3D()}E{7.8.r.L.w.1S(7.8.r.L.q+\'.g-\'+7.12+\'-4w\')}c(P 7.d.w.14(\'g\')===\'1a\'){N=7.d.w.14(\'g\').N;c(P N===\'1a\'&&N.Q>0){1T(i=0;i<N.Q-1;i++){c(N[i].12===7.12){N.5X(i,1)}}}}$.19.g.N.5X(7.12,1);c(P N===\'1a\'&&N.Q>0){7.d.w.14(\'g\').3f=N.Q-1}E{7.d.w.7n(\'g\')}c(4D){7.d.w.W(7.1t.W[0],4D)}7.5A.S(7);B 7.d.w},7o:h(){R r,1s;c(!7.U.1c){B p}r=(7.d.j.H(\'28\')!==\'35\')?p:G;c(r){7.d.j.H({3E:\'1G\'}).r()}1s=7.d.j.1s();c(r){7.d.j.H({3E:\'2I\'}).C()}B 1s},38:h(){R r,2h;c(!7.U.1c){B p}r=(!7.d.j.37(\':2I\'))?G:p;c(r){7.d.j.H({3E:\'1G\'}).r()}2h={F:7.d.j.4I(),k:7.d.j.4J()};c(r){7.d.j.H({3E:\'2I\'}).C()}B 2h}})}$.19.g=h(8,4F){R i,12,N,20,2a,1U,15,V;c(P 8===\'1A\'){c($(u).14(\'g\')){c(8===\'V\'){B $(u).14(\'g\').N[$(u).14(\'g\').3f]}E c(8===\'N\'){B $(u).14(\'g\').N}}E{B $(u)}}E{c(!8){8={}}c(P 8.A!==\'1a\'||(8.A.4H&&8.A.Q>0)){8.A={1o:8.A}}c(P 8.A.T!==\'1a\'){8.A.T={1o:8.A.T}}c(P 8.o!==\'1a\'){8.o={s:8.o}}c(P 8.o.s!==\'1a\'){8.o.s={w:8.o.s,j:8.o.s}}c(P 8.r!==\'1a\'){8.r={L:8.r}}c(P 8.r.L!==\'1a\'){8.r.L={q:8.r.L}}c(P 8.r.11!==\'1a\'){8.r.11={17:8.r.11}}c(P 8.C!==\'1a\'){8.C={L:8.C}}c(P 8.C.L!==\'1a\'){8.C.L={q:8.C.L}}c(P 8.C.11!==\'1a\'){8.C.11={17:8.C.11}}c(P 8.e!==\'1a\'){8.e={22:8.e}}8.e=4G(8.e);20=$.2k(G,{},$.19.g.2W,8);20.e=4E.S({8:20},20.e);20.4z=$.2k(G,{},8)}B $(u).1F(h(){R 7=$(u),A=p;c(P 8===\'1A\'){1U=8.2M();N=$(u).g(\'N\');c(P N===\'1a\'){c(4F===G&&1U===\'2U\'){1T(i=N.Q-1;i>-1;i--){c(\'1a\'===P N[i]){N[i].2U()}}}E{c(4F!==G){N=[$(u).g(\'V\')]}1T(i=0;i<N.Q;i++){c(1U===\'2U\'){N[i].2U()}E c(N[i].U.1c===G){c(1U===\'r\'){N[i].r()}E c(1U===\'C\'){N[i].C()}E c(1U===\'2D\'){N[i].2D()}E c(1U===\'3G\'){N[i].3G(G)}E c(1U===\'7s\'){N[i].3G(p)}E c(1U===\'7p\'){N[i].29()}}}}}}E{15=$.2k(G,{},20);15.C.11.Q=20.C.11.Q;15.r.11.Q=20.r.11.Q;c(15.o.3o===p){15.o.3o=$(3O.7q)}c(15.o.w===p){15.o.w=$(u)}c(15.r.L.w===p){15.r.L.w=$(u)}c(15.C.L.w===p){15.C.L.w=$(u)}15.o.s.j=2B 2K(15.o.s.j);15.o.s.w=2B 2K(15.o.s.w);c(!15.A.1o.Q){$([\'T\',\'69\']).1F(h(i,W){R 2v=7.W(W);c(2v&&2v.Q){A=[W,2v];7.14(\'4A\'+W,2v).7r(W);15.A.1o=2v.3l(/\\n/7f,\'<7e />\');B p}})}12=$.19.g.N.Q;1T(i=0;i<12;i++){c(P $.19.g.N[i]===\'63\'){12=i;1C}}2a=2B 61($(u),15,12);$.19.g.N[12]=2a;2a.1t.W=A;c(P $(u).14(\'g\')===\'1a\'&&$(u).14(\'g\')){c(P $(u).W(\'g\')===\'63\'){$(u).14(\'g\').3f=$(u).14(\'g\').N.Q}$(u).14(\'g\').N.6c(2a)}E{$(u).14(\'g\',{3f:0,N:[2a]})}c(15.A.68===p&&15.r.L.q!==p&&15.r.3U!==G){15.r.L.w.1K(15.r.L.q+\'.g-\'+12+\'-4w\',{g:12},h(q){V=$.19.g.N[q.14.g];V.8.r.L.w.1S(V.8.r.L.q+\'.g-\'+q.14.g+\'-4w\');V.1t.1M={M:q.3y,K:q.4y};4L.S(V);V.8.r.L.w.73(V.8.r.L.q)})}E{2a.1t.1M={M:15.r.L.w.1s().M,K:15.r.L.w.1s().K};4L.S(2a)}}})};$.19.g.N=[];$.19.g.19={W:$.19.W};$.19.W=h(W){R V=$(u).g(\'V\');B(2Y.Q===1&&(/T|69/i).24(W)&&V.U&&V.U.1c===G)?$(u).14(\'4A\'+V.1t.W[0]):$.19.g.19.W.4K(u,2Y)};$.19.g.2W={A:{68:p,1o:p,1w:p,14:1y,T:{1o:p,1j:p}},o:{w:p,s:{w:\'3z\',j:\'3n\'},1f:{x:0,y:0,1M:G,4Y:p,3r:G,3t:G},17:\'33\',3o:p},r:{L:{w:p,q:\'39\'},11:{17:\'3J\',Q:51},2P:76,1W:p,3U:p},C:{L:{w:p,q:\'4O\'},11:{17:\'3J\',Q:51},2P:0,3i:p},V:{4U:h(){},52:h(){},5b:h(){},55:h(){},5a:h(){},4Z:h(){},5c:h(){},4S:h(){},57:h(){},54:h(){},58:h(){},4W:h(){},4X:h(){},5H:h(){},5z:h(){},5A:h(){},5B:h(){},5F:h(){}}};$.19.g.2Z={2W:{1p:\'5f\',I:\'#7w\',2t:\'1G\',7B:\'M\',k:{2c:0,1L:7V},2A:\'7T 7S\',J:{k:1,D:0,I:\'#7L\'},f:{s:p,I:p,O:{k:13,F:13},3A:1},T:{1p:\'#7C\',7D:\'7z\',2A:\'7H 7K\'},1j:{6e:\'6t\'},1g:{w:\'\',f:\'g-f\',T:\'g-T\',1j:\'g-1j\',A:\'g-A\',3B:\'g-3B\'}},5m:{J:{k:3,D:0,I:\'#6r\'},T:{1p:\'#6p\',I:\'#5r\'},1p:\'#6o\',I:\'#5r\',1g:{j:\'g-5m\'}},5i:{J:{k:3,D:0,I:\'#6n\'},T:{1p:\'#6k\',I:\'#5h\'},1p:\'5f\',I:\'#5h\',1g:{j:\'g-5i\'}},5j:{J:{k:3,D:0,I:\'#6f\'},T:{1p:\'#6h\',I:\'#5k\'},1p:\'#6i\',I:\'#5k\',1g:{j:\'g-5j\'}},4C:{J:{k:3,D:0,I:\'#6d\'},T:{1p:\'#6K\',I:\'#5d\'},1p:\'#6L\',I:\'#5d\',1g:{j:\'g-4C\'}},5x:{J:{k:3,D:0,I:\'#6x\'},T:{1p:\'#6w\',I:\'#5I\'},1p:\'#6D\',I:\'#5I\',1g:{j:\'g-5x\'}},5N:{J:{k:3,D:0,I:\'#6v\'},T:{1p:\'#6y\',I:\'#6A\'},1p:\'#6z\',I:\'#6I\',1g:{j:\'g-5N\'}}}}(7m));', 62, 495, '|||||||self|options||||if|elements|style|tip|qtip|function||tooltip|width||||position|false|event|show|corner||this||target||||content|return|hide|radius|else|height|true|css|color|border|top|when|left|interfaces|size|typeof|length|var|call|title|status|api|attr|coordinates|div|coords||effect|id||data|config|browser|type|px|fn|object|returned|rendered|msie|canvas|adjust|classes|adj|center|button|context|targetWidth|my|targetHeight|text|background|newWidth|get|offset|cache|wrapper|Math|url|parseInt|null|contentWrapper|string|finalStyle|break|timers|getContext|each|hidden|1px|class|find|bind|max|mouse|tips|first|ieAdjust|rel|containers|unbind|for|command|bgiframe|solo|positionAdjust|inactive|disabled|opts|posOptions|name|bottom|test|right|case|static|display|updatePosition|obj|imagePos|min||zoom|window|clearTimeout|dimensions|margin|html|extend|path|adapted|add|number|betweenCorners|borders|hideTarget|styleExtend|overflow|precedance|val|afterHide|toggle|elemWidth|elemHeight|padding|new|default|focus|90|line|jQueryStyle|children|visible|charAt|Corner|at|toLowerCase|styleObj|afterShow|delay|myOffset|atOffset|borderAdjust|method|destroy|topEdge|defaults|adjusted|arguments|styles|value|state|images|absolute|parsedContent|none|showTarget|is|getDimensions|mouseover|version|rightEdge|bottomEdge|font|pRight|current|pBottom|borderBottom|fixed|borderTop|leftEdge|replace|300|topLeft|container|elemIndex|styleArray|scroll|behavior|resize|VML|focused|newIndex|index|pageX|bottomRight|opacity|active|shape|remove|visiblity|aria|disable|inactiveMethod|fillcolor|fade|floor|parent|unfocus|solid|document|delete|align|arc|prepend|inactiveEvents|ready|newMargin|stop|coordsize|image|positionTip|updateWidth|drawBorder|calculateBorders|betweenWidth|dir|ltr|paddingSize|paddingCorner|scrollTop|relative|block|setTimeout|marginTop|showMethod|vertical|hideMethod|scrollLeft|mapName|animate|createTip|animated|sub|calculateTip|adapt|topRight|sideWidth|switch|vertWidth|borderCoord|bottomLeft|drawTip|src|create|mousemove|pageY|user|old|curIndex|red|oldattr|buildStyle|blanket|sanitizeStyle|jquery|outerHeight|outerWidth|apply|construct|afterLoad|img|mouseout|updateContent|loadedImages|setupContent|onHide|queue|beforeRender|dequeue|onContentLoad|beforeTitleUpdate|screen|onShow||100|onRender|slide|onContentUpdate|onPositionUpdate|condition|beforeContentUpdate|beforeContentLoad|grow|beforeShow|beforePositionUpdate|beforeHide|9C2F2F|append|white|stroked|454545|light|dark|f3f3f3|parents|cream|click|prependTo|mousedown|inline|A27D35|fill|role|assignEvents|createTitle|filter|green|addClass|beforeDestroy|onDestroy|beforeFocus|beginPath|lineTo|fillStyle|onFocus|createBorder|onTitleUpdate|58792E|topright|post|bottomleft|topleft|blue|nodeName|String|loadContent|auto|clearRect|clone|match|not|zIndex|splice|bottomright|updateTitle|middle|QTip|270|undefined|unshift|abs|ceil|in|prerender|alt|reposition|appendTo|push|CE6F6F|cursor|303030|eq|404040|505050|use|f1f1f1|strict|marginLeft|E2E2E2|FBF7AA|F0DE7D|xe|F9E98E|filled|pointer|leftcenter|ADD9ED|b9db8c|A9DB66|D0E9F5|E5F6FE|5E99BD|while|PI|CDE6AC|Right|endangle|startangle|Left|4D9FBF|rightbottom|f28279|F79992|bottomcenter|moveTo|topcenter|rightcenter|labelledby|0px|leftbottom|borderWidth|righttop|lefttop|search|moz|usemap|map|split|rect|circle|trigger|poly|area|140|slideDown|fadeIn|removeAttribute|fadeOut|slideUp|boolean|float|br|gi|backgroundColor|borderColor|updateStyle|15000|load|complete|jQuery|removeData|getPosition|update|body|removeAttr|enable|200|siblings|swing|111|removeClass|mouseleave|bold|mouseenter|textAlign|e1e1e1|fontWeight|preventDefault|stopPropagation|out|7px|leave|relatedTarget|12px|d3d3d3|mouseup|tabindex|frameborder|dblclick|alpha|javascript|9px|5px|iframe|250|webkit|describedby|normal'.split('|'), 0, {  }));

window.MND = {
    estOffset: 300,
    staleMinutes: 5,
    constants: {
        one_second: 1000,
        one_minute: 1000 * 60,
        one_hour: 1000 * 60 * 60,
        one_day: 1000 * 60 * 60 * 24
    }
};

$(document).ready(function () {

    var myFile = document.location.toString();
    if (myFile.match('#')) { // the URL contains an anchor
        // click the navigation item corresponding to the anchor
        var myAnchor = '#' + myFile.split('#')[1];
        var myUrl = myFile.split('#')[0];
        var uname = myAnchor.match('\#\{uname=(.*?)\}');
        if (!uname) {
            uname = myAnchor.match('\#\%7Buname=(.*?)\%7D');
        }
        if (uname) {
            var usernameFixed = uname[1].replace('+', '-');
            window.location = '/members/' + usernameFixed + '/entry.aspx?ReturnUrl=' + escape(myUrl);
        }

        var postId = myFile.split('#')[1];
        $('a[name=' + postId + ']').next('.CommonCommentArea').addClass('highlight');
    }

    $('.accordianMenu li div.hiddenlisttitle').click(
         function () {
             var isOpen = $(this).hasClass('open');
             var checkElement = $(this).next();

             if (checkElement.is('div') && isOpen) {
                 checkElement.slideUp('normal');
                 $(this).removeClass('open');
                 return false;
             }
             if (checkElement.is('div') && !isOpen) {
                 $('.accordianMenu div.hiddenlisttitle').removeClass('open');
                 $('.accordianMenu div.hiddenlistcontent:visible').slideUp('normal');
                 checkElement.slideDown('normal');
                 $(this).addClass('open');
                 return false;
             }
         }
       );
    $('.tabheader a').click(function () {
        var href = $(this).attr('href');
        if (href.match('#') && href.length > 1) {
            $(this).parent().siblings('.tabheader').removeClass('tabselected');
            var showPanel = $(href);
            showPanel.siblings('.tabpanel').removeClass('tabselected');
            showPanel.addClass('tabselected');
            $(this).parent().addClass('tabselected');
            return false;
        }
    });
    $('.tablist').each(function (index) {
        $(this).children('.tabheader:first').children('a').click();
    });
    $('li:last-child').addClass("last-child");
    $('li:first-child').addClass("first-child");
    $('td:first-child').addClass('first');
    $('td:last-child').addClass('last');
    $('tbody tr:first-child').addClass('first');
    $('tbody tr:last-child').addClass('last');

    $('.EditAdListContent').hover(function () { }, function () { $(this).hide() });


    $('.showTip').live('mouseover', function () {
        $(this).qtip({
            overwrite: false,
            style: {
                background: '#FFFFFF',
                color: 'black',
                textAlign: 'center',
                border: {
                    color: '#98BCE5',
                    radius: 3,
                    width: 2
                },
                name: 'blue',
                tip: true
            },
            position: {
                corner: {
                    target: 'topMiddle',
                    tooltip: 'bottomMiddle'
                }
            },
            show: {
                ready: true,
                delay: 0
            }
        });
    });

    $('.showTipBelow').live('mouseover', function () {
        $(this).qtip({
            overwrite: false,
            style: {
                background: '#FFFFFF',
                color: 'black',
                textAlign: 'center',
                border: {
                    color: '#98BCE5',
                    radius: 3,
                    width: 2
                },
                name: 'blue',
                tip: true
            },
            position: {
                corner: {
                    target: 'bottomMiddle',
                    tooltip: 'topMiddle'
                }
            },
            show: {
                ready: true,
                delay: 0
            }
        });
    });
    $('body').live('click', function (event) {
        if (!$(event.target).parents().is('.dropDownContainer.open')) {
            $('.dropDownRoot.open').removeClass('open').addClass('closed');
        }
    });

    $('.dropDownHeader a').live('click', function () {
        var parentRoot = $(this).parents('.dropDownRoot');
        if (parentRoot.hasClass('open')) {
            parentRoot.removeClass('open').addClass('closed');
        } else {
            $('.dropDownRoot').removeClass('open').addClass('closed'); ;
            parentRoot.removeClass('closed').addClass('open');
        }
        return false;
    });
    $('.ChangeLocation').click(function () {
        $(this).next().toggle();
        return false;
    });
    $('.ProfileContentArea .CommonContentBox, .CommonSidebar.Premium .CommonContentBox').hover(function () {
        $('.EditLink', this).show();
    }, function () {
        $('.EditLink', this).hide();
    });

    var userClickHandler = function (evt) {
        if ($(evt.target).closest('.user-dropdown').length == 0) {
            $('.user-dropdown').hide();
            $('body').unbind('click', userClickHandler);
        }
    };


    $('.w-dispname', '#CommonHeaderUserArea').click(function (evt) {
        var dropdown = $(this).siblings('.user-dropdown');
        evt.stopPropagation();
        if (dropdown.length) {
            dropdown.toggle();
            if (dropdown.is(':visible')) {
                $('body').bind('click', userClickHandler);
            } else {
                $('body').unbind('click', userClickHandler);
            }
        }
        return false;
    });
    $('.tablist.video .today').click(function () {
        var theDate = new Date();
        return gotoDate(theDate, false, 'video');
    });
    $('.tablist.video .yesterday').click(function () {
        var theDate = new Date();
        theDate.setDate(theDate.getDate() - 1);
        return gotoDate(theDate, false, 'video');
    });

    $('.question-link').live('click', function () {
        MND.helpers.setupDialog($(this).attr('href'), $(this).attr('title'), 650);
        return false;
    });


    if ($.browser.msie) {
        $('.soc-menu iframe').live('hover', function () {
            $(this).closest(".soc-menu").addClass('hover');
        });
        $('.soc-menu').live('mouseleave', function () {
            $(this).removeClass('hover');
        });
    }


    $('.email-sub-link').live('click', function () {
        var lnk = $(this);
        var appKeys = lnk.data('appkeys');
        var defaultKeys = lnk.data('defaultkeys');

        if ($('#email-sub-modal').length == 0) {
            $('body').append('<div id="email-sub-modal-parent"><div id="email-sub-modal"><div class="modal-t"></div><div class="modal-m"></div><div class="modal-b"></div></div></div>');
            $('#email-sub-modal-parent').css({
                left: lnk.offset().left + 'px',
                top: (lnk.offset().top + lnk.height()) + 'px'
            });
            var url = lnk.attr('href') + "?cb=" + Math.ceil((Math.random() * 100000)) + "&appkeys=" + appKeys + '&defaultkeys=' + defaultKeys;
            $('#email-sub-modal .modal-m').load(url, function () {
                $('#email-sub-modal-close').live('click', function () {
                    $('#email-sub-modal').slideToggle('fast', function () {
                        $('#email-sub-modal-parent').remove();
                    });
                    lnk.toggleClass('modal');
                    return false;
                });
            });
            $('#email-sub-modal').slideToggle('fast');
        } else {
            $('#email-sub-modal').slideToggle('fast');
        }
        lnk.toggleClass('modal');
        return false;
    });

});

function gotoDate(theDate, isRandom, applicationKey) {
    return gotoDateFormatted(theDate, isRandom, 'yy/mm/dd', applicationKey);
}
function gotoDateFormatted(theDate, isRandom, format, applicationKey) {
    var url = '/channels/' + getApplicationKeyUrl(applicationKey) + 'archive/' + $.datepicker.formatDate(format, theDate) + '.aspx' + (isRandom ? '#random' : '');
    document.location = url;
    return false;
}
function getApplicationKeyUrl(appKey) {
    if (appKey && appKey.length > 0)
        return appKey + '/';
    return '';
}
function initializeArchiveDatepicker(picker, autoRedirect, earliestDate, today, applicationKey){ 
    if(autoRedirect){
        $(picker).datepicker({ changeMonth: true, changeYear: true, minDate: earliestDate, gotoCurrent:true, maxDate: '+0d', defaultDate: today,
            onSelect: function(dateText, inst) {
                var theDate = new Date(dateText);
                return gotoDate(theDate,false, applicationKey);
            }
        });
    }else{
        $(picker).datepicker({ changeMonth: true, changeYear: true, minDate: earliestDate, gotoCurrent:true, maxDate: '+0d', defaultDate: today});
    }
    $('.today').click(function(){
        var theDate = new Date();
        return gotoDate(theDate,false, applicationKey);
    });
     $('.yesterday').click(function(){
        var theDate = new Date();
        theDate.setDate(theDate.getDate() -1);
        return gotoDate(theDate,false, applicationKey);
    });
     $('.random').click(function(){
        var theDate = new Date();        
        var startMillis = earliestDate.getTime();
        var endMillis = theDate.getTime();
        var randomDate = new Date(startMillis +Math.random()*(endMillis-startMillis));                    
        return gotoDate(randomDate,true, applicationKey);
    });
    $('.gotodate').click(function(){
        var theDate = $(picker).datepicker( "getDate" );
        return gotoDate(theDate,false, applicationKey);
    });                
    $('.gotomonth').click(function(){                    
        var month = $("#" + picker + " .ui-datepicker-month :selected").val();
        var year = $("#" + picker + " .ui-datepicker-year :selected").val();
        var theDate = new Date(year,month,1);
        return gotoDateFormatted(theDate,false,'yy/mm', applicationKey);
    });
}
function initializeCommentDatepicker(picker, autoRedirect, earliestDate, today, rootPath) {
    if (autoRedirect) {
        $(picker).datepicker({ changeMonth: true, changeYear: true, minDate: earliestDate, gotoCurrent: true, maxDate: '+0d', defaultDate: today,
            onSelect: function (dateText, inst) {
                var theDate = new Date(dateText);
                return gotoCommentDate(theDate, false, rootPath);
            }
        });
    } else {
        $(picker).datepicker({ changeMonth: true, changeYear: true, minDate: earliestDate, gotoCurrent: true, maxDate: '+0d', defaultDate: today });
    }
    $('.today').click(function () {
        var theDate = new Date();
        return gotoCommentDate(theDate, false, rootPath);
    });
    $('.yesterday').click(function () {
        var theDate = new Date();
        theDate.setDate(theDate.getDate() - 1);
        return gotoCommentDate(theDate, false, rootPath);
    });
    $('.random').click(function () {
        var theDate = new Date();
        var startMillis = earliestDate.getTime();
        var endMillis = theDate.getTime();
        var randomDate = new Date(startMillis + Math.random() * (endMillis - startMillis));
        return gotoCommentDate(randomDate, true, rootPath);
    });
    $('.gotodate').click(function () {
        var theDate = $(picker).datepicker("getDate");
        return gotoCommentDate(theDate, false, rootPath);
    });
    $('.gotomonth').click(function () {
        var month = $("#" + picker + " .ui-datepicker-month :selected").val();
        var year = $("#" + picker + " .ui-datepicker-year :selected").val();
        var theDate = new Date(year, month, 1);
        return gotoCommentDateFormatted(theDate, false, 'yy/mm', rootPath);
    });
}
function gotoCommentDate(theDate, isRandom, rootPath) {
    return gotoCommentDateFormatted(theDate, isRandom, 'yy/mm/dd', rootPath);
}
function gotoCommentDateFormatted(theDate, isRandom, format, rootPath) {
    var url = getApplicationKeyUrl(rootPath) + $.datepicker.formatDate(format, theDate) + '/history.aspx' + (isRandom ? '#random' : '');
    document.location = url;
    return false;
}
function initializeComments(comments, actionUrl, adminUrl, listUrl, submit, body, topicId, featured, listPageSize, commentTemplate) {
    if (actionUrl.length > 0) {
        comments.find('.Comment')
        .live('mouseenter', function () {
            var crntDiv = $(this);
            if (crntDiv.attr('id') != "") {
                $('<div />').html('flag').addClass('CommentWarnMenu').appendTo($(this)).click(function () {
                    WarnComment(crntDiv.attr('cid'), actionUrl);
                    $('.CommentWarnMenu').css('display', 'none');
                    return false;
                });
            }
        })
        .live('mouseleave', function () {
            $(this).find('.CommentWarnMenu').remove();
        });
    }
    if (adminUrl.length > 0) {
        comments.find('.Comment')
        .live('mouseenter', function () {
            var crntDiv = $(this);
            if (crntDiv.attr('id') != "") {
                var isFeatured = crntDiv.hasClass('Featured');
                var featureVerbiage = isFeatured ? 'un-feature' : 'feature';

                $('<div />').html(featureVerbiage).addClass('CommentFeatureMenu').appendTo($(this)).click(function () {
                    FeatureComment(comments,crntDiv.attr('cid'), adminUrl,isFeatured);
                    return false;
                });
                $('<div />').html('delete').addClass('CommentDeleteMenu').appendTo($(this)).click(function () {
                    DeleteComment(comments,crntDiv.attr('cid'), adminUrl);
                    return false;
                });
            }
        })
        .live('mouseleave', function () {
            $(this).find('.CommentDeleteMenu').remove();
            $(this).find('.CommentFeatureMenu').remove();
        });
    }
    if (listUrl.length > 0) {
        scrollLoadInit(comments, listUrl, topicId, listPageSize, featured, commentTemplate);
    }
    if (submit) {
        submit.click(function () {
            if (body.val().length > 0) {
                AddComment(actionUrl, body.val(), topicId, function () { reloadComments(comments, listUrl, topicId, listPageSize, featured, commentTemplate); });
                body.val('');
                return false;
            }
        });
    }
}
function scrollLoadInit(comments,listUrl,topicId, listPageSize,featured,commentTemplate){
    var crntPageInput = comments.find('.crntpage');
    var totalPageInput = comments.find('.totalpages');
    if (crntPageInput.length == 0) {
        crntPageInput = $('<input />').attr('type', 'hidden').addClass('crntpage').val('1').appendTo(comments);
    }
    if (totalPageInput.length == 0) {
        totalPageInput = $('<input />').attr('type', 'hidden').addClass('totalpages').val('-1').appendTo(comments);
    }
    comments.scrollLoad({
        url: listUrl, //your ajax file to be loaded when scroll breaks ScrollAfterHeight

        getData: function () {
            //you can post some data along with ajax request
            var crntPage = parseInt(crntPageInput.val());
            crntPage++;
            crntPageInput.val(crntPage);
            return { topicid: topicId, PageSize: listPageSize, PageIndex: crntPage, featured: featured };
        },

        start: function () {
            $('<div class="loading"><img src="/utility/images/ajax-loader.gif"/></div>').appendTo(this);
            // you can add your effect before loading data
        },

        ScrollAfterHeight: 95, 		//this is the height in percentage after which ajax stars

        onload: function (data) {
            $(this).append(data);
            $('.loading').remove();
            totalPageInput.val(data.totalpages);
            var tempDiv = $("<div />").setTemplate(commentTemplate);
            tempDiv.processTemplate(data);
            comments.append(tempDiv.html());
        }, // this event fires on ajax success

        continueWhile: function (resp) {
            var totalPages = parseInt(totalPageInput.val());
            var crntPage = parseInt(crntPageInput.val());
            if ((totalPages != -1 && crntPage >= totalPages) || crntPage * listPageSize > 100) { // stops when number of 'li' reaches 100
                return false;
            }
            return true;
        }
    });
}
function reloadComments(comments, url, topicId, listPageSize, featured, template) {
    comments.html('');
    $('<div class="loading"><img src="/utility/images/ajax-loader.gif"/></div>').appendTo(comments);
    $.post(url, { topicid: topicId, PageSize: listPageSize, PageIndex: 1, featured: featured }, function (data) {
        if (!data) {
            alert('There was an error reloading comments');
        } else if (data && !data.success) {
            alert(data.result);
        } else {
            $('.loading').remove();
            comments.scrollTop(0);
            var tempDiv = $("<div />").setTemplate(template);
            tempDiv.processTemplate(data);
            comments.append(tempDiv.html());
            $('<input />').attr('type', 'hidden').addClass('crntpage').val('1').appendTo(comments);
            $('<input />').attr('type', 'hidden').addClass('totalpages').val(data.totalpages).appendTo(comments);
            scrollLoadInit(comments, url, topicId, listPageSize, featured, template);
        }
    }, 'json');
}
function AddComment(url, commentBody, topic, callback) {
    $.post(url, { action: 'add', url: document.location.href, comment: commentBody, topicId: topic }, function (data) {
        if (!data) {
            alert('There was an error during the add process');
        } else if (data && !data.success) {
            alert(data.result);
        } else {
            $('<div />').html(data.result).attr('id', 'newcomment').addClass('message').addClass('success').css('display', 'none').appendTo('body').center().fadeInFadeOut(2000, function () {
                $('#newcomment').remove();
            });
            callback.call();
        }
    }, 'json');
}
function WarnComment(id, url) {
    url += id;
    $.post(url, { action: 'report' }, function (data) {
        if (!data) {
            alert('There was an error during the warn process');
        } else if (data && !data.success) {
            alert(data.result);
        } else {
            $('<div />').html(data.result).attr('id', 'message' + id).addClass('message').addClass('success').css('display', 'none').appendTo('body').center().fadeInFadeOut(2000, function () {
                $('#message' + id).remove();
            });
        }
    }, 'json');
}

function DeleteComment(comments, id, url) {
    if (confirm('Are You Sure You Want to Delete this Comment?')) {
        url += id;
        $.post(url, { action: 'delete' }, function (data) {
            if (data && !data.success) {
                alert(data.result);
            } else {
                comments.find('.comment' + id).remove();
            }
        }, 'json');
    }
}

function FeatureComment(comments, id, url, isFeatured) {    
    var message = 'Are You Sure You Want to Feature this Comment?';
    if (isFeatured)
        message = 'Are You Sure You Want to Un-Feature this Comment?';

    if (confirm(message)) {
        url += id;
        $.post(url, { action: 'feature' }, function (data) {
            if (data && !data.success) {
                alert(data.result);
            } else {
                if(data.featured)
                    comments.find('.comment' + id).addClass('Featured');
                else
                    comments.find('.comment' + id).removeClass('Featured');

                $('<div />').html(data.result).attr('id', 'message' + id).addClass('message').addClass('success').css('display', 'none').appendTo('body').center().fadeInFadeOut(2000, function () {
                    $('#message' + id).remove();
                });
            }
        }, 'json');
    }
}

function AddCurrentFavorite() {
    var url = document.URL;
    var title = document.title + ' - Mortgage News Daily';
    if (document.all)
        window.external.AddFavorite(url, title);
    else if (window.sidebar)
        window.sidebar.addPanel(title, url, "");
}
function setHome() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(window.location.href);
    } else {
        this.style.behavior = 'url(#default#homepage)';
        this.setHomePage(window.location.href);
    }
}
function SetupWarnBlog(warnUrl, warnInfo) {
    warnInfo.dialog({
        autoOpen: false
        , modal: true
        , resizable: false
        , title: 'Report This Comment'
        , draggable: false
        , width: 400
    }).show();
    $('.CommonCommentArea').hover(function () {
        var crntDiv = $(this).prev('a');
        if (crntDiv.attr('name') != "") {
            $('<div />').html('Report This Comment').addClass('CommentWarnMenu').css({ 'position': 'absolute' }).appendTo($(this).find('.CommonCommentBubble')).click(function (evt) {
                var url = warnUrl + '?PostID=' + crntDiv.attr('name') + '&action=report';
                WarnBlogComment(url, warnInfo);
                evt.preventDefault();
            });
        }
    }, function () {
        $(this).find('.CommentWarnMenu').remove();
    });
   
}
function WarnBlogComment(url, warnInfo) {
    warnInfo.dialog('option', 'buttons', {
        "Ok": function () {
            $.validity.start();
            $("#ReportReason",warnInfo).require();
            var result = $.validity.end();

            if (result.valid) {                
                $.post(url, { reason: $('#ReportReason', warnInfo).val() }, function (data) {
                    if (!data) {
                        alert('There was an error during the warn process');
                    } else if (data && !data.success) {
                        alert(data.result);
                    } else {
                        warnInfo.find('input,textarea').val('');
                        warnInfo.dialog('close');
                        $('<div />').html(data.result).addClass('message').addClass('success').css('display', 'none').appendTo('body').center().fadeInFadeOut(2000, function () {
                            $(this).remove();
                        });
                    }
                }, 'json');
            }
        }
        , "Cancel": function () {
            $(this).dialog("close");
        }
    }).dialog('open');
}
function flash(type, msg) {

    var flash = $('#flash');
    flash.html(msg).removeClass().addClass(type);
    flash.slideDown('slow');
    if (type == 'info') {
        // flash informational messages and fade after 1200ms
        flash.delay('1200').fadeOut('slow');
    }
    flash.click(function () {
        flash.toggle('highlight')
    });
}
jQuery.fn.extend({
    highlight: function (search, insensitive, hls_class) {
        var content = this.html();
        if (content == null)
            return;
        var regex = new RegExp("(<[^>]*>)|(\\b" + search.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1") + ")", insensitive ? "ig" : "g");
        return this.html(content.replace(regex, function (a, b, c) {
            return (a.charAt(0) == "<") ? a : "<strong class=\"" + hls_class + "\">" + c + "</strong>";
        }));
    }
});
/**
* Pulse plugin for jQuery 
* ---
* @author James Padolsey (http://james.padolsey.com)
* @version 0.1
* @updated 16-DEC-09
* ---
* Note: In order to animate color properties, you need
* the color plugin from here: http://plugins.jquery.com/project/color
* ---
* @info http://james.padolsey.com/javascript/simple-pulse-plugin-for-jquery/
*/

jQuery.fn.pulse = function (prop, speed, times, easing, callback) {

    if (isNaN(times)) {
        callback = easing;
        easing = times;
        times = 1;
    }

    var optall = jQuery.speed(speed, easing, callback),
        queue = optall.queue !== false,
        largest = 0;

    for (var p in prop) {
        largest = Math.max(prop[p].length, largest);
    }

    optall.times = optall.times || times;

    return this[queue ? 'queue' : 'each'](function () {

        var counts = {},
            opt = jQuery.extend({}, optall),
            self = jQuery(this);

        pulse();

        function pulse() {

            var propsSingle = {},
                doAnimate = false;

            for (var p in prop) {

                // Make sure counter is setup for current prop
                counts[p] = counts[p] || { runs: 0, cur: -1 };

                // Set "cur" to reflect new position in pulse array
                if (counts[p].cur < prop[p].length - 1) {
                    ++counts[p].cur;
                } else {
                    // Reset to beginning of pulse array
                    counts[p].cur = 0;
                    ++counts[p].runs;
                }

                if (prop[p].length === largest) {
                    doAnimate = opt.times > counts[p].runs;
                }

                propsSingle[p] = prop[p][counts[p].cur];

            }

            opt.complete = pulse;
            opt.queue = false;

            if (doAnimate) {
                self.animate(propsSingle, opt);
            } else {
                optall.complete.call(self[0]);
            }

        }

    });

};

(function ($) {
    $.fn.pulsebg = function(options) {
        return this.each(function () {
            new $.PulseBg(this, options);
        })
    };

    $.PulseBg = function(e, o) {
        var element = $(e);
        var opts = $.extend({}, $.fn.pulsebg.defaults, o);
        if(!element.data('bgcolor')) {
            element.data('bgcolor',element.css('background-color'));
        }
        var bgColor = element.data('bgcolor');
        element.data('pulsing', true);
        element.css({ backgroundColor: opts.color });
        setTimeout(function() {
            element.data('pulsing', false);
            element.css({ backgroundColor: bgColor });
        }, opts.duration);
        
    };

    $.fn.pulsebg.defaults = {
        duration: 500,
        color: "#FFFFFF"
      };
})(jQuery); 

(function ($) {
    $.fn.summary = function (options) {
        return this.each(function () {
            new $.Summary(this, options);
        });
    };

    $.Summary = function (e, o) {
        var element = $(e);
        var options = o || {};  
        var maxHeight = options.maxHeight || 100;
        var className = options.className || 'expand';
        var textHeight = e.offsetHeight;
        var ignoreExpand = options.ignoreExpand || false;

        if (textHeight > maxHeight) {
            element.css({ overflow: 'hidden' });
            element.height(maxHeight);

            var moreLink = $("<a href='#'>View More</a>").addClass(className);
            if(!ignoreExpand)
                moreLink.click(expand);
            element.append('...');
            element.after(moreLink);
        }

        function expand() {
            element.animate({ height: textHeight }, 'fast');
            moreLink.hide();
        };
    };
})(jQuery);
/*
 * jQuery Expander plugin
 * Version 0.4  (12/09/2008)
 * @requires jQuery v1.1.1+
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */


(function($) {

  $.fn.expander = function(options) {

    var opts = $.extend({}, $.fn.expander.defaults, options);
    var delayedCollapse;
    return this.each(function() {
      var $this = $(this);
      var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
     	var cleanedTag, startTags, endTags;	
     	var allText = $this.html();
     	var startText = allText.slice(0, o.slicePoint).replace(/\w+$/,'');
     	startTags = startText.match(/<\w[^>]*>/g);
   	  if (startTags) {startText = allText.slice(0,o.slicePoint + startTags.join('').length).replace(/\w+$/,'');}
   	  
     	if (startText.lastIndexOf('<') > startText.lastIndexOf('>') ) {
     	  startText = startText.slice(0,startText.lastIndexOf('<'));
     	}
     	var endText = allText.slice(startText.length);    	  
     	// create necessary expand/collapse elements if they don't already exist
   	  if (!$('span.details', this).length) {
        // end script if text length isn't long enough.
       	if ( endText.replace(/\s+$/,'').split(' ').length < o.widow ) { return; }
       	// otherwise, continue...    
       	if (endText.indexOf('</') > -1) {
         	endTags = endText.match(/<(\/)?[^>]*>/g);
          for (var i=0; i < endTags.length; i++) {

            if (endTags[i].indexOf('</') > -1) {
              var startTag, startTagExists = false;
              for (var j=0; j < i; j++) {
                startTag = endTags[j].slice(0, endTags[j].indexOf(' ')).replace(/(\w)$/,'$1>');
                if (startTag == rSlash(endTags[i])) {
                  startTagExists = true;
                }
              }              
              if (!startTagExists) {
                startText = startText + endTags[i];
                var matched = false;
                for (var s=startTags.length - 1; s >= 0; s--) {
                  if (startTags[s].slice(0, startTags[s].indexOf(' ')).replace(/(\w)$/,'$1>') == rSlash(endTags[i]) 
                  && matched == false) {
                    cleanedTag = cleanedTag ? startTags[s] + cleanedTag : startTags[s];
                    matched = true;
                  }
                };
              }
            }
          }

          endText = cleanedTag && cleanedTag + endText || endText;
        }
     	  $this.html([
     		startText,
     		'<span class="read-more">',
     		o.expandPrefix,
       		'<a href="#">',
       		  o.expandText,
       		'</a>',
        '</span>',
     		'<span class="details">',
     		  endText,
     		'</span>'
     		].join('')
     	  );
      }
      var $thisDetails = $('span.details', this),
        $readMore = $('span.read-more', this);
   	  $thisDetails.hide();
 	    $readMore.find('a').click(function() {
          if(o.expandEffect === 'none'){
            //return false;
          }else{
 	          $readMore.hide();
         
 	          if (o.expandEffect === 'show' && !o.expandSpeed) {
              o.beforeExpand($this);
 	            $thisDetails.show();
              o.afterExpand($this);
              delayCollapse(o, $thisDetails);
 	          } else {
              o.beforeExpand($this);
 	            $thisDetails[o.expandEffect](o.expandSpeed, function() {
                $thisDetails.css({zoom: ''});
                o.afterExpand($this);
                delayCollapse(o, $thisDetails);
 	            });
 	          }
            return false;
          }
 	    });
      if (o.userCollapse) {
        $this
        .find('span.details').append('<span class="re-collapse">' + o.userCollapsePrefix + '<a href="#">' + o.userCollapseText + '</a></span>');
        $this.find('span.re-collapse a').click(function() {

          clearTimeout(delayedCollapse);
          var $detailsCollapsed = $(this).parents('span.details');
          reCollapse($detailsCollapsed);
          o.onCollapse($this, true);
          return false;
        });
      }
    });
    function reCollapse(el) {
       el.hide()
        .prev('span.read-more').show();
    }
    function delayCollapse(option, $collapseEl) {
      if (option.collapseTimer) {
        delayedCollapse = setTimeout(function() {  
          reCollapse($collapseEl);
          option.onCollapse($collapseEl.parent(), false);
          },
          option.collapseTimer
        );
      }
    }
    function rSlash(rString) {
      return rString.replace(/\//,'');
    }    
  };
    // plugin defaults
  $.fn.expander.defaults = {
    slicePoint:       100,  // the number of characters at which the contents will be sliced into two parts. 
                            // Note: any tag names in the HTML that appear inside the sliced element before 
                            // the slicePoint will be counted along with the text characters.
    widow:            4,  // a threshold of sorts for whether to initially hide/collapse part of the element's contents. 
                          // If after slicing the contents in two there are fewer words in the second part than 
                          // the value set by widow, we won't bother hiding/collapsing anything.
    expandText:       'read more', // text displayed in a link instead of the hidden part of the element. 
                                      // clicking this will expand/show the hidden/collapsed text
    expandPrefix:     '&hellip; ',
    collapseTimer:    0, // number of milliseconds after text has been expanded at which to collapse the text again
    expandEffect:     'fadeIn',
    expandSpeed:      '',   // speed in milliseconds of the animation effect for expanding the text
    userCollapse:     true, // allow the user to re-collapse the expanded text.
    userCollapseText: '[collapse expanded text]',  // text to use for the link to re-collapse the text
    userCollapsePrefix: ' ',
    beforeExpand: function($thisEl) {},
    afterExpand: function($thisEl) {},
    onCollapse: function($thisEl, byUser) {}
  };
})(jQuery);

(function ($) {
    $.fn.trunc = function (options) {
        var opts = $.extend({}, $.fn.trunc.defaults, options);
        return this.each(function () {
            var $this = $(this);
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

            var cleanedTag, startTags, endTags;
            var allText = $this.html();
            var startText = allText.slice(0, o.maxLength).replace(/\w+$/, '');
            startTags = startText.match(/<\w[^>]*>/g);
            if (startTags) { startText = allText.slice(0, o.maxLength + startTags.join('').length).replace(/\w+$/, ''); }

            if (startText.lastIndexOf('<') > startText.lastIndexOf('>')) {
                startText = startText.slice(0, startText.lastIndexOf('<'));
            }
            var endText = allText.slice(startText.length);
            var appendText = '... <a href="#">Read More</a>';
            if (endText.replace(/\s+$/, '').split(' ').length < o.widow) { 
                //return; 
                appendText = '';                
           }
            // otherwise, continue...    
            if (endText.indexOf('</') > -1) {
                endTags = endText.match(/<(\/)?[^>]*>/g);
                for (var i = 0; i < endTags.length; i++) {

                    if (endTags[i].indexOf('</') > -1) {
                        var startTag, startTagExists = false;
                        for (var j = 0; j < i; j++) {
                            startTag = endTags[j].slice(0, endTags[j].indexOf(' ')).replace(/(\w)$/, '$1>');
                            if (startTag == rSlash(endTags[i])) {
                                startTagExists = true;
                            }
                        }
                        if (!startTagExists) {
                            startText = startText + endTags[i];
                            var matched = false;
                            for (var s = startTags.length - 1; s >= 0; s--) {
                                if (startTags[s].slice(0, startTags[s].indexOf(' ')).replace(/(\w)$/, '$1>') == rSlash(endTags[i])
                      && matched == false) {
                                    cleanedTag = cleanedTag ? startTags[s] + cleanedTag : startTags[s];
                                    matched = true;
                                }
                            };
                        }
                    }
                }

                endText = cleanedTag && cleanedTag + endText || endText;
            }

            //$(startText).removeClass().before($this);

            $this.before($(startText).append(appendText).removeClass().addClass(o.summaryClass));
            //$this.append($(startText).removeClass().addClass('summary').append('...'));
            //$this.append($(allText));
            $this.html(allText);
            return $this;

        });
        function rSlash(rString) {
            return rString.replace(/\//, '');
        }
    };
    // plugin defaults
    $.fn.trunc.defaults = {
        maxLength: 100,  // the number of characters at which the contents will be sliced into two parts. 
        // Note: any tag names in the HTML that appear inside the sliced element before 
        // the slicePoint will be counted along with the text characters.
        widow: 4,  // a threshold of sorts for whether to initially hide/collapse part of the element's contents. 
        // If after slicing the contents in two there are fewer words in the second part than 
        // the value set by widow, we won't bother hiding/collapsing anything.
        summaryClass: 'summary'
    };
})(jQuery);

/*!
* iButton jQuery Plug-in
*
* Copyright 2009 Giva, Inc. (http://www.givainc.com/labs/) 
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
* 	http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Date: 2009-08-25
* Rev:  1.0.01
*/
; (function ($) {
    // set default options
    $.iButton = {
        version: "1.0.01",
        setDefaults: function (options) {
            $.extend(defaults, options);
        }
    };

    $.fn.iButton = function (options) {
        var method = typeof arguments[0] == "string" && arguments[0];
        var args = method && Array.prototype.slice.call(arguments, 1) || arguments;
        // get a reference to the first iButton found
        var self = (this.length == 0) ? null : $.data(this[0], "iButton");

        // if a method is supplied, execute it for non-empty results
        if (self && method && this.length) {

            // if request a copy of the object, return it			
            if (method.toLowerCase() == "object") return self;
            // if method is defined, run it and return either it's results or the chain
            else if (self[method]) {
                // define a result variable to return to the jQuery chain
                var result;
                this.each(function (i) {
                    // apply the method to the current element
                    var r = $.data(this, "iButton")[method].apply(self, args);
                    // if first iteration we need to check if we're done processing or need to add it to the jquery chain
                    if (i == 0 && r) {
                        // if this is a jQuery item, we need to store them in a collection
                        if (!!r.jquery) {
                            result = $([]).add(r);
                            // otherwise, just store the result and stop executing
                        } else {
                            result = r;
                            // since we're a non-jQuery item, just cancel processing further items
                            return false;
                        }
                        // keep adding jQuery objects to the results
                    } else if (!!r && !!r.jquery) {
                        result = result.add(r);
                    }
                });

                // return either the results (which could be a jQuery object) or the original chain
                return result || this;
                // everything else, return the chain
            } else return this;
            // initializing request
        } else {
            // create a new iButton for each object found
            return this.each(function () {
                new iButton(this, options);
            });
        };
    };

    // count instances	
    var counter = 0;
    // detect iPhone
    $.browser.iphone = (navigator.userAgent.toLowerCase().indexOf("iphone") > -1);

    var iButton = function (input, options) {
        var self = this
			, $input = $(input)
			, id = ++counter
			, disabled = false
			, width = {}
			, mouse = { dragging: false, clicked: null }
			, dragStart = { position: null, offset: null, time: null }
        // make a copy of the options and use the metadata if provided
			, options = $.extend({}, defaults, options, (!!$.metadata ? $input.metadata() : {}))
        // check to see if we're using the default labels
			, bDefaultLabelsUsed = (options.labelOn == ON && options.labelOff == OFF)
        // set valid field types
			, allow = ":checkbox, :radio";

        // only do for checkboxes buttons, if matches inside that node
        if (!$input.is(allow)) return $input.find(allow).iButton(options);

        // store a reference to this marquee
        $.data($input[0], "iButton", self);

        // if using the "auto" setting, then don't resize handle or container if using the default label (since we'll trust the CSS)
        if (options.resizeHandle == "auto") options.resizeHandle = !bDefaultLabelsUsed;
        if (options.resizeContainer == "auto") options.resizeContainer = !bDefaultLabelsUsed;

        // toggles the state of a button (or can turn on/off)
        this.toggle = function (t) {
            var toggle = (arguments.length > 0) ? t : !$input.is(":checked");
            $input.attr("checked", toggle ? "checked" : "").trigger("change");
        };

        // disable/enable the control
        this.disable = function (t) {
            var toggle = (arguments.length > 0) ? t : !disabled;
            // mark the control disabled
            disabled = toggle;
            // mark the input disabled
            $input.attr("disabled", toggle);
            // set the diabled styles
            $container[toggle ? "addClass" : "removeClass"](options.classDisabled);
            // run callback
            if ($.isFunction(options.disable)) options.disable.apply(self, [disabled, $input, options]);
        };

        // repaint the button
        this.repaint = function () {
            positionHandle();
        };

        // this will destroy the iButton style
        this.destroy = function () {
            // remove behaviors
            $([$input[0], $container[0]]).unbind(".iButton");
            $(document).unbind(".iButton_" + id);
            // move the checkbox to it's original location
            $container.after($input).remove();
            // kill the reference
            $.data($input[0], "iButton", null);
            // run callback
            if ($.isFunction(options.destroy)) options.destroy.apply(self, [$input, options]);
        };

        $input
        // create the wrapper code
			.wrap('<div class="' + options.classContainer + '" />')
    	.after(
				  '<div class="' + options.classHandle + '"><div class="' + options.classHandleRight + '"><div class="' + options.classHandleMiddle + '" /></div></div>'
      	+ '<div class="' + options.classLabelOff + '"><span><label>' + options.labelOff + '</label></span></div>'
      	+ '<div class="' + options.classLabelOn + '"><span><label>' + options.labelOn + '</label></span></div>'
      	+ '<div class="' + options.classPaddingLeft + '"></div><div class="' + options.classPaddingRight + '"></div>'
			);

        var $container = $input.parent()
			, $handle = $input.siblings("." + options.classHandle)
			, $offlabel = $input.siblings("." + options.classLabelOff)
			, $offspan = $offlabel.children("span")
			, $onlabel = $input.siblings("." + options.classLabelOn)
			, $onspan = $onlabel.children("span");


        // if we need to do some resizing, get the widths only once
        if (options.resizeHandle || options.resizeContainer) {
            width.onspan = $onspan.outerWidth();
            width.offspan = $offspan.outerWidth();
        }

        // automatically resize the handle
        if (options.resizeHandle) {
            width.handle = Math.min(width.onspan, width.offspan);
            $handle.css("width", width.handle);
        } else {
            width.handle = $handle.width();
        }

        // automatically resize the control
        if (options.resizeContainer) {
            width.container = (Math.max(width.onspan, width.offspan) + width.handle + 20);
            $container.css("width", width.container);
            // adjust the off label to match the new container size
            $offlabel.css("width", width.container - 5);
        } else {
            width.container = $container.width();
        }

        var handleRight = width.container - width.handle - 6;

        var positionHandle = function (animate) {
            var checked = $input.attr("checked")
				, x = (checked) ? handleRight : 0
				, animate = (arguments.length > 0) ? arguments[0] : true;

            if (animate && options.enableFx) {
                $handle.stop().animate({ left: x }, options.duration, options.easing);
                $onlabel.stop().animate({ width: x + 4 }, options.duration, options.easing);
                $onspan.stop().animate({ marginLeft: x - handleRight }, options.duration, options.easing);
                $offspan.stop().animate({ marginRight: -x }, options.duration, options.easing);
            } else {
                $handle.css("left", x);
                $onlabel.css("width", x + 4);
                $onspan.css("marginLeft", x - handleRight);
                $offspan.css("marginRight", -x);
            }
        };

        // place the buttons in their default location	
        positionHandle(false);

        var getDragPos = function (e) {
            return e.pageX || ((e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageX : 0);
        };

        // monitor mouse clicks in the container
        $container.bind("mousedown.iButton touchstart.iButton", function (e) {
            // abort if disabled or allow clicking the input to toggle the status (if input is visible)
            if ($(e.target).is(allow) || disabled || (!options.allowRadioUncheck && $input.is(":radio:checked"))) return;

            e.preventDefault();
            mouse.clicked = $handle;
            dragStart.position = getDragPos(e);
            dragStart.offset = dragStart.position - (parseInt($handle.css("left"), 10) || 0);
            dragStart.time = (new Date()).getTime();
            return false;
        });

        // make sure dragging support is enabled		
        if (options.enableDrag) {
            // monitor mouse movement on the page
            $(document).bind("mousemove.iButton_" + id + " touchmove.iButton_" + id, function (e) {
                // if we haven't clicked on the container, cancel event
                if (mouse.clicked != $handle) { return }
                e.preventDefault();

                var x = getDragPos(e);
                if (x != dragStart.offset) {
                    mouse.dragging = true;
                    $container.addClass(options.classHandleActive);
                }

                // make sure number is between 0 and 1			
                var pct = Math.min(1, Math.max(0, (x - dragStart.offset) / handleRight));

                $handle.css("left", pct * handleRight);
                $onlabel.css("width", pct * handleRight + 4);
                $offspan.css("marginRight", -pct * handleRight);
                $onspan.css("marginLeft", -(1 - pct) * handleRight);

                return false;
            });
        }

        // monitor when the mouse button is released
        $(document).bind("mouseup.iButton_" + id + " touchend.iButton_" + id, function (e) {
            if (mouse.clicked != $handle) { return false }
            e.preventDefault();

            // track if the value has changed			
            var changed = true;

            // if not dragging or click time under a certain millisecond, then just toggle			
            if (!mouse.dragging || (((new Date()).getTime() - dragStart.time) < options.clickOffset)) {
                var checked = $input.attr("checked");
                $input.attr("checked", !checked);

                // run callback
                if ($.isFunction(options.click)) options.click.apply(self, [!checked, $input, options]);
            } else {
                var x = getDragPos(e);

                var pct = (x - dragStart.offset) / handleRight;
                var checked = (pct >= 0.5);

                // if the value is the same, don't run change event
                if ($input.is(":checked") == checked) changed = false;

                $input.attr("checked", checked);
            }

            // remove the active handler class			
            $container.removeClass(options.classHandleActive);
            mouse.clicked = null;
            mouse.dragging = null;
            // run any change event for the element
            if (changed) $input.trigger("change");
            // if the value didn't change, just reset the handle
            else positionHandle();

            return false;
        });

        // animate when we get a change event
        $input
			.bind("change.iButton", function () {
			    // move handle
			    positionHandle();

			    // if a radio element, then we must repaint the other elements in it's group to show them as not selected
			    if ($input.is(":radio")) {
			        var el = $input[0];

			        // try to use the DOM to get the grouped elements, but if not in a form get by name attr
			        var $radio = $(el.form ? el.form[el.name] : ":radio[name=" + el.name + "]");

			        // repaint the radio elements that are not checked	
			        $radio.filter(":not(:checked)").iButton("repaint");
			    }

			    // run callback
			    if ($.isFunction(options.change)) options.change.apply(self, [$input, options]);
			})
        // if the element has focus, we need to highlight the container
			.bind("focus.iButton", function () {
			    $container.addClass(options.classFocus);
			})
        // if the element has focus, we need to highlight the container
			.bind("blur.iButton", function () {
			    $container.removeClass(options.classFocus);
			});

        // if a click event is registered, we must register on the checkbox so it's fired if triggered on the checkbox itself
        if ($.isFunction(options.click)) {
            $input.bind("click.iButton", function () {
                options.click.apply(self, [$input.attr("checked"), $input, options]);
            });
        }

        // if the field is disabled, mark it as such
        if ($input.is(":disabled")) this.disable(true);

        // special behaviors for IE    
        if ($.browser.msie) {
            // disable text selection in IE, other browsers are controlled via CSS
            $container.find("*").andSelf().attr("unselectable", "on");
            // IE needs to register to the "click" event to make changes immediately (the change event only occurs on blur)
            $input.bind("click.iButton", function () { $input.triggerHandler("change.iButton"); });
        }

        // run the init callback
        if ($.isFunction(options.init)) options.init.apply(self, [$input, options]);
    };

    var defaults = {
        duration: 200                           // the speed of the animation
		, easing: "swing"                         // the easing animation to use
		, labelOn: "ON"                           // the text to show when toggled on
		, labelOff: "OFF"                         // the text to show when toggled off
		, resizeHandle: "auto"                    // determines if handle should be resized
		, resizeContainer: "auto"                 // determines if container should be resized
		, enableDrag: true                        // determines if we allow dragging
		, enableFx: true                          // determines if we show animation
		, allowRadioUncheck: false                // determine if a radio button should be able to be unchecked
		, clickOffset: 120                        // if millseconds between a mousedown & mouseup event this value, then considered a mouse click

        // define the class statements
		, classContainer: "ibutton-container"
		, classDisabled: "ibutton-disabled"
		, classFocus: "ibutton-focus"
		, classLabelOn: "ibutton-label-on"
		, classLabelOff: "ibutton-label-off"
		, classHandle: "ibutton-handle"
		, classHandleMiddle: "ibutton-handle-middle"
		, classHandleRight: "ibutton-handle-right"
		, classHandleActive: "ibutton-active-handle"
		, classPaddingLeft: "ibutton-padding-left"
		, classPaddingRight: "ibutton-padding-right"

        // event handlers
		, init: null                              // callback that occurs when a iButton is initialized
		, change: null                            // callback that occurs when the button state is changed
		, click: null                             // callback that occurs when the button is clicked
		, disable: null                           // callback that occurs when the button is disabled/enabled
		, destroy: null                           // callback that occurs when the button is destroyed
    }, ON = defaults.labelOn, OFF = defaults.labelOff;

})(jQuery);

(function ($, window, undefined) {
    var isMobile = (/iphone|ipad|android/gi).test(navigator.appVersion);
    $.fn.scrollpane = function (opts) {
        opts = $.extend({
            idleOpacity: '0'
        }, opts || {});
        if (isMobile) {
            return this.each(function () {
                var pane = $(this);
                var iscroll = pane.data('iscroll');
                if (iscroll) {
                    iscroll.destroy();
                } else {
                    pane.wrapInner('<div class="scrollpane-content"></div>');
                }
                pane.css({
                    height: '100%'
                });
                pane.data('iscroll', new iScroll(this));
            });
        } else {
            return this.each(function () {
                var pane = $(this),
                    data = pane.data('scrollpane');
                if ($.browser.msie && $.browser.version.charAt(0) === '7') {
                    setTimeout(function () {
                        pane.height(pane.parent().height());
                    }, 1);
                    pane.css({
                        'margin-right': '0px',
                        'overflow-y': 'auto',
                        'position': 'relative'
                    });
                    return;
                }
                if (!data) {
                    data = init();
                }
                var scrollbar = data.scrollbar,
                    content = data.content,
                    track = data.track,
                    drag = data.drag,
                    contentHeight = content.outerHeight(),
                    height = pane.height(),
                    offset = pane.offset(),
                    ratio = height / contentHeight;
                if (ratio < 1) {
                    scrollbar.show();
                    scrollbar.height(height);
                    drag.height(Math.floor(height * ratio) - 6);
                } else {
                    scrollbar.hide();
                }
                pane.unbind('updateDragTop').bind('updateDragTop', function () {
                    var scrollTop = pane.scrollTop(),
                        top = Math.min(Math.round(scrollTop * ratio), height - drag.height());
                    drag.css('top', top + 'px');
                });
                pane.unbind('resizeCheck').bind('resizeCheck', function () {
                    var newOffset = pane.offset();
                    var dataOffset = offset;
                    if (newOffset && dataOffset) {
                        if ((pane.height() != height) || (content.height() != contentHeight) || (newOffset.top != dataOffset.top) || (newOffset.left != dataOffset.left)) {
                            try {
                                pane.scrollpane();
                            } catch (e) { }
                        }
                    }
                });

                function init() {
                    var barWidth = calcScrollbarWidth(),
                        scrollbarHTML = '<div class="scrollbar-container" style="display:none;">' + '<div class="scrollbar-track"><div class="scrollbar-drag">' + '</div></div></div>',
                        scrollbar = $(scrollbarHTML),
                        content = $('<div class="scrollpane-content"></div>'),
                        drag = $('.scrollbar-drag', scrollbar);
                    drag.css('opacity', opts.idleOpacity)
                    pane.wrapInner(content);
                    pane.append(scrollbar);
                    pane.attr('data-scrollpane', true);
                    content = $('> div:first', pane);
                    pane.css({
                        marginRight: '-' + barWidth + 'px',
                        overflowX: 'hidden',
                        overflowY: 'scroll',
                        height: '100%'
                    });
                    pane.bind('mouseenter.scrollpane', function (e) {
                        drag.animate({
                            duration: 100,
                            opacity: '0.5'
                        });
                    });
                    pane.bind('mouseleave.scrollpane', function () {
                        drag.animate({
                            duration: 100,
                            opacity: opts.idleOpacity
                        });
                    });
                    pane.bind('scroll.scrollpane', throttle(function () {
                        pane.trigger('updateDragTop');
                    }, 10));
                    drag.mousedown(function (event) {
                        $(document).unbind('mousemove.scrollpane');
                        event.preventDefault();
                        var offsetTop = event.pageY - drag.offset().top;
                        $(document).bind('mousemove.scrollpane', function (event) {
                            pane.scrollTop((event.pageY - pane.offset().top - offsetTop) / (pane.height() / content.outerHeight()));
                            return false;
                        }).mouseup(function () {
                            $(document).unbind('mousemove.scrollpane');
                        });
                        return false;
                    });
                    (function resizeCheck() {
                        setTimeout(function () {
                            pane.trigger('resizeCheck');
                            resizeCheck();
                        }, 500);
                    })();
                    var scrollpane = {
                        scrollbar: scrollbar,
                        content: content,
                        track: $('.scrollbar-track', scrollbar),
                        drag: drag
                    }
                    pane.data('scrollpane', scrollpane);
                    return scrollpane;
                }
            });
        }
    }

    function calcScrollbarWidth() {
        var divHTML = '<div style="width:50px;height:50px;overflow-y:scroll;position:absolute;top:-2000px;left:-2000px;">' + '<div style="height:100px;"></div></div>',
            div = $(divHTML);
        $('body').append(div);
        var w = $('div', div).innerWidth();
        div.remove();
        return (50 - w);
    }

    function throttle(callback, delay) {
        var lasttime = 0;
        return function () {
            var elapsed = +new Date() - lasttime,
                args = arguments,
                self = this;
            if (elapsed > delay) {
                lasttime = +new Date();
                callback.apply(self, args);
            }
        }
    };
})(jQuery, window); ;
(function () {
    function iScroll(el, options) {
        var that = this,
            doc = document,
            i;
        that.wrapper = typeof el == 'object' ? el : doc.getElementById(el);
        that.wrapper.style.overflow = 'hidden';
        that.scroller = that.wrapper.children[0];
        that.scroller.style.cssText += '-webkit-transition-property:-webkit-transform;-webkit-transform-origin:0 0;-webkit-transform:' + trnOpen + '0,0' + trnClose;
        that.scroller.style.cssText += '-webkit-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);-webkit-transition-duration:0;';
        that.options = {
            hScroll: true,
            vScroll: true,
            bounce: has3d,
            bounceLock: false,
            momentum: has3d,
            lockDirection: true,
            hScrollbar: true,
            vScrollbar: true,
            fixedScrollbar: isAndroid,
            fadeScrollbar: (isIDevice && has3d) || !hasTouch,
            hideScrollbar: isIDevice || !hasTouch,
            scrollbarClass: '',
            onScrollStart: null,
            onScrollEnd: null
        };
        for (i in options) {
            that.options[i] = options[i];
        }
        that.options.hScrollbar = that.options.hScroll && that.options.hScrollbar;
        that.options.vScrollbar = that.options.vScroll && that.options.vScrollbar;
        that.refresh();
        that._bind(RESIZE_EV, window);
        that._bind(START_EV);
    }
    iScroll.prototype = {
        x: 0,
        y: 0,
        handleEvent: function (e) {
            var that = this;
            switch (e.type) {
                case START_EV:
                    that._start(e);
                    break;
                case MOVE_EV:
                    that._move(e);
                    break;
                case END_EV:
                case CANCEL_EV:
                    that._end(e);
                    break;
                case 'webkitTransitionEnd':
                    that._transitionEnd(e);
                    break;
                case RESIZE_EV:
                    that._resize();
                    break;
            }
        },
        _scrollbar: function (dir) {
            var that = this,
                doc = document,
                bar;
            if (!that[dir + 'Scrollbar']) {
                if (that[dir + 'ScrollbarWrapper']) {
                    that[dir + 'ScrollbarIndicator'].style.webkitTransform = '';
                    that[dir + 'ScrollbarWrapper'].parentNode.removeChild(that[dir + 'ScrollbarWrapper']);
                    that[dir + 'ScrollbarWrapper'] = null;
                    that[dir + 'ScrollbarIndicator'] = null;
                }
                return;
            }
            if (!that[dir + 'ScrollbarWrapper']) {
                bar = doc.createElement('div');
                if (that.options.scrollbarClass) {
                    bar.className = that.options.scrollbarClass + dir.toUpperCase();
                } else {
                    bar.style.cssText = 'position:absolute;z-index:100;' + (dir == 'h' ? 'height:7px;bottom:1px;left:2px;right:7px' : 'width:7px;bottom:7px;top:2px;right:1px');
                }
                bar.style.cssText += 'pointer-events:none;-webkit-transition-property:opacity;-webkit-transition-duration:' + (that.options.fadeScrollbar ? '350ms' : '0') + ';overflow:hidden;opacity:' + (that.options.hideScrollbar ? '0' : '1');
                that.wrapper.appendChild(bar);
                that[dir + 'ScrollbarWrapper'] = bar;
                bar = doc.createElement('div');
                if (!that.options.scrollbarClass) {
                    bar.style.cssText = 'position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);-webkit-background-clip:padding-box;-webkit-box-sizing:border-box;' + (dir == 'h' ? 'height:100%;-webkit-border-radius:4px 3px;' : 'width:100%;-webkit-border-radius:3px 4px;');
                }
                bar.style.cssText += 'pointer-events:none;-webkit-transition-property:-webkit-transform;-webkit-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);-webkit-transition-duration:0;-webkit-transform:' + trnOpen + '0,0' + trnClose;
                that[dir + 'ScrollbarWrapper'].appendChild(bar);
                that[dir + 'ScrollbarIndicator'] = bar;
            }
            if (dir == 'h') {
                that.hScrollbarSize = that.hScrollbarWrapper.clientWidth;
                that.hScrollbarIndicatorSize = m.max(m.round(that.hScrollbarSize * that.hScrollbarSize / that.scrollerW), 8);
                that.hScrollbarIndicator.style.width = that.hScrollbarIndicatorSize + 'px';
                that.hScrollbarMaxScroll = that.hScrollbarSize - that.hScrollbarIndicatorSize;
                that.hScrollbarProp = that.hScrollbarMaxScroll / that.maxScrollX;
            } else {
                that.vScrollbarSize = that.vScrollbarWrapper.clientHeight;
                that.vScrollbarIndicatorSize = m.max(m.round(that.vScrollbarSize * that.vScrollbarSize / that.scrollerH), 8);
                that.vScrollbarIndicator.style.height = that.vScrollbarIndicatorSize + 'px';
                that.vScrollbarMaxScroll = that.vScrollbarSize - that.vScrollbarIndicatorSize;
                that.vScrollbarProp = that.vScrollbarMaxScroll / that.maxScrollY;
            }
            that._indicatorPos(dir, true);
        },
        _resize: function () {
            var that = this;
            setTimeout(function () {
                that.refresh();
            }, 0);
        },
        _pos: function (x, y) {
            var that = this;
            that.x = that.hScroll ? x : 0;
            that.y = that.vScroll ? y : 0;
            that.scroller.style.webkitTransform = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose;
            that._indicatorPos('h');
            that._indicatorPos('v');
        },
        _indicatorPos: function (dir, hidden) {
            var that = this,
                pos = dir == 'h' ? that.x : that.y;
            if (!that[dir + 'Scrollbar']) return;
            pos = that[dir + 'ScrollbarProp'] * pos;
            if (pos < 0) {
                pos = that.options.fixedScrollbar ? 0 : pos + pos * 3;
                if (that[dir + 'ScrollbarIndicatorSize'] + pos < 9) pos = -that[dir + 'ScrollbarIndicatorSize'] + 8;
            } else if (pos > that[dir + 'ScrollbarMaxScroll']) {
                pos = that.options.fixedScrollbar ? that[dir + 'ScrollbarMaxScroll'] : pos + (pos - that[dir + 'ScrollbarMaxScroll']) * 3;
                if (that[dir + 'ScrollbarIndicatorSize'] + that[dir + 'ScrollbarMaxScroll'] - pos < 9) pos = that[dir + 'ScrollbarIndicatorSize'] + that[dir + 'ScrollbarMaxScroll'] - 8;
            }
            that[dir + 'ScrollbarWrapper'].style.webkitTransitionDelay = '0';
            that[dir + 'ScrollbarWrapper'].style.opacity = hidden && that.options.hideScrollbar ? '0' : '1';
            that[dir + 'ScrollbarIndicator'].style.webkitTransform = trnOpen + (dir == 'h' ? pos + 'px,0' : '0,' + pos + 'px') + trnClose;
        },
        _transitionTime: function (time) {
            var that = this;
            time += 'ms';
            that.scroller.style.webkitTransitionDuration = time;
            if (that.hScrollbar) that.hScrollbarIndicator.style.webkitTransitionDuration = time;
            if (that.vScrollbar) that.vScrollbarIndicator.style.webkitTransitionDuration = time;
        },
        _start: function (e) {
            if (e.target.nodeName.toLowerCase() === "select") {
                e.stopPropagation();
                return;
            }
            var that = this,
                point = hasTouch ? e.changedTouches[0] : e,
                matrix;
            that.moved = false;
            e.preventDefault();
            that.moved = false;
            that.distX = 0;
            that.distY = 0;
            that.absDistX = 0;
            that.absDistY = 0;
            that.dirX = 0;
            that.dirY = 0;
            that.returnTime = 0;
            that._transitionTime(0);
            if (that.options.momentum) {
                matrix = new WebKitCSSMatrix(window.getComputedStyle(that.scroller, null).webkitTransform);
                if (matrix.m41 != that.x || matrix.m42 != that.y) {
                    that._unbind('webkitTransitionEnd');
                    that._pos(matrix.m41, matrix.m42);
                }
            }
            that.scroller.style.webkitTransitionTimingFunction = 'cubic-bezier(0.33,0.66,0.66,1)';
            if (that.hScrollbar) that.hScrollbarIndicator.style.webkitTransitionTimingFunction = 'cubic-bezier(0.33,0.66,0.66,1)';
            if (that.vScrollbar) that.vScrollbarIndicator.style.webkitTransitionTimingFunction = 'cubic-bezier(0.33,0.66,0.66,1)';
            that.startX = that.x;
            that.startY = that.y;
            that.pointX = point.pageX;
            that.pointY = point.pageY;
            that.startTime = e.timeStamp;
            if (that.options.onScrollStart) that.options.onScrollStart.call(that);
            that._bind(MOVE_EV);
            that._bind(END_EV);
            that._bind(CANCEL_EV);
        },
        _move: function (e) {
            if (hasTouch && e.touches.length > 1) return;
            var that = this,
                point = hasTouch ? e.changedTouches[0] : e,
                deltaX = point.pageX - that.pointX,
                deltaY = point.pageY - that.pointY,
                newX = that.x + deltaX,
                newY = that.y + deltaY;
            e.preventDefault();
            that.pointX = point.pageX;
            that.pointY = point.pageY;
            if (newX > 0 || newX < that.maxScrollX) {
                newX = that.options.bounce ? that.x + (deltaX / 2.4) : newX >= 0 || that.maxScrollX >= 0 ? 0 : that.maxScrollX;
            }
            if (newY > 0 || newY < that.maxScrollY) {
                newY = that.options.bounce ? that.y + (deltaY / 2.4) : newY >= 0 || that.maxScrollY >= 0 ? 0 : that.maxScrollY;
            }
            if (that.absDistX < 4 && that.absDistY < 4) {
                that.distX += deltaX;
                that.distY += deltaY;
                that.absDistX = m.abs(that.distX);
                that.absDistY = m.abs(that.distY);
                return;
            }
            if (that.options.lockDirection) {
                if (that.absDistX > that.absDistY + 3) {
                    newY = that.y;
                    deltaY = 0;
                } else if (that.absDistY > that.absDistX + 3) {
                    newX = that.x;
                    deltaX = 0;
                }
            }
            that.moved = true;
            that._pos(newX, newY);
            that.dirX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
            that.dirY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
            if (e.timeStamp - that.startTime > 300) {
                that.startTime = e.timeStamp;
                that.startX = that.x;
                that.startY = that.y;
            }
        },
        _end: function (e) {
            if (hasTouch && e.touches.length != 0) return;
            var that = this,
                point = hasTouch ? e.changedTouches[0] : e,
                target, ev, momentumX = {
                    dist: 0,
                    time: 0
                },
                momentumY = {
                    dist: 0,
                    time: 0
                },
                duration = e.timeStamp - that.startTime,
                newPosX = that.x,
                newPosY = that.y,
                newDuration;
            that._unbind(MOVE_EV);
            that._unbind(END_EV);
            that._unbind(CANCEL_EV);
            if (!that.moved) {
                if (hasTouch) {
                    that.doubleTapTimer = null;
                    target = point.target;
                    while (target.nodeType != 1) {
                        target = target.parentNode;
                    }
                    ev = document.createEvent('MouseEvents');
                    ev.initMouseEvent('click', true, true, e.view, 1, point.screenX, point.screenY, point.clientX, point.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, 0, null);
                    ev._fake = true;
                    target.dispatchEvent(ev);
                }
                that._resetPos();
                return;
            }
            if (duration < 300 && that.options.momentum) {
                momentumX = newPosX ? that._momentum(newPosX - that.startX, duration, -that.x, that.scrollerW - that.wrapperW + that.x, that.options.bounce ? that.wrapperW : 0) : momentumX;
                momentumY = newPosY ? that._momentum(newPosY - that.startY, duration, -that.y, (that.maxScrollY < 0 ? that.scrollerH - that.wrapperH + that.y : 0), that.options.bounce ? that.wrapperH : 0) : momentumY;
                newPosX = that.x + momentumX.dist;
                newPosY = that.y + momentumY.dist;
                if ((that.x > 0 && newPosX > 0) || (that.x < that.maxScrollX && newPosX < that.maxScrollX)) momentumX = {
                    dist: 0,
                    time: 0
                };
                if ((that.y > 0 && newPosY > 0) || (that.y < that.maxScrollY && newPosY < that.maxScrollY)) momentumY = {
                    dist: 0,
                    time: 0
                };
            }
            if (momentumX.dist || momentumY.dist) {
                newDuration = m.max(m.max(momentumX.time, momentumY.time), 10);
                that.scrollTo(newPosX, newPosY, newDuration);
                return;
            }
            that._resetPos(200);
        },
        _resetPos: function (time) {
            var that = this,
                resetX = that.x,
                resetY = that.y;
            if (that.x >= 0) resetX = 0;
            else if (that.x < that.maxScrollX) resetX = that.maxScrollX;
            if (that.y >= 0 || that.maxScrollY > 0) resetY = 0;
            else if (that.y < that.maxScrollY) resetY = that.maxScrollY;
            if (resetX == that.x && resetY == that.y) {
                if (that.moved) {
                    if (that.options.onScrollEnd) that.options.onScrollEnd.call(that);
                    that.moved = false;
                }
                if (that.hScrollbar && that.options.hideScrollbar) {
                    that.hScrollbarWrapper.style.webkitTransitionDelay = '300ms';
                    that.hScrollbarWrapper.style.opacity = '0';
                }
                if (that.vScrollbar && that.options.hideScrollbar) {
                    that.vScrollbarWrapper.style.webkitTransitionDelay = '300ms';
                    that.vScrollbarWrapper.style.opacity = '0';
                }
                return;
            }
            if (time) {
                that.scroller.style.webkitTransitionTimingFunction = 'cubic-bezier(0.33,0.0,0.33,1)';
                if (that.hScrollbar) that.hScrollbarIndicator.style.webkitTransitionTimingFunction = 'cubic-bezier(0.33,0.0,0.33,1)';
                if (that.vScrollbar) that.vScrollbarIndicator.style.webkitTransitionTimingFunction = 'cubic-bezier(0.33,0.0,0.33,1)';
            }
            that.scrollTo(resetX, resetY, time || 0);
        },
        _transitionEnd: function (e) {
            var that = this;
            if (e) e.stopPropagation();
            that._unbind('webkitTransitionEnd');
            that._resetPos(that.returnTime);
            that.returnTime = 0;
        },
        _momentum: function (dist, time, maxDistUpper, maxDistLower, size) {
            var that = this,
                deceleration = 0.0006,
                speed = m.abs(dist) / time,
                newDist = (speed * speed) / (2 * deceleration),
                newTime = 0,
                outsideDist = 0;
            if (dist > 0 && newDist > maxDistUpper) {
                outsideDist = size / (6 / (newDist / speed * deceleration));
                maxDistUpper = maxDistUpper + outsideDist;
                that.returnTime = 800 / size * outsideDist + 100;
                speed = speed * maxDistUpper / newDist;
                newDist = maxDistUpper;
            } else if (dist < 0 && newDist > maxDistLower) {
                outsideDist = size / (6 / (newDist / speed * deceleration));
                maxDistLower = maxDistLower + outsideDist;
                that.returnTime = 800 / size * outsideDist + 100;
                speed = speed * maxDistLower / newDist;
                newDist = maxDistLower;
            }
            newDist = newDist * (dist < 0 ? -1 : 1);
            newTime = speed / deceleration;
            return {
                dist: newDist,
                time: m.round(newTime)
            };
        },
        _offset: function (el, tree) {
            var left = -el.offsetLeft,
                top = -el.offsetTop;
            if (!tree) return {
                x: left,
                y: top
            };
            while (el = el.offsetParent) {
                left -= el.offsetLeft;
                top -= el.offsetTop;
            }
            return {
                x: left,
                y: top
            };
        },
        _bind: function (type, el) {
            (el || this.scroller).addEventListener(type, this, false);
        },
        _unbind: function (type, el) {
            (el || this.scroller).removeEventListener(type, this, false);
        },
        destroy: function () {
            var that = this;
            that.hScrollbar = false;
            that.vScrollbar = false;
            that._scrollbar('h');
            that._scrollbar('v');
            that.scroller.style.webkitTransform = '';
            that._unbind('webkitTransitionEnd');
            that._unbind(RESIZE_EV);
            that._unbind(START_EV);
            that._unbind(MOVE_EV);
            that._unbind(END_EV);
            that._unbind(CANCEL_EV);
        },
        refresh: function () {
            var that = this;
            that.wrapperW = that.wrapper.clientWidth;
            that.wrapperH = that.wrapper.clientHeight;
            that.scrollerW = that.scroller.offsetWidth;
            that.scrollerH = that.scroller.offsetHeight;
            that.maxScrollX = that.wrapperW - that.scrollerW;
            that.maxScrollY = that.wrapperH - that.scrollerH;
            that.dirX = 0;
            that.dirY = 0;
            that._transitionTime(0);
            that.hScroll = that.options.hScroll && that.maxScrollX < 0;
            that.vScroll = that.options.vScroll && (!that.options.bounceLock && !that.hScroll || that.scrollerH > that.wrapperH);
            that.hScrollbar = that.hScroll && that.options.hScrollbar;
            that.vScrollbar = that.vScroll && that.options.vScrollbar && that.scrollerH > that.wrapperH;
            that._scrollbar('h');
            that._scrollbar('v');
            that._resetPos();
        },
        scrollTo: function (x, y, time, relative) {
            var that = this;
            if (relative) {
                x = that.x - x;
                y = that.y - y;
            }
            time = !time || (m.round(that.x) == m.round(x) && m.round(that.y) == m.round(y)) ? 0 : time;
            that.moved = true;
            if (time) that._bind('webkitTransitionEnd');
            that._transitionTime(time);
            that._pos(x, y);
            if (!time) setTimeout(function () {
                that._transitionEnd();
            }, 0);
        },
        scrollToElement: function (el, time) {
            var that = this,
                pos;
            el = el.nodeType ? el : that.scroller.querySelector(el);
            if (!el) return;
            pos = that._offset(el);
            pos.x = pos.x > 0 ? 0 : pos.x < that.maxScrollX ? that.maxScrollX : pos.x;
            pos.y = pos.y > 0 ? 0 : pos.y < that.maxScrollY ? that.maxScrollY : pos.y;
            time = time === undefined ? m.max(m.abs(pos.x) * 2, m.abs(pos.y) * 2) : time;
            that.scrollTo(pos.x, pos.y, time);
        }
    };
    var has3d = 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix(),
        hasTouch = 'ontouchstart' in window,
        isIDevice = (/iphone|ipad/gi).test(navigator.appVersion),
        isAndroid = (/android/gi).test(navigator.appVersion),
        RESIZE_EV = 'onorientationchange' in window ? 'orientationchange' : 'resize',
        START_EV = hasTouch ? 'touchstart' : 'mousedown',
        MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
        END_EV = hasTouch ? 'touchend' : 'mouseup',
        CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup',
        trnOpen = 'translate' + (has3d ? '3d(' : '('),
        trnClose = has3d ? ',0)' : ')',
        m = Math;
    if (typeof exports !== 'undefined') exports.iScroll = iScroll;
    else window.iScroll = iScroll;
})();

jQuery.fn.shorten = function(settings) {
  var config = {
    showChars : 100,
    ellipsesText : "...",
    moreText : "more",
    lessText : "less"
  };
 
  if (settings) {
    $.extend(config, settings);
  }
 
  $('.morelink').live('click', function() {
    var $this = $(this);
    if ($this.hasClass('less')) {
      $this.removeClass('less');
      $this.html(config.moreText);
    } else {
      $this.addClass('less');
      $this.html(config.lessText);
    }
    $this.parent().prev().toggle();
    $this.prev().toggle();
    return false;
  });
 
  return this.each(function() {
    var $this = $(this);
 
    var content = $this.html();
    if (content.length > config.showChars) {
      var c = content.substr(0, config.showChars);
      var h = content.substr(config.showChars , content.length - config.showChars);
      var html = c + '<span class="moreellipses">' + config.ellipsesText + '&nbsp;</span><span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<a href="#" class="morelink">' + config.moreText + '</a></span>';
      $this.html(html);
      $(".morecontent span").hide();
    }
  });
}
MND.helpers = (function () {
    var helper = {
        setupDialog: function (url, title, width) {
            $.get(url, null, function (data) {
                helper.setupDialogForm(data, title, width);
            });
        },
        setupDialogForm: function (data, title, width) {
            var actionPopup = $("<div />").append($('<div />').addClass('formcontainer').append(data));

            actionPopup.dialog({
                modal: true
                , resizable: false
                , title: title
                , draggable: false
                , width: width
                , buttons: {
                    "Save": function () {
                        var frm = $('form', actionPopup);
                        $.post(frm.attr('action'), frm.serialize(), function (postData) {
                            var newData = $("<div />").append($('<div />').addClass('formcontainer').append(postData));
                            if ($('.success', newData).length > 0) {
                                $(actionPopup).dialog('close');
                                flash('info', $('.success', newData).html());
                            } else {
                                $('.formcontainer', actionPopup).replaceWith(newData);
                            }
                        });
                    }
                    , "Cancel": function () {
                        $(this).dialog("close");
                    }
                }, close: function (event, ui) {
                    $(this).remove();
                }
            }).show();
        },
        setupContentDialog: function (url, title, width, height) {
            $.get(url, null, function (data) {
                var newDiv = $("<div />").append(data);
                if (height) {
                    newDiv.css({
                        overflow: 'auto',
                        height: height + 'px',
                        padding: '15px'
                    });
                    newDiv = $('<div class="scroll" />').append(newDiv);
                }
                var actionPopup = $("<div />").addClass('dialog-holder').append(newDiv);

                actionPopup.dialog({
                    modal: true
                , resizable: false
                , title: title
                , draggable: false
                , width: width
                , close: function (event, ui) {
                    $(this).remove();
                }, open: function (event, ui) {
                    if (height) {
                        $(this).css('padding', 0);
                        //$('.scroll', this).scrollpane();
                    }
                }
                }).show();
            });
        },
        loadHighcharts: function (callback) {
            if (Window.Highcharts) {
                if (callback)
                    callback();
            } else {
                $.getScript('/utility/js/mnd.rates.min.js', function () {
                    if (callback)
                        callback();
                });
            }
        },
        setupTogglePost: function (input, checked, url, action) {
            input.attr('checked', checked);
            input.iButton({
                labelOn: 'Show',
                labelOff: 'Hide',
                change: function ($input) {                    
                    $.post(url, { action: action }, function (data) {
                        if (data.success) {
                            $input.attr('checked', data.value);
                            flash('info', data.result);
                        } else {
                            flash('error', data.result);
                        }
                    });
                }
            });
        },
        setupVideoUrl: function (url, title) {
            var self = this;
            $.post('/getcalendar.ashx', { action: 'getvideoembed', url: url }, function (data) {
                if (!data) {
                    alert('There was an error during the Get Video process');
                } else if (data && !data.success) {
                    alert(data.result);
                } else {
                    helper.setupVideoDialog(data,title);
                }
            }, 'json');

        },
        setupVideoDialog: function (data,title) {
            var self = this;
            if (data.redirectUrl) {
                window.open(data.redirectUrl);
            } else {
                $('<div />').html(data.embedCode).dialog({
                    modal: true
            , resizable: false
            , title: title || data.title
                    //, draggable: false
            , width: 620
            , close: function (event, ui) {
                $(this).dialog("destroy");
                $(this).remove();
            }
                }).show();
            }
        }
    };

    return helper;
})();
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function ($) { $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]) } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob) }, cfg.interval) } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]) }; var handleHover = function (e) { var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) } if (e.type == "mouseenter") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob) }, cfg.interval) } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob) }, cfg.timeout) } } }; return this.bind('mouseenter', handleHover).bind('mouseleave', handleHover) } })(jQuery);
(function(a){a.fn.fadeInFadeOut=function(c,b){return a(this).fadeIn(c,function(){a(this).fadeOut(c);if(b){return b()}else{return a(this)}})};a.fn.center=function(){this.css("position","absolute");this.css("top",(a(window).height()-this.height())/2+a(window).scrollTop()+"px");this.css("left",(a(window).width()-this.width())/2+a(window).scrollLeft()+"px");return this}})(jQuery);
/// <reference path="jquery-1.5.2.js" />

/*!
** Unobtrusive Ajax support library for jQuery
** Copyright (C) Microsoft Corporation. All rights reserved.
*/

/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
/*global window: false, jQuery: false */

(function ($) {
    var data_click = "unobtrusiveAjaxClick",
        data_validation = "unobtrusiveValidation";

    function getFunction(code, argNames) {
        var fn = window, parts = (code || "").split(".");
        while (fn && parts.length) {
            fn = fn[parts.shift()];
        }
        if (typeof (fn) === "function") {
            return fn;
        }
        argNames.push(code);
        return Function.constructor.apply(null, argNames);
    }

    function isMethodProxySafe(method) {
        return method === "GET" || method === "POST";
    }

    function asyncOnBeforeSend(xhr, method) {
        if (!isMethodProxySafe(method)) {
            xhr.setRequestHeader("X-HTTP-Method-Override", method);
        }
    }

    function asyncOnSuccess(element, data, contentType) {
        var mode;

        if (contentType.indexOf("application/x-javascript") !== -1) {  // jQuery already executes JavaScript for us
            return;
        }

        mode = (element.getAttribute("data-ajax-mode") || "").toUpperCase();
        $(element.getAttribute("data-ajax-update")).each(function (i, update) {
            var top;

            switch (mode) {
            case "BEFORE":
                top = update.firstChild;
                $("<div />").html(data).contents().each(function () {
                    update.insertBefore(this, top);
                });
                break;
            case "AFTER":
                $("<div />").html(data).contents().each(function () {
                    update.appendChild(this);
                });
                break;
            default:
                $(update).html(data);
                break;
            }
        });
    }

    function asyncRequest(element, options) {
        var confirm, loading, method, duration;

        confirm = element.getAttribute("data-ajax-confirm");
        if (confirm && !window.confirm(confirm)) {
            return;
        }

        loading = $(element.getAttribute("data-ajax-loading"));
        duration = element.getAttribute("data-ajax-loading-duration") || 0;

        $.extend(options, {
            type: element.getAttribute("data-ajax-method") || undefined,
            url: element.getAttribute("data-ajax-url") || undefined,
            beforeSend: function (xhr) {
                var result;
                asyncOnBeforeSend(xhr, method);
                result = getFunction(element.getAttribute("data-ajax-begin"), ["xhr"]).apply(this, arguments);
                if (result !== false) {
                    loading.show(duration);
                }
                return result;
            },
            complete: function () {
                loading.hide(duration);
                getFunction(element.getAttribute("data-ajax-complete"), ["xhr", "status"]).apply(this, arguments);
            },
            success: function (data, status, xhr) {
                asyncOnSuccess(element, data, xhr.getResponseHeader("Content-Type") || "text/html");
                getFunction(element.getAttribute("data-ajax-success"), ["data", "status", "xhr"]).apply(this, arguments);
            },
            error: getFunction(element.getAttribute("data-ajax-failure"), ["xhr", "status", "error"])
        });

        options.data.push({ name: "X-Requested-With", value: "XMLHttpRequest" });

        method = options.type.toUpperCase();
        if (!isMethodProxySafe(method)) {
            options.type = "POST";
            options.data.push({ name: "X-HTTP-Method-Override", value: method });
        }

        $.ajax(options);
    }

    function validate(form) {
        var validationInfo = $(form).data(data_validation);
        return !validationInfo || !validationInfo.validate || validationInfo.validate();
    }

    $("a[data-ajax=true]").live("click", function (evt) {
        evt.preventDefault();
        asyncRequest(this, {
            url: this.href,
            type: "GET",
            data: []
        });
    });

    $("form[data-ajax=true] input[type=image]").live("click", function (evt) {
        var name = evt.target.name,
            $target = $(evt.target),
            form = $target.parents("form")[0],
            offset = $target.offset();

        $(form).data(data_click, [
            { name: name + ".x", value: Math.round(evt.pageX - offset.left) },
            { name: name + ".y", value: Math.round(evt.pageY - offset.top) }
        ]);

        setTimeout(function () {
            $(form).removeData(data_click);
        }, 0);
    });

    $("form[data-ajax=true] :submit").live("click", function (evt) {
        var name = evt.target.name,
            form = $(evt.target).parents("form")[0];

        $(form).data(data_click, name ? [{ name: name, value: evt.target.value }] : []);

        setTimeout(function () {
            $(form).removeData(data_click);
        }, 0);
    });

    $("form[data-ajax=true]").live("submit", function (evt) {
        var clickInfo = $(this).data(data_click) || [];
        evt.preventDefault();
        if (!validate(this)) {
            return;
        }
        asyncRequest(this, {
            url: this.action,
            type: this.method || "GET",
            data: clickInfo.concat($(this).serializeArray())
        });
    });
}(jQuery));
// Underscore.js 1.1.7
// (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function(){var p=this,C=p._,m={},i=Array.prototype,n=Object.prototype,f=i.slice,D=i.unshift,E=n.toString,l=n.hasOwnProperty,s=i.forEach,t=i.map,u=i.reduce,v=i.reduceRight,w=i.filter,x=i.every,y=i.some,o=i.indexOf,z=i.lastIndexOf;n=Array.isArray;var F=Object.keys,q=Function.prototype.bind,b=function(a){return new j(a)};typeof module!=="undefined"&&module.exports?(module.exports=b,b._=b):p._=b;b.VERSION="1.1.7";var h=b.each=b.forEach=function(a,c,b){if(a!=null)if(s&&a.forEach===s)a.forEach(c,b);else if(a.length===
+a.length)for(var e=0,k=a.length;e<k;e++){if(e in a&&c.call(b,a[e],e,a)===m)break}else for(e in a)if(l.call(a,e)&&c.call(b,a[e],e,a)===m)break};b.map=function(a,c,b){var e=[];if(a==null)return e;if(t&&a.map===t)return a.map(c,b);h(a,function(a,g,G){e[e.length]=c.call(b,a,g,G)});return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var k=d!==void 0;a==null&&(a=[]);if(u&&a.reduce===u)return e&&(c=b.bind(c,e)),k?a.reduce(c,d):a.reduce(c);h(a,function(a,b,f){k?d=c.call(e,d,a,b,f):(d=a,k=!0)});if(!k)throw new TypeError("Reduce of empty array with no initial value");
return d};b.reduceRight=b.foldr=function(a,c,d,e){a==null&&(a=[]);if(v&&a.reduceRight===v)return e&&(c=b.bind(c,e)),d!==void 0?a.reduceRight(c,d):a.reduceRight(c);a=(b.isArray(a)?a.slice():b.toArray(a)).reverse();return b.reduce(a,c,d,e)};b.find=b.detect=function(a,c,b){var e;A(a,function(a,g,f){if(c.call(b,a,g,f))return e=a,!0});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(w&&a.filter===w)return a.filter(c,b);h(a,function(a,g,f){c.call(b,a,g,f)&&(e[e.length]=a)});return e};
b.reject=function(a,c,b){var e=[];if(a==null)return e;h(a,function(a,g,f){c.call(b,a,g,f)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=!0;if(a==null)return e;if(x&&a.every===x)return a.every(c,b);h(a,function(a,g,f){if(!(e=e&&c.call(b,a,g,f)))return m});return e};var A=b.some=b.any=function(a,c,d){c=c||b.identity;var e=!1;if(a==null)return e;if(y&&a.some===y)return a.some(c,d);h(a,function(a,b,f){if(e|=c.call(d,a,b,f))return m});return!!e};b.include=b.contains=function(a,c){var b=
!1;if(a==null)return b;if(o&&a.indexOf===o)return a.indexOf(c)!=-1;A(a,function(a){if(b=a===c)return!0});return b};b.invoke=function(a,c){var d=f.call(arguments,2);return b.map(a,function(a){return(c.call?c||a:a[c]).apply(a,d)})};b.pluck=function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);var e={computed:-Infinity};h(a,function(a,b,f){b=c?c.call(d,a,b,f):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,
c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};h(a,function(a,b,f){b=c?c.call(d,a,b,f):a;b<e.computed&&(e={value:a,computed:b})});return e.value};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,f){return{value:a,criteria:c.call(d,a,b,f)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,b){var d={};h(a,function(a,f){var g=b(a,f);(d[g]||(d[g]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||
(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(b.isArray(a))return f.call(a);if(b.isArguments(a))return f.call(a);return b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?f.call(a,0,b):a[0]};b.rest=b.tail=function(a,b,d){return f.call(a,b==null||d?1:b)};b.last=function(a){return a[a.length-1]};b.compact=function(a){return b.filter(a,
function(a){return!!a})};b.flatten=function(a){return b.reduce(a,function(a,d){if(b.isArray(d))return a.concat(b.flatten(d));a[a.length]=d;return a},[])};b.without=function(a){return b.difference(a,f.call(arguments,1))};b.uniq=b.unique=function(a,c){return b.reduce(a,function(a,e,f){if(0==f||(c===!0?b.last(a)!=e:!b.include(a,e)))a[a.length]=e;return a},[])};b.union=function(){return b.uniq(b.flatten(arguments))};b.intersection=b.intersect=function(a){var c=f.call(arguments,1);return b.filter(b.uniq(a),
function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a,c){return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=f.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(o&&a.indexOf===o)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(a[d]===c)return d;return-1};b.lastIndexOf=function(a,
b){if(a==null)return-1;if(z&&a.lastIndexOf===z)return a.lastIndexOf(b);for(var d=a.length;d--;)if(a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);d=arguments[2]||1;for(var e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};b.bind=function(a,b){if(a.bind===q&&q)return q.apply(a,f.call(arguments,1));var d=f.call(arguments,2);return function(){return a.apply(b,d.concat(f.call(arguments)))}};b.bindAll=function(a){var c=f.call(arguments,1);
c.length==0&&(c=b.functions(a));h(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var b=c.apply(this,arguments);return l.call(d,b)?d[b]:d[b]=a.apply(this,arguments)}};b.delay=function(a,b){var d=f.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(f.call(arguments,1)))};var B=function(a,b,d){var e;return function(){var f=this,g=arguments,h=function(){e=null;
a.apply(f,g)};d&&clearTimeout(e);if(d||!e)e=setTimeout(h,b)}};b.throttle=function(a,b){return B(a,b,!1)};b.debounce=function(a,b){return B(a,b,!0)};b.once=function(a){var b=!1,d;return function(){if(b)return d;b=!0;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(f.call(arguments));return b.apply(this,d)}};b.compose=function(){var a=f.call(arguments);return function(){for(var b=f.call(arguments),d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=
function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}};b.keys=F||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[],d;for(d in a)l.call(a,d)&&(b[b.length]=d);return b};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){h(f.call(arguments,1),function(b){for(var d in b)b[d]!==void 0&&(a[d]=b[d])});return a};b.defaults=function(a){h(f.call(arguments,
1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,c){if(a===c)return!0;var d=typeof a;if(d!=typeof c)return!1;if(a==c)return!0;if(!a&&c||a&&!c)return!1;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual)return a.isEqual(c);if(c.isEqual)return c.isEqual(a);if(b.isDate(a)&&b.isDate(c))return a.getTime()===c.getTime();if(b.isNaN(a)&&b.isNaN(c))return!1;
if(b.isRegExp(a)&&b.isRegExp(c))return a.source===c.source&&a.global===c.global&&a.ignoreCase===c.ignoreCase&&a.multiline===c.multiline;if(d!=="object")return!1;if(a.length&&a.length!==c.length)return!1;d=b.keys(a);var e=b.keys(c);if(d.length!=e.length)return!1;for(var f in a)if(!(f in c)||!b.isEqual(a[f],c[f]))return!1;return!0};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(l.call(a,c))return!1;return!0};b.isElement=function(a){return!!(a&&a.nodeType==
1)};b.isArray=n||function(a){return E.call(a)==="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return!(!a||!l.call(a,"callee"))};b.isFunction=function(a){return!(!a||!a.constructor||!a.call||!a.apply)};b.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)};b.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===!0||a===!1};b.isDate=function(a){return!(!a||!a.getTimezoneOffset||
!a.setUTCFullYear)};b.isRegExp=function(a){return!(!a||!a.test||!a.exec||!(a.ignoreCase||a.ignoreCase===!1))};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.noConflict=function(){p._=C;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.mixin=function(a){h(b.functions(a),function(c){H(c,b[c]=a[c])})};var I=0;b.uniqueId=function(a){var b=I++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g};
b.template=function(a,c){var d=b.templateSettings;d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(d.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";d=new Function("obj",d);return c?d(c):d};
var j=function(a){this._wrapped=a};b.prototype=j.prototype;var r=function(a,c){return c?b(a).chain():a},H=function(a,c){j.prototype[a]=function(){var a=f.call(arguments);D.call(a,this._wrapped);return r(c.apply(b,a),this._chain)}};b.mixin(b);h(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=i[a];j.prototype[a]=function(){b.apply(this._wrapped,arguments);return r(this._wrapped,this._chain)}});h(["concat","join","slice"],function(a){var b=i[a];j.prototype[a]=function(){return r(b.apply(this._wrapped,
arguments),this._chain)}});j.prototype.chain=function(){this._chain=!0;return this};j.prototype.value=function(){return this._wrapped}})();

// Backbone.js 0.5.3
// (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://documentcloud.github.com/backbone
(function(){var h=this,p=h.Backbone,e;e=typeof exports!=="undefined"?exports:h.Backbone={};e.VERSION="0.5.3";var f=h._;if(!f&&typeof require!=="undefined")f=require("underscore")._;var g=h.jQuery||h.Zepto;e.noConflict=function(){h.Backbone=p;return this};e.emulateHTTP=!1;e.emulateJSON=!1;e.Events={bind:function(a,b,c){var d=this._callbacks||(this._callbacks={});(d[a]||(d[a]=[])).push([b,c]);return this},unbind:function(a,b){var c;if(a){if(c=this._callbacks)if(b){c=c[a];if(!c)return this;for(var d=
0,e=c.length;d<e;d++)if(c[d]&&b===c[d][0]){c[d]=null;break}}else c[a]=[]}else this._callbacks={};return this},trigger:function(a){var b,c,d,e,f=2;if(!(c=this._callbacks))return this;for(;f--;)if(b=f?a:"all",b=c[b])for(var g=0,h=b.length;g<h;g++)(d=b[g])?(e=f?Array.prototype.slice.call(arguments,1):arguments,d[0].apply(d[1]||this,e)):(b.splice(g,1),g--,h--);return this}};e.Model=function(a,b){var c;a||(a={});if(c=this.defaults)f.isFunction(c)&&(c=c.call(this)),a=f.extend({},c,a);this.attributes={};
this._escapedAttributes={};this.cid=f.uniqueId("c");this.set(a,{silent:!0});this._changed=!1;this._previousAttributes=f.clone(this.attributes);if(b&&b.collection)this.collection=b.collection;this.initialize(a,b)};f.extend(e.Model.prototype,e.Events,{_previousAttributes:null,_changed:!1,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.attributes[a];
return this._escapedAttributes[a]=(b==null?"":""+b).replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")},has:function(a){return this.attributes[a]!=null},set:function(a,b){b||(b={});if(!a)return this;if(a.attributes)a=a.attributes;var c=this.attributes,d=this._escapedAttributes;if(!b.silent&&this.validate&&!this._performValidation(a,b))return!1;if(this.idAttribute in a)this.id=a[this.idAttribute];
var e=this._changing;this._changing=!0;for(var g in a){var h=a[g];if(!f.isEqual(c[g],h))c[g]=h,delete d[g],this._changed=!0,b.silent||this.trigger("change:"+g,this,h,b)}!e&&!b.silent&&this._changed&&this.change(b);this._changing=!1;return this},unset:function(a,b){if(!(a in this.attributes))return this;b||(b={});var c={};c[a]=void 0;if(!b.silent&&this.validate&&!this._performValidation(c,b))return!1;delete this.attributes[a];delete this._escapedAttributes[a];a==this.idAttribute&&delete this.id;this._changed=
!0;b.silent||(this.trigger("change:"+a,this,void 0,b),this.change(b));return this},clear:function(a){a||(a={});var b,c=this.attributes,d={};for(b in c)d[b]=void 0;if(!a.silent&&this.validate&&!this._performValidation(d,a))return!1;this.attributes={};this._escapedAttributes={};this._changed=!0;if(!a.silent){for(b in c)this.trigger("change:"+b,this,void 0,a);this.change(a)}return this},fetch:function(a){a||(a={});var b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&
c(b,d)};a.error=i(a.error,b,a);return(this.sync||e.sync).call(this,"read",this,a)},save:function(a,b){b||(b={});if(a&&!this.set(a,b))return!1;var c=this,d=b.success;b.success=function(a,e,f){if(!c.set(c.parse(a,f),b))return!1;d&&d(c,a,f)};b.error=i(b.error,c,b);var f=this.isNew()?"create":"update";return(this.sync||e.sync).call(this,f,this,b)},destroy:function(a){a||(a={});if(this.isNew())return this.trigger("destroy",this,this.collection,a);var b=this,c=a.success;a.success=function(d){b.trigger("destroy",
b,b.collection,a);c&&c(b,d)};a.error=i(a.error,b,a);return(this.sync||e.sync).call(this,"delete",this,a)},url:function(){var a=k(this.collection)||this.urlRoot||l();if(this.isNew())return a;return a+(a.charAt(a.length-1)=="/"?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this)},isNew:function(){return this.id==null},change:function(a){this.trigger("change",this,a);this._previousAttributes=f.clone(this.attributes);this._changed=!1},hasChanged:function(a){if(a)return this._previousAttributes[a]!=
this.attributes[a];return this._changed},changedAttributes:function(a){a||(a=this.attributes);var b=this._previousAttributes,c=!1,d;for(d in a)f.isEqual(b[d],a[d])||(c=c||{},c[d]=a[d]);return c},previous:function(a){if(!a||!this._previousAttributes)return null;return this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},_performValidation:function(a,b){var c=this.validate(a);if(c)return b.error?b.error(this,c,b):this.trigger("error",this,c,b),!1;return!0}});
e.Collection=function(a,b){b||(b={});if(b.comparator)this.comparator=b.comparator;f.bindAll(this,"_onModelEvent","_removeReference");this._reset();a&&this.reset(a,{silent:!0});this.initialize.apply(this,arguments)};f.extend(e.Collection.prototype,e.Events,{model:e.Model,initialize:function(){},toJSON:function(){return this.map(function(a){return a.toJSON()})},add:function(a,b){if(f.isArray(a))for(var c=0,d=a.length;c<d;c++)this._add(a[c],b);else this._add(a,b);return this},remove:function(a,b){if(f.isArray(a))for(var c=
0,d=a.length;c<d;c++)this._remove(a[c],b);else this._remove(a,b);return this},get:function(a){if(a==null)return null;return this._byId[a.id!=null?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");this.models=this.sortBy(this.comparator);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},
reset:function(a,b){a||(a=[]);b||(b={});this.each(this._removeReference);this._reset();this.add(a,{silent:!0});b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a||(a={});var b=this,c=a.success;a.success=function(d,f,e){b[a.add?"add":"reset"](b.parse(d,e),a);c&&c(b,d)};a.error=i(a.error,b,a);return(this.sync||e.sync).call(this,"read",this,a)},create:function(a,b){var c=this;b||(b={});a=this._prepareModel(a,b);if(!a)return!1;var d=b.success;b.success=function(a,e,f){c.add(a,b);
d&&d(a,e,f)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId={};this._byCid={}},_prepareModel:function(a,b){if(a instanceof e.Model){if(!a.collection)a.collection=this}else{var c=a;a=new this.model(c,{collection:this});a.validate&&!a._performValidation(c,b)&&(a=!1)}return a},_add:function(a,b){b||(b={});a=this._prepareModel(a,b);if(!a)return!1;var c=this.getByCid(a);if(c)throw Error(["Can't add the same model to a set twice",
c.id]);this._byId[a.id]=a;this._byCid[a.cid]=a;this.models.splice(b.at!=null?b.at:this.comparator?this.sortedIndex(a,this.comparator):this.length,0,a);a.bind("all",this._onModelEvent);this.length++;b.silent||a.trigger("add",a,this,b);return a},_remove:function(a,b){b||(b={});a=this.getByCid(a)||this.get(a);if(!a)return null;delete this._byId[a.id];delete this._byCid[a.cid];this.models.splice(this.indexOf(a),1);this.length--;b.silent||a.trigger("remove",a,this,b);this._removeReference(a);return a},
_removeReference:function(a){this==a.collection&&delete a.collection;a.unbind("all",this._onModelEvent)},_onModelEvent:function(a,b,c,d){(a=="add"||a=="remove")&&c!=this||(a=="destroy"&&this._remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,arguments))}});f.each(["forEach","each","map","reduce","reduceRight","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max",
"min","sortBy","sortedIndex","toArray","size","first","rest","last","without","indexOf","lastIndexOf","isEmpty","groupBy"],function(a){e.Collection.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});e.Router=function(a){a||(a={});if(a.routes)this.routes=a.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var q=/:([\w\d]+)/g,r=/\*([\w\d]+)/g,s=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(e.Router.prototype,e.Events,{initialize:function(){},route:function(a,
b,c){e.history||(e.history=new e.History);f.isRegExp(a)||(a=this._routeToRegExp(a));e.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d))},this))},navigate:function(a,b){e.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(s,"\\$&").replace(q,
"([^/]*)").replace(r,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});e.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")};var j=/^#*/,t=/msie [\w.]+/,m=!1;f.extend(e.History.prototype,{interval:50,getFragment:function(a,b){if(a==null)if(this._hasPushState||b){a=window.location.pathname;var c=window.location.search;c&&(a+=c);a.indexOf(this.options.root)==0&&(a=a.substr(this.options.root.length))}else a=window.location.hash;return decodeURIComponent(a.replace(j,
""))},start:function(a){if(m)throw Error("Backbone.history has already been started");this.options=f.extend({},{root:"/"},this.options,a);this._wantsPushState=!!this.options.pushState;this._hasPushState=!(!this.options.pushState||!window.history||!window.history.pushState);a=this.getFragment();var b=document.documentMode;if(b=t.exec(navigator.userAgent.toLowerCase())&&(!b||b<=7))this.iframe=g('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);
this._hasPushState?g(window).bind("popstate",this.checkUrl):"onhashchange"in window&&!b?g(window).bind("hashchange",this.checkUrl):setInterval(this.checkUrl,this.interval);this.fragment=a;m=!0;a=window.location;b=a.pathname==this.options.root;if(this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;else if(this._wantsPushState&&this._hasPushState&&b&&a.hash)this.fragment=a.hash.replace(j,""),window.history.replaceState({},
document.title,a.protocol+"//"+a.host+this.options.root+this.fragment);if(!this.options.silent)return this.loadUrl()},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.iframe.location.hash));if(a==this.fragment||a==decodeURIComponent(this.fragment))return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(a){var b=this.fragment=this.getFragment(a);
return f.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){var c=(a||"").replace(j,"");if(!(this.fragment==c||this.fragment==decodeURIComponent(c))){if(this._hasPushState){var d=window.location;c.indexOf(this.options.root)!=0&&(c=this.options.root+c);this.fragment=c;window.history.pushState({},document.title,d.protocol+"//"+d.host+c)}else if(window.location.hash=this.fragment=c,this.iframe&&c!=this.getFragment(this.iframe.location.hash))this.iframe.document.open().close(),
this.iframe.location.hash=c;b&&this.loadUrl(a)}}});e.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.delegateEvents();this.initialize.apply(this,arguments)};var u=/^(\S+)\s*(.*)$/,n=["model","collection","el","id","attributes","className","tagName"];f.extend(e.View.prototype,e.Events,{tagName:"div",$:function(a){return g(a,this.el)},initialize:function(){},render:function(){return this},remove:function(){g(this.el).remove();return this},make:function(a,
b,c){a=document.createElement(a);b&&g(a).attr(b);c&&g(a).html(c);return a},delegateEvents:function(a){if(a||(a=this.events))for(var b in f.isFunction(a)&&(a=a.call(this)),g(this.el).unbind(".delegateEvents"+this.cid),a){var c=this[a[b]];if(!c)throw Error('Event "'+a[b]+'" does not exist');var d=b.match(u),e=d[1];d=d[2];c=f.bind(c,this);e+=".delegateEvents"+this.cid;d===""?g(this.el).bind(e,c):g(this.el).delegate(d,e,c)}},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=
0,c=n.length;b<c;b++){var d=n[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el){if(f.isString(this.el))this.el=g(this.el).get(0)}else{var a=this.attributes||{};if(this.id)a.id=this.id;if(this.className)a["class"]=this.className;this.el=this.make(this.tagName,a)}}});e.Model.extend=e.Collection.extend=e.Router.extend=e.View.extend=function(a,b){var c=v(this,a,b);c.extend=this.extend;return c};var w={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};e.sync=function(a,
b,c){var d=w[a];c=f.extend({type:d,dataType:"json"},c);if(!c.url)c.url=k(b)||l();if(!c.data&&b&&(a=="create"||a=="update"))c.contentType="application/json",c.data=JSON.stringify(b.toJSON());if(e.emulateJSON)c.contentType="application/x-www-form-urlencoded",c.data=c.data?{model:c.data}:{};if(e.emulateHTTP&&(d==="PUT"||d==="DELETE")){if(e.emulateJSON)c.data._method=d;c.type="POST";c.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)}}if(c.type!=="GET"&&!e.emulateJSON)c.processData=
!1;return g.ajax(c)};var o=function(){},v=function(a,b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){return a.apply(this,arguments)};f.extend(d,a);o.prototype=a.prototype;d.prototype=new o;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},k=function(a){if(!a||!a.url)return null;return f.isFunction(a.url)?a.url():a.url},l=function(){throw Error('A "url" property or function must be specified');},i=function(a,b,c){return function(d){a?
a(b,d,c):b.trigger("error",b,d,c)}}}).call(this);


