
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console) {
    arguments.callee = arguments.callee.caller;
    var newarr = [].slice.call(arguments);
    (typeof console.log === 'object' ? log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr));
  }
};

// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
{console.log();return window.console;}catch(err){return window.console={};}})());

// place any jQuery/helper plugins in here, instead of separate, slower script files.

(function($){var managed={},cache={};$.manageAjax=function(){function create(name,opts){managed[name]=new $.manageAjax._manager(name,opts);return managed[name]}function destroy(name){if(managed[name]){managed[name].clear(true);delete managed[name]}}var publicFns={create:create,destroy:destroy};return publicFns}();$.manageAjax._manager=function(name,opts){this.requests={};this.inProgress=0;this.name=name;this.qName=name;this.opts=$.extend({},$.manageAjax.defaults,opts);if(opts&&opts.queue&&opts.queue!==
true&&typeof opts.queue==="string"&&opts.queue!=="clear")this.qName=opts.queue};$.manageAjax._manager.prototype={add:function(url,o){if(typeof url=="object")o=url;else if(typeof url=="string")o=$.extend(o||{},{url:url});o=$.extend({},this.opts,o);var origCom=o.complete||$.noop,origSuc=o.success||$.noop,beforeSend=o.beforeSend||$.noop,origError=o.error||$.noop,strData=typeof o.data=="string"?o.data:$.param(o.data||{}),xhrID=o.type+o.url+strData,that=this,ajaxFn=this._createAjax(xhrID,o,origSuc,origCom);
if(o.preventDoubleRequests&&o.queueDuplicateRequests){if(o.preventDoubleRequests)o.queueDuplicateRequests=false;setTimeout(function(){throw"preventDoubleRequests and queueDuplicateRequests can't be both true";},0)}if(this.requests[xhrID]&&o.preventDoubleRequests)return;ajaxFn.xhrID=xhrID;o.xhrID=xhrID;o.beforeSend=function(xhr,opts){var ret=beforeSend.call(this,xhr,opts);if(ret===false)that._removeXHR(xhrID);xhr=null;return ret};o.complete=function(xhr,status){that._complete.call(that,this,origCom,
xhr,status,xhrID,o);xhr=null};o.success=function(data,status,xhr){that._success.call(that,this,origSuc,data,status,xhr,o);xhr=null};o.error=function(ahr,status,errorStr){var httpStatus="",content="";if(status!=="timeout"&&ahr){httpStatus=ahr.status;content=ahr.responseXML||ahr.responseText}if(origError)origError.call(this,ahr,status,errorStr,o);else setTimeout(function(){throw status+"| status: "+httpStatus+" | URL: "+o.url+" | data: "+strData+" | thrown: "+errorStr+" | response: "+content;},0);ahr=
null};if(o.queue==="clear")$(document).clearQueue(this.qName);if(o.queue||o.queueDuplicateRequests&&this.requests[xhrID]){$.queue(document,this.qName,ajaxFn);if(this.inProgress<o.maxRequests&&(!this.requests[xhrID]||!o.queueDuplicateRequests))$.dequeue(document,this.qName);return xhrID}return ajaxFn()},_createAjax:function(id,o,origSuc,origCom){var that=this;return function(){if(o.beforeCreate.call(o.context||that,id,o)===false)return;that.inProgress++;if(that.inProgress===1)$.event.trigger(that.name+
"AjaxStart");if(o.cacheResponse&&cache[id])if(!cache[id].cacheTTL||cache[id].cacheTTL<0||(new Date).getTime()-cache[id].timestamp<cache[id].cacheTTL){that.requests[id]={};setTimeout(function(){that._success.call(that,o.context||o,origSuc,cache[id]._successData,"success",cache[id],o);that._complete.call(that,o.context||o,origCom,cache[id],"success",id,o)},0)}else delete cache[id];if(!o.cacheResponse||!cache[id])if(o.async)that.requests[id]=$.ajax(o);else $.ajax(o);return id}},_removeXHR:function(xhrID){if(this.opts.queue||
this.opts.queueDuplicateRequests)$.dequeue(document,this.qName);this.inProgress--;this.requests[xhrID]=null;delete this.requests[xhrID]},clearCache:function(){cache={}},_isAbort:function(xhr,status,o){if(!o.abortIsNoSuccess||!xhr&&!status)return false;var ret=!!(!xhr||xhr.readyState===0||this.lastAbort===o.xhrID);xhr=null;return ret},_complete:function(context,origFn,xhr,status,xhrID,o){if(this._isAbort(xhr,status,o)){status="abort";o.abort.call(context,xhr,status,o)}origFn.call(context,xhr,status,
o);$.event.trigger(this.name+"AjaxComplete",[xhr,status,o]);if(o.domCompleteTrigger)$(o.domCompleteTrigger).trigger(this.name+"DOMComplete",[xhr,status,o]).trigger("DOMComplete",[xhr,status,o]);this._removeXHR(xhrID);if(!this.inProgress)$.event.trigger(this.name+"AjaxStop");xhr=null},_success:function(context,origFn,data,status,xhr,o){var that=this;if(this._isAbort(xhr,status,o)){xhr=null;return}if(o.abortOld)$.each(this.requests,function(name){if(name===o.xhrID)return false;that.abort(name)});if(o.cacheResponse&&
!cache[o.xhrID]){if(!xhr)xhr={};cache[o.xhrID]={status:xhr.status,statusText:xhr.statusText,responseText:xhr.responseText,responseXML:xhr.responseXML,_successData:data,cacheTTL:o.cacheTTL,timestamp:(new Date).getTime()};if("getAllResponseHeaders"in xhr){var responseHeaders=xhr.getAllResponseHeaders();var parsedHeaders;var parseHeaders=function(){if(parsedHeaders)return;parsedHeaders={};$.each(responseHeaders.split("\n"),function(i,headerLine){var delimiter=headerLine.indexOf(":");parsedHeaders[headerLine.substr(0,
delimiter)]=headerLine.substr(delimiter+2)})};$.extend(cache[o.xhrID],{getAllResponseHeaders:function(){return responseHeaders},getResponseHeader:function(name){parseHeaders();return name in parsedHeaders?parsedHeaders[name]:null}})}}origFn.call(context,data,status,xhr,o);$.event.trigger(this.name+"AjaxSuccess",[xhr,o,data]);if(o.domSuccessTrigger)$(o.domSuccessTrigger).trigger(this.name+"DOMSuccess",[data,o]).trigger("DOMSuccess",[data,o]);xhr=null},getData:function(id){if(id){var ret=this.requests[id];
if(!ret&&this.opts.queue)ret=$.grep($(document).queue(this.qName),function(fn,i){return fn.xhrID===id})[0];return ret}return{requests:this.requests,queue:this.opts.queue?$(document).queue(this.qName):[],inProgress:this.inProgress}},abort:function(id){var xhr;if(id){xhr=this.getData(id);if(xhr&&xhr.abort){this.lastAbort=id;xhr.abort();this.lastAbort=false}else $(document).queue(this.qName,$.grep($(document).queue(this.qName),function(fn,i){return fn!==xhr}));xhr=null;return}var that=this,ids=[];$.each(this.requests,
function(id){ids.push(id)});$.each(ids,function(i,id){that.abort(id)})},clear:function(shouldAbort){$(document).clearQueue(this.qName);if(shouldAbort)this.abort()}};$.manageAjax._manager.prototype.getXHR=$.manageAjax._manager.prototype.getData;$.manageAjax.defaults={beforeCreate:$.noop,abort:$.noop,abortIsNoSuccess:true,maxRequests:1,cacheResponse:false,async:true,domCompleteTrigger:false,domSuccessTrigger:false,preventDoubleRequests:true,queueDuplicateRequests:false,cacheTTL:-1,queue:false};$.each($.manageAjax._manager.prototype,
function(n,fn){if(n.indexOf("_")===0||!$.isFunction(fn))return;$.manageAjax[n]=function(name,o){if(!managed[name])if(n==="add")$.manageAjax.create(name,o);else return;var args=Array.prototype.slice.call(arguments,1);managed[name][n].apply(managed[name],args)}})})(jQuery);

