if(typeof window.console==='undefined'){window.console={};}
if(typeof window.console.emulated==='undefined'){if(typeof window.console.log==='function'){window.console.hasLog=true;}
else{if(typeof window.console.log==='undefined'){window.console.log=function(){};}
window.console.hasLog=false;}
if(typeof window.console.debug==='function'){window.console.hasDebug=true;}
else{if(typeof window.console.debug==='undefined'){window.console.debug=!window.console.hasLog?function(){}:function(){var arr=['console.debug:'];for(var i=0;i<arguments.length;i++){arr.push(arguments[i]);};window.console.log.apply(window.console,arr);};}
window.console.hasDebug=false;}
if(typeof window.console.warn==='function'){window.console.hasWarn=true;}
else{if(typeof window.console.warn==='undefined'){window.console.warn=!window.console.hasLog?function(){}:function(){var arr=['console.warn:'];for(var i=0;i<arguments.length;i++){arr.push(arguments[i]);};window.console.log.apply(window.console,arr);};}
window.console.hasWarn=false;}
if(typeof window.console.error==='function'){window.console.hasError=true;}
else{if(typeof window.console.error==='undefined'){window.console.error=function(){var msg="An error has occured.";if(window.console.hasLog){var arr=['console.error:'];for(var i=0;i<arguments.length;i++){arr.push(arguments[i]);};window.console.log.apply(window.console,arr);msg='An error has occured. More information is available in your browser\'s javascript console.'}
for(var i=0;i<arguments.length;++i){if(typeof arguments[i]!=='string'){break;}
msg+="\n"+arguments[i];}
if(typeof Error!=='undefined'){throw new Error(msg);}
else{throw(msg);}};}
window.console.hasError=false;}
if(typeof window.console.trace==='function'){window.console.hasTrace=true;}
else{if(typeof window.console.trace==='undefined'){window.console.trace=function(){window.console.error('console.trace does not exist');};}
window.console.hasTrace=false;}
window.console.emulated=true;}
String.prototype.trim=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,'');};String.prototype.strip=String.prototype.strip||function(value,regex){value=String(value);var str=this;if(value.length){if(!(regex||false)){value=value.replace(/([\[\]\(\)\^\$\.\?\|\/\\])/g,'\\$1');}
str=str.replace(eval('/^'+value+'+|'+value+'+$/g'),'');}
return String(str);}
String.prototype.stripLeft=String.prototype.stripLeft||function(value,regex){value=String(value);var str=this;if(value.length){if(!(regex||false)){value=value.replace(/([\[\]\(\)\^\$\.\?\|\/\\])/g,'\\$1');}
str=str.replace(eval('/^'+value+'+/g'),'');}
return String(str);}
String.prototype.stripRight=String.prototype.stripRight||function(value,regex){value=String(value);var str=this;if(value.length){if(!(regex||false)){value=value.replace(/([\[\]\(\)\^\$\.\?\|\/\\])/g,'\\$1');}
str=str.replace(eval('/'+value+'+$/g'),'');}
return String(str);}
String.prototype.toInt=String.prototype.toInt||function(){return parseInt(this,10);};String.prototype.wrap=String.prototype.wrap||function(start,end){return start+this+end;};String.prototype.wrapSelection=String.prototype.wrapSelection||function(start,end,a,z){if(typeof a==='undefined'||a===null)a=this.length;if(typeof z==='undefined'||z===null)z=this.length;return this.substring(0,a)+start+this.substring(a,z)+end+this.substring(z);};String.prototype.toSlug=String.prototype.toSlug||function(){return this.toLowerCase().replace(/[\s_]/g,'-').replace(/[^-a-z0-9]/g,'').replace(/--+/g,'-').replace(/^-+|-+$/g,'');}
String.prototype.queryStringToJSON=String.prototype.queryStringToJSON||function()
{var params=String(this);params=params.substring(params.indexOf('?')+1);params=params.replace(/\+/g,'%20');if(params.substring(0,1)==='{'&&params.substring(params.length-1)==='}')
{return eval(decodeURIComponent(params));}
params=params.split(/\&(amp\;)?/);var json={};for(var i=0,n=params.length;i<n;++i)
{var param=params[i]||null;if(param===null){continue;}
param=param.split('=');if(param===null){continue;}
var key=param[0]||null;if(key===null){continue;}
if(typeof param[1]==='undefined'){continue;}
var value=param[1];key=decodeURIComponent(key);value=decodeURIComponent(value);try{value=eval(value);}catch(e){}
var keys=key.split('.');if(keys.length===1)
{json[key]=value;}
else
{var path='',cmd='';$.each(keys,function(ii,key){path+='["'+key.replace(/"/g,'\\"')+'"]';jsonCLOSUREGLOBAL=json;cmd='if ( typeof jsonCLOSUREGLOBAL'+path+' === "undefined" ) jsonCLOSUREGLOBAL'+path+' = {}';eval(cmd);json=jsonCLOSUREGLOBAL;delete jsonCLOSUREGLOBAL;});jsonCLOSUREGLOBAL=json;valueCLOSUREGLOBAL=value;cmd='jsonCLOSUREGLOBAL'+path+' = valueCLOSUREGLOBAL';eval(cmd);json=jsonCLOSUREGLOBAL;delete jsonCLOSUREGLOBAL;delete valueCLOSUREGLOBAL;}}
return json;};(function($){$.fn.binder=$.fn.binder||function(event,data,callback){var $this=$(this);if((callback||false)){$this.bind(event,data,callback);}else{callback=data;$this.bind(event,callback);}
return $this;};$.fn.once=$.fn.once||function(event,data,callback){var $this=$(this);if((callback||false)){$this.unbind(event,callback);$this.bind(event,data,callback);}else{callback=data;$this.unbind(event,callback);$this.bind(event,callback);}
return $this;};$.fn.enter=$.fn.enter||function(data,callback){return $(this).binder('enter',data,callback);};$.event.special.enter=$.event.special.enter||{setup:function(data,namespaces){$(this).bind('keypress',$.event.special.enter.handler);},teardown:function(namespaces){$(this).unbind('keypress',$.event.special.enter.handler);},handler:function(event){var $el=$(this);var enterKey=event.keyCode===13;if(enterKey){event.type='enter';$.event.handle.apply(this,[event]);return true;}
return;}};$.fn.cancel=$.fn.cancel||function(data,callback){return $(this).binder('cancel',data,callback);};$.event.special.cancel=$.event.special.cancel||{setup:function(data,namespaces){$(this).bind('keyup',$.event.special.cancel.handler);},teardown:function(namespaces){$(this).unbind('keyup',$.event.special.cancel.handler);},handler:function(event){var $el=$(this);var moz=typeof event.DOM_VK_ESCAPE==='undefined'?false:event.DOM_VK_ESCAPE;var escapeKey=event.keyCode===27;if(moz||escapeKey){event.type='cancel';$.event.handle.apply(this,[event]);return true;}
return;}};$.fn.lastclick=$.fn.lastclick||function(data,callback){return $(this).binder('lastclick',data,callback);};$.event.special.lastclick=$.event.special.lastclick||{setup:function(data,namespaces){$(this).bind('click',$.event.special.lastclick.handler);},teardown:function(namespaces){$(this).unbind('click',$.event.special.lastclick.handler);},handler:function(event){var clear=function(){var Me=this;var $el=$(Me);var timeout=$el.data('lastclick-timeout')||false;if(timeout){clearTimeout(timeout);}
timeout=false;$el.data('lastclick-timeout',timeout);};var check=function(event){var Me=this;clear.call(Me);var $el=$(Me);$el.data('lastclick-clicks',($el.data('lastclick-clicks')||0)+1);var timeout=setTimeout(function(){var clicks=$el.data('lastclick-clicks');clear.apply(Me,[event]);$el.data('lastclick-clicks',0);event.type='lastclick';$.event.handle.apply(Me,[event,clicks])},500);$el.data('lastclick-timeout',timeout);};check.apply(this,[event]);}};$.fn.firstclick=$.fn.firstclick||function(data,callback){return $(this).binder('firstclick',data,callback);};$.event.special.firstclick=$.event.special.firstclick||{setup:function(data,namespaces){$(this).bind('click',$.event.special.firstclick.handler);},teardown:function(namespaces){$(this).unbind('click',$.event.special.firstclick.handler);},handler:function(event){var clear=function(event){var Me=this;var $el=$(Me);var timeout=$el.data('firstclick-timeout')||false;if(timeout){clearTimeout(timeout);}
timeout=false;$el.data('firstclick-timeout',timeout);};var check=function(event){var Me=this;clear.call(Me);var $el=$(Me);$el.data('firstclick-clicks',($el.data('firstclick-clicks')||0)+1);if($el.data('firstclick-clicks')===1){event.type='firstclick';$.event.handle.apply(Me,[event])}
var timeout=setTimeout(function(){clear.apply(Me,[event]);$el.data('firstclick-clicks',0);},500);$el.data('firstclick-timeout',timeout);};check.apply(this,[event]);}};$.fn.singleclick=$.fn.singleclick||function(data,callback){return $(this).binder('singleclick',data,callback);};$.event.special.singleclick=$.event.special.singleclick||{setup:function(data,namespaces){$(this).bind('click',$.event.special.singleclick.handler);},teardown:function(namespaces){$(this).unbind('click',$.event.special.singleclick.handler);},handler:function(event){var clear=function(event){var Me=this;var $el=$(Me);var timeout=$el.data('singleclick-timeout')||false;if(timeout){clearTimeout(timeout);}
timeout=false;$el.data('singleclick-timeout',timeout);};var check=function(event){var Me=this;clear.call(Me);var $el=$(Me);$el.data('singleclick-clicks',($el.data('singleclick-clicks')||0)+1);var timeout=setTimeout(function(){var clicks=$el.data('singleclick-clicks');clear.apply(Me,[event]);$el.data('singleclick-clicks',0);if(clicks===1){event.type='singleclick';$.event.handle.apply(Me,[event])}},500);$el.data('singleclick-timeout',timeout);};check.apply(this,[event]);}};})(jQuery);(function($){$.fn.opacityFix=$.fn.opacityFix||function(){var $this=$(this);var color=$this.css('background-color');if(color&&color!=='rgba(0, 0, 0, 0)'){return this;}
var $parent=$this;while($parent.inDOM()){$parent=$parent.parent();color=$parent.css('background-color');if(color&&color!=='rgba(0, 0, 0, 0)'){$this.css('background-color',color);break;}}
return this;};$.fn.parentsAndSelf=$.fn.parentsAndSelf||function(selector){var $this=$(this);return $this.parents(selector).andSelf().filter(selector);};$.fn.findAndSelf=$.fn.findAndSelf||function(selector){var $this=$(this);return $this.find(selector).andSelf().filter(selector);};$.fn.firstInput=$.fn.firstInput||function(){var $this=$(this);return $this.findAndSelf(':input').filter(':first');};$.fn.choose=$.fn.choose||function(value){var $this=$(this);if(typeof value==='undefined'){value=$this.val();}else if($this.val()!==value){return this;}
switch(true){case this.is('option'):$this.parents('select:first').choose(value);break;case $this.is(':checkbox'):$this.attr('checked',true);break;case $this.is(':radio'):$this.attr('checked',true);break;case $this.is('select'):$this.val(value);break;default:break;}
return this;};$.fn.unchoose=$.fn.unchoose||function(){var $this=$(this);switch(true){case $this.is('option'):$this.parents(':select:first').unchoose();break;case $this.is(':checkbox'):$this.attr('checked',false);break;case $this.is(':radio'):$this.attr('checked',false);break;case $this.is('select'):$this.val($this.find('option:first').val());break;default:break;}
return this;};$.fn.wouldSubmit=$.fn.wouldSubmit||function(){var $input=$(this).findAndSelf(':input');var result=true;if(!$input.length||!($input.attr('name')||false)||($input.is(':radio,:checkbox')&&!$input.is(':selected,:checked'))){result=false;}
return result;};$.fn.values=$.fn.values||function(){var $inputs=$(this).findAndSelf(':input');var values={};$inputs.each(function(){var $input=$(this);var name=$input.attr('name')||null;var value=$input.val();if(!$input.wouldSubmit()){return true;}
if(name.indexOf('[]')!==-1){if(typeof values[name]==='undefined'){values[name]=[];}
values[name].push(value);}
else{values[name]=value;}});return values;};$.fn.submitForm=$.fn.submitForm||function(){var $this=$(this);var $form=$this.parentsAndSelf('form:first').trigger('submit');return $this;};$.fn.inDOM=$.fn.inDOM||function(){var $ancestor=$(this).parent().parent();return $ancestor.size()&&($ancestor.height()||$ancestor.width());};$.fn.valWrap=$.fn.valWrap||function(start,end){var $field=$(this);return $field.val($field.val().wrap(start,end));};$.fn.valWrapSelection=$.fn.valWrapSelection||function(start,end,a,z){var $field=$(this);var field=$field.get(0);start=start||'';end=end||'';if(a||z){$field.val($field.val().wrapSelection(start,end,a,z));}
else{var a=field.selectionStart,z=field.selectionEnd;if(document.selection){field.focus();var sel=document.selection.createRange();sel.text=start+sel.text+end;}
else{var scrollTop=field.scrollTop;$field.val($field.val().wrapSelection(start,end,a,z));field.focus();field.selectionStart=a+start.length;field.selectionEnd=z+start.length;field.scrollTop=scrollTop;}}
return $field;};$.fn.giveFocus=$.fn.giveFocus||function(){var $this=$(this);var selector=':input:visible:first';$this.findAndSelf(selector).focus();return this;};$.fn.giveTarget=$.fn.giveTarget||function(){var $this=$(this);$('.target').removeClass('target');$this.addClass('target');return this;};$.fn.highlight=$.fn.highlight||function(duration){return $(this).effect('highlight',{},duration||3000);};$.fn.htmlAndSelf=$.fn.htmlAndSelf||function(){return $(this).attr('outerHTML');};$.fn.preventDefaultOnClick=$.fn.preventDefaultOnClick||function(){return $(this).click(function(event){event.preventDefault();return false;});};$.fn.attemptTypeChangeTo=$.fn.attemptTypeChangeTo||function(type){var $input=$(this),result=false,el=$input.get(0),oldType=el.type;if(type===oldType){result=true;}
else if($input.is('input')){if(!$.browser.msie){el.type=type;if(el.type!==oldType){result=true;}}}
return result;};})(jQuery);(function($){$.prepareObject=$.prepareObject||function(baseObject,userObject){var newObject={};var skipValue='$.prepareObject.skipValue';$.extend(newObject,baseObject||{});$.intercept(true,newObject,userObject);var objects=arguments;objects[0]=objects[1]=skipValue;$.each(objects,function(i,object){if(object===skipValue)return true;$.intercept(true,newObject,object);});return newObject;};$.intercept=$.intercept||function(){var objects=arguments,object,deep=false,copy=false;var skipValue='$.intercept.skipValue';if(typeof objects[0]==='boolean'){deep=objects[0];objects[0]=skipValue;if(typeof objects[1]==='boolean'){copy=objects[1];objects[1]=skipValue;if(copy){object={};}
else{object=objects[2];objects[2]=skipValue;}}
else{object=objects[1];objects[1]=skipValue;}}
else{object=objects[0];objects[0]=skipValue;}
var keys={};$.each(object,function(key){keys[key]=true;});if(deep){$.each(objects,function(i,v){if(v===skipValue)return true;$.each(v,function(key,value){if(typeof keys[key]==='undefined')return true;if(typeof value==='object'&&!(value.test||false&&value.exec||false)){$.extend(object[key],value||{});}
else{object[key]=value;}});})}
else{$.each(objects,function(i,v){$.each(v,function(key,value){if(typeof keys[key]==='undefined')return true;if(typeof value==='object'&&!(value.test||false&&value.exec||false)){$.intercept(true,object[key],value);}
else{object[key]=value;}});})}
return object;};$.promise=$.promise||function(options){var object=options.object||this;if(typeof object[options.handlers]==='undefined'){object[options.handlers]=[];}
if(typeof object[options.flag]==='undefined'){object[options.flag]=false;}
var handlers=object[options.handlers],flag=object[options.flag],handler=options.arguments[0];switch(typeof handler){case'boolean':flag=object[options.flag]=handler;case'undefined':if(flag&&handlers.length){$.each(handlers,function(i,handler){handler.call(object);});object[options.handlers]=[];}
break;case'function':if(flag){handler.call(object);}
else{object[options.handlers].push(handler);}
break;default:window.console.error('Unknown arguments for $.promise',[this,arguments]);break;}
return flag;}})(jQuery);(function($){if(!($.ScrollTo||false)){$.ScrollTo={config:{duration:400,easing:'swing',callback:undefined,durationMode:'each'},configure:function(options){var ScrollTo=$.ScrollTo;$.extend(ScrollTo.config,options||{});return this;},scroll:function(collections,config){var ScrollTo=$.ScrollTo;var collection=collections.pop(),$container=collection.$container,$target=collection.$target;var $inline=$('<span/>').css({'position':'absolute','top':'0px','left':'0px'});var position=$container.css('position');$container.css('position','relative');$inline.appendTo($container);var startOffset=$inline.offset().top,targetOffset=$target.offset().top,offsetDifference=targetOffset-startOffset;$inline.remove();$container.css('position',position);var callback=function(event){if(collections.length===0){if(typeof config.callback==='function'){config.callback.apply(this,[event]);}}
else{ScrollTo.scroll(collections,config);}
return true;};$container.animate({'scrollTop':offsetDifference+'px'},config.duration,config.easing,callback);return true;},fn:function(options){var ScrollTo=$.ScrollTo;var $target=$(this);if($target.length===0){return this;}
var $container=$target.parent(),collections=[];config=$.extend({},ScrollTo.config,options);while($container.length===1&&!$container.is('body')){var container=$container.get(0);if($container.css('overflow-y')!=='visible'&&container.scrollHeight!==container.clientHeight){collections.push({'$container':$container,'$target':$target});$target=$container;}
$container=$container.parent();}
collections.push({'$container':$($.browser.msie?'html':'body'),'$target':$target});if(config.durationMode==='all'){config.duration/=collections.length;}
ScrollTo.scroll(collections,config);return this;},construct:function(options){var ScrollTo=$.ScrollTo;$.fn.ScrollTo=ScrollTo.fn;ScrollTo.config=$.extend(ScrollTo.config,options);return this;}};$.ScrollTo.construct();}
else{window.console.warn("$.ScrollTo has already been defined...");}})(jQuery);(function($)
{if(!($.History||false)){$.History={options:{debug:false},state:'',$window:null,$iframe:null,handlers:{generic:[],specific:{}},extractHash:function(url){var hash=url.replace(/^[^#]*#/,'').replace(/^#+|#+$/,'');return hash;},getState:function(){var History=$.History;return History.state;},setState:function(state){var History=$.History;state=History.extractHash(state)
History.state=state;return History.state;},getHash:function(){var History=$.History;var hash=History.extractHash(window.location.hash||location.hash);return hash;},setHash:function(hash){var History=$.History;hash=History.extractHash(hash);if(typeof window.location.hash!=='undefined'){if(window.location.hash!==hash){window.location.hash=hash;}}else if(location.hash!==hash){location.hash=hash;}
return hash;},go:function(to){var History=$.History;to=History.extractHash(to);var hash=History.getHash(),state=History.getState();if(to!==hash){History.setHash(to);}else{if(to!==state){History.setState(to);}
History.trigger();}
return true;},hashchange:function(e){var History=$.History;var hash=History.getHash();History.go(hash);return true;},bind:function(state,handler){var History=$.History;if(handler){if(typeof History.handlers.specific[state]==='undefined'){History.handlers.specific[state]=[];}
History.handlers.specific[state].push(handler);}
else{handler=state;History.handlers.generic.push(handler);}
return true;},trigger:function(state){var History=$.History;if(typeof state==='undefined'){state=History.getState();}
var i,n,handler,list;if(typeof History.handlers.specific[state]!=='undefined'){list=History.handlers.specific[state];for(i=0,n=list.length;i<n;++i){handler=list[i];handler(state);}}
list=History.handlers.generic;for(i=0,n=list.length;i<n;++i){handler=list[i];handler(state);}
return true;},construct:function(){var History=$.History;$(document).ready(function(){History.domReady();});return true;},configure:function(options){var History=$.History;History.options=$.extend(History.options,options);return true;},domReadied:false,domReady:function(){var History=$.History;if(History.domRedied){return;}
History.domRedied=true;History.$window=$(window);History.$window.bind('hashchange',this.hashchange);setTimeout(History.hashchangeLoader,200);return true;},nativeSupport:function(browser){browser=browser||$.browser;var browserVersion=browser.version,browserVersionInt=parseInt(browserVersion,10),browserVersionParts=browserVersion.split(/[^0-9]/g),browserVersionPartsOne=parseInt(browserVersionParts[0],10),browserVersionPartsTwo=parseInt(browserVersionParts[1],10),browserVersionPartsThree=parseInt(browserVersionParts[2],10),nativeSupport=false;if((browser.msie||false)&&browserVersionInt>=8){nativeSupport=true;}
else if((browser.webkit||false)&&browserVersionInt>=528){nativeSupport=true;}
else if((browser.mozilla||false)){if(browserVersionPartsOne>1){nativeSupport=true;}
else if(browserVersionPartsOne===1){if(browserVersionPartsTwo>9){nativeSupport=true;}
else if(browserVersionPartsTwo===9){if(browserVersionPartsThree>=2){nativeSupport=true;}}}}
else if((browser.opera||false)){if(browserVersionPartsOne>10){nativeSupport=true;}
else if(browserVersionPartsOne===10){if(browserVersionPartsTwo>=60){nativeSupport=true;}}}
return nativeSupport;},hashchangeLoader:function(){var History=$.History;var nativeSupport=History.nativeSupport();if(!nativeSupport){var checker;if($.browser.msie){History.$iframe=$('<iframe id="jquery-history-iframe" style="display: none;"></$iframe>').prependTo(document.body)[0];History.$iframe.contentWindow.document.open();History.$iframe.contentWindow.document.close();var iframeHit=false;checker=function(){var hash=History.getHash();var state=History.getState();var iframeHash=History.extractHash(History.$iframe.contentWindow.document.location.hash);if(state!==hash){if(!iframeHit){History.$iframe.contentWindow.document.open();History.$iframe.contentWindow.document.close();History.$iframe.contentWindow.document.location.hash=hash;}
iframeHit=false;History.$window.trigger('hashchange');}
else{if(state!==iframeHash){iframeHit=true;History.setHash(iframeHash);}}};}
else{checker=function(){var hash=History.getHash();var state=History.getState();if(state!==hash){History.$window.trigger('hashchange');}};}
setInterval(checker,200);}
else{var hash=History.getHash();if(hash){History.$window.trigger('hashchange');}}
return true;}};$.History.construct();}
else{window.console.warn('$.History has already been defined...');}})(jQuery);(function($){$(document.body).addClass('js');if(!($.Ajaxy||false)){$.Ajaxy={options:{root_url:'',base_url:'',relative_url:'',request_match:false,no_log_class:'ajaxy-no_log',redirect:false,relative_as_base:true,support_text:true,analytics:true,auto_ajaxify:true,auto_ajaxify_documentReady:true,auto_sparkle_documentReady:true,add_sparkle_extension:true,scrollto_content:false,scrollto_options:{duration:800,easing:'swing'},anchor_param_name:'anchor',track_all_anchors:false,track_all_internal_links:false,debug:true,aliases:[['','/']],Controllers:{}},defaults:{Controller:{classname:null,selector:null,matches:null,controller:null,response:null,request:null,error:null,refresh:null},Action:{propagate:true,action:null,state:null,State:null,controller:null,Controller:null,forward:function(){window.console.error('Ajaxy.Action.forward: Forward never defined.',[this,arguments]);window.console.trace();},trigger:function(){window.console.error('Ajaxy.Action.trigger: Trigger never defined.',[this,arguments]);window.console.trace();},stopPropagation:function(){this.propagate=false;},preventDefault:function(){this.propagate=false;},documentReady:function($el,options){var Ajaxy=$.Ajaxy;var Action=this;if(typeof options!=='object'){options={};}
var defaults={};switch(Action.action){case'refresh':defaults.auto_ajaxify_documentReady=defaults.auto_sparkle_documentReady=false;break;default:break;}
var config=$.extend(true,{},defaults,options);return Ajaxy.stateCompleted(Action.State,$el,config);}},State:{mode:null,el:null,isLink:false,isForm:false,anchor:'',querystring:'',state:'',hash:'',location:'',locationShort:'',raw:{anchor:'',querystring:'',hash:'',state:'',location:'',locationShort:''},vanilla:{anchor:'',querystring:'',hash:'',state:'',location:'',locationShort:''},clean:{anchor:'',querystring:'',hash:'',state:'',location:'',locationShort:''},controller:null,Request:{url:null,data:{}},Response:{callback:null,data:{}},Error:{callback:null,data:{}},User:{data:{}}}},isConstructed:false,aliases:{},postpone:false,Controllers:{},States:{},ignoredStates:{},currentState:{},ajaxQueue:[],data:{},redirected:false,get:function(name){var Ajaxy=$.Ajaxy;if(typeof Ajaxy.data[name]!=='undefined'){return Ajaxy.data[name];}else{return undefined;}},set:function(data,value){var Ajaxy=$.Ajaxy;if(typeof value==='undefined'){if(typeof data==='object'){Ajaxy.data.extend(true,data);}}else{Ajaxy.data[data]=value;}},ensureString:function(str){var result='';switch(typeof str){case'number':case'string':result=String(str);break;default:result='';}
return result;},extractRelativeUrl:function(url,fixSlash){var Ajaxy=$.Ajaxy;var History=$.History;if(typeof fixSlash==='undefined'){fixSlash=true;}
url=Ajaxy.ensureString(url);var relative_url=url.stripLeft(Ajaxy.options.root_url).stripLeft(Ajaxy.options.base_url);if(fixSlash&&relative_url==='/')relative_url='';return relative_url;},extractState:function(url){var Ajaxy=$.Ajaxy;var state=Ajaxy.extractRelativeUrl(url,false);return state;},extractHash:function(state){var Ajaxy=$.Ajaxy;var state=Ajaxy.extractState(state);var hash=state.match(/^([^#?]*)/)||'';if(hash&&hash.length||false===2){hash=hash[1]||'';}
return hash;},extractAnchor:function(state){var Ajaxy=$.Ajaxy;var state=Ajaxy.extractState(state),anchor_param_name=Ajaxy.options.anchor_param_name;var anchor=state.replace(/[^#]+#/g,'#').match(/#+([^#\?]*)/)||'';if(anchor&&anchor.length||false===2){anchor=anchor[1]||'';}
if(anchor===state){anchor='';}
if(!anchor){var anchor=state.match(RegExp(anchor_param_name+'=([a-zA-Z0-9-_]+)'))||'';if(anchor&&anchor.length||false===2){anchor=anchor[1]||'';}}
return anchor;},extractQuerystring:function(state){var Ajaxy=$.Ajaxy;var state=Ajaxy.extractState(state);var querystring=state.match(/\?(.*)$/)||'';if(querystring&&querystring.length||false===2){querystring=querystring[1]||'';}
return querystring;},track:function(State){var Ajaxy=$.Ajaxy;if( _gat && _gat._getTracker ){var url=State.vanilla.locationShort;if(Ajaxy.options.debug)window.console.debug('Ajaxy.track',[this,arguments],[url]);_gaq.push(['_trackPageview',url]);}
return true;},matches:function(matches,state){var Ajaxy=$.Ajaxy;var isAMatch=false;switch(typeof matches){case'function':case'object':if(matches.test||false&&matches.exec||false){isAMatch=matches.test(state);break;}
case'array':$.each(matches,function(i,match){isAMatch=Ajaxy.matches(match,state);if(isAMatch)return false;});break;case'number':case'string':isAMatch=(String(matches)===state);break;}
return isAMatch;},match:function(state){var Ajaxy=$.Ajaxy;var matchedController=false;$.each(Ajaxy.Controllers,function(controller,Controller){var matches=Ajaxy.matches(Controller.matches||false,state);if(matches){matchedController=controller;return false;}});return matchedController;},getController:function(controller,create){var Ajaxy=$.Ajaxy;var Controller=undefined,controllerType=typeof(controller||undefined);if((controllerType==='number'||controllerType==='string')&&typeof Ajaxy.Controllers[controller]!=='undefined'){Controller=Ajaxy.Controllers[controller];}
else if(controllerType==='object'&&typeof controller.controller==='string'){Controller=Ajaxy.getController(controller.controller,create);}
else if(create){Controller=$.extend(true,{},Ajaxy.defaults.Controller);}
else if(create===false){}
else{window.console.error('Ajaxy.getController: Controller does not exist',[this,arguments]);window.console.trace();}
return Controller;},getControllerAction:function(controller,action,create){var Ajaxy=$.Ajaxy;var ControllerAction=undefined,Controller=Ajaxy.getController(controller,false);if(typeof Controller==='undefined'){if(create===false){}
else{window.console.error('Ajaxy.getControllerAction: Controller does not exist',[this,arguments]);window.console.trace();}}
else{var controllerActionType=typeof(Controller[action]||undefined);if(controllerActionType==='function'||controllerActionType==='object'){ControllerAction=Controller[action];}
else if(create===false){}
else{window.console.error('Ajaxy.getControllerAction: Controller Action does not exist',[this,arguments]);window.console.trace();}}
return ControllerAction;},bind:function(){var Ajaxy=$.Ajaxy;return Ajaxy.addControllers.apply(this,arguments);},addController:function(controller,Controller){var Ajaxy=$.Ajaxy;if(typeof Controller==='undefined'&&typeof controller==='object'){Controller=controller;}
else if(typeof controller==='string'&&typeof Controller==='function'){Controller={'controller':controller,'response':Controller};}
else if(typeof controller==='string'&&typeof Controller==='object'){if(typeof Controller.controller==='undefined'){Controller.controller=controller;}}
else{window.console.error('Ajaxy.addController: Unknown Controller Format',[this,arguments]);window.console.trace();}
if(typeof Ajaxy.Controllers[Controller.controller]!=='undefined'){window.console.error('Ajaxy.addController: Controller ['+Controller.controller+'] has already been bound.',[this,arguments],[Controller]);window.console.trace();return false;}
Controller=$.prepareObject(Ajaxy.defaults.Controller,Controller);if(!Controller.selector&&Controller.classname){Controller.selector='.'+Controller.classname;}
Ajaxy.Controllers[Controller.controller]=Controller;if(Ajaxy.options.auto_ajaxify){Ajaxy.ajaxifyController(Controller);}
return Controller;},addControllers:function(Controllers){var Ajaxy=$.Ajaxy;if(typeof Controllers==='object'&&typeof Controllers.controller==='string'){window.console.warn('Ajaxy.addControllers: It seems you intended to call addController instead.',[this,arguments]);}
else if(typeof Controllers==='object'||typeof Controllers==='array'){$.each(Controllers,function(controller,Controller){Ajaxy.addController(controller,Controller);});}
return true;},getState:function(state,create,error){var Ajaxy=$.Ajaxy;state=Ajaxy.extractState((state||{}).state||state);var State=undefined,type=typeof(state||undefined),typeStringable=(type==='number'||type==='string');if(typeStringable&&typeof Ajaxy.States[state]!=='undefined'){State=Ajaxy.States[state];}
else if(create){State=Ajaxy.createState(state);}
else if(create===false){}
else if(error||false){window.console.error('Ajaxy.getState: State does not exist',[this,arguments]);window.console.trace();}
if(State){Ajaxy.rebuildState(State);}
return State;},createState:function(state){var Ajaxy=$.Ajaxy;state=Ajaxy.extractState((state||{}).state||state);State=$.extend(true,{},Ajaxy.defaults.State,{state:state});Ajaxy.rebuildState(State);return State;},buildState:function(UserState){var Ajaxy=$.Ajaxy;var History=$.History;if(Ajaxy.options.debug)window.console.debug('Ajaxy.buildState:',[this,arguments]);if(typeof UserState==='string'){UserState={url:UserState};}
var State=Ajaxy.getState(false,true);$.extend(true,State,UserState);if(!(State.state||false)&&(State.url||false)){State.state=Ajaxy.extractState(State.url);}
if(!State.state){State.state='/';}
if(State.el){var $el=$(State.el);if($el.is('form')){State.isForm=true;State.isLink=false;}
else if($el.is('a')){State.isForm=false;State.isLink=true;}
else{window.console.warn('Ajaxy.buildState: Unknown element type passed.',[this,arguments],[State.el]);}
delete $el;}
Ajaxy.rebuildState(State);if(State.anchor===State.state||State.anchor===State.hash){State.anchor='';}
if(!(State.hash||false)&&!State.raw.querystring&&(State.anchor||'')){State.hash=Ajaxy.currentState.hash||'';State.querystring=State.raw.querystring;Ajaxy.rebuildState(State);}
if(!State.state||(!State.hash&&!State.raw.querystring)){window.console.warn('Ajaxy.go: No state or (hash and querystring).',[this,arguments],[State]);}
if(!State.mode){if(State.isLink&&Ajaxy.postpone){if(State.anchor&&!State.raw.querystring&&(State.hash===Ajaxy.options.relative_url)){State.mode='ignore';}
else{State.mode='postpone';}}
else if(State.isForm){State.mode='silent';}
else{State.mode='default';}}
return State;},rebuildState:function(State,mode){var Ajaxy=$.Ajaxy;var state=Ajaxy.extractState(State.state),hash=Ajaxy.ensureString(State.hash)||Ajaxy.extractHash(state),anchor=Ajaxy.ensureString(State.anchor)||Ajaxy.extractAnchor(state),querystring=Ajaxy.ensureString(State.querystring)||Ajaxy.extractQuerystring(state),base_url=Ajaxy.options.base_url,root_url=Ajaxy.options.root_url,anchor_param_name=Ajaxy.options.anchor_param_name;if(anchor){var params=querystring.queryStringToJSON();params.anchor=anchor;querystring=unescape($.param(params));delete params;}
State.anchor=anchor;State.querystring=querystring;State.hash=hash;State.state=hash+(querystring?'?'+querystring:'');State.locationShort=base_url+'#'+State.state;State.location=root_url+State.locationShort;State.raw.anchor='';State.raw.querystring=State.querystring.replace(RegExp('&?'+anchor_param_name+'=[a-zA-Z0-9-_]+','gi'),'').replace(/^&+/g,'');State.raw.hash=State.hash;State.raw.state=State.hash+(State.raw.querystring?'?'+State.raw.querystring:'');State.raw.locationShort=base_url+(State.raw.state?'#'+State.raw.state:'');State.raw.location=root_url+State.raw.locationShort;State.vanilla.anchor=State.anchor;State.vanilla.querystring=State.raw.querystring;State.vanilla.hash=State.vanilla.anchor;State.vanilla.state=State.vanilla.anchor;State.vanilla.locationShort=base_url+State.raw.hash+(State.vanilla.querystring?'?'+State.vanilla.querystring:'')+(State.vanilla.anchor?'#'+State.vanilla.anchor:'');State.vanilla.location=root_url+State.vanilla.locationShort;State.clean.anchor='';State.clean.querystring=State.raw.querystring;State.clean.hash='';State.clean.state='';State.clean.locationShort=base_url+State.hash+(State.clean.querystring?'?'+State.clean.querystring:'');State.clean.location=root_url+State.clean.locationShort;return State;},storeState:function(State){var Ajaxy=$.Ajaxy;var result=true,stateType=typeof(State||undefined);Ajaxy.rebuildState(State);if(stateType==='object'&&typeof State.state==='string'){result=Ajaxy.States[State.state]=State;}
else{window.console.error('Ajaxy.storeState: Unknown State Format',[this,arguments]);window.console.trace();result=false;}
return result;},statesEquivalent:function(newState,oldState){var Ajaxy=$.Ajaxy;var result=false;if(newState.isForm||oldState.isForm){result=false;}
else if(newState.state||false){var aliases=Ajaxy.aliases[newState.hash]||[newState.hash];$.each(aliases,function(i,alias){if(alias===oldState.hash&&newState.raw.querystring===oldState.raw.querystring){result=true;return false;}});}
return result;},stateCompleted:function(State,$content,options){var Ajaxy=$.Ajaxy;if(typeof State!=='object'){State={};}
if(!($content instanceof jQuery)||!$content.length){$content=$(document.body);}
if(typeof options!=='object'){options={};}
var config=$.extend({},Ajaxy.options,options);if(config.auto_sparkle_documentReady&&$.Sparkle||false){if(config.add_sparkle_extension){config.auto_ajaxify_documentReady=false;}
$content.sparkle();}
if(config.auto_ajaxify_documentReady){$content.ajaxify();}
var anchor=State.anchor||false;if(anchor){State.anchor=false;var $anchor=$('#'+anchor).giveTarget();$anchor.ScrollTo(config.scrollto_options);}
else if(config.scrollto_content&&!$content.is('body')){$content.ScrollTo(config.scrollto_options);}
return true;},refresh:function(){var Ajaxy=$.Ajaxy;var History=$.History;return Ajaxy.go(History.getHash());},go:function(UserState){var Ajaxy=$.Ajaxy;var History=$.History;if(Ajaxy.options.debug)window.console.debug('Ajaxy.go:',[this,arguments]);var State=Ajaxy.buildState(UserState);Ajaxy.storeState(State);switch(State.mode){case'silent':Ajaxy.stateChange(State.state)
break;case'ignore':Ajaxy.ignoredStates[State.vanilla.state]=State;document.location=State.vanilla.location;break;case'postpone':document.location=State.location;break;case'default':default:History.go(State.state);break;}
return true;},trigger:function(controller,action,state){var Ajaxy=$.Ajaxy;if(Ajaxy.options.debug)window.console.debug('Ajaxy.trigger: ',[this,arguments]);var i,n,list,call_generic=true;if(!controller){window.console.warn('Ajaxy.trigger: No controller was passed, reset to _generic.',[this,arguments]);controller='_generic';}
var Controller=Ajaxy.getController(controller);var ControllerAction=Ajaxy.getControllerAction(controller,action,false);var State=Ajaxy.getState(state,true),state=State.state||undefined;if(typeof Controller==='undefined'){window.console.error('Ajaxy.trigger: Controller does not exist',[this,arguments]);window.console.trace();if(controller!=='_generic'){Ajaxy.trigger('_generic','error',State);}
return false;}
if(typeof ControllerAction==='undefined'){if(action==='refresh'){window.console.warn('Ajaxy.trigger: Controller Action ['+controller+'].['+action+'] does not exist. Defaulting to ['+controller+'].['+action+'] Action.',[this,arguments]);return Ajaxy.trigger(controller,'response',State);}
else{if(controller==='_generic'){window.console.error('Ajaxy.trigger: Controller Action ['+controller+'].['+action+'] does not exist.',[this,arguments]);window.console.trace();}
else{window.console.warn('Ajaxy.trigger: Controller Action ['+controller+'].['+action+'] does not exist. Defaulting to [_generic].['+action+'] Action.',[this,arguments]);Ajaxy.trigger('_generic',action,State);}
return false;}}
var Action=$.extend(true,{},Ajaxy.defaults.Action,{'action':action,'controller':controller,'Controller':Controller,'state':state,'State':State});Action.forward=Action.trigger=function(_controller,_action,_state){if(Ajaxy.options.debug)window.console.debug('Ajaxy.Action.trigger:',[this,arguments]);_controller=_controller||controller;_action=_action||action;_state=_state||state;Ajaxy.trigger(_controller,_action,_state);return true;};var result=ControllerAction.apply(Action,[]);if(Action.propagate===false){call_generic=false;}
if(call_generic&&controller!=='_generic'){Action.forward('_generic');}
return true;},request:function(state){var Ajaxy=$.Ajaxy;var History=$.History;if(Ajaxy.options.debug)window.console.debug('Ajaxy.request:',[this,arguments]);var skip_ajax=false;var ignoredByMatch=(Ajaxy.options.request_match instanceof RegExp)&&!Ajaxy.options.request_match.test(state),ignoredByState=(typeof Ajaxy.ignoredStates[state]!=='undefined');if(ignoredByMatch||ignoredByState){if(Ajaxy.options.debug)window.console.debug('Ajaxy.request: We are an ignored state',[this,arguments],[state]);return true;}
delete ignoredByMatch;delete ignoredByState;var State=Ajaxy.getState(state,true);if(Ajaxy.redirected!==false){Ajaxy.redirected=false;return;}
$('.target').removeClass('target');if(Ajaxy.statesEquivalent(State,Ajaxy.currentState)){State.controller=Ajaxy.currentState.controller;State.Request=Ajaxy.currentState.Request;State.Response=Ajaxy.currentState.Response;State.Error=Ajaxy.currentState.Error;Ajaxy.currentState=State;Ajaxy.storeState(State);Ajaxy.trigger(State.controller,'refresh',Ajaxy.currentState);if(Ajaxy.options.debug)window.console.debug('Ajaxy.request: There has been no considerable change',[this,arguments],[Ajaxy.currentState,State,state]);return true;}
Ajaxy.ajaxQueue.push(state);if(Ajaxy.ajaxQueue.length!==1){return false;}
if(Ajaxy.options.analytics){Ajaxy.track(State);}
Ajaxy.currentState=State;var controller=State.controller||Ajaxy.match(state)||undefined;State.controller=controller;State.Request.url=(State.Request.url||State.clean.location);Ajaxy.storeState(State);Ajaxy.trigger(controller,'request');var Request={data:State.Request.data,url:State.Request.url,type:'post',success:function(responseData,status){if(Ajaxy.options.debug)window.console.debug('Ajaxy.request.success:',[this,arguments]);responseData=$.extend(true,{},Ajaxy.defaults.State.Response.data,responseData);responseData.Ajaxy=responseData.Ajaxy||{};if(responseData.Ajaxy.redirected){var newState=Ajaxy.extractState(responseData.Ajaxy.redirected.to);Ajaxy.redirected={status:true,from:state,to:newState};History.go(newState);};Ajaxy.ajaxQueue.shift();var queueState=Ajaxy.ajaxQueue.pop();if(queueState&&queueState!==state){Ajaxy.ajaxQueue=[];Ajaxy.stateChange(queueState);return false;}
State.Response.data=responseData;State.Error.data={};var controller=responseData.controller||State.controller||null;if(controller===null){controller='_generic';window.console.warn('Ajaxy.request.success.controller: The controller was unable to be determined, defaulted to _generic.',[this,arguments],[responseData.controller,State.controller]);}
if(State.Response.callback){if(State.Response.callback.apply(State,arguments)||controller==='callback'){return true;}}
return Ajaxy.trigger(controller,'response',State);},error:function(XMLHttpRequest,textStatus,errorThrown,responseData){if(Ajaxy.options.debug)window.console.debug('Ajaxy.request.error:',[this,arguments]);if(!responseData){responseData={responseText:XMLHttpRequest.responseText.trim()||false}}
Ajaxy.ajaxQueue.shift()
var queueState=Ajaxy.ajaxQueue.pop();if(queueState&&queueState!==state){Ajaxy.ajaxQueue=[];Ajaxy.stateChange(queueState);return false;}
var errorData={XMLHttpRequest:XMLHttpRequest,textStatus:textStatus,errorThrown:errorThrown};State.Request.XMLHttpRequest=XMLHttpRequest;State.Response.data=responseData;State.Error.data={};var controller=responseData.controller||State.controller||null;if(controller===null){controller='_generic';window.console.warn('Ajaxy.request.error.controller: The controller was unable to be determined, defaulted to _generic.',[this,arguments],[responseData.controller,State.controller]);}
if(State.Error.callback){if(State.Error.callback.apply(State,arguments)||controller==='callback'){return true;}}
return Ajaxy.trigger(controller,'error',State);},complete:function(XMLHttpRequest,textStatus){if(Ajaxy.options.debug)window.console.debug('Ajaxy.request.complete:',[this,arguments]);State.Request.XMLHttpRequest=XMLHttpRequest;if(false&&this.url!==XMLHttpRequest.channel.name){var newState=Ajaxy.extractState(XMLHttpRequest.channel.name);Ajaxy.redirected={status:true,from:state,to:newState};History.go(newState);};}};if(State.isForm){var $form=$(State.el);var enctype=$form.attr('enctype');if(enctype==='multipart/form-data'){var iframe_id='ajaxy_form_iframe_'+Math.floor(Math.random()*99999);var $iframe=$('<iframe style="display:none" src="about:blank" id="'+iframe_id+'" name="'+iframe_id+'" >').appendTo('body').hide();var $ajax=$('<input type="hidden" name="ajax" value="true"/>').appendTo($form);var $hidden=$('<input type="hidden" name="Ajaxy[form]" value="true"/>').appendTo($form);$iframe.bind('load',function(){var iframe=this.document||this.currentDocument||this.contentWindow.document;if(iframe.location.href==='about:blank'){return true;}
var text=$iframe.contents().find('.response').val();var json=false;try{json=$.parseJSON(text);}catch(e){window.console.error('Ajaxy.request.form: Invalid Response.',[this,arguments],[text]);}
if(json){request.success(json);}else{request.error(json);}
$form.removeAttr('target');$iframe.remove();$ajax.remove();$hidden.remove();});$form.attr('target',iframe_id);$form.submit();var values=$form.values();Request.data=$.extend(true,Request.data,values||{});skip_ajax=true;}
else{var values=$form.values();Request.data=$.extend(true,Request.data,values||{});}}
var result=true;State.Request=Request;if(!skip_ajax){result=Ajaxy.ajax(Request);}
return result;},ajax:function(options){var Ajaxy=$.Ajaxy;var History=$.History;if(Ajaxy.options.debug)window.console.debug('Ajaxy.ajax:',[this,arguments]);var callbacks={};callbacks.success=options.success||function(data,status){if(Ajaxy.options.debug)window.console.debug('Ajaxy.ajax.callbacks.success:',[this,arguments]);$('.error').empty();};callbacks.error=options.error||function(XMLHttpRequest,textStatus,errorThrown,data){if(Ajaxy.options.debug)window.console.debug('Ajaxy.ajax.callbacks.error:',[this,arguments]);$('.error').html(errorThrown);};callbacks.complete=options.complete||function(XMLHttpRequest,textStatus){if(Ajaxy.options.debug)window.console.debug('Ajaxy.ajax.callbacks.complete:',[this,arguments]);};delete options.success;delete options.error;delete options.complete;var request={type:'post',dataType:(Ajaxy.options.support_text?'text':'json')};$.extend(true,request,options);request.success=function(responseText,status){if(Ajaxy.options.debug)window.console.debug('Ajaxy.ajax.request.success:',[this,arguments]);var Response={},responseData={};if(typeof responseText!=='object'&&Ajaxy.options.support_text&&responseText){try{responseData=$.parseJSON(responseText);}
catch(e){var html=Ajaxy.htmlCompat(responseText),$html=$(html),$head=$html.find('#ajaxy-head'),$body=$html.find('#ajaxy-body'),$title=$html.find('#ajaxy-title'),$controller=$html.find('#ajaxy-controller'),title=($title.length?$title.text():''),head=($head.length?$head.htmlAndSelf():''),body=($body.length?$body.htmlAndSelf():''),content=($body.length?$body.html():html),controller=($controller.length?$controller.text().trim():null);responseData={"controller":controller,"responseText":responseText,"html":html,"title":title,"head":head,"body":body,"content":content};}}
else{responseData=responseText;}
Response.data=responseData;if(Ajaxy.options.debug)window.console.debug('Ajaxy.ajax.success:',[this,arguments]);if(typeof responseData.controller==='undefined'&&((typeof responseData.success!=='undefined'&&!responseData.success)||(typeof responseData.error!=='undefined'&&responseData.error))){return callbacks.error.apply(this,[null,status,responseData.error||true,responseData]);}
return callbacks.success.apply(this,[responseData,status]);};request.error=function(XMLHttpRequest,textStatus,errorThrown){if(Ajaxy.options.debug)window.console.debug('Ajaxy.ajax.request.error:',[this,arguments]);var responseText=XMLHttpRequest.responseText||false;if(responseText)responseText=responseText.trim();if(!responseText)responseText=false;var responseData={error:errorThrown||true,responseText:responseText};if(responseText){try{responseData=$.parseJSON(responseText);}catch(e){}finally{return this.success.apply(this,[responseData,textStatus]);}}
return callbacks.error.apply(this,[XMLHttpRequest,textStatus,errorThrown,responseData]);};return $.ajax(request);},configure:function(options){var Ajaxy=$.Ajaxy;var History=$.History;options=options||{};if(typeof options!=='object'){window.console.error('Ajaxy.configure: Invalid Options Passed',[this,arguments]);return;}
var Controllers;if(typeof options.Controllers==='object'){Controllers=options.Controllers;delete options.Controllers;}
else if(typeof options.controllers==='object'){Controllers=options.controllers;delete options.controllers;}
else{Controllers=options;options={};}
Ajaxy.options=$.extend(true,Ajaxy.options,options.options||options);Ajaxy.options.root_url=(Ajaxy.options.root_url||document.location.protocol.toString()+'//'+document.location.hostname.toString()).replace(/\/+$/,'')+'/';Ajaxy.options.base_url=(Ajaxy.options.base_url||'');Ajaxy.options.relative_url=Ajaxy.extractState(Ajaxy.options.relative_url||document.location.pathname.toString());if(Ajaxy.options.relative_as_base){if(Ajaxy.options.base_url.length===0){Ajaxy.options.base_url=Ajaxy.options.relative_url;Ajaxy.options.relative_url='';}}
Ajaxy.options.root_url=Ajaxy.options.root_url.replace(/\/+$/,'');Ajaxy.options.base_url=Ajaxy.options.base_url.replace(/\/+$/,'');Ajaxy.options.relative_url=Ajaxy.extractRelativeUrl(Ajaxy.options.relative_url);if(Ajaxy.options.root_url==='/')Ajaxy.options.root_url='';if(Ajaxy.options.base_url==='/')Ajaxy.options.base_url='';if(Ajaxy.options.relative_url==='/')Ajaxy.options.relative_url='';if(Ajaxy.options.request_match===true){var regParts=[];if(Ajaxy.options.root_url){regParts.push('^'+Ajaxy.options.root_url+Ajaxy.options.base_url);}
if(Ajaxy.options.base_url){regParts.push('^'+Ajaxy.options.base_url);}
regParts.push('^/');Ajaxy.options.request_match=RegExp(regParts.join('|'),'i');delete regParts;}
if(Ajaxy.options.debug)window.console.debug('Ajaxy.configure:',[this,arguments]);if(Ajaxy.options.relative_url&&Ajaxy.options.relative_url!==null){if(Ajaxy.options.redirect===true){var location=Ajaxy.options.root_url+Ajaxy.options.base_url+'#'+Ajaxy.options.relative_url,hash=History.getHash();if(hash){location+='?anchor='+hash;}
document.location=location;}
else if(Ajaxy.options.redirect==='postpone'){Ajaxy.postpone=true;}
else if(Ajaxy.options.redirect==='disable'){Ajaxy.addAjaxy=Ajaxy.ajaxify=Ajaxy.bind=function(){};$(function(){$('.ajaxy').removeAjaxy();});}}
Ajaxy.aliases=[];$.each(Ajaxy.options.aliases,function(i,aliasesGroup){$.each(aliasesGroup,function(i,alias){Ajaxy.aliases[alias]=aliasesGroup;});});Ajaxy.addControllers(Controllers);Ajaxy.onConfigured(true);return true;},construct:function(){var Ajaxy=$.Ajaxy,History=$.History,Sparkle=$.Sparkle;if(Ajaxy.isConstructed){return;}else{Ajaxy.isConstructed=true;}
History.bind(function(state){return Ajaxy.stateChange(state);});if($.Sparkle||false&&Ajaxy.options.add_sparkle_extension){$.Sparkle.addExtension('ajaxy',function(){$(this).ajaxify();});}
$.fn.ajaxy=Ajaxy.fn.ajaxify;$.each(Ajaxy.fn,function(key,fn){$.fn[key]=fn;});$(function(){Ajaxy.onDocumentReady(true);});Ajaxy.onReady(function(){if(Ajaxy.options.auto_ajaxify){$('body').ajaxify();}});Ajaxy.onConfigured(function(){Ajaxy.onDocumentReady(function(){Ajaxy.onReady(true);});});return true;},ajaxifyController:function(controller){var Ajaxy=$.Ajaxy;var Controller=Ajaxy.getController(controller);if(Controller&&(Controller.selector||false)){$(function(){var $els=$(Controller.selector);$els.data('ajaxy-controller',controller).addAjaxy();});}
return true;},fn:{ajaxify:function(){var Ajaxy=$.Ajaxy;var $el=$(this);$.each(Ajaxy.Controllers,function(controller,Controller){Ajaxy.ajaxifyController(controller);});if(Ajaxy.options.track_all_internal_links){var $internalLinks=$el.findAndSelf('a[href^=/],a[href^=./]');if(Ajaxy.options.root_url){var $internalLinksRoot=$('a[href^='+Ajaxy.options.root_url+']');$internalLinks=$internalLinks.add($internalLinksRoot);delete $internalLinksRoot;}
$internalLinks=$internalLinks.filter(':not(.ajaxy,.no-ajaxy)').addClass('ajaxy');delete $internalLinks;}
if(Ajaxy.options.track_all_anchors){$el.findAndSelf('a[href^=#]:not(.ajaxy,.no-ajaxy)').addClass('ajaxy');}
$el.addAjaxy();return $el;},addAjaxy:function(controller){var Ajaxy=$.Ajaxy;var $el=$(this);if($el.is('form,a')){$el.addClass('ajaxy');}
if(controller){var Controller=Ajaxy.getController(controller);if(Controller.classname){$el.addClass(Controller.classname);}}
$el.findAndSelf('a.ajaxy:not(.ajaxy-has)').addClass('ajaxy-has').once('click',Ajaxy.ajaxifyHelpers.a);$el.findAndSelf('form.ajaxy:not(.ajaxy-has)').addClass('ajaxy-has').once('submit',Ajaxy.ajaxifyHelpers.form);return $el;},removeAjaxy:function(options){var Ajaxy=$.Ajaxy;var $el=$(this),config=$.extend({permanently:true},options);var $a=$el.findAndSelf('a.ajaxy').removeClass('ajaxy ajaxy-has').unbind('click',Ajaxy.ajaxifyHelpers.a);var $form=$el.findAndSelf('form.ajaxy').removeClass('ajaxy ajaxy-has').unbind('submit',Ajaxy.ajaxifyHelpers.form);if(config.permanently){$a.add($form).addClass('no-ajaxy');}
return $el;}},ajaxifyHelpers:{a:function(event){var Ajaxy=$.Ajaxy;var $a=$(this);var href=Ajaxy.extractRelativeUrl($a.attr('href')).replace(/^\/?\.\//,'/');var state=Ajaxy.extractState(href);var anchor=Ajaxy.extractAnchor(href);if('/'+anchor===state||anchor===state)anchor='';var log=!$a.hasClass(Ajaxy.options.no_log_class);var controller=$a.data('ajaxy-controller')||null;Ajaxy.go({'state':state,'controller':controller,'log':log,'anchor':anchor,'el':this});event.stopPropagation();event.preventDefault();return false;},form:function(event){var Ajaxy=$.Ajaxy;var $form=$(this);var valid=($($form).valid());if(valid){var disabled=$form.attr('disabled');disabled=disabled||disabled==='false';if(disabled){return false;}
if($form.attr('target')){return true;}
var href=Ajaxy.extractRelativeUrl($form.attr('action')).replace(/^\/?\.\//,'/');var state=Ajaxy.extractState(href);Ajaxy.go({'state':state,'el':this});event.stopPropagation();event.preventDefault();return false;}}},htmlCompat:function(html){var result=String(html).replace(/<\!DOCTYPE[^>]*>/i,'').replace(/<(html|head|body|title|meta)/gi,'<div id="ajaxy-$1"').replace(/<\/(html|head|body|title|meta)/gi,'</div');return result;},stateChange:function(state){var Ajaxy=$.Ajaxy;var History=$.History;Ajaxy.request(state);},onConfigured:function(){var Ajaxy=this;return $.promise({'object':Ajaxy,'handlers':'onConfiguredHandlers','flag':'isConfigured','arguments':arguments});},onDocumentReady:function(handler){var Ajaxy=this;return $.promise({'object':Ajaxy,'handlers':'onDocumentReadyHandlers','flag':'isDocumentReady','arguments':arguments});},onReady:function(handler){var Ajaxy=this;return $.promise({'object':Ajaxy,'handlers':'onReadyHandlers','flag':'isReady','arguments':arguments});}};$.Ajaxy.construct();}
else{window.console.warn('$.Ajaxy has already been defined...');}})(jQuery);
