(function(c){var a=c.scrollTo=function(f,e,d){c(window).scrollTo(f,e,d)};a.defaults={axis:"xy",duration:parseFloat(c.fn.jquery)>=1.3?0:1};a.window=function(d){return c(window).scrollable()};c.fn.scrollable=function(){return this.map(function(){var e=this,d=!e.nodeName||c.inArray(e.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!d){return e}var f=(e.contentWindow||e).document||e.ownerDocument||e;return c.browser.safari||f.compatMode=="BackCompat"?f.body:f.documentElement})};c.fn.scrollTo=function(f,e,d){if(typeof e=="object"){d=e;e=0}if(typeof d=="function"){d={onAfter:d}}if(f=="max"){f=9000000000}d=c.extend({},a.defaults,d);e=e||d.speed||d.duration;d.queue=d.queue&&d.axis.length>1;if(d.queue){e/=2}d.offset=b(d.offset);d.over=b(d.over);return this.scrollable().each(function(){var m=this,k=c(m),l=f,j,h={},n=k.is("html,body");switch(typeof l){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(l)){l=b(l);break}l=c(l,this);case"object":if(l.is||l.style){j=(l=c(l)).offset()}}c.each(d.axis.split(""),function(r,s){var t=s=="x"?"Left":"Top",u=t.toLowerCase(),q="scroll"+t,o=m[q],p=s=="x"?"Width":"Height";if(j){h[q]=j[u]+(n?0:o-k.offset()[u]);if(d.margin){h[q]-=parseInt(l.css("margin"+t))||0;h[q]-=parseInt(l.css("border"+t+"Width"))||0}h[q]+=d.offset[u]||0;if(d.over[u]){h[q]+=l[p.toLowerCase()]()*d.over[u]}}else{h[q]=l[u]}if(/^\d+$/.test(h[q])){h[q]=h[q]<=0?0:Math.min(h[q],g(p))}if(!r&&d.queue){if(o!=h[q]){i(d.onAfterFirst)}delete h[q]}});i(d.onAfter);function i(o){k.animate(h,e,d.easing,o&&function(){o.call(this,f,d)})}function g(s){var p="scroll"+s;if(!n){return m[p]}var r="client"+s,q=m.ownerDocument.documentElement,o=m.ownerDocument.body;return Math.max(q[p],o[p])-Math.min(q[r],o[r])}}).end()};function b(d){return typeof d=="object"?d:{top:d,left:d}}})(jQuery);
;
(function(){var a=false,b=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.SammyClass=function(){};SammyClass.extend=function(g){var e=this.prototype;a=true;var d=new this();a=false;for(var c in g){d[c]=typeof g[c]=="function"&&typeof e[c]=="function"&&b.test(g[c])?(function(h,i){return function(){var k=this._super;this._super=e[h];var j=i.apply(this,arguments);this._super=k;return j}})(c,g[c]):g[c]}function f(){if(!a&&this.init){this.init.apply(this,arguments)}}f.prototype=d;f.constructor=f;f.extend=arguments.callee;return f}})();(function(a){a.srender=function(b,c,d){a.srender.cache=a.srender.cache||{};if(a.srender.cache[b]){fn=a.srender.cache[b]}else{if(typeof c=="undefined"){return false}fn=a.srender.cache[b]=new Function("obj",'var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push("'+c.replace(/[\r\t\n]/g," ").replace(/\"/g,'\\"').split("<%").join("\t").replace(/((^|%>)[^\t]*)/g,"$1\r").replace(/\t=(.*?)%>/g,'",$1,"').split("\t").join('");').split("%>").join('p.push("').split("\r").join("")+"\");}return p.join('');")}if(typeof d!="undefined"){return fn(d)}else{return fn}}})(jQuery);(function(d){var b="([^/]+)";var c=/:([\w\d]+)/g;var a=/\?([^#]*)$/;Sammy={};Sammy.VERSION="0.2.1";Sammy.Object=SammyClass.extend({init:function(e){d.extend(this,e)},clone:function(e){if(typeof e=="undefined"){e=this}return d.extend({},e)},toHash:function(){var e={};this.each(function(g,f){if(!d.isFunction(f)){e[g]=f}});return e},toHTML:function(){var e="";this.each(function(g,f){if(!d.isFunction(f)){e+="<strong>"+g+"</strong> "+f+"<br />"}});return e},uuid:function(){if(typeof this._uuid=="undefined"||!this._uuid){this._uuid=(new Date()).getTime()+"-"+parseInt(Math.random()*1000)}return this._uuid},each:function(){var g,f,h,e;g=this;if(typeof arguments[0]!="function"){f=arguments[0];h=arguments[1]}else{f=this;h=arguments[0]}e=function(){return h.apply(g,arguments)};d.each(f,e)},log:function(){var e=[].slice.call(arguments);e.unshift("["+Date()+"]");if(typeof window.console!="undefined"){window.console.log.apply(window.console,e)}else{if(typeof console!="undefined"){console.log.apply(this,e)}else{}}}});Sammy.Application=Sammy.Object.extend({ROUTE_VERBS:["get","post","put","delete"],APP_EVENTS:["run","unload","lookup-route","run-route","route-found","event-context-before","event-context-after","changed","error-404","check-form-submission","redirect"],_last_route:null,_running:false,data_store_name:"sammy-app",element_selector:"body",debug:false,silence_404:true,run_interval_every:50,init:function(e){var f=this;this.routes={};this.listeners={};this.befores=[];this.namespace=this.uuid();this.context_prototype=Sammy.EventContext.extend({});this.each(this.ROUTE_VERBS,function(g,h){this._defineRouteShortcut(h)});e.apply(this);if(this.debug){this.addLogger(function(h,g){f.log(f.toString(),h.cleaned_type,g||{})})}},toString:function(){return"Sammy.Application:"+this.element_selector},$element:function(){return d(this.element_selector)},route:function(k,h,m){var j=this;var l=[];var e;if(h.constructor==String){l=(h.match(c)||[]);for(e=0;e<l.length;e+=1){l[e]=l[e].replace(/^:/,"")}h=new RegExp(h.replace(c,b)+"$")}var f={verb:k,path:h,callback:m,param_names:l};if(typeof this.routes[k]=="undefined"||this.routes[k].length==0){this.routes[k]=[f]}else{var g=false;this.each(this.routes[k],function(o,n){if(h.toString().length>=n.path.toString().length){this.routes[k].splice(o,0,f);g=true;return false}});if(!g){this.routes[k].push(f)}}return f},eventNamespace:function(){return this.data_store_name+"-"+this.namespace+"-"},bind:function(e,g,h){if(typeof h=="undefined"){h=g}var f=function(){var k,i,j;k=arguments[0];i=arguments[1];j=arguments[2];k.cleaned_type=k.type.replace(i.eventNamespace(),"");h.apply(i,[k,j])};if(!this.listeners[e]){this.listeners[e]=[]}this.listeners[e].push(f);if(this.isRunning()){return this._listen(e,f)}},trigger:function(e,g,f){if(typeof f=="undefined"){f=new this.context_prototype(this,"bind",e,g)}return this.$element().triggerHandler(f.eventNamespace()+e,[f,g])},before:function(e){return this.befores.push(e)},after:function(e){return this.bind("event-context-after",e)},isRunning:function(){return this._running},helpers:function(e){this.context_prototype=this.context_prototype.extend(e)},run:function(e){if(this.isRunning()){return false}var f=this;this.each(this.listeners,function(g,h){this.each(h,function(k,j){this._listen(g,j)})});this.trigger("run",{start_url:e});this._running=true;this.$element().data(this.data_store_name,this);this.last_location=null;if(this.getLocation()==""&&typeof e!="undefined"){this.setLocation(e)}this._checkLocation();this._interval=setInterval(function(){f._checkLocation.apply(f)},this.run_interval_every);this.bind("changed",function(){f.$element().find("form:not(."+f.eventNamespace()+")").bind("submit",function(){return f._checkFormSubmission(this)}).addClass(f.eventNamespace())});d("body").bind("onunload",function(){f.unload()});this.trigger("changed")},unload:function(){if(!this.isRunning()){return false}var e=this;this.trigger("unload");clearInterval(this._interval);this.$element().find("form").unbind("submit").removeClass(e.eventNamespace());this.$element().removeData(this.data_store_name);this.each(this.listeners,function(f,g){this.each(g,function(j,h){this._unlisten(f,h)})});this._running=false},addLogger:function(e){this.each(this.APP_EVENTS,function(f,g){this.bind(g,e)})},_canonical:function(e){return e.replace(a,"")},lookupRoute:function(g,f){var e=false;this.trigger("lookup-route",{verb:g,path:f});if(typeof this.routes[g]!="undefined"){this.each(this.routes[g],function(j,h){if(this._canonical(f).match(h.path)){e=h;return false}})}return e},_parse_query:function(j){var g={},h,f,k,e;h=j.match(a);if(h){f=h[1].split("&");for(e=0;e<f.length;e+=1){k=f[e].split("=");g[k[0]]=k[1]}}return g},runRoute:function(l,i,k){this.trigger("run-route",{verb:l,path:i,params:k});if(typeof k=="undefined"){k={}}jQuery.extend(k,this._parse_query(i));var f=this.lookupRoute(l,i);if(f){this.trigger("route-found",{route:f});if((path_params=f.path.exec(this._canonical(i)))!=null){path_params.shift();this.each(path_params,function(m,n){if(f.param_names[m]){k[f.param_names[m]]=n}else{if(!k.splat){k.splat=[]}k.splat.push(n)}})}var g=new this.context_prototype(this,l,i,k);this.last_route=f;var e=true;var j=this.befores.slice(0);while(j.length>0){if(j.shift().apply(g)===false){return false}}g.trigger("event-context-before");var h=f.callback.apply(g);g.trigger("event-context-after");return h}else{this.notFound(l,i)}},getLocation:function(){var e=window.location.toString().match(/^[^#]*(#.+)$/);if(e){return e[1]}else{return""}},setLocation:function(e){window.location=e},swap:function(e){return this.$element().html(e)},notFound:function(f,e){this.trigger("error-404",{verb:f,path:e});throw ("404 Not Found "+f+" "+e)},_defineRouteShortcut:function(f){var e=this;this[f]=function(g,h){e.route.apply(e,[f,g,h])}},_checkLocation:function(){try{var f,g;f=this.getLocation();if(f!=this.last_location){g=this.runRoute("get",f)}this.last_location=f}catch(h){this.last_location=f;if(h.toString().match(/^404/)&&this.silence_404){return g}else{throw (h)}}return g},_checkFormSubmission:function(h){var f,j,l,k,g;this.trigger("check-form-submission",{form:h});f=d(h);j=f.attr("action");l=f.attr("method").toString().toLowerCase();k={};f.find(":input[type!=submit]").each(function(){if(d(this).is(":checkbox:not(:checked)")){k[d(this).attr("name")]=""}else{k[d(this).attr("name")]=d(this).val()}});try{g=this.runRoute(l,j,k);this.last_location=j}catch(i){if(i.toString().match(/^404/)&&this.silence_404){return true}else{throw (i)}}return(typeof g=="undefined")?false:g},_listen:function(e,f){return this.$element().bind(this.eventNamespace()+e,f)},_unlisten:function(e,f){return this.$element().unbind(this.eventNamespace()+e,f)}});Sammy.EventContext=Sammy.Object.extend({init:function(h,g,e,f){this.app=h;this.verb=g;this.path=e;this.params=f},$element:function(){return this.app.$element()},template:function(f,g,e){if(typeof e=="undefined"){e=f}return d.srender(e,f,d.extend({},g,this))},partial:function(h,g,j){var f,i,e;e=this;if(typeof j=="undefined"){if(typeof g=="function"){j=g;g={}}else{j=function(k){e.app.swap(k)}}}f=d.srender(h);g=d.extend({},g,this);if(f&&!this.app.debug){i=f(g);j.apply(e,[i]);e.trigger("changed")}else{d.get(h,function(k){i=d.srender(h,k,g);j.apply(e,[i]);e.trigger("changed")})}},redirect:function(e){this.trigger("redirect",{to:e});return this.app.setLocation(e)},trigger:function(e,f){return this.app.trigger(e,f,this)},eventNamespace:function(){return this.app.eventNamespace()},notFound:function(){return this.app.notFound(this.verb,this.path)}});d.sammy=function(e){return new Sammy.Application(e)}})(jQuery);
;
if(!Object.keys){Object.keys=function(c){var b=[];for(var a in c){if(c.hasOwnProperty(a)){b.push(a)}}return b}};
;
if(!Array.prototype.map){Array.prototype.map=function(b){var a=this.length>>>0;if(typeof b!="function"){throw new TypeError()}var e=new Array(a);var d=arguments[1];for(var c=0;c<a;c++){if(c in this){e[c]=b.call(d,this[c],c)}}return e}}if(!Array.prototype.reduce){Array.prototype.reduce=function(b){var a=this.length>>>0;if(typeof b!="function"){throw new TypeError()}if(a==0&&arguments.length==1){throw new TypeError()}var c=0;if(arguments.length>=2){var d=arguments[1]}else{do{if(c in this){d=this[c++];break}if(++c>=a){throw new TypeError()}}while(true);for(;c<a;c++){if(c in this){d=b.call(null,d,this[c],c,this)}}return d}}}if(!Array.prototype.inject){Array.prototype.inject=function(f,c,e){var b=this.length>>>0,a=f,d;if(typeof c!="function"){throw new TypeError()}for(d=0;d<b;d+=1){a=c.apply(e,[a,this[d],d])}return a}}if(!Array.prototype.filter){Array.prototype.filter=function(b){var a=this.length>>>0;if(typeof b!="function"){throw new TypeError()}var e=new Array();var d=arguments[1];for(var c=0;c<a;c++){if(c in this){var f=this[c];if(b.call(d,f,c)){e.push(f)}}}return e}}if(!Array.prototype.first){Array.prototype.first=function(){return this[0]}}if(!Array.prototype.last){Array.prototype.last=function(){var a=this.length>>>0;return this[a-1]}}if(!Array.prototype.unique){Array.prototype.unique=function unique(){var a=this;return this.filter(function(c,b){return $j.inArray(c,a)>=b})}}if(!Array.prototype.flat){Array.prototype.flat=function flat(){return this.inject([],function(a,b){if($j.isArray(b)){b.map(function(c){a.push(c)})}else{a.push(b)}return a})}};
;
jive.namespace("Pager");jive.Pager.Parameter=function(e,a){var f=a,d=Number(a)===a,h=$j.isArray(a);function g(i){switch(i){case"next":g(f+1);break;case"previous":g(f-1);break;case"first":g(1);break;default:if(Number(i)===i||i&&i.match&&i.match(/^[0-9]+/)){f=Number(i);if(f<1){f=1}}else{f=a}}}function b(i){if(i){if(typeof(i.split)=="function"){f=i.split("+")}else{f=i}}else{f=a}}function c(i){if(typeof(i)!="undefined"){f=i}else{f=a}}this.key=e;this.value=f;this.default_value=a;this.set=function(i){if(d){g(i)}else{if(h){b(i)}else{c(i)}}this.key=e;this.value=f;this.default_value=a;return f}};jive.Pager.Parameter.prototype={add:function(a){if(!$j.isArray(this.value)){throw new TypeError()}return this.set(this.value.concat(a).unique())},remove:function(a){if(!$j.isArray(this.value)){throw new TypeError()}return this.set(this.value.filter(function(b){return b!==a}))},unset:function(){return this.set()}};
;
jive.namespace("Pager");jive.Pager.MainView=function(g){var a=this,f=true,e=[];function d(i){var h=Array.prototype.slice.call(arguments,1);return e.inject(true,function(j,l){var k;if(typeof(l[i])=="function"){k=l[i].apply(a,h);return j&&(typeof(k)=="undefined"?true:k)}})}function c(h){var i;if(typeof(h.button)!="undefined"&&h.button!==0){return}i=$j(this).attr("href").match(/#.*$/);i=i?i[0]:$j(this).attr("href");return d("link_clicked",i)}$j("[href*=#/]").live("click",c);function b(){var j=$j(g),l=j.find("[tabindex]:first"),k=j.find("a:not([href^=#]):first"),i=j.find("a:first"),h=j.find(":input:not(:disabled):first");return[l,k,i,h].filter(function(m){return m.length>0}).first()}this.add_listener=function(h){e.push(h)};this.update=function(){b().focus()};this.unload=function(){$j("[href*=#/]").die("click",c)}};
;
jive.namespace("Pager");jive.Pager.Main=function(f,h,m,l){var d,c=["updated","created","alpha"],n=[],g={page:1,per_page:15,tags:[]},i=new jive.Pager.MainView(f);if(typeof(l)==="undefined"){l=true}$j.extend(g,m||{});Object.keys(g).map(function(o){n.push(new jive.Pager.Parameter(o,g[o]))});function k(o){var p=n.filter(function(q){return q.key==o}).first();if(!p){p=new jive.Pager.Parameter(o);n.push(p)}return p}function b(o){return k("page").set(o)}function a(){return n.sort(function(p,o){return p.key<o.key?-1:(p.key>o.key?1:0)}).map(function(o){if(o.key=="page"){return[["start",(k("page").value-1)*k("per_page").value]]}else{if(o.key=="per_page"){return[["range",k("per_page").value],["numResults",k("per_page").value]]}else{if($j.isArray(o.value)){return o.value.map(function(p){return[o.key,p]})}else{return[[o.key,o.value]]}}}}).flat().filter(function(o){return o[1]||o[1]===0}).map(function(o){return o.join("=")}).join("&")}function e(){return["#/",n.filter(function(o){return o.value&&(!$j.isArray(o.value)||o.value.length>0)&&o.value!=o.default_value}).sort(function(p,o){return p.key<o.key?-1:(p.key>o.key?1:0)}).map(function(o){if($j.isArray(o.value)){return[o.key,o.value.join("+")]}else{return[o.key,o.value]}}).map(function(o){return o.join("=")}).join("&")].filter(function(o){return o}).join("?")}function j(o){$j(f).load(h,a(),function(p,q){if(q=="success"){i.update();o.trigger("changed")}})}d=$j.sammy(function(){this.get(/^#\/$/,function(){var o=this;n.map(function(q){q.unset()});Object.keys(this.params).map(function(p){k(p).set(o.params[p])});j(this)});this.get("#/pages/:page_number",function(){b(this.params.page_number);this.redirect(e())});this.get(/^#\/page_sizes\/(\d*)$/,function(){k("per_page").set(this.params.splat[0]||this.params.numResults);b(1);this.redirect(e())});this.get("#/sorts/:sort_type",function(){k("sort").set(this.params.sort_type);k("prefix").set(this.params.prefix);b(1);this.redirect(e())});this.get("#/with_tags/:tags",function(){var o=k("tags");this.params.tags.split("+").map(function(p){o.add(p)});b(1);this.redirect(e())});this.get("#/without_tags/:tags",function(){var o=k("tags");this.params.tags.split("+").map(function(p){o.remove(p)});b(1);this.redirect(e())});this.get("#/parameters/",function(){var o=this;Object.keys(this.params).map(function(p){k(p).set(o.params[p])});b(1);this.redirect(e())});this.bind("update",function(){j(this)})});d.run();i.add_listener({link_clicked:function(p){try{d.runRoute("get",p);return false}catch(o){if(o.toString().match(/^404/)){return}else{throw (o)}}}});this.set_parameters=function(p){var o={};if(typeof(p.page)=="undefined"){b(1)}Object.keys(p).map(function(q){o[q]=k(q).set(p[q])});if(l){d.setLocation(e())}else{j(d)}return o};this.get_parameters=function(){var o={};n.map(function(q){o[q.key]=q.value});return o};this.update=function(){d.trigger("update")};this.unload=function(){d.unload();i.unload()};this._app=d};
;
(function(a){a.extend(a.fn,{livequery:function(f,e,d){var c=this,g;if(a.isFunction(f)){d=e,e=f,f=undefined}a.each(a.livequery.queries,function(h,j){if(c.selector==j.selector&&c.context==j.context&&f==j.type&&(!e||e.$lqguid==j.fn.$lqguid)&&(!d||d.$lqguid==j.fn2.$lqguid)){return(g=j)&&false}});g=g||new a.livequery(this.selector,this.context,f,e,d);g.stopped=false;a.livequery.run(g.id);return this},expire:function(f,e,d){var c=this;if(a.isFunction(f)){d=e,e=f,f=undefined}a.each(a.livequery.queries,function(g,h){if(c.selector==h.selector&&c.context==h.context&&(!f||f==h.type)&&(!e||e.$lqguid==h.fn.$lqguid)&&(!d||d.$lqguid==h.fn2.$lqguid)&&!this.stopped){a.livequery.stop(h.id)}});return this}});a.livequery=function(c,e,g,f,d){this.selector=c;this.context=e||document;this.type=g;this.fn=f;this.fn2=d;this.elements=[];this.stopped=false;this.id=a.livequery.queries.push(this)-1;f.$lqguid=f.$lqguid||a.livequery.guid++;if(d){d.$lqguid=d.$lqguid||a.livequery.guid++}return this};a.livequery.prototype={stop:function(){var c=this;if(this.type){this.elements.unbind(this.type,this.fn)}else{if(this.fn2){this.elements.each(function(d,e){c.fn2.apply(e)})}}this.elements=[];this.stopped=true},run:function(){if(this.stopped){return}var e=this;var f=this.elements,d=a(this.selector,this.context),c=d.not(f);this.elements=d;if(this.type){c.bind(this.type,this.fn);if(f.length>0){a.each(f,function(g,h){if(a.inArray(h,d)<0){a.event.remove(h,e.type,e.fn)}})}}else{c.each(function(){e.fn.apply(this)});if(this.fn2&&f.length>0){a.each(f,function(g,h){if(a.inArray(h,d)<0){e.fn2.apply(h)}})}}}};a.extend(a.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if(a.livequery.running&&a.livequery.queue.length){var c=a.livequery.queue.length;while(c--){a.livequery.queries[a.livequery.queue.shift()].run()}}},pause:function(){a.livequery.running=false},play:function(){a.livequery.running=true;a.livequery.run()},registerPlugin:function(){a.each(arguments,function(d,e){if(!a.fn[e]){return}var c=a.fn[e];a.fn[e]=function(){var f=c.apply(this,arguments);a.livequery.run();return f}})},run:function(c){if(c!=undefined){if(a.inArray(c,a.livequery.queue)<0){a.livequery.queue.push(c)}}else{a.each(a.livequery.queries,function(d){if(a.inArray(d,a.livequery.queue)<0){a.livequery.queue.push(d)}})}if(a.livequery.timeout){clearTimeout(a.livequery.timeout)}a.livequery.timeout=setTimeout(a.livequery.checkQueue,20)},stop:function(c){if(c!=undefined){a.livequery.queries[c].stop()}else{a.each(a.livequery.queries,function(d){a.livequery.queries[d].stop()})}}});a.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove");a(function(){a.livequery.play()});var b=a.prototype.init;a.prototype.init=function(d,f){var e=b.apply(this,arguments);if(d&&d.selector){e.context=d.context,e.selector=d.selector}if(typeof d=="string"){e.context=f||document,e.selector=d}return e};a.prototype.init.prototype=a.prototype})(jQuery);
;
jive.namespace("Autosubmitter",function(){function a(){$j(this).parents("form").trigger("submit")}$j("form.autosubmit:not(.autosubmit-registered) :input:not(:checkbox)").livequery("change",a);$j("form.autosubmit:not(.autosubmit-registered) :checkbox").livequery("click",a)});$j(document).ready(function(){var a=new jive.Autosubmitter()});
;