//IMAGESLOADED

/*!
 * jQuery imagesLoaded plugin v1.0.4
 * http://github.com/desandro/imagesloaded
 *
 * MIT License. by Paul Irish et al.
 */

(function($, undefined) {

  // $('#my-container').imagesLoaded(myFunction)
  // or
  // $('img').imagesLoaded(myFunction)

  // execute a callback when all images have loaded.
  // needed because .load() doesn't work on cached images

  // callback function gets image collection as argument
  //  `this` is the container

  $.fn.imagesLoaded = function( callback ) {
    var $this = this,
        $images = $this.find('img').add( $this.filter('img') ),
        len = $images.length,
        blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';

    function triggerCallback() {
      callback.call( $this, $images );
    }

    function imgLoaded( event ) {
      if ( --len <= 0 && event.target.src !== blank ){
        setTimeout( triggerCallback );
        $images.unbind( 'load error', imgLoaded );
      }
    }

    if ( !len ) {
      triggerCallback();
    }

    $images.bind( 'load error',  imgLoaded ).each( function() {
      // cached images don't fire load sometimes, so we reset src.
      if (this.complete || typeof this.complete === "undefined"){
        var src = this.src;
        // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
        // data uri bypasses webkit log warning (thx doug jones)
        this.src = blank;
        this.src = src;
      }
    });

    return $this;
  };
})(jQuery);


