/*
* jQuery Address Plugin v1.2
* http://www.asual.com/jquery/address/
*
* Copyright (c) 2009-2010 Rostislav Hristov
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2010-02-24 00:26:11 +0200 (Wed, 24 Feb 2010)
*/
(function(d) {
    d.address = function() {
        var z = function(a) { d(d.address).trigger(d.extend(d.Event(a), function() { for (var b = {}, f = d.address.parameterNames(), e = 0, o = f.length; e < o; e++) b[f[e]] = d.address.parameter(f[e]); return { value: d.address.value(), path: d.address.path(), pathNames: d.address.pathNames(), parameterNames: f, parameters: b, queryString: d.address.queryString()} } .call(d.address))) }, u = function(a, b, f) { if (f || b) d(d.address).bind(a, f || b, f && b); return d.address }, r = function() {
            var a = c.href.indexOf("#"); return a != -1 ?
R(G(c.href.substr(a + 1))) : ""
        }, S = function(a, b) { if (k.strict) a = b ? a.substr(0, 1) != "/" ? "/" + a : a : a == "" ? "/" : a; return a }, H = function(a, b) { return s && c.protocol == "file:" ? b ? g.replace(/\?/, "%3F") : g.replace(/%253F/, "?") : a }, T = function(a) { for (var b, f, e = 0, o = a.childNodes.length; e < o; e++) { if (a.childNodes[e].src) b = String(a.childNodes[e].src); if (f = T(a.childNodes[e])) b = f } return b }, U = function() {
            if (!I) {
                var a = r(), b = g != a; if (A && l < 523) { if (B != D.length) { B = D.length; if (typeof v[B - 1] != w) g = v[B - 1]; E(m) } } else if (s && l < 7 && b) c.reload(); else if (b) {
                    g =
a; E(m)
                } 
            } 
        }, E = function(a) { z("change"); z(a ? "internalChange" : "externalChange"); C(V, 10) }, V = function() { var a = (c.pathname + (/\/$/.test(c.pathname) ? "" : "/") + d.address.value()).replace(/\/\//, "/").replace(/^\/$/, ""), b = window[k.tracker]; if (typeof b == F) b(a); else if (typeof _gaq != w && typeof _gaq.push == F) _gaq.push(["_trackPageview", a]); else if (typeof pageTracker != w && typeof pageTracker._trackPageview == F) pageTracker._trackPageview(a); else typeof urchinTracker == F && urchinTracker(a) }, W = function() {
            var a = i.contentWindow.document;
            a.open(); a.write("<html><head><title>" + h.title + "</title><script>var " + p + ' = "' + r() + '";<\/script></head></html>'); a.close()
        }, L = function() {
            if (!X) {
                X = j; if (s && l < 8) {
                    var a = h.getElementsByTagName("frameset")[0]; i = h.createElement((a ? "" : "i") + "frame"); if (a) { a.insertAdjacentElement("beforeEnd", i); a[a.cols ? "cols" : "rows"] += ",0"; i.src = "javascript:false"; i.noResize = j; i.frameBorder = i.frameSpacing = 0 } else { i.src = "javascript:false"; i.style.display = "none"; h.body.insertAdjacentElement("afterBegin", i) } C(function() {
                        d(i).bind("load",
function() { var f = i.contentWindow; g = typeof f[p] != w ? f[p] : ""; if (g != r()) { E(m); c.hash = H(g, j) } }); typeof i.contentWindow[p] == w && W()
                    }, 50)
                } else if (A) { if (l < 418) { d(h.body).append('<form id="' + p + '" style="position:absolute;top:-9999px;" method="get"></form>'); K = h.getElementById(p) } if (typeof c[p] == w) c[p] = {}; if (typeof c[p][c.pathname] != w) v = c[p][c.pathname].split(",") } C(function() { z("init"); E(m) }, 1); if (s && l > 7 || !s && "onhashchange" in t) {
                    var b = h.body.onhashchange; h.body.onhashchange = function() {
                        typeof b == F && b.call(t);
                        U.call(t)
                    } 
                } else aa(U, 50); d("a[rel*=address:]").address()
            } 
        }, p = "jQueryAddress", F = "function", w = "undefined", j = true, m = false, n = d.browser, l = parseFloat(d.browser.version), Y = n.mozilla, s = n.msie, q = n.opera, A = n.safari, M = m, t = function() { try { return top.document !== undefined ? top : window } catch (a) { return window } } (), h = t.document, D = t.history, c = t.location, aa = setInterval, C = setTimeout, G = decodeURI, R = encodeURI; n = navigator.userAgent; var i, K, x = T(document), Z = x ? x.indexOf("?") : -1, ba = h.title, B = D.length, I = m, X = m, N = j, $ = j, J = m, v = [], g =
r(), k = { autoUpdate: j, history: j, strict: j }; if (s) { l = parseFloat(n.substr(n.indexOf("MSIE") + 4)); if (h.documentMode && h.documentMode != l) l = h.documentMode != 8 ? 7 : 8 } if (M = Y && l >= 1 || s && l >= 6 || q && l >= 9.5 || A && l >= 312) {
            for (n = 1; n < B; n++) v.push(""); v.push(r()); if (s && c.hash != r()) c.hash = "#" + H(r(), j); if (q) history.navigationMode = "compatible"; if (x && Z != -1) {
                x = x.substr(Z + 1).split("&"); for (n = 0; n < x.length; n++) {
                    q = x[n].split("="); if (/^(autoUpdate|history|strict)$/.test(q[0])) k[q[0]] = isNaN(q[1]) ? /^(true|yes)$/i.test(q[1]) : parseInt(q[1],
10) !== 0; if (/^tracker$/.test(q[0])) k[q[0]] = q[1]
                } 
            } if (h.readyState == "complete") L(); else { window == t && d(L); d(t).load(L) } 
        } else if (!M && c.href.indexOf("#") != -1 || A && l < 418 && c.href.indexOf("#") != -1 && c.search != "") { h.open(); h.write('<html><head><meta http-equiv="refresh" content="0;url=' + c.href.substr(0, c.href.indexOf("#")) + '" /></head></html>'); h.close() } else V(); return { init: function(a, b) { return u("init", a, b) }, change: function(a, b) { return u("change", a, b) }, internalChange: function(a, b) {
            return u("internalChange",
a, b)
        }, externalChange: function(a, b) { return u("externalChange", a, b) }, baseURL: function() { var a = c.href; if (a.indexOf("#") != -1) a = a.substr(0, a.indexOf("#")); if (a.substr(a.length - 1) == "/") a = a.substr(0, a.length - 1); return a }, strict: function(a) { if (a !== undefined) { k.strict = a; return this } return k.strict }, autoUpdate: function(a) { if (a !== undefined) { k.autoUpdate = a; return this } return k.autoUpdate }, update: function() { J = j; this.value(g); J = m; return this }, history: function(a) { if (a !== undefined) { k.history = a; return this } return k.history },
            tracker: function(a) { if (a !== undefined) { k.tracker = a; return this } return k.tracker }, title: function(a) { if (a !== undefined) { a = G(a); C(function() { ba = h.title = a; if ($ && i && i.contentWindow && i.contentWindow.document) { i.contentWindow.document.title = a; $ = m } if (!N && Y) c.replace(c.href.indexOf("#") != -1 ? c.href : c.href + "#"); N = m }, 50); return this } return h.title }, value: function(a) {
                if (a !== undefined) {
                    a = R(G(S(a, j))); if (a == "/") a = ""; if (g == a && !J) return; N = j; g = a; if (k.autoUpdate || J) {
                        I = j; E(j); v[D.length] = g; if (A) if (k.history) {
                            c[p][c.pathname] =
v.toString(); B = D.length + 1; if (l < 418) { if (c.search == "") { K.action = "#" + g; K.submit() } } else if (l < 523 || g == "") { a = h.createEvent("MouseEvents"); a.initEvent("click", j, j); var b = h.createElement("a"); b.href = "#" + g; b.dispatchEvent(a) } else c.hash = "#" + g
                        } else c.replace("#" + g); else if (g != r()) if (k.history) c.hash = "#" + H(g, j); else c.replace("#" + g); s && l < 8 && k.history && C(W, 50); if (A) C(function() { I = m }, 1); else I = m
                    } return this
                } if (!M) return null; return G(S(H(g, m), m))
            }, path: function(a) {
                if (a !== undefined) {
                    var b = this.queryString(); this.value(a +
(b ? "?" + b : "")); return this
                } a = this.value(); return a.indexOf("?") != -1 ? a.split("?")[0] : a
            }, queryString: function(a) { if (a !== undefined) { this.value(this.path() + (a ? "?" + a : "")); return this } a = this.value(); var b = a.indexOf("?"); if (b != -1 && b < a.length) return a.substr(b + 1) }, parameter: function(a, b, f) {
                var e, o; if (b !== undefined) {
                    var O = this.parameterNames(); o = []; for (e = 0; e < O.length; e++) {
                        var P = O[e], y = this.parameter(P); if (typeof y == "string") y = [y]; if (P == a) y = b === null || b == "" ? [] : f ? y.concat([b]) : [b]; for (var Q = 0; Q < y.length; Q++) o.push(P +
"=" + y[Q])
                    } d.inArray(a, O) == -1 && o.push(a + "=" + b); this.queryString(o.join("&")); return this
                } b = this.value(); e = b.indexOf("?"); if (e != -1) { b = b.substr(e + 1); o = b.split("&"); b = []; for (e = 0; e < o.length; e++) { f = o[e].split("="); f[0] == a && b.push(f[1]) } if (b.length !== 0) return b.length != 1 ? b : b[0] } 
            }, pathNames: function() { var a = this.path(), b = a.split("/"); if (a.substr(0, 1) == "/" || a.length === 0) b.splice(0, 1); a.substr(a.length - 1, 1) == "/" && b.splice(b.length - 1, 1); return b }, parameterNames: function() {
                var a = this.value(), b = a.indexOf("?"),
f = []; if (b != -1) { a = a.substr(b + 1); if (a != "" && a.indexOf("=") != -1) { a = a.split("&"); for (b = 0; b < a.length; b++) { var e = a[b].split("=")[0]; d.inArray(e, f) == -1 && f.push(e) } } } return f
            } }
        } (); d.fn.address = function(z) { var u = function() { var r = z ? z.call(this) : /address:/.test(d(this).attr("rel")) ? d(this).attr("rel").split("address:")[1].split(" ")[0] : d(this).attr("href").replace(/^#/, ""); d.address.value(r); return false }; d(this).click(u).live("click", u) } 
    })(jQuery);

