/*
 * jQuery BBQ: Back Button & Query Library - v1.0.2 - 10/10/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($,L){var G,N=document.location,K=Array.prototype.slice,P=decodeURIComponent,A=$.param,C,J,S,B=$.bbq=$.bbq||{},O,H,d,E="hashchange",Y="querystring",b="fragment",U="hash",W="elemUrlAttr",I="href",R="src",e=$.browser,D=e.msie&&e.version<8,M="on"+E in L&&!D,V=/^.*\?|#.*$/g,T=/^.*\#/,a={};function c(f){return typeof f==="string"}function Z(g){var f=K.call(arguments,1);return function(){return g.apply(this,f.concat(K.call(arguments)))}}function F(h,n,f,i,g){var o,l,k,m,j;if(i!==G){k=f.match(h?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);j=k[3]||"";if(g===2&&c(i)){l=i.replace(n,"")}else{m=J(k[2]);i=c(i)?J[h?b:Y](i):i;l=g===2?i:g===1?$.extend({},i,m):$.extend({},m,i);l=A(l)}o=k[1]+(h?"#":l||!k[1]?"?":"")+l+j}else{if(f){o=f.replace(n,"")}else{o=h?N[U]?N[I].replace(n,""):"":N.search.replace(/^\??/,"")}}return o}A[Y]=Z(F,0,V);A[b]=C=Z(F,1,T);$.deparam=J=function(i,f){var h={},g={"true":!0,"false":!1,"null":null};$.each(i.replace(/\+/g," ").split("&"),function(m,r){var l=r.split("="),q=P(l[0]),k,p=h,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=P(l[1]);if(f){k=k&&!isNaN(k)?+k:k==="undefined"?G:g[k]!==G?g[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(h[q])){h[q].push(k)}else{if(h[q]!==G){h[q]=[h[q],k]}else{h[q]=k}}}}else{if(q){h[q]=f?G:""}}});return h};function X(i,h,f,g){if(f===G||typeof f==="boolean"){g=f;f=A[i]()}else{f=c(f)?f.replace(h,""):f}return J(f,g)}J[Y]=Z(X,Y,V);J[b]=S=Z(X,b,T);$[W]||($[W]=function(f){return $.extend(a,f)})({a:I,base:I,iframe:R,img:R,input:R,form:"action",link:I,script:R});H=$[W];function Q(i,g,h,f){if(!c(h)&&typeof h!=="object"){f=h;h=g;g=G}return this.each(function(){var l=$(this),j=g||H()[(this.nodeName||"").toLowerCase()]||"",k=j&&l.attr(j)||"";l.attr(j,A[i](k,h,f))})}$.fn[Y]=Z(Q,Y);$.fn[b]=Z(Q,b);B.pushState=O=function(i,f){if(c(i)&&/^#/.test(i)&&f===G){f=2}var h=i!==G,g=C(N[I],h?i:{},h?f:2);N[I]=g+(/#/.test(g)?"":"#")};B.getState=function(f,g){return f===G||typeof f==="boolean"?S(f):S(g)[f]};B.pollDelay=100;$.event.special[E]={setup:function(){if(M){return false}d.start()},teardown:function(){if(M){return false}d.stop()},add:function(f,h,g){return function(j){var i=j[b]=C();j.getState=function(k,l){return k===G||typeof k==="boolean"?J(i,k):J(i,l)[k]};f.apply(this,arguments)}}};d=(function(){var f={},k,g,h,j;function i(){h=j=function(l){return l};if(D){g=$('<iframe src="javascript:0"/>').hide().appendTo("body")[0].contentWindow;j=function(){return g.document.location[U].replace(/^#/,"")};h=function(n,l){if(n!==l){var m=g.document;m.open();m.close();m.location[U]="#"+n}};h(C())}}f.start=function(){if(k){return }var m=C();h||i();(function l(){var o=C(),n=j(m);if(o!==m){h(m=o,n);$(L).trigger(E)}else{if(n!==m){O("#"+n)}}k=setTimeout(l,B.pollDelay)})()};f.stop=function(){if(!g){k&&clearTimeout(k);k=0}};return f})()})(jQuery,this);