/*
 * jQuery BBQ: Back Button & Query Library - v1.0.3 - 12/2/2009
 * http://benalman.com/projects/jquery-bbq-plugin/
 * 
 * Copyright (c) 2009 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,n){var g,p=n.location,k=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,j,u,b=$.bbq=$.bbq||{},q,h,E,e="hashchange",z="querystring",C="fragment",x="elemUrlAttr",i="href",t="src",F=$.browser,d=F.msie&&F.version<8,o="on"+e in n&&!d,w=/^.*\?|#.*$/g,v=/^.*\#/,B={};function D(G){return typeof G==="string"}function A(H){var G=k.call(arguments,1);return function(){return H.apply(this,G.concat(k.call(arguments)))}}function l(G){return G.replace(/^[^#]*#?(.*)$/,"$1")}function m(G){return G.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(I,N,G,J,H){var P,M,L,O,K;if(J!==g){L=G.match(I?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);K=L[3]||"";if(H===2&&D(J)){M=J.replace(I?v:w,"")}else{O=j(L[2]);J=D(J)?j[I?C:z](J):J;M=H===2?J:H===1?$.extend({},J,O):$.extend({},O,J);M=a(M)}P=L[1]+(I?"#":M||!L[1]?"?":"")+M+K}else{P=N(G!==g?G:p[i])}return P}a[z]=A(f,0,m);a[C]=c=A(f,1,l);$.deparam=j=function(J,G){var I={},H={"true":!0,"false":!1,"null":null};$.each(J.replace(/\+/g," ").split("&"),function(M,R){var L=R.split("="),Q=r(L[0]),K,P=I,N=0,S=Q.split("]["),O=S.length-1;if(/\[/.test(S[0])&&/\]$/.test(S[O])){S[O]=S[O].replace(/\]$/,"");S=S.shift().split("[").concat(S);O=S.length-1}else{O=0}if(L.length===2){K=r(L[1]);if(G){K=K&&!isNaN(K)?+K:K==="undefined"?g:H[K]!==g?H[K]:K}if(O){for(;N<=O;N++){Q=S[N]===""?P.length:S[N];P=P[Q]=N<O?P[Q]||(S[N+1]&&isNaN(S[N+1])?{}:[]):K}}else{if($.isArray(I[Q])){I[Q].push(K)}else{if(I[Q]!==g){I[Q]=[I[Q],K]}else{I[Q]=K}}}}else{if(Q){I[Q]=G?g:""}}});return I};function y(I,G,H){if(G===g||typeof G==="boolean"){H=G;G=a[I?C:z]()}else{G=D(G)?G.replace(I?v:w,""):G}return j(G,H)}j[z]=A(y,0);j[C]=u=A(y,1);$[x]||($[x]=function(G){return $.extend(B,G)})({a:i,base:i,iframe:t,img:t,input:t,form:"action",link:i,script:t});h=$[x];function s(J,H,I,G){if(!D(I)&&typeof I!=="object"){G=I;I=H;H=g}return this.each(function(){var M=$(this),K=H||h()[(this.nodeName||"").toLowerCase()]||"",L=K&&M.attr(K)||"";M.attr(K,a[J](L,I,G))})}$.fn[z]=A(s,z);$.fn[C]=A(s,C);b.pushState=q=function(J,G){if(D(J)&&/^#/.test(J)&&G===g){G=2}var I=J!==g,H=c(p[i],I?J:{},I?G:2);p[i]=H+(/#/.test(H)?"":"#")};b.getState=function(G,H){return G===g||typeof G==="boolean"?u(G):u(H)[G]};b.pollDelay=100;$.event.special[e]={setup:function(){if(o){return false}E.start()},teardown:function(){if(o){return false}E.stop()},add:function(G,I,H){return function(K){var J=K[C]=c();K.getState=function(L,M){return L===g||typeof L==="boolean"?j(J,L):j(J,M)[L]};G.apply(this,arguments)}}};E=(function(){var G={},L,H,I,K;function J(){I=K=function(M){return M};if(d){H=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;K=function(){return l(H.document.location[i])};I=function(O,M){if(O!==M){var N=H.document;N.open().close();N.location.hash="#"+O}};I(c())}}G.start=function(){if(L){return}var N=c();I||J();(function M(){var P=c(),O=K(N);if(P!==N){I(N=P,O);$(n).trigger(e)}else{if(O!==N){q("#"+O)}}L=setTimeout(M,b.pollDelay)})()};G.stop=function(){if(!H){L&&clearTimeout(L);L=0}};return G})()})(jQuery,this);