//SAMMY

(function($,window){var Sammy,PATH_REPLACER="([^/]+)",PATH_NAME_MATCHER=/:([\w\d]+)/g,QUERY_STRING_MATCHER=/\?([^#]*)$/,_makeArray=function(nonarray){return Array.prototype.slice.call(nonarray)},_isFunction=function(obj){return Object.prototype.toString.call(obj)==="[object Function]"},_isArray=function(obj){return Object.prototype.toString.call(obj)==="[object Array]"},_decode=function(str){return decodeURIComponent(str.replace(/\+/g," "))},_encode=encodeURIComponent,_escapeHTML=function(s){return String(s).replace(/&(?!\w+;)/g,
"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},_routeWrapper=function(verb){return function(path,callback){return this.route.apply(this,[verb,path,callback])}},_template_cache={},loggers=[];Sammy=function(){var args=_makeArray(arguments),app,selector;Sammy.apps=Sammy.apps||{};if(args.length===0||args[0]&&_isFunction(args[0]))return Sammy.apply(Sammy,["body"].concat(args));else if(typeof(selector=args.shift())=="string"){app=Sammy.apps[selector]||new Sammy.Application;app.element_selector=
selector;if(args.length>0)$.each(args,function(i,plugin){app.use(plugin)});if(app.element_selector!=selector)delete Sammy.apps[selector];Sammy.apps[app.element_selector]=app;return app}};Sammy.VERSION="0.6.3";Sammy.addLogger=function(logger){loggers.push(logger)};Sammy.log=function(){var args=_makeArray(arguments);args.unshift("["+Date()+"]");$.each(loggers,function(i,logger){logger.apply(Sammy,args)})};if(typeof window.console!="undefined")if(_isFunction(window.console.log.apply))Sammy.addLogger(function(){window.console.log.apply(window.console,
arguments)});else Sammy.addLogger(function(){window.console.log(arguments)});else if(typeof console!="undefined")Sammy.addLogger(function(){console.log.apply(console,arguments)});$.extend(Sammy,{makeArray:_makeArray,isFunction:_isFunction,isArray:_isArray});Sammy.Object=function(obj){return $.extend(this,obj||{})};$.extend(Sammy.Object.prototype,{escapeHTML:_escapeHTML,h:_escapeHTML,toHash:function(){var json={};$.each(this,function(k,v){if(!_isFunction(v))json[k]=v});return json},toHTML:function(){var display=
"";$.each(this,function(k,v){if(!_isFunction(v))display+="<strong>"+k+"</strong> "+v+"<br />"});return display},keys:function(attributes_only){var keys=[];for(var property in this)if(!_isFunction(this[property])||!attributes_only)keys.push(property);return keys},has:function(key){return this[key]&&$.trim(this[key].toString())!=""},join:function(){var args=_makeArray(arguments);var delimiter=args.shift();return args.join(delimiter)},log:function(){Sammy.log.apply(Sammy,arguments)},toString:function(include_functions){var s=
[];$.each(this,function(k,v){if(!_isFunction(v)||include_functions)s.push('"'+k+'": '+v.toString())});return"Sammy.Object: {"+s.join(",")+"}"}});Sammy.HashLocationProxy=function(app,run_interval_every){this.app=app;this.is_native=false;this._startPolling(run_interval_every)};Sammy.HashLocationProxy.prototype={bind:function(){var proxy=this,app=this.app;$(window).bind("hashchange."+this.app.eventNamespace(),function(e,non_native){if(proxy.is_native===false&&!non_native){Sammy.log("native hash change exists, using");
proxy.is_native=true;window.clearInterval(Sammy.HashLocationProxy._interval)}app.trigger("location-changed")});if(!Sammy.HashLocationProxy._bindings)Sammy.HashLocationProxy._bindings=0;Sammy.HashLocationProxy._bindings++},unbind:function(){$(window).unbind("hashchange."+this.app.eventNamespace());Sammy.HashLocationProxy._bindings--;if(Sammy.HashLocationProxy._bindings<=0)window.clearInterval(Sammy.HashLocationProxy._interval)},getLocation:function(){var matches=window.location.toString().match(/^[^#]*(#.+)$/);
return matches?matches[1]:""},setLocation:function(new_location){return window.location=new_location},_startPolling:function(every){var proxy=this;if(!Sammy.HashLocationProxy._interval){if(!every)every=10;var hashCheck=function(){var current_location=proxy.getLocation();if(!Sammy.HashLocationProxy._last_location||current_location!=Sammy.HashLocationProxy._last_location)window.setTimeout(function(){$(window).trigger("hashchange",[true])},13);Sammy.HashLocationProxy._last_location=current_location};
hashCheck();Sammy.HashLocationProxy._interval=window.setInterval(hashCheck,every)}}};Sammy.Application=function(app_function){var app=this;this.routes={};this.listeners=new Sammy.Object({});this.arounds=[];this.befores=[];this.namespace=(new Date).getTime()+"-"+parseInt(Math.random()*1E3,10);this.context_prototype=function(){Sammy.EventContext.apply(this,arguments)};this.context_prototype.prototype=new Sammy.EventContext;if(_isFunction(app_function))app_function.apply(this,[this]);if(!this._location_proxy)this.setLocationProxy(new Sammy.HashLocationProxy(this,
this.run_interval_every));if(this.debug)this.bindToAllEvents(function(e,data){app.log(app.toString(),e.cleaned_type,data||{})})};Sammy.Application.prototype=$.extend({},Sammy.Object.prototype,{ROUTE_VERBS:["get","post","put","delete"],APP_EVENTS:["run","unload","lookup-route","run-route","route-found","event-context-before","event-context-after","changed","error","check-form-submission","redirect","location-changed"],_last_route:null,_location_proxy:null,_running:false,element_selector:"body",debug:false,
raise_errors:false,run_interval_every:50,template_engine:null,toString:function(){return"Sammy.Application:"+this.element_selector},$element:function(selector){return selector?$(this.element_selector).find(selector):$(this.element_selector)},use:function(){var args=_makeArray(arguments),plugin=args.shift(),plugin_name=plugin||"";try{args.unshift(this);if(typeof plugin=="string"){plugin_name="Sammy."+plugin;plugin=Sammy[plugin]}plugin.apply(this,args)}catch(e){if(typeof plugin==="undefined")this.error("Plugin Error: called use() but plugin ("+
plugin_name.toString()+") is not defined",e);else if(!_isFunction(plugin))this.error("Plugin Error: called use() but '"+plugin_name.toString()+"' is not a function",e);else this.error("Plugin Error",e)}return this},setLocationProxy:function(new_proxy){var original_proxy=this._location_proxy;this._location_proxy=new_proxy;if(this.isRunning()){if(original_proxy)original_proxy.unbind();this._location_proxy.bind()}},route:function(verb,path,callback){var app=this,param_names=[],add_route,path_match;if(!callback&&
_isFunction(path)){path=verb;callback=path;verb="any"}verb=verb.toLowerCase();if(path.constructor==String){PATH_NAME_MATCHER.lastIndex=0;while((path_match=PATH_NAME_MATCHER.exec(path))!==null)param_names.push(path_match[1]);path=new RegExp("^"+path.replace(PATH_NAME_MATCHER,PATH_REPLACER)+"$")}if(typeof callback=="string")callback=app[callback];add_route=function(with_verb){var r={verb:with_verb,path:path,callback:callback,param_names:param_names};app.routes[with_verb]=app.routes[with_verb]||[];app.routes[with_verb].push(r)};
if(verb==="any")$.each(this.ROUTE_VERBS,function(i,v){add_route(v)});else add_route(verb);return this},get:_routeWrapper("get"),post:_routeWrapper("post"),put:_routeWrapper("put"),del:_routeWrapper("delete"),any:_routeWrapper("any"),mapRoutes:function(route_array){var app=this;$.each(route_array,function(i,route_args){app.route.apply(app,route_args)});return this},eventNamespace:function(){return["sammy-app",this.namespace].join("-")},bind:function(name,data,callback){var app=this;if(typeof callback==
"undefined")callback=data;var listener_callback=function(){var e,context,data;e=arguments[0];data=arguments[1];if(data&&data.context){context=data.context;delete data.context}else context=new app.context_prototype(app,"bind",e.type,data,e.target);e.cleaned_type=e.type.replace(app.eventNamespace(),"");callback.apply(context,[e,data])};if(!this.listeners[name])this.listeners[name]=[];this.listeners[name].push(listener_callback);if(this.isRunning())this._listen(name,listener_callback);return this},trigger:function(name,
data){this.$element().trigger([name,this.eventNamespace()].join("."),[data]);return this},refresh:function(){this.last_location=null;this.trigger("location-changed");return this},before:function(options,callback){if(_isFunction(options)){callback=options;options={}}this.befores.push([options,callback]);return this},after:function(callback){return this.bind("event-context-after",callback)},around:function(callback){this.arounds.push(callback);return this},isRunning:function(){return this._running},
helpers:function(extensions){$.extend(this.context_prototype.prototype,extensions);return this},helper:function(name,method){this.context_prototype.prototype[name]=method;return this},run:function(start_url){if(this.isRunning())return false;var app=this;$.each(this.listeners.toHash(),function(name,callbacks){$.each(callbacks,function(i,listener_callback){app._listen(name,listener_callback)})});this.trigger("run",{start_url:start_url});this._running=true;this.last_location=null;if(this.getLocation()==
""&&typeof start_url!="undefined")this.setLocation(start_url);this._checkLocation();this._location_proxy.bind();this.bind("location-changed",function(){app._checkLocation()});this.bind("submit",function(e){var returned=app._checkFormSubmission($(e.target).closest("form"));return returned===false?e.preventDefault():false});$(window).bind("beforeunload",function(){app.unload()});return this.trigger("changed")},unload:function(){if(!this.isRunning())return false;var app=this;this.trigger("unload");this._location_proxy.unbind();
this.$element().unbind("submit").removeClass(app.eventNamespace());$.each(this.listeners.toHash(),function(name,listeners){$.each(listeners,function(i,listener_callback){app._unlisten(name,listener_callback)})});this._running=false;return this},bindToAllEvents:function(callback){var app=this;$.each(this.APP_EVENTS,function(i,e){app.bind(e,callback)});$.each(this.listeners.keys(true),function(i,name){if(app.APP_EVENTS.indexOf(name)==-1)app.bind(name,callback)});return this},routablePath:function(path){return path.replace(QUERY_STRING_MATCHER,
"")},lookupRoute:function(verb,path){var app=this,routed=false;this.trigger("lookup-route",{verb:verb,path:path});if(typeof this.routes[verb]!="undefined")$.each(this.routes[verb],function(i,route){if(app.routablePath(path).match(route.path)){routed=route;return false}});return routed},runRoute:function(verb,path,params,target){var app=this,route=this.lookupRoute(verb,path),context,wrapped_route,arounds,around,befores,before,callback_args,path_params,final_returned;this.log("runRoute",[verb,path].join(" "));
this.trigger("run-route",{verb:verb,path:path,params:params});if(typeof params=="undefined")params={};$.extend(params,this._parseQueryString(path));if(route){this.trigger("route-found",{route:route});if((path_params=route.path.exec(this.routablePath(path)))!==null){path_params.shift();$.each(path_params,function(i,param){if(route.param_names[i])params[route.param_names[i]]=_decode(param);else{if(!params.splat)params.splat=[];params.splat.push(_decode(param))}})}context=new this.context_prototype(this,
verb,path,params,target);arounds=this.arounds.slice(0);befores=this.befores.slice(0);callback_args=[context].concat(params.splat);wrapped_route=function(){var returned;while(befores.length>0){before=befores.shift();if(app.contextMatchesOptions(context,before[0])){returned=before[1].apply(context,[context]);if(returned===false)return false}}app.last_route=route;context.trigger("event-context-before",{context:context});returned=route.callback.apply(context,callback_args);context.trigger("event-context-after",
{context:context});return returned};$.each(arounds.reverse(),function(i,around){var last_wrapped_route=wrapped_route;wrapped_route=function(){return around.apply(context,[last_wrapped_route])}});try{final_returned=wrapped_route()}catch(e){this.error(["500 Error",verb,path].join(" "),e)}return final_returned}else return this.notFound(verb,path)},contextMatchesOptions:function(context,match_options,positive){var options=match_options;if(typeof options==="undefined"||options=={})return true;if(typeof positive===
"undefined")positive=true;if(typeof options==="string"||_isFunction(options.test))options={path:options};if(options.only)return this.contextMatchesOptions(context,options.only,true);else if(options.except)return this.contextMatchesOptions(context,options.except,false);var path_matched=true,verb_matched=true;if(options.path)if(_isFunction(options.path.test))path_matched=options.path.test(context.path);else path_matched=options.path.toString()===context.path;if(options.verb)verb_matched=options.verb===
context.verb;return positive?verb_matched&&path_matched:!(verb_matched&&path_matched)},getLocation:function(){return this._location_proxy.getLocation()},setLocation:function(new_location){return this._location_proxy.setLocation(new_location)},swap:function(content){return this.$element().html(content)},templateCache:function(key,value){if(typeof value!="undefined")return _template_cache[key]=value;else return _template_cache[key]},clearTemplateCache:function(){return _template_cache={}},notFound:function(verb,
path){var ret=this.error(["404 Not Found",verb,path].join(" "));return verb==="get"?ret:true},error:function(message,original_error){if(!original_error)original_error=new Error;original_error.message=[message,original_error.message].join(" ");this.trigger("error",{message:original_error.message,error:original_error});if(this.raise_errors)throw original_error;else this.log(original_error.message,original_error)},_checkLocation:function(){var location,returned;location=this.getLocation();if(!this.last_location||
this.last_location[0]!="get"||this.last_location[1]!=location){this.last_location=["get",location];returned=this.runRoute("get",location)}return returned},_getFormVerb:function(form){var $form=$(form),verb,$_method;$_method=$form.find('input[name="_method"]');if($_method.length>0)verb=$_method.val();if(!verb)verb=$form[0].getAttribute("method");if(!verb||verb=="")verb="get";return $.trim(verb.toString().toLowerCase())},_checkFormSubmission:function(form){var $form,path,verb,params,returned;this.trigger("check-form-submission",
{form:form});$form=$(form);path=$form.attr("action");verb=this._getFormVerb($form);this.log("_checkFormSubmission",$form,path,verb);if(verb==="get"){this.setLocation(path+"?"+this._serializeFormParams($form));returned=false}else{params=$.extend({},this._parseFormParams($form));returned=this.runRoute(verb,path,params,form.get(0))}return typeof returned=="undefined"?false:returned},_serializeFormParams:function($form){var queryString="",fields=$form.serializeArray(),i;if(fields.length>0){queryString=
this._encodeFormPair(fields[0].name,fields[0].value);for(i=1;i<fields.length;i++)queryString=queryString+"&"+this._encodeFormPair(fields[i].name,fields[i].value)}return queryString},_encodeFormPair:function(name,value){return _encode(name)+"="+_encode(value)},_parseFormParams:function($form){var params={},form_fields=$form.serializeArray(),i;for(i=0;i<form_fields.length;i++)params=this._parseParamPair(params,form_fields[i].name,form_fields[i].value);return params},_parseQueryString:function(path){var params=
{},parts,pairs,pair,i;parts=path.match(QUERY_STRING_MATCHER);if(parts){pairs=parts[1].split("&");for(i=0;i<pairs.length;i++){pair=pairs[i].split("=");params=this._parseParamPair(params,_decode(pair[0]),_decode(pair[1]))}}return params},_parseParamPair:function(params,key,value){if(params[key])if(_isArray(params[key]))params[key].push(value);else params[key]=[params[key],value];else params[key]=value;return params},_listen:function(name,callback){return this.$element().bind([name,this.eventNamespace()].join("."),
callback)},_unlisten:function(name,callback){return this.$element().unbind([name,this.eventNamespace()].join("."),callback)}});Sammy.RenderContext=function(event_context){this.event_context=event_context;this.callbacks=[];this.previous_content=null;this.content=null;this.next_engine=false;this.waiting=false};Sammy.RenderContext.prototype=$.extend({},Sammy.Object.prototype,{then:function(callback){if(!_isFunction(callback))if(typeof callback==="string"&&callback in this.event_context){var helper=this.event_context[callback];
callback=function(content){return helper.apply(this.event_context,[content])}}else return this;var context=this;if(this.waiting)this.callbacks.push(callback);else{this.wait();window.setTimeout(function(){var returned=callback.apply(context,[context.content,context.previous_content]);if(returned!==false)context.next(returned)},13)}return this},wait:function(){this.waiting=true},next:function(content){this.waiting=false;if(typeof content!=="undefined"){this.previous_content=this.content;this.content=
content}if(this.callbacks.length>0)this.then(this.callbacks.shift())},load:function(location,options,callback){var context=this;return this.then(function(){var should_cache,cached,is_json,location_array;if(_isFunction(options)){callback=options;options={}}else options=$.extend({},options);if(callback)this.then(callback);if(typeof location==="string"){is_json=location.match(/\.json$/)||options.json;should_cache=is_json&&options.cache===true||options.cache!==false;context.next_engine=context.event_context.engineFor(location);
delete options.cache;delete options.json;if(options.engine){context.next_engine=options.engine;delete options.engine}if(should_cache&&(cached=this.event_context.app.templateCache(location)))return cached;this.wait();$.ajax($.extend({url:location,data:{},dataType:is_json?"json":null,type:"get",success:function(data){if(should_cache)context.event_context.app.templateCache(location,data);context.next(data)}},options));return false}else{if(location.nodeType)return location.innerHTML;if(location.selector){context.next_engine=
location.attr("data-engine");if(options.clone===false)return location.remove()[0].innerHTML.toString();else return location[0].innerHTML.toString()}}})},render:function(location,data,callback){if(_isFunction(location)&&!data)return this.then(location);else{if(!data&&this.content)data=this.content;return this.load(location).interpolate(data,location).then(callback)}},partial:function(location,data){return this.render(location,data).swap()},send:function(){var context=this,args=_makeArray(arguments),
fun=args.shift();if(_isArray(args[0]))args=args[0];return this.then(function(content){args.push(function(response){context.next(response)});context.wait();fun.apply(fun,args);return false})},collect:function(array,callback,now){var context=this;var coll=function(){if(_isFunction(array)){callback=array;array=this.content}var contents=[],doms=false;$.each(array,function(i,item){var returned=callback.apply(context,[i,item]);if(returned.jquery&&returned.length==1){returned=returned[0];doms=true}contents.push(returned);
return returned});return doms?contents:contents.join("")};return now?coll():this.then(coll)},renderEach:function(location,name,data,callback){if(_isArray(name)){callback=data;data=name;name=null}return this.load(location).then(function(content){var rctx=this;if(!data)data=_isArray(this.previous_content)?this.previous_content:[];if(callback)$.each(data,function(i,value){var idata={},engine=this.next_engine||location;name?idata[name]=value:idata=value;callback(value,rctx.event_context.interpolate(content,
idata,engine))});else return this.collect(data,function(i,value){var idata={},engine=this.next_engine||location;name?idata[name]=value:idata=value;return this.event_context.interpolate(content,idata,engine)},true)})},interpolate:function(data,engine,retain){var context=this;return this.then(function(content,prev){if(!data&&prev)data=prev;if(this.next_engine){engine=this.next_engine;this.next_engine=false}var rendered=context.event_context.interpolate(content,data,engine);return retain?prev+rendered:
rendered})},swap:function(){return this.then(function(content){this.event_context.swap(content)}).trigger("changed",{})},appendTo:function(selector){return this.then(function(content){$(selector).append(content)}).trigger("changed",{})},prependTo:function(selector){return this.then(function(content){$(selector).prepend(content)}).trigger("changed",{})},replace:function(selector){return this.then(function(content){$(selector).html(content)}).trigger("changed",{})},trigger:function(name,data){return this.then(function(content){if(typeof data==
"undefined")data={content:content};this.event_context.trigger(name,data)})}});Sammy.EventContext=function(app,verb,path,params,target){this.app=app;this.verb=verb;this.path=path;this.params=new Sammy.Object(params);this.target=target};Sammy.EventContext.prototype=$.extend({},Sammy.Object.prototype,{$element:function(){return this.app.$element(_makeArray(arguments).shift())},engineFor:function(engine){var context=this,engine_match;if(_isFunction(engine))return engine;engine=(engine||context.app.template_engine).toString();
if(engine_match=engine.match(/\.([^\.]+)$/))engine=engine_match[1];if(engine&&_isFunction(context[engine]))return context[engine];if(context.app.template_engine)return this.engineFor(context.app.template_engine);return function(content,data){return content}},interpolate:function(content,data,engine){return this.engineFor(engine).apply(this,[content,data])},render:function(location,data,callback){return(new Sammy.RenderContext(this)).render(location,data,callback)},renderEach:function(location,name,
data,callback){return(new Sammy.RenderContext(this)).renderEach(location,name,data,callback)},load:function(location,options,callback){return(new Sammy.RenderContext(this)).load(location,options,callback)},partial:function(location,data){return(new Sammy.RenderContext(this)).partial(location,data)},send:function(){var rctx=new Sammy.RenderContext(this);return rctx.send.apply(rctx,arguments)},redirect:function(){var to,args=_makeArray(arguments),current_location=this.app.getLocation();if(args.length>
1){args.unshift("/");to=this.join.apply(this,args)}else to=args[0];this.trigger("redirect",{to:to});this.app.last_location=[this.verb,this.path];this.app.setLocation(to);if(current_location==to)this.app.trigger("location-changed")},trigger:function(name,data){if(typeof data=="undefined")data={};if(!data.context)data.context=this;return this.app.trigger(name,data)},eventNamespace:function(){return this.app.eventNamespace()},swap:function(contents){return this.app.swap(contents)},notFound:function(){return this.app.notFound(this.verb,
this.path)},json:function(string){return $.parseJSON(string)},toString:function(){return"Sammy.EventContext: "+[this.verb,this.path,this.params].join(" ")}});$.sammy=window.Sammy=Sammy})(jQuery,window);

//TINYSCROLLBAR

(function($){$.tiny=$.tiny||{};$.tiny.scrollbar={options:{axis:'y',wheel:40,scroll:true,size:'auto',sizethumb:'auto'}};$.fn.tinyscrollbar=function(options){var options=$.extend({},$.tiny.scrollbar.options,options);this.each(function(){$(this).data('tsb',new Scrollbar($(this),options));});return this;};$.fn.tinyscrollbar_update=function(sScroll){return $(this).data('tsb').update(sScroll);};function Scrollbar(root,options){var oSelf=this;var oWrapper=root;var oViewport={obj:$('.viewport',root)};var oContent={obj:$('.overview',root)};var oScrollbar={obj:$('.scrollbar',root)};var oTrack={obj:$('.track',oScrollbar.obj)};var oThumb={obj:$('.thumb',oScrollbar.obj)};var sAxis=options.axis=='x',sDirection=sAxis?'left':'top',sSize=sAxis?'Width':'Height';var iScroll,iPosition={start:0,now:0},iMouse={};function initialize(){oSelf.update();setEvents();return oSelf;}
this.update=function(sScroll){oViewport[options.axis]=oViewport.obj[0]['offset'+sSize];oContent[options.axis]=oContent.obj[0]['scroll'+sSize];oContent.ratio=oViewport[options.axis]/oContent[options.axis];oScrollbar.obj.toggleClass('disable',oContent.ratio>=1);oTrack[options.axis]=options.size=='auto'?oViewport[options.axis]:options.size;oThumb[options.axis]=Math.min(oTrack[options.axis],Math.max(0,(options.sizethumb=='auto'?(oTrack[options.axis]*oContent.ratio):options.sizethumb)));oScrollbar.ratio=options.sizethumb=='auto'?(oContent[options.axis]/oTrack[options.axis]):(oContent[options.axis]-oViewport[options.axis])/(oTrack[options.axis]-oThumb[options.axis]);iScroll=(sScroll=='relative'&&oContent.ratio<=1)?Math.min((oContent[options.axis]-oViewport[options.axis]),Math.max(0,iScroll)):0;iScroll=(sScroll=='bottom'&&oContent.ratio<=1)?(oContent[options.axis]-oViewport[options.axis]):isNaN(parseInt(sScroll))?iScroll:parseInt(sScroll);setSize();};function setSize(){oThumb.obj.css(sDirection,iScroll/oScrollbar.ratio);oContent.obj.css(sDirection,-iScroll);iMouse['start']=oThumb.obj.offset()[sDirection];var sCssSize=sSize.toLowerCase();oScrollbar.obj.css(sCssSize,oTrack[options.axis]);oTrack.obj.css(sCssSize,oTrack[options.axis]);oThumb.obj.css(sCssSize,oThumb[options.axis]);};function setEvents(){oThumb.obj.bind('mousedown',start);oThumb.obj[0].ontouchstart=function(oEvent){oEvent.preventDefault();oThumb.obj.unbind('mousedown');start(oEvent.touches[0]);return false;};oTrack.obj.bind('mouseup',drag);if(options.scroll&&this.addEventListener){oWrapper[0].addEventListener('DOMMouseScroll',wheel,false);oWrapper[0].addEventListener('mousewheel',wheel,false);}
else if(options.scroll){oWrapper[0].onmousewheel=wheel;}};function start(oEvent){iMouse.start=sAxis?oEvent.pageX:oEvent.pageY;var oThumbDir=parseInt(oThumb.obj.css(sDirection));iPosition.start=oThumbDir=='auto'?0:oThumbDir;$(document).bind('mousemove',drag);document.ontouchmove=function(oEvent){$(document).unbind('mousemove');drag(oEvent.touches[0]);};$(document).bind('mouseup',end);oThumb.obj.bind('mouseup',end);oThumb.obj[0].ontouchend=document.ontouchend=function(oEvent){$(document).unbind('mouseup');oThumb.obj.unbind('mouseup');end(oEvent.touches[0]);};return false;};function wheel(oEvent){if(!(oContent.ratio>=1)){oEvent=$.event.fix(oEvent||window.event);var iDelta=oEvent.wheelDelta?oEvent.wheelDelta/120:-oEvent.detail/3;iScroll-=iDelta*options.wheel;iScroll=Math.min((oContent[options.axis]-oViewport[options.axis]),Math.max(0,iScroll));oThumb.obj.css(sDirection,iScroll/oScrollbar.ratio);oContent.obj.css(sDirection,-iScroll);oEvent.preventDefault();};};function end(oEvent){$(document).unbind('mousemove',drag);$(document).unbind('mouseup',end);oThumb.obj.unbind('mouseup',end);document.ontouchmove=oThumb.obj[0].ontouchend=document.ontouchend=null;return false;};function drag(oEvent){if(!(oContent.ratio>=1)){iPosition.now=Math.min((oTrack[options.axis]-oThumb[options.axis]),Math.max(0,(iPosition.start+((sAxis?oEvent.pageX:oEvent.pageY)-iMouse.start))));iScroll=iPosition.now*oScrollbar.ratio;oContent.obj.css(sDirection,-iScroll);oThumb.obj.css(sDirection,iPosition.now);}
return false;};return initialize();};})(jQuery);

//a freelance is around

