if(LMI){
LMI.MinEvents = (function () {
    var C = {
        63232: 38,
        63233: 40,
        63234: 37,
        63235: 39,
        63273: 36,
        63275: 35,
        63276: 33,
        63277: 34
    };

    function E(I, H, J) {
        if (I.addEventListener) {
            I.addEventListener(H, J, false)
        } else {
            if (I.attachEvent) {
                I.attachEvent("on" + H, J)
            } else {
                throw new Error("addEvent: unsupported browser")
            }
        }
    }
    function G(I, H, J) {
        if (I.removeEventListener) {
            I.removeEventListener(H, J, false)
        } else {
            if (I.detachEvent) {
                I.detachEvent("on" + H, J)
            } else {
                throw new Error("removeEvent: unsupported browser")
            }
        }
    }
    function B(H) {
        var I;
        if (window.onload) {
            I = window.onload
        }
        window.onload = function () {
            if (typeof I === "function") {
                I()
            }
            H()
        }
    }
    function D(H) {
        if (H.stopPropagation) {
            H.stopPropagation()
        } else {
            H.cancelBubble = true
        }
        if (H.preventDefault) {
            H.preventDefault()
        } else {
            H.returnValue = false
        }
    }
    function A(I) {
        var H = 0,
            J = I.charCode;
        if (J > 60000 && (J in C)) {
            H = C[J]
        } else {
            if (!J) {
                H = I.keyCode
            }
        }
        return H
    }
    function F(J, I) {
        var H = J.target || J.srcElement;
        I = I.toUpperCase();
        while (H && H.nodeName !== I) {
            H = H.parentNode
        }
        return H
    }
    return {
        on: E,
        addEvent: E,
        addWindowLoadEvent: B,
        stopEvent: D,
        getKeyCode: A,
        findTarget: F,
        removeEvent: G
    }
})();
LMI.DropDown = (function () {
    var I = LMI.MinEvents,
        D = [],
        J = false,
        K = /\bhilite\b/,
        M = {
        backspace: 8,
        tab: 9,
        enter: 13,
        esc: 27,
        pgup: 33,
        pgdn: 34,
        end: 35,
        home: 36,
        left: 37,
        up: 38,
        right: 39,
        down: 40,
        del: 46
    };

    function H(Q) {
        var O, N, P;
        Q = Q || window.event;
        P = Q.target || Q.srcElement;
        for (O = 0, N = D.length; O < N; ++O) {
            D[O].hideIfUnrelated(P)
        }
    }
    function G() {
        if (!J) {
            J = true;
            LMI.MinEvents.addEvent(document.body, "click", H)
        }
    }
    function E(N, O) {
        O.appendChild(N)
    }
    function C(N, P) {
        var O = P.nextSibling;
        if (O) {
            O.parentNode.insertBefore(N, O)
        } else {
            P.parentNode.appendChild(N)
        }
    }
    function B(Q, P, O, S, R) {
        var N = document.createElement(P);
        R = R || E;
        if (O) {
            N.className = O
        }
        if (S) {
            N.appendChild(document.createTextNode(S))
        }
        R(N, Q);
        return N
    }
    function L(N, O) {
        if (N.currentStyle) {
            O = O.replace(/\-(\w)/g, function (P, Q) {
                return Q.toUpperCase()
            });
            return N.currentStyle[O]
        } else {
            return getComputedStyle(N, "").getPropertyValue(O)
        }
    }
    function F(N) {
        var P = N,
            O = {
            x: 0,
            y: 0
        };
        do {
            O.x += P.offsetLeft;
            O.y += P.offsetTop;
            if (P !== N) {
                O.x += parseInt(L(P, "border-left-width"), 10) || 0;
                O.y += parseInt(L(P, "border-top-width"), 10) || 0
            }
            P = P.offsetParent
        } while (P && L(P, "position") === "static");
        return O
    }
    function A(O, N) {
        this.init(O, N)
    }
    A.prototype = {
        init: function (O, N) {
            this.id = O;
            this.options = N || {};
            this.textbox = document.getElementById(O);
            if (!this.textbox || this.textbox.id !== O) {
                throw new TypeError('DropDown: unable to find textbox with id "' + O + '"')
            }
            this.textbox.setAttribute("autocomplete", "off");
            if (this.options.readOnly) {
                this.textbox.setAttribute("readOnly", true)
            }
            this.lastSection = "LMIDDNoSection";
            this.sections = {};
            this.eventHandlers = {};
            this.addArrow();
            this.createMenu();
            this.addEventListeners();
            D.push(this);
            G()
        },
        isShown: function () {
            return this.container.style.display === "block"
        },
        syncShim: function () {
            var O, N;
            if (this.shim) {
                O = this.container;
                N = this.shim;
                N.style.top = O.style.top;
                N.style.left = O.style.left;
                N.style.display = O.style.display;
                N.style.width = O.offsetWidth + "px";
                N.style.height = O.offsetHeight + "px"
            }
        },
        showMenu: function () {
            var P = this.container,
                N = this.textbox,
                O = F(N);
            P.style.top = O.y + N.offsetHeight + "px";
            P.style.left = O.x + "px";
            P.style.display = "block";
            this.shadow.style.overflow = "auto";
            this.syncShim()
        },
        hideMenu: function () {
            this.container.style.display = "none";
            this.syncShim()
        },
        hideIfUnrelated: function (N) {
            if (N === this.textbox || N === this.arrow) {
                return
            }
            while (N && !(N.nodeName === "DIV" && N.className.match(/\bLMIDropDown\b/))) {
                N = N.parentNode
            }
            if (!N) {
                this.hideMenu()
            }
        },
        toggleMenu: function () {
            if (this.isShown()) {
                this.hideMenu()
            } else {
                this.showMenu()
            }
        },
        addArrow: function () {
            if ("arrowSrc" in this.options) {
                this.arrow = B(this.textbox.parentNode, "img", "LMIDDArrow");
                this.arrow.src = this.options.arrowSrc;
                this.positionArrow()
            }
        },
        positionArrow: function () {
            this.arrow.style.top = F(this.textbox).y + "px"
        },
        createMenu: function () {
            this.container = B(this.textbox.parentNode, "div", "LMIDropDown");
            this.container.id = "LMIDD_" + this.id;
            this.shadow = B(this.container, "div", "LMIDDShadow");
            this.menu = B(this.container, "div", "LMIDDMenu");
            this.list = B(this.menu, "dl", "LMIDDList");
            if (document.all && !window.opera) {
                this.shim = B(this.textbox.parentNode, "iframe", "LMIDDShim");
                this.shim.src = "about:blank"
            }
        },
        addSection: function (Q, P, N) {
            var O;
            N = N || {};
            if (this.sections[Q]) {
                throw new Error('section "' + Q + '" already exists')
            }
            this.lastSection = Q;
            if (P) {
                if (typeof P === "string") {
                    O = B(this.list, "dt", Q);
                    B(O, "span", "", P)
                }
                if ("hint" in N) {
                    if (typeof N.hint === "string") {
                        B(O, "span", "hint", N.hint)
                    } else {
                        if (!N.hint.className.match(/\bhint\b/)) {
                            N.hint.className += " hint"
                        }
                        O.appendChild(N.hint)
                    }
                }
            }
            this.sections[Q] = {
                header: O,
                items: []
            }
        },
        clearSection: function (S, Q) {
            var P, N, O, R = this.sections[S];
            if (R) {
                O = R.items;
                for (P = 0, N = O.length; P < N; ++P) {
                    O[P].element.parentNode.removeChild(O[P].element);
                    O[P] = null
                }
                R.items = []
            }
        },
        addItem: function (T, S, N, U) {
            var Q, O, R, P = {
                display: T,
                options: N
            };
            S = S || this.lastSection;
            if (!this.sections[S]) {
                this.addSection(S)
            }
            O = this.sections[S];
            if (O.items.length) {
                Q = O.items[O.items.length - 1].element;
                R = C
            } else {
                if (O.header) {
                    Q = O.header;
                    R = C
                } else {
                    Q = this.list
                }
            }
            P.type = S;
            P.element = B(Q, "dd", S, T, R);
            O.items.push(P);
            if (N && "selected" in N && N.selected) {
                this.selectItem(S, O.items.length - 1)
            }
        },
        selectItem: function (O, N) {
            this.selected = this.sections[O].items[N];
            this.textbox.value = this.selected.display;
            this.hideMenu();
            this.textbox.focus();
            this.eventHandler("select", this.selected)
        },
        hiliteItem: function (P, N) {
            var O = this.sections[P].items[N];
            this.hilited = [P, N];
            if (!K.test(O.element.className)) {
                O.element.className += " hilite"
            }
        },
        unhiliteItem: function (P, N) {
            var O;
            if (this.hilited) {
                if (!P || !N) {
                    P = this.hilited[0];
                    N = this.hilited[1]
                }
                O = this.sections[P].items[N];
                this.hilited = null;
                O.element.className = O.element.className.replace(K, "")
            }
        },
        previous: function () {
            var O, P, N, Q = this.hilited;
            if (Q) {
                this.unhiliteItem(Q[0], Q[1]);
                O = this.sections[Q[0]].items[Q[1]].element.previousSibling;
                while (O && O.nodeName !== "DD") {
                    O = O.previousSibling
                }
            }
            if (!O) {
                N = this.list.getElementsByTagName("dd");
                if (N.length) {
                    O = N[N.length - 1]
                }
            }
            if (O) {
                P = this.getItemByElement(O);
                this.hiliteItem(P[0], P[1])
            }
        },
        next: function () {
            var N, O, P = this.hilited;
            if (P) {
                this.unhiliteItem();
                N = this.sections[P[0]].items[P[1]].element.nextSibling;
                while (N && N.nodeName !== "DD") {
                    N = N.nextSibling
                }
            }
            if (!N) {
                N = this.list.getElementsByTagName("dd")[0]
            }
            if (N) {
                O = this.getItemByElement(N);
                this.hiliteItem(O[0], O[1])
            }
        },
        getItemByElement: function (R) {
            var P, N, O, Q = R.className.split(" ")[0],
                S = this.sections[Q];
            if (S) {
                O = S.items;
                for (P = 0, N = O.length; P < N; ++P) {
                    if (O[P].element === R) {
                        return [Q, P]
                    }
                }
            }
            return null
        },
        mouseHandler: function (O) {
            var N = I.findTarget(O, "dd");
            if (N) {
                N = this.getItemByElement(N);
                if (N) {
                    if (O.type === "click") {
                        this.selectItem(N[0], N[1])
                    } else {
                        if (O.type === "mouseover") {
                            this.hiliteItem(N[0], N[1])
                        } else {
                            this.unhiliteItem(N[0], N[1])
                        }
                    }
                }
            }
        },
        keyHandler: function (O) {
            var N = I.getKeyCode(O);
            if (N === M.enter || O.charCode === M.enter || N === M.right) {
                if (this.isShown() && this.hilited) {
                    I.stopEvent(O);
                    this.selectItem(this.hilited[0], this.hilited[1])
                }
            } else {
                if (O.type === "keydown") {
                    switch (N) {
                    case M.up:
                        this.showMenu();
                        this.previous();
                        I.stopEvent(O);
                        break;
                    case M.down:
                        this.showMenu();
                        this.next();
                        I.stopEvent(O);
                        break;
                    case M.tab:
                        if (this.isShown()) {
                            if (this.hilited) {
                                this.selectItem(this.hilited[0], this.hilited[1])
                            }
                            this.hideMenu()
                        }
                        break
                    }
                } else {
                    if (this.selected && this.selected.display !== this.textbox.value) {
                        this.selected = null
                    }
                }
            }
        },
        addEventListeners: function () {
            var N = this;
            this._fieldClickHandler = function () {
                N.textbox.focus();
                N.toggleMenu()
            };
            this._keyHandler = function (O) {
                N.keyHandler(O || window.event)
            };
            this._mouseHandler = function (O) {
                N.mouseHandler(O || window.event)
            };
            if (this.arrow) {
                I.addEvent(this.arrow, "click", this._fieldClickHandler)
            }
            if (!("openOnFieldClick" in this.options) || this.options.openOnFieldClick) {
                I.addEvent(this.textbox, "click", this._fieldClickHandler)
            }
            I.addEvent(this.textbox, "keydown", this._keyHandler);
            I.addEvent(this.textbox, "keypress", this._keyHandler);
            I.addEvent(this.menu, "click", this._mouseHandler);
            I.addEvent(this.menu, "mouseover", this._mouseHandler);
            I.addEvent(this.menu, "mouseout", this._mouseHandler)
        },
        eventHandler: function (Q, R) {
            var O, N, P;
            if (Q in this.eventHandlers) {
                P = this.eventHandlers[Q];
                for (O = 0, N = P.length; O < N; ++O) {
                    P[O].call(this, R)
                }
            }
        },
        addEventHandler: function (N, P) {
            var O = this;
            if (!this["_" + N + "Handler"]) {
                this["_" + N + "Handler"] = function (Q) {
                    O.eventHandler(N, Q || window.event)
                };
                if (N !== "select") {
                    I.addEvent(this.textbox, N, this["_" + N + "Handler"])
                }
            }
            if (!(N in this.eventHandlers)) {
                this.eventHandlers[N] = []
            }
            this.eventHandlers[N].push(P)
        },
        addSubmitHandler: function (O) {
            var N = this;
            if (!this._submitHandler) {
                this._submitHandler = function (P) {
                    N.eventHandler("submit", P || window.event)
                };
                I.addEvent(this.textbox.form, "submit", this._submitHandler)
            }
            if (!("submit" in this.eventHandlers)) {
                this.eventHandlers.submit = []
            }
            this.eventHandlers.submit.push(O)
        },
        addModule: function (P) {
            var O, N, R, Q = ["keyup", "focus", "blur", "select"];
            for (O = 0, N = Q.length; O < N; ++O) {
                R = Q[O] + "Handler";
                if (R in P) {
                    this.addEventHandler(Q[O], P[R])
                }
            }
            if ("submitHandler" in P) {
                this.addSubmitHandler(P.submitHandler)
            }
            if ("methods" in P) {
                for (O in P.methods) {
                    if (P.methods.hasOwnProperty(O)) {
                        this[O] = P.methods[O]
                    }
                }
            }
        }
    };
    A.getById = function (P) {
        var O = 0,
            N = D.length;
        for (; O < N; ++O) {
            if (D[O].id === P) {
                return D[O]
            }
        }
        return null
    };
    return A
})();
LMI.DropDown.Hint = (function () {
    var A = /\bhintText\b/;

    function D() {
        return (this.mod_hint_text && (this.textbox.value === "" || this.textbox.value === this.mod_hint_text))
    }
    function H() {
        if (this.hasHint()) {
            if (!A.test(this.textbox.className)) {
                this.textbox.className += " hintText"
            }
            this.textbox.value = this.mod_hint_text
        }
    }
    function C() {
        if (A.test(this.textbox.className)) {
            this.textbox.className = this.textbox.className.replace(A, "");
            if (this.textbox.value === this.mod_hint_text) {
                this.textbox.value = ""
            }
        }
    }
    function B() {
        this.hideHintText()
    }
    function G() {
        this.showHintText()
    }
    function F() {
        this.hideHintText()
    }
    function E(I) {
        this.mod_hint_text = I;
        this.showHintText()
    }
    return {
        blurHandler: G,
        focusHandler: B,
        submitHandler: F,
        selectHandler: C,
        methods: {
            hasHint: D,
            setHintText: E,
            showHintText: H,
            hideHintText: C
        }
    }
})();
LMI.DropDown.Suggest = (function () {
    var minChars = 2;

    function A(E, F) {
        var D = LMI.Data.Urls.suggest;
        if (D.indexOf('?') == -1) {
            D += "?";
        } else {
            D += "&";
        }
        D += "query=" + encodeURIComponent(E);
        LMI.XHR.makeXHRRequest(D, "get", F)
    }
    function C(D, E) {
        return function (H) {
            var G, F;
            if (D.suggest_requestId === E) {
                D.unhiliteItem();
                D.clearSection("suggest");
                for (G = 0, F = H.length; G < F; ++G) {
                    D.addItem(H[G].key, "suggest")
                }
                if (H.length > 0 && (!D.selected || D.selected.display != D.textbox.value)) {
                    D.showMenu()
                }
            }
        }
    }
    return {
        keyupHandler: function () {
            var D = this.textbox.value;
            if (D.length < minChars) {
                this.clearSection("suggest");
                this.suggest_prevSearch = ""
            } else {
                if (D !== this.suggest_prevSearch) {
                    this.suggest_requestId = new Date().getTime().toString().substring(4);
                    this.suggest_prevSearch = this.textbox.value;
                    A(this.textbox.value, C(this, this.suggest_requestId))
                }
            }
        }
    }
})();
LMI.XHR = (function () {
    var getXHRObject, msXHRClass, msxhr = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
    if (window.XMLHttpRequest) {
        getXHRObject = function () {
            return new XMLHttpRequest()
        }
    } else {
        if (window.ActiveXObject && navigator.userAgent.indexOf("Mac") === - 1) {
            getXHRObject = function () {
                var i, len, xhr;
                if (msXHRClass) {
                    return new ActiveXObject(msXHRClass)
                } else {
                    for (i = 0, len = msxhr.length; i < len; ++i) {
                        try {
                            xhr = new ActiveXObject(msxhr[i]);
                            msXHRClass = msxhr[i];
                            return xhr
                        } catch (ex) {}
                    }
                }
                return null
            }
        } else {
            getXHRObject = function () {
                return null
            }
        }
    }
    function getStateChangeFunc(req) {
        return function () {
            var reply;
            if (req.xhr.readyState === 4) {
                reply = req.xhr.responseText;
                req.callback(eval(reply));
            }
        }
    }
    function makeXHRRequest(url, type, callback) {
        var req = {
            xhr: getXHRObject(),
            callback: callback
        };
        if (req.xhr) {
            req.xhr.onreadystatechange = getStateChangeFunc(req);
            req.xhr.open(type, url, true);
            req.xhr.send(null)
        }
    }
    return {
        makeXHRRequest: makeXHRRequest
    }
})();
LMI.Strings = (function () {
    var A = LMI.Data.strings,
        B = LMI.Data.strings_debug;
    return {
        setString: function (C, D) {
            A[C] = D
        },
        setStrings: function (C) {
            A = C
        },
        setDebug: function (C) {
            B = C
        },
        getString: function (E) {
            var D, C, F = "";
            if (E in A) {
                F = A[E];
                C = arguments.length;
                for (D = 1; D < C; ++D) {
                    F = F.replace(new RegExp("{" + (D - 1) + "\\}", "g"), arguments[D])
                }
            } else {
                if (B) {
                    F = "Unknown Message Key: '" + E + "'"
                }
            }
            return F
        }
    }
})();
LMI.Window = (function () {
    return {
        getHeight: function () {
            if (self.innerHeight) {
                return self.innerHeight
            } else {
                if (document.documentElement && document.documentElement.clientHeight) {
                    return document.documentElement.clientHeight
                } else {
                    if (document.body) {
                        return document.body.clientHeight
                    }
                }
            }
            return 0
        },
        getWidth: function () {
            if (self.innerWidth) {
                return window.innerWidth
            } else {
                if (document.documentElement && document.documentElement.clientWidth) {
                    return document.documentElement.clientWidth
                } else {
                    if (document.body) {
                        return document.body.clientHeight
                    }
                }
            }
            return 0
        },
        getScrollTop: function () {
            if (self.pageYOffset) {
                return self.pageYOffset
            } else {
                if (document.documentElement && document.documentElement.scrollTop) {
                    return document.documentElement.scrollTop
                } else {
                    if (document.body) {
                        return document.body.scrollTop
                    }
                }
            }
            return 0
        },
        getScrollLeft: function () {
            if (self.pageXOffset) {
                return self.pageXOffset
            } else {
                if (document.documentElement && document.documentElement.scrollLeft) {
                    return document.documentElement.scrollLeft
                } else {
                    if (document.body) {
                        return document.body.scrollLeft
                    }
                }
            }
            return 0
        }
    }
})();

LMI.SearchForm = (function () {
    var M = LMI.Strings.getString,
        R = LMI.MinEvents,
        D = {
        arrowSrc: LMI.Data.Urls.ddArrow
    },
        Q;

    function S(W) {
        var V = document.getElementById(W);
        return V && V.id === W
    }
    function F() {
        var W = document.createElement("div"),
            V = document.createElement("strong");
        W.className = "LMIMessages tip";
        V.appendChild(document.createTextNode(M("js.dropdown.tip")));
        W.appendChild(V);
        V = document.createElement("span");
        V.appendChild(document.createTextNode(M("js.dropdown.tip.text")));
        W.appendChild(V);
        return W
    }
    function J(V, W, X) {
        return function (Y) {
            var Z = Y || window.event;
            R.stopEvent(Z);
            (document.createElement("img")).src = X + ";jsessionid=" + LMI.Data.state.sessionId + "?noresponse=1";
            V.clearSection("recent")
        }
    }
    function N(V, X) {
        var W = document.createElement("a");
        W.href = "#";
        R.on(W, "click", J(V, W, X));
        W.appendChild(document.createTextNode(M("js.dropdown.clear")));
        return W
    }
    function U(Z) {
        var W, Y, V, X = LMI.Data.recentSearches;
        if (S(Z)) {
            if (LMI.Data.searchType === "PROPERTY") {
                Y = new LMI.DropDown(Z, D);
                Y.addModule(LMI.DropDown.Hint);
                Y.setHintText(M("js.what.hint"));
                V = N(Y, LMI.Data.Urls.removeSearches);
                Y.addSection("recent", M("js.titles.recent"), {
                    hint: V
                });
                if (X) {
                    for (W in X) {
                        if (X.hasOwnProperty(W) && X[W].searchTerms) {
                            Y.addItem(X[W].searchTerms, "recent")
                        }
                    }
                }
            } else {}
        }
    }
    function L(b) {
        var Y, X, W, Z = LMI.Data,
            V = Z.recentLocations;
        if (S(b)) {
            X = new LMI.DropDown(b, D);
            X.addSection("suggest", M("js.dropdown.suggestions"));
            X.addModule(LMI.DropDown.Hint);
            X.setHintText(M("js.where.hint"));
            X.addModule(LMI.DropDown.Suggest);
            /*
            W = N(X, Z.Urls.removeLocations);
            X.addSection("recent", M("js.titles.recentlocs"), {
                hint: W
            });
            if (V) {
                for (Y in V) {
                    if (V.hasOwnProperty(Y)) {
                        X.addItem(V[Y].locationValue, "recent")
                    }
                }
            }*/
            X.menu.appendChild(F())
        }
    }
    function I(X, W) {
        var V;
        for (V = 0; V < X.length; V++) {
            if (X[V] === W) {
                return true
            }
        }
        return false
    }
    function E() {
        var X = document.getElementById("refine"),
            V, W;
        if (X) {
            V = LMI.Element.getAll("#refine .refineList li span span", X);
            LMI.Lang.forEach(V, function (Y) {
                LMI.Element.destroy(Y)
            });
            W = LMI.Element.getOne("#openHouse label span");
            if (W) {
                LMI.Element.destroy(W)
            }
        }
    }
    function A(Z) {
    }
    function T(W) {
        var V = W.target || W.srcElement;
        A(V.value)
    }
    function P() {
    }
    function G(X) {
        var W = LMI.MapSearchSize.getDimensions(),
            V = R.findTarget(X, "FORM");
        if (V.mapWidth) {
            V.mapWidth.value = W.x;
            V.mapHeight.value = W.y
        }
    }
    function B() {
    }
    B();
    P();

    function H() {
    }
    function K(X) {
    }
    function O() {
    }
    O();
    return {
        createWhereDropDown: L
    }
})();
LMI.MinEvents.addWindowLoadEvent(function () {
    LMI.SearchForm.createWhereDropDown("where");
//    LMI.SearchForm.createWhereDropDown("where_glex");    
});
LMI.PopupFormCollection = (function () {
    var B = [];

    function D(E) {
        B.push(E)
    }
    function C() {
        for (o in B) {
            if ("popup" in B[o] && B[o].popup != null && B[o].popup.className.match(/hidden/) == null) {
                B[o].hidePopup()
            }
        }
    }
    function A(E) {
        var F;
        for (F = 0; F < B.length; F++) {
            if (B[F].form.id == E + "Form") {
                return B[F]
            }
        }
        return null
    }
    return {
        registerForm: D,
        hidePopupForms: C,
        getPopupByName: A
    }
})();
LMI.PopupForm = (function () {
    var E = LMI.MinEvents;
    var J = null;

    function A(L, M) {
        this.init(L, M)
    }
    A.prototype = {
        init: function (P, R) {
            var Q, N, L, M, O = this;
            this.form = document.getElementById(P + "Form");
            this.strategy = {};
            if (this.form) {
                this.shim = document.getElementById(P + "Shim");
                this.popup = document.getElementById(P + "Widget");
                LMI.PopupFormCollection.registerForm(this);
                if (R) {
                    if (typeof R == "object") {
                        for (N = 0; N < R.length; N++) {
                            L = document.getElementById(R[N]);
                            if (L) {
                                E.on(L, "click", function (S) {
                                    O.togglePopupHandler.call(O, S)
                                })
                            }
                        }
                    } else {
                        L = document.getElementById(R);
                        if (L) {
                            E.on(L, "click", function (S) {
                                O.togglePopupHandler.call(O, S)
                            })
                        }
                    }
                }
                M = this.form.getElementsByTagName("input");
                for (N = 0; N < M.length; N++) {
                    E.on(M[N], "keypress", function (T) {
                        var S = LMI.MinEvents.getKeyCode(T);
                        if (S && S == 13) {
                            E.stopEvent(T);
                            O.popupFormHandler.call(O, T)
                        }
                    })
                }
                E.on(this.form, "submit", function (S) {
                    E.stopEvent(S);
                    O.popupFormHandler.call(O, S)
                });
                Q = document.getElementById(P + "Close");
                if (Q) {
                    E.on(Q, "click", function (S) {
                        O.togglePopupHandler.call(O, S)
                    })
                }
            }
            J = B()
        },
        setStrategy: function (L) {
            this.strategy = L
        },
        getStrategy: function () {
            return this.strategy
        },
        togglePopupHandler: function (L) {
            this.togglePopupForm();
            E.stopEvent(L)
        },
        togglePopupForm: function () {
            var L = false;
            if (this.popup.className.match(/hidden/) == null) {
                L = true
            }
            LMI.PopupFormCollection.hidePopupForms();
            LMI.Messages.clear();
            H(this.form);
            F(this.form);
            if (!L) {
                if (this.strategy.showElem) {
                    this.strategy.showElem(this.popup)
                } else {
                    K(this.popup);
                    C(this.popup)
                }
                if (this.shim) {
                    K(this.shim)
                }
            }
        },
        hidePopup: function () {
            if (this.strategy.hideElem) {
                this.strategy.hideElem(this.popup)
            } else {
                LMI.PopupForm.hideElem(this.popup)
            }
            if (this.shim) {
                LMI.PopupForm.hideElem(this.shim)
            }
        },
        popupFormHandler: function (L) {
            E.stopEvent(L);
            this.submitForm()
        },
        submitForm: function () {
            var L = LMI.Data.baseUrl;
            if (this.strategy.buildSubmitUrl) {
                L = this.strategy.buildSubmitUrl.call(this, this.form)
            }
            H(this.form);
            LMI.XHR.makeXHRRequest(L, "post", this.getSubmitCallback())
        },
        getSubmitCallback: function () {
            var L = this;
            return function (M) {
                if (M[0].success) {
                    L.handleSuccess.call(L, M[0])
                } else {
                    L.handleError.call(L, M[0])
                }
            }
        },
        handleSuccess: function (L) {
            var M;
            if (this.strategy.handleSuccess) {
                this.strategy.handleSuccess.call(this, L)
            } else {
                if (L.infoMessages != null) {
                    if (this.popup) {
                        M = document.getElementById("DSContents")
                    } else {
                        M = this.form.parentNode
                    }
                    for (o in L.infoMessages) {
                        LMI.Messages.addMessage(G(L.infoMessages[o]), {
                            insertionPoint: M,
                            insertionStrategy: J
                        })
                    }
                }
            }
            if (this.popup) {
                this.hidePopup()
            }
        },
        handleError: function (M) {
            var N, L, O, P;
            if (M.fieldErrors != null || M.errors != null) {
                if (this.strategy.handleError) {
                    this.strategy.handleError.call(this, M)
                } else {
                    if (M.fieldErrors != null) {
                        for (o in M.fieldErrors) {
                            if (o) {
                                L = document.getElementById(o);
                                if (L) {
                                    L.className += (L.className.length > 0 ? " " : "") + "fieldError";
                                    L.parentNode.parentNode.appendChild(D(M.fieldErrors[o][0]))
                                }
                            }
                        }
                    }
                    if (M.errors != null) {
                        for (P = this.popup.firstChild; P; P = P.nextSibling) {
                            if ("className" in P && P.className.match(/contents/) != null) {
                                O = P;
                                break
                            }
                        }
                        for (o in M.errors) {
                            if (o) {
                                LMI.Messages.addMessage(D(M.errors[o]), {
                                    insertionPoint: O
                                })
                            }
                        }
                    }
                }
            }
        }
    };

    function F(N) {
        var L, M = 0;
        if (N) {
            L = N.getElementsByTagName("input");
            if (L.length > 0) {
                do {
                    switch (L[M].type) {
                    case "checkbox":
                        L[M].checked = false;
                        break;
                    case "hidden":
                        break;
                    default:
                        L[M].value = ""
                    }
                    M++
                } while (M < L.length)
            }
            L = N.getElementsByTagName("textarea");
            if (L.length > 0) {
                M = 0;
                do {
                    L[M].value = "";
                    M++
                } while (M < L.length)
            }
        }
    }
    function H(M) {
        var N, L;
        if (M) {
            N = M.getElementsByTagName("span");
            if (N.length > 0) {
                for (L = N.length - 1; L >= 0; L--) {
                    if (N[L].className.match(/formError/) != null) {
                        N[L].parentNode.removeChild(N[L])
                    }
                }
            }
            N = M.getElementsByTagName("input");
            if (N.length > 0) {
                for (L = N.length - 1; L >= 0; L--) {
                    if (N[L].className.match(/fieldError/) != null) {
                        N[L].className = N[L].className.replace(/fieldError/, "")
                    }
                }
            }
        }
    }
    function D(M) {
        var L = G(M);
        span = document.createElement("span");
        span.className = "formError";
        span.appendChild(document.createTextNode(L));
        return span
    }
    function G(N) {
        var O = N.messageCode.name.toLowerCase(),
            M, L;
        while (O.match(/_/) != null) {
            O = O.replace(/_/, ".")
        }
        M = LMI.Strings.getString("js." + O);
        for (L = 0; L < N.messageValues.length; L++) {
            M = M.replace("{" + L + "}", N.messageValues[L])
        }
        return M
    }
    function C(M) {
        var L;
        if (M) {
            L = M.getElementsByTagName("input");
            if (L && L[0]) {
                L[0].focus()
            }
        }
    }
    function K(L) {
        L.className = L.className.replace(/hidden/, "")
    }
    function I(L) {
        if (!L.className.match(/hidden/)) {
            L.className += (L.className.length > 0 ? " " : "") + "hidden"
        }
    }
    function B() {
        if (document.getElementById("mapImage")) {
            return function (N, P) {
                var L, O, M = YAHOO.util.Dom;
                if (N.firstChild) {
                    N.insertBefore(P, N.firstChild)
                } else {
                    N.appendChild(P)
                }
                L = LMI.Element.getAll(".control, .mapTilesLinks");
                O = P.offsetHeight + 10;
                LMI.Lang.forEach(L, function (Q) {
                    if (Q.parentNode == document.body) {
                        M.setStyle(Q, "top", parseInt(M.getStyle(Q, "top"), 10) + O + "px")
                    }
                })
            }
        } else {
            return "firstChild"
        }
    }
    A.getErrorMessage = D;
    A.clearErrorMessages = H;
    A.getMessage = G;
    A.showElem = K;
    A.hideElem = I;
    A.focusForm = C;
    return A
})();
(function () {
    function C(L, N) {
        var P, O, K, M;
        L.style.left = 0;
        L.style.top = 0;
        P = LMI.Element.getOffsets(N);
        O = LMI.Element.getOffsets(L);
        K = P.x - O.x + (0.3 * L.offsetWidth);
        M = (K < 0 ? 0 : K);
        L.style.left = M + "px";
        L.style.top = (P.y - O.y - 180) + "px"
    }
    function H(L) {
        var P = LMI.MinEvents.findTarget(L, "A"),
            O = document.getElementById("loginWidget"),
            Q = {
            x: 0,
            y: 0
        },
            N, K, M = YAHOO.util.Dom;
        L = L || window.event;
        if (L.pageX) {
            Q.x = L.pageX;
            Q.y = L.pageY
        } else {
            if (L.clientX) {
                Q.x = L.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
                Q.y = L.clientY + document.body.scrollTop + document.documentElement.scrollTop
            }
        }
        Q.x = (Q.x - 140 < 0) ? 0 : Q.x - 140;
        Q.y = (Q.y - 45 < 0) ? 0 : Q.y - 45;
        K = document.getElementById("registerWidget");
        if (K) {
            K.style.left = Q.x + "px";
            if (Q.y + K.offsetHeight > M.getViewportHeight() - 10) {
                Q.y = Q.y - (Q.y + K.offsetHeight - M.getViewportHeight());
                Q.y = (Q.y < 0 ? 0 : Q.y)
            }
            K.style.top = Q.y + "px"
        }
    }
    function I(K) {
        var L = document.getElementById("captcha");
        if (L) {
            L = L.getElementsByTagName("img")[0];
            L.src = LMI.Data.Urls.registerCaptcha + "?t=" + new Date().getTime()
        }
    }
    function E(K) {
        var L = document.getElementById("loginRegister");
        I(K);
        K.style.visibility = "hidden";
        LMI.PopupForm.showElem(K);
        C(K, L);
        K.style.visibility = "visible";
        LMI.PopupForm.focusForm(K)
    }
    function G(K) {
        I(K);
        LMI.PopupForm.showElem(K);
        LMI.PopupForm.focusForm(K)
    }
    function F(K) {
        return function (S) {
            var N = document.getElementById("userLinks"),
                T, Y, V, W, X, R = K.value,
                U, Q, P, L, O;
            if (document.body.id != "mywww") {
                while (N && N.firstChild) {
                    N.removeChild(N.firstChild)
                }
                W = document.createElement("span");
                W.appendChild(document.createTextNode(LMI.Strings.getString("js.hdr.welcome", R)));
                N.appendChild(W);
                if (document.getElementById("fromAddress")) {
                    document.getElementById("fromAddress").value = R
                }
                X = document.createElement("div");
                X.id = "userLinksList";
                T = document.createElement("ul");
                T.className = "linkList horizontalLinkList";
                V = document.createElement("a");
                V.href = LMI.Data.Urls.editAccount;
                V.rel = "nofollow";
                V.appendChild(document.createTextNode(LMI.Strings.getString("js.page.myacct")));
                Y = document.createElement("li");
                Y.appendChild(V);
                Y.appendChild(document.createTextNode(" |"));
                T.appendChild(Y);
                V = document.createElement("a");
                V.href = LMI.Data.Urls.logout;
                V.appendChild(document.createTextNode(LMI.Strings.getString("js.hdr.signout")));
                Y = document.createElement("li");
                Y.className = "last";
                Y.appendChild(V);
                T.appendChild(Y);
                X.appendChild(T);
                N.appendChild(X);
                if ("visitorVO" in LMI.Data.state) {
                    LMI.Data.state.visitorVO = S.visitorVO;
                    LMI.Data.recentSearches = S.recentSearches;
                    LMI.Data.recentLocations = S.recentLocations;
                    U = LMI.DropDown.getById("what");
                    if (U) {
                        U.clearSection("recent");
                        L = LMI.Data.recentSearches;
                        if (L) {
                            for (P in L) {
                                if (L.hasOwnProperty(P) && L[P].searchTerms) {
                                    U.addItem(L[P].searchTerms, "recent")
                                }
                            }
                        }
                    }
                    Q = LMI.DropDown.getById("where");
                    if (Q) {
                        Q.clearSection("recent");
                        L = LMI.Data.recentLocations;
                        if (L) {
                            for (P in L) {
                                if (L.hasOwnProperty(P) && L[P].locationValue) {
                                    Q.addItem(L[P].locationValue, "recent")
                                }
                            }
                        }
                    }
                }
            } else {
                var M = new LMI.Url(window.location.href);
                if (M.page == "editaccount.ds") {
                    window.location = LMI.Urls.get("editaccount.ds")
                } else {
                    window.location = LMI.Urls.get("displaymywww.ds")
                }
            }
        }
    }
    function D(K) {
        return function (M) {
            var O, L, N;
            if (M.fieldErrors != null) {
                for (o in M.fieldErrors) {
                    switch (o) {
                    case "username":
                        O = "emailInp";
                        break;
                    case "password":
                        O = (K == "login") ? "pass" : "passwordReg";
                        break;
                    case "emailAddress":
                        O = "emailAddress";
                        break;
                    case "captchaCode":
                        O = "verifyCaptcha";
                        break;
                    case "verifyEmailAddress":
                        O = "verifyEmailAddress";
                        break;
                    case "verifyPassword":
                        O = "verifyPassword";
                        break;
                    default:
                        O = ""
                    }
                    if (O) {
                        L = document.getElementById(O);
                        L.className += (L.className.length > 0 ? " " : "") + "fieldError";
                        L.parentNode.parentNode.appendChild(LMI.PopupForm.getErrorMessage(M.fieldErrors[o][0]))
                    }
                }
            }
            N = document.getElementById("pass");
            if (N) {
                N.value = ""
            }
        }
    }
    var B = {
        handleSuccess: F(document.getElementById("emailInp")),
        handleError: D("login"),
        buildSubmitUrl: function (L) {
            var N = L.username.value,
                K = L.password.value,
                M = L.rememberMe.checked ? "1" : "0";
            return LMI.Data.Urls.login + "?username=" + N + "&password=" + K + "&rememberMe=" + M
        }
    };
    var J = {
        handleSuccess: F(document.getElementById("emailAddress")),
        handleError: D("register"),
        buildSubmitUrl: function (N) {
            var M = N.emailAddress.value,
                P = N.verifyEmailAddress.value,
                L = N.password.value,
                O = N.verifyPassword.value,
                K = N.captchaCode.value,
                Q = N.rememberMe.checked ? "1" : "0";
            return LMI.Data.Urls.register + "?emailAddress=" + M + "&verifyEmailAddress=" + P + "&password=" + L + "&verifyPassword=" + O + "&captchaCode=" + K + "&rememberMe=" + Q
        }
    };
    if (document.body.id == "mywww") {
        J.showElem = E
    } else {
        J.showElem = G
    }
    function A() {
        var N = document.getElementById("loginWidget") || document.getElementById("signinReturn"),
            L, O, K = document.getElementById("loginRegister"),
            M = document.getElementById("registerPopup");
        if (N) {
            L = new LMI.PopupForm("login", "loginPopup");
            L.setStrategy(B)
        }
        N = document.getElementById("registerWidget");
        if (N) {
            O = new LMI.PopupForm("register", ["registerPopup", "loginRegister"]);
            O.setStrategy(J);
            if (K) {
                LMI.MinEvents.addEvent(K, "click", H);
                if (M) {
                    LMI.MinEvents.addEvent(M, "click", function (Q) {
                        var P = document.getElementById("registerWidget");
                        if (P) {
                            P.style.left = "";
                            P.style.top = "123px"
                        }
                    })
                }
            }
        }
    }
    A()
})();
(function () {
    var C = LMI.MinEvents,
        G = 0.25;

    function L(N) {
        var M;
        if (document.body.id === "mywww") {
            YAHOO.util.Dom.setStyle(N, "height", 0);
            YAHOO.util.Dom.removeClass(N, "hidden");
            M = new YAHOO.util.Anim(N, {
                height: {
                    to: N.scrollHeight
                }
            }, G);
            M.onComplete.subscribe(function () {
                YAHOO.util.Dom.setStyle(N, "height", "auto")
            });
            M.animate()
        } else {
            N.className = N.className.replace(/hidden/, "")
        }
    }
    function H(N) {
        var M;
        if (!N.className.match("hidden")) {
            if (document.body.id === "mywww") {
                M = new YAHOO.util.Anim(N, {
                    height: {
                        to: 0
                    }
                }, G);
                M.onComplete.subscribe(function () {
                    YAHOO.util.Dom.addClass(N, "hidden")
                });
                M.animate()
            } else {
                N.className += (N.className.length > 0 ? " " : "") + "hidden"
            }
        }
    }
    function K() {
        var N = document.getElementById("forgotpass"),
            M = document.getElementById("forgotlink");
        LMI.PopupForm.clearErrorMessages(N);
        if (N.className.match(/hidden/)) {
            L(N);
            H(M)
        } else {
            H(N);
            L(M)
        }
    }
    function D(P) {
        var O = document.getElementById("loginForm"),
            R, M = document.getElementById("forgotInp"),
            N, Q;
        if (document.body.id === "mywww") {
            R = "signinContainer"
        } else {
            R = O.parentNode
        }
        LMI.Messages.clear();
        if (P.infoMessages !== null) {
            for (Q in P.infoMessages) {
                if (P.infoMessages.hasOwnProperty(Q)) {
                    LMI.Messages.addMessage(LMI.PopupForm.getMessage(P.infoMessages[Q]), {
                        insertionPoint: R
                    })
                }
            }
        }
        K();
        M.value = "";
        N = LMI.PopupFormCollection.getPopupByName("login");
        if (N) {
            LMI.PopupForm.clearErrorMessages(N.form)
        }
    }
    function A(N) {
        var O, M, P;
        if (N.fieldErrors !== null) {
            for (P in N.fieldErrors) {
                if (N.fieldErrors.hasOwnProperty(P)) {
                    if (P === "username") {
                        O = "forgotInp"
                    } else {
                        O = ""
                    }
                    if (O) {
                        M = document.getElementById(O);
                        M.className += (M.className.length > 0 ? " " : "") + "fieldError";
                        M.parentNode.parentNode.appendChild(LMI.PopupForm.getErrorMessage(N.fieldErrors[P][0]))
                    }
                }
            }
        }
    }
    function J() {
        return function (M) {
            if (M[0].success) {
                D(M[0])
            } else {
                A(M[0])
            }
        }
    }
    function F(N) {
        var O = N.username.value,
            M = LMI.Data.Urls.forgotPassword + "?username=" + O;
        LMI.PopupForm.clearErrorMessages(N);
        LMI.XHR.makeXHRRequest(M, "post", J())
    }
    function B(N) {
        var M = N.target || N.srcElement;
        C.stopEvent(N);
        F(M)
    }
    function I(M) {
        K();
        C.stopEvent(M)
    }
    function E() {
        var M = document.getElementById("forgotForm");
        if (M) {
            C.on(M, "submit", B)
        }
        M = document.getElementById("forgotlink");
        if (M) {
            C.on(M, "click", I)
        }
        M = document.getElementById("closeForgot");
        if (M) {
            C.on(M, "click", I)
        }
    }
    E()
})();
LMI.Messages = (function () {
    var I = {
        FIRST_CHILD: function (L, M) {
            if (L.firstChild) {
                L.insertBefore(M, L.firstChild)
            } else {
                L.appendChild(M)
            }
        }
    };
    var B, F = "DSContents",
        C = "firstChild";

    function K(L) {
        var M = (L && "insertionStrategy" in L) ? L.insertionStrategy : C;
        switch (M) {
        case "firstChild":
            return I.FIRST_CHILD;
        default:
            return M
        }
    }
    function D(M) {
        var L = (M && "insertionPoint" in M) ? M.insertionPoint : F;
        if (typeof L == "string") {
            return document.getElementById(L)
        } else {
            return L
        }
    }
    function A(O, M) {
        M = M || {};
        var N = K(M),
            L = D(M);
        if (!B) {
            B = document.createElement("div");
            B.className = "LMIMessages"
        }
        B.appendChild(O);
        if (M.type && M.type == "error") {
            if (B.className.match(/error/) == null) {
                B.className += " error"
            }
        } else {
            if (B.className.match(/error/) != null) {
                B.className = B.className.replace(/error/, "")
            }
        }
        if (N && L) {
            N(L, B)
        } else {
            throw new Error("LMI.Messages: missing strategy or insertion point")
        }
    }
    function J(N, M) {
        var L;
        if (typeof N === "string") {
            L = document.createTextNode(N);
            N = document.createElement("p");
            N.appendChild(L)
        }
        A(N, M)
    }
    function H(L) {
        F = L
    }
    function G(L) {
        C = L
    }
    function E() {
        if (B) {
            B.parentNode.removeChild(B);
            B = null
        }
    }
    return {
        clear: E,
        addMessage: J,
        setInsertionStrategy: G,
        setInsertionPoint: H
    }
})();
}
function correctPricesForPriceFreq(form){
	if(typeof form == 'undefined'){
		form = document.refine_search
	}
	var priceLowForm = getFormValue(form, 'minprice');
	var priceHighForm = getFormValue(form, 'maxprice');

	var price_freq = getFormValue(form, 'c_price_freq');
	var price_mu = price_freq == 'annually' ? 1/12 : 1;
	priceLowForm = price_mu * priceLowForm;
	priceHighForm = price_mu * priceHighForm;
	if(priceLowForm != '' && price_mu != 1) setFormValue(form, 'minprice', priceLowForm);
	if(priceHighForm != '' && price_mu != 1) setFormValue(form, 'maxprice', priceHighForm);
}
function getFormValue(form, param) {
	  for (var j = 0; j < form.elements.length; j++) {
	    var e = form.elements[j];
		 
	    if (e.type == 'radio' && (e.name == param) ){
	    	if(e.checked){
	    		return e.value;
	    	}
	    }
	    else if (param == e.name) {
	      var value = '';
	      if (e.selectedIndex && e.selectedIndex != -1) {
	        value = e.options[e.selectedIndex].value;
	      } else if (e.value) {

	        value = e.value;
	        if (e.name == 'c_location' && ((typeof locationHint != 'undefined' && value == locationHint))) {
	            value = '';
	        }
	      }
	      return value;
	    }
	  }
	  return '';
}
function setFormValue(form, param, value) {
	  for (var j = 0; j < form.elements.length; j++) {
	    var e = form.elements[j];

	    if (param == e.name) {
	      if (e.selectedIndex) {
	        for (var i = 0; i < e.options.length; i++) {
	          if (e.options[i].value == value) {
	            e.selectedIndex = i;
	            break;
	          }
	        }
	      } else {
	        e.value = value;
	      }
	    }
	  }
}
