/*
* jQuery Address Plugin v1.3.2
* http://www.asual.com/jquery/address/
*
* Copyright (c) 2009-2010 Rostislav Hristov
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Date: 2011-02-04 12:34:19 +0200 (Fri, 04 Feb 2011)
*/
(function (c) {
    c.address = function () {
        var z = function (a) { c(c.address).trigger(c.extend(c.Event(a), function () { for (var b = {}, e = c.address.parameterNames(), h = 0, q = e.length; h < q; h++) b[e[h]] = c.address.parameter(e[h]); return { value: c.address.value(), path: c.address.path(), pathNames: c.address.pathNames(), parameterNames: e, parameters: b, queryString: c.address.queryString()} } .call(c.address))) }, A = function (a, b, e) { c(c.address).bind(a, b, e); return c.address }, C = function () { return B.pushState && d.state !== i }, u = function () {
            return ("/" +
g.pathname.replace(new RegExp(d.state), "") + g.search + (K() ? "#" + K() : "")).replace(ba, "/")
        }, K = function () { var a = g.href.indexOf("#"); return a != -1 ? D(g.href.substr(a + 1), l) : "" }, w = function () { return C() ? u() : K() }, va = function () { return "javascript" }, r = function (a) { a = a.toString(); return (d.strict && a.substr(0, 1) != "/" ? "/" : "") + a }, D = function (a, b) { if (d.crawlable && b) return (a != "" ? "!" : "") + a; return a.replace(/^\!/, "") }, E = function (a, b) { return parseInt(a.css(b), 10) }, ca = function (a) {
            for (var b, e, h = 0, q = a.childNodes.length; h < q; h++) {
                if (a.childNodes[h].src) b =
String(a.childNodes[h].src); if (e = ca(a.childNodes[h])) b = e
            } return b
        }, O = function () { if (!T) { var a = w(), b = f != a; if (F && p < 523) { if (L != B.length) { L = B.length; if (J[L - 1] !== i) f = J[L - 1]; M(l) } } else if (b) if (G && p < 7) g.reload(); else { G && p < 8 && d.history && x(W, 50); f = a; M(l) } } }, M = function (a) { z(da); z(a ? ea : fa); x(ga, 10) }, ga = function () {
            if (d.tracker !== "null" && d.tracker !== null) {
                var a = c.isFunction(d.tracker) ? d.tracker : k[d.tracker], b = (g.pathname + g.search + (c.address && !C() ? c.address.value() : "")).replace(/\/\//, "/").replace(/^\/$/, ""); if (c.isFunction(a)) a(b);
                else if (c.isFunction(k.urchinTracker)) k.urchinTracker(b); else if (k.pageTracker !== i && c.isFunction(k.pageTracker._trackPageview)) k.pageTracker._trackPageview(b); else k._gaq !== i && c.isFunction(k._gaq.push) && k._gaq.push(["_trackPageview", decodeURI(b)])
            } 
        }, W = function () {
            var a = va() + ":" + l + ";document.open();document.writeln('<html><head><title>" + n.title.replace("'", "\\'") + "</title><script>var " + s + ' = "' + encodeURIComponent(w()) + (n.domain != g.hostname ? '";document.domain="' + n.domain : "") + "\";<\/script></head></html>');document.close();";
            if (p < 7) o.src = a; else o.contentWindow.location.replace(a)
        }, ia = function () { if (P && ha != -1) { var a, b = P.substr(ha + 1).split("&"); for (v = 0; v < b.length; v++) { a = b[v].split("="); if (/^(autoUpdate|crawlable|history|strict|wrap)$/.test(a[0])) d[a[0]] = isNaN(a[1]) ? /^(true|yes)$/i.test(a[1]) : parseInt(a[1], 10) !== 0; if (/^(state|tracker)$/.test(a[0])) d[a[0]] = a[1] } P = null } f = w() }, ka = function () {
            if (!ja) {
                ja = m; ia(); var a = function () { wa.call(this); xa.call(this) }, b = c("body").ajaxComplete(a); a(); if (d.wrap) {
                    c("body > *").wrapAll('<div style="padding:' +
(E(b, "marginTop") + E(b, "paddingTop")) + "px " + (E(b, "marginRight") + E(b, "paddingRight")) + "px " + (E(b, "marginBottom") + E(b, "paddingBottom")) + "px " + (E(b, "marginLeft") + E(b, "paddingLeft")) + 'px;" />').parent().wrap('<div id="' + s + '" style="height:100%;overflow:auto;position:relative;' + (F ? window.statusbar.visible && !/chrome/i.test(X) ? "" : "resize:both;" : "") + '" />'); c("html, body").css({ height: "100%", margin: 0, padding: 0, overflow: "hidden" }); F && c('<style type="text/css" />').appendTo("head").text("#" + s + "::-webkit-resizer { background-color: #fff; }")
                } if (G &&
p < 8) { a = n.getElementsByTagName("frameset")[0]; o = n.createElement((a ? "" : "i") + "frame"); if (a) { a.insertAdjacentElement("beforeEnd", o); a[a.cols ? "cols" : "rows"] += ",0"; o.noResize = m; o.frameBorder = o.frameSpacing = 0 } else { o.style.display = "none"; o.style.width = o.style.height = 0; o.tabIndex = -1; n.body.insertAdjacentElement("afterBegin", o) } x(function () { c(o).bind("load", function () { var e = o.contentWindow; f = e[s] !== i ? c.address.decode(e[s]) : ""; if (f != w()) { M(l); g.hash = D(f, m) } }); o.contentWindow[s] === i && W() }, 50) } else if (F) {
                    if (p <
418) { c(n.body).append('<form id="' + s + '" style="position:absolute;top:-9999px;" method="get"></form>'); Y = n.getElementById(s) } if (g[s] === i) g[s] = {}; if (g[s][g.pathname] !== i) J = g[s][g.pathname].split(",")
                } x(function () { z("init"); M(l) }, 1); if (!C()) if (G && p > 7 || !G && "on" + Q in k) if (k.addEventListener) k.addEventListener(Q, O, l); else k.attachEvent && k.attachEvent("on" + Q, O); else ya(O, 50)
            } 
        }, wa = function () {
            var a, b = c("a"), e = b.size(), h = -1; x(function () {
                if (++h != e) {
                    a = c(b.get(h)); a.is('[rel*="address:"]') && a.address(); x(arguments.callee,
1)
                } 
            }, 1)
        }, za = function () { if (f != w()) { f = w(); M(l) } }, Aa = function () { if (k.removeEventListener) k.removeEventListener(Q, O, l); else k.detachEvent && k.detachEvent("on" + Q, O) }, xa = function () {
            if (d.crawlable) {
                var a = g.pathname.replace(/\/$/, ""); c("body").html().indexOf("_escaped_fragment_") != -1 && c("a[href]:not([href^=http]), , a[href*=" + document.domain + "]").each(function () {
                    var b = c(this).attr("href").replace(/^http:/, "").replace(new RegExp(a + "/?$"), ""); if (b == "" || b.indexOf("_escaped_fragment_") != -1) c(this).attr("href",
"#" + c.address.decode(b.replace(/\/(.*)\?_escaped_fragment_=(.*)$/, "!$2")))
                })
            } 
        }, la = function (a) { return a.replace(/\+/g, " ") }, H = function (a) { return ma(na(a)).replace(/%20/g, "+") }, oa = function (a) { return a.split("#")[0].split("?")[0] }, pa = function (a) { a = oa(a); var b = a.replace(ba, "/").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 }, R = function (a) { a = a.split("?"); return a.slice(1, a.length).join("?").split("#")[0] }, qa = function (a, b) {
            if (b =
R(b)) { params = b.split("&"); b = []; for (v = 0; v < params.length; v++) { var e = params[v].split("="); if (e[0] == a || c.address.decode(e[0]) == a) b.push(e.slice(1).join("=")) } if (b.length !== 0) return b.length != 1 ? b : b[0] } 
        }, ra = function (a) { var b = R(a); a = []; if (b && b.indexOf("=") != -1) { b = b.split("&"); for (var e = 0; e < b.length; e++) { var h = b[e].split("=")[0]; c.inArray(h, a) == -1 && a.push(h) } } return a }, U = function (a) { a = a.split("#"); return a.slice(1, a.length).join("#") }, i, s = "jQueryAddress", Q = "hashchange", da = "change", ea = "internalChange", fa =
"externalChange", m = true, l = false, d = { autoUpdate: m, crawlable: l, history: m, strict: m, wrap: l }, t = c.browser, p = parseFloat(c.browser.version), sa = t.mozilla, G = t.msie, ta = t.opera, F = t.webkit || t.safari, Z = l, k = function () { try { return top.document !== i ? top : window } catch (a) { return window } } (), n = k.document, B = k.history, g = k.location, ya = setInterval, x = setTimeout, ma = encodeURIComponent, na = decodeURIComponent, ba = /\/{2,9}/g, X = navigator.userAgent, o, Y, P = ca(document), ha = P ? P.indexOf("?") : -1, $ = n.title, L = B.length, T = l, ja = l, aa = m, ua = m, V = l, J =
[], f = w(); if (G) { p = parseFloat(X.substr(X.indexOf("MSIE") + 4)); if (n.documentMode && n.documentMode != p) p = n.documentMode != 8 ? 7 : 8; c(document).bind("propertychange", function () { if (n.title != $ && n.title.indexOf("#" + w()) != -1) n.title = $ }) } if (Z = sa && p >= 1 || G && p >= 6 || ta && p >= 9.5 || F && p >= 312) {
            for (var v = 1; v < L; v++) J.push(""); J.push(f); if (ta) history.navigationMode = "compatible"; if (document.readyState == "complete") var Ba = setInterval(function () { if (c.address) { ka(); clearInterval(Ba) } }, 50); else { ia(); c(ka) } t = u(); if (d.state !== i) if (B.pushState) t.substr(0,
3) == "/#/" && g.replace(d.state.replace(/^\/$/, "") + t.substr(2)); else t != "/" && t.replace(/^\/#/, "") != K() && g.replace(d.state.replace(/^\/$/, "") + "/#" + t); c(window).bind({ popstate: za, unload: Aa })
        } else !Z && K() != "" || F && p < 418 && K() != "" && g.search != "" ? g.replace(g.href.substr(0, g.href.indexOf("#"))) : ga(); return { bind: function (a, b, e) { return A(a, b, e) }, init: function (a) { return A("init", a) }, change: function (a) { return A(da, a) }, internalChange: function (a) { return A(ea, a) }, externalChange: function (a) { return A(fa, a) }, baseURL: function () {
            var a =
g.href; if (a.indexOf("#") != -1) a = a.substr(0, a.indexOf("#")); if (/\/$/.test(a)) a = a.substr(0, a.length - 1); return a
        }, autoUpdate: function (a) { if (a !== i) { d.autoUpdate = a; return this } return d.autoUpdate }, crawlable: function (a) { if (a !== i) { d.crawlable = a; return this } return d.crawlable }, history: function (a) { if (a !== i) { d.history = a; return this } return d.history }, state: function (a) { if (a !== i) { d.state = a; return this } return d.state }, strict: function (a) { if (a !== i) { d.strict = a; return this } return d.strict }, tracker: function (a) {
            if (a !==
i) { d.tracker = a; return this } return d.tracker
        }, wrap: function (a) { if (a !== i) { d.wrap = a; return this } return d.wrap }, update: function () { V = m; this.value(f); V = l; return this }, encode: function (a) {
            var b = pa(a), e = ra(a), h = R(a), q = U(a), I = a.substr(0, 1), N = a.substr(a.length - 1), j = ""; c.each(b, function (y, S) { j += "/" + H(S) }); if (h !== "") { j += "?"; if (e.length === 0) j += h; else { c.each(e, function (y, S) { y = qa(S, a); if (typeof y !== "string") c.each(y, function (Da, Ca) { j += H(S) + "=" + H(Ca) + "&" }); else j += H(S) + "=" + H(y) + "&" }); j = j.substr(0, j.length - 1) } } if (q !==
"") j += "#" + H(q); if (I != "/" && j.substr(0, 1) == "/") j = j.substr(1); if (I == "/" && j.substr(0, 1) != "/") j = "/" + j; if (/#|&|\?/.test(N)) j += N; return j
        }, decode: function (a) { if (a !== i) { var b = [], e = function (I) { return na(I.toString().replace(/\+/g, "%20")) }; if (typeof a == "object" && a.length !== i) { for (var h = 0, q = a.length; h < q; h++) b[h] = e(a[h]); return b } else return e(a) } }, title: function (a) {
            if (a !== i) {
                x(function () {
                    $ = n.title = a; if (ua && o && o.contentWindow && o.contentWindow.document) { o.contentWindow.document.title = a; ua = l } if (!aa && sa) g.replace(g.href.indexOf("#") !=
-1 ? g.href : g.href + "#"); aa = l
                }, 50); return this
            } return n.title
        }, value: function (a) {
            if (a !== i) {
                a = r(a); if (d.autoUpdate) a = this.encode(a); if (a == "/") a = ""; if (f == a && !V) return; aa = m; f = a; if (d.autoUpdate || V) {
                    M(m); if (C()) B[d.history ? "pushState" : "replaceState"]({}, "", d.state.replace(/\/$/, "") + (f == "" ? "/" : f)); else {
                        T = m; J[B.length] = f; if (F) if (d.history) {
                            g[s][g.pathname] = J.toString(); L = B.length + 1; if (p < 418) { if (g.search == "") { Y.action = "#" + D(f, m); Y.submit() } } else if (p < 523 || f == "") {
                                a = n.createEvent("MouseEvents"); a.initEvent("click",
m, m); var b = n.createElement("a"); b.href = "#" + D(f, m); b.dispatchEvent(a)
                            } else g.hash = "#" + D(f, m)
                        } else g.replace("#" + D(f, m)); else if (f != w()) if (d.history) g.hash = "#" + D(this.decode(r(f)), m); else g.replace("#" + D(f, m)); G && p < 8 && d.history && x(W, 50); if (F) x(function () { T = l }, 1); else T = l
                    } 
                } return this
            } if (!Z) return null; return this.decode(r(f))
        }, path: function (a) { if (a !== i) { var b = R(r(f)), e = U(r(f)); this.value(a + (b ? "?" + b : "") + (e ? "#" + e : "")); return this } return this.decode(oa(r(f))) }, pathNames: function () { return this.decode(pa(r(f))) },
            queryString: function (a) { if (a !== i) { var b = U(r(f)); this.value(this.path() + (a ? "?" + a : "") + (b ? "#" + b : "")); return this } return this.decode(R(r(f))) }, parameter: function (a, b, e) {
                var h, q; if (b !== i) {
                    var I = this.parameterNames(); q = []; b = b ? ma(b) : ""; for (h = 0; h < I.length; h++) { var N = I[h], j = this.parameter(N); if (typeof j == "string") j = [j]; if (N == a) j = b === null || b === "" ? [] : e ? j.concat([b]) : [b]; for (var y = 0; y < j.length; y++) q.push(N + "=" + la(H(j[y]))) } c.inArray(a, I) == -1 && b !== null && b !== "" && q.push(a + "=" + la(H(b))); this.queryString(q.join("&"));
                    return this
                } return this.decode(qa(a, r(f)))
            }, parameterNames: function () { return this.decode(ra(r(f))) }, hash: function (a) { if (a !== i) { this.value(r(f).split("#")[0] + (a ? "#" + a : "")); return this } return this.decode(U(r(f))) } 
        }
    } (); c.fn.address = function (z) {
        if (!c(this).attr("address")) {
            var A = function (C) {
                if (c(this).is("a")) {
                    var u = z ? z.call(this) : /address:/.test(c(this).attr("rel")) ? c(this).attr("rel").split("address:")[1].split(" ")[0] : c.address.state() !== undefined && c.address.state() != "/" ? c(this).attr("href").replace(new RegExp("^(.*" +
c.address.state() + "|\\.)"), "") : c(this).attr("href").replace(/^(#\!?|\.)/, ""); c.address.value(u); C.preventDefault()
                } 
            }; c(this).click(A).live("click", A).live("submit", function (C) { if (c(this).is("form")) { var u = c(this).attr("action"); u = z ? z.call(this) : (u.indexOf("?") != -1 ? u.replace(/&$/, "") : u + "?") + c.address.decode(c(this).serialize()); c.address.value(u); C.preventDefault() } }).attr("address", true)
        } return this
    } 
})(jQuery);

