/*!
 * Enables AJAX functions in nEon.
 * Requires the jQuery library to be loaded
 *
 * Copyright (c) 2011 by Florian Moser @ novalab - new media engineering novalab.ch
 */
var neonAjax={baseUrl:"",nonce:"",requestRunning:false,currentRequest:null,options:{activityIndicator:$([]),onContentLoaded:$.noop,onInitComplete:$.noop},initialize:function(d,c,b){if(document.URL.match(/^[^#?]+/)[0]!=d){location.href=d+"#/"+document.URL.slice(d.length);return}this.baseUrl=d;this.nonce=c;this.options=$.extend(this.options,b||{});var a=this;$(document).ajaxStart(function(){a.requestRunning=true;a.options.activityIndicator.show()}).ajaxStop(function(){a.requestRunning=false;a.options.activityIndicator.hide()});$(window).bind("hashchange",a.onHashChange);var e=document.URL.match(/#\/.+/);if(e){this.getContent(this.pathToAbsoluteUrl(e[0]));a.options.onInitComplete(true)}else{a.options.onInitComplete(false)}},onHashChange:function(){neonAjax.getContent(neonAjax.pathToAbsoluteUrl(location.hash))},pathToAbsoluteUrl:function(a){return this.baseUrl+a.substr(2)},absoluteUrlToPath:function(a){return"#/"+a.substr(this.baseUrl.length)},updateAddressBar:function(b){var a=this;var c=this.absoluteUrlToPath(b);if(location.hash.substr(0,c.length)!=c){$(window).unbind("hashchange");location.hash=c;window.setTimeout(function(){$(window).bind("hashchange",a.onHashChange)},100)}},getContent:function(b,c,d){if(c!=="POST"){c="GET"}if(!d){d=""}var a=this;if(b.indexOf("?")<0){b=b+"?_NEON_NONCE="+this.nonce}else{b=b+"&_NEON_NONCE="+this.nonce}if(this.currentRequest){this.currentRequest.abort()}this.currentRequest=$.ajax({url:b,dataType:"text",type:c,data:d,complete:function(e,g){if(g=="abort"){return}a.currentRequest=null;if(!e.getResponseHeader("nEonAjax")||e.status==403){document.location=a.baseUrl;return}var f=$.parseJSON(e.responseText);a.updateAddressBar(f._NEON_CURRENT_URL);a.options.onContentLoaded(f)}})}};
/*!
 * Collection of jQuery addons
 * Copyright (c) 2011 by Florian Moser @ novalab - new media engineering novalab.ch
 */
(function(a){a.fn.makeRequestsAsynchronous=function(c){var d={includeAbsolutePath:"",excludeSelector:null,replaceLinks:true};c=a.extend(d,c||{});var b=a([]);if(c.excludeSelector!==null){b=a(c.excludeSelector)}return this.each(function(){var g=c.includeAbsolutePath.length;var e=a(this);var f=e.find('a[href^="/"]').not(b);f.each(function(){var i=a(this);var j="#"+i.attr("href");if(c.replaceLinks){i.attr("href",j)}else{i.data("hrefAjax",j)}});var h=a([]);if(c.includeAbsolutePath!==""){h=a('a[href^="'+c.includeAbsolutePath+'"]').not(b);h.each(function(){var i=a(this);var j="#"+i.attr("href").substr(g-1);if(c.replaceLinks){i.attr("href",j)}else{i.data("hrefAjax",j)}})}if(!c.replaceLinks){f.add(h).click(function(i){i.preventDefault();document.location=a(this).data("hrefAjax")})}e.find("form").not(b).submit(function(k){k.preventDefault();var i=a(this);var j;if(i.attr("action")==""){j=document.URL.match(/^[^#?]+/)[0]+document.URL.match(/#.+/)[0].substr(2)}else{j=i.attr("action").match(/^[^#?]+/)[0]}neonAjax.getContent(j,"POST",i.serialize())})})};a.fn.updateMenu=function(b){return this.each(function(){var c=a(this);c.find("li.activeBranch").removeClass("activeBranch");c.find("a.activeNode").removeClass("activeNode");c.find("a.activePath").removeClass("activePath");if(!b){return}c.find("#"+b).addClass("activeNode").parentsUntil(c,"li").each(function(){a(this).addClass("activeBranch").children("a[class!=activeNode]").addClass("activePath")})})}})(jQuery);
/*!
 * jQuery hashchange event - v1.3 - 7/21/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 *
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);
