var route=function(path){return new route.fn.init(path)};route.fn=route.prototype={init:function(path){if(typeof window.routes=="undefined"){window.routes={}}if(typeof path=="undefined"){path=""}if(typeof args=="undefined"){var args={}}if(typeof this.events=="undefined"){this.events=new Array()}if(typeof bindPath=="undefined"){bindPath=""}this.args=args;this.path=path;this.bindPath=path;if(typeof window.routes[this.bindPath]=="undefined"){window.routes[this.bindPath]={}}if(typeof window.routes[this.bindPath].events=="undefined"){window.routes[this.bindPath].events=new Array()}if(typeof window.routes[this.bindPath].args=="undefined"){window.routes[this.bindPath].args={}}this.path=this.path.replace("//","/");if(this.path[this.path.length-1]=="/"){this.path=this.path.substring(0,this.path.length-1)}while(this.path[0]=="#"||this.path[0]=="/"){this.path=this.path.substring(1)}if(typeof window.routes[this.path]=="object"){for(var i=0;i<window.routes[this.path].events.length;i++){this.events.push(window.routes[this.path].events[i])}}else{for(r in window.routes){var A=this.path.split("/");var B=r.split("/");var D=false;var E=[];for(i=0;i<A.length;i++){var C=A[i];if(typeof B[i]!="undefined"&&(C==B[i]||B[i].indexOf(":")>-1)){D=true;continue}if(D){if(B[i]&&B[i].indexOf(":")>-1){var F=B[i].replace(/:/,"");E[F]=C}}}if(D){this.args=E;this.path=r;for(k=0;k<window.routes[r].events.length;k++){this.events.push(window.routes[r].events[k])}break}}}return this},bind:function(fn){if(this.bindPath==""){return"nothing to bind"}if(typeof fn!="function"){return"fn is invalid and cannot bind to route"}window.routes[this.bindPath].events.push(fn);return"fn bound to route"},run:function(A){if(this.events.length==0){return false}var B=(typeof window.routes.last_args=="undefined")?new Array():window.routes.last_args;for(var i=0;i<this.events.length;i++){var C=(window.routes.last_path==this.path);this.events[i](this.args,C,B,A);window.routes.last_args=this.args}window.routes.last_path=this.path;return true}};route.fn.init.prototype=route.fn;
