﻿var NF_autocomplete = null;
var AdvS_autocomplete = {
    city_state: null,
    zip: null
};

function start_autocomplete(d, e, b) {
    NF_autocomplete = null;
    if (!d) {
        NF_autocomplete = new Autocomplete("location", "form_query", xb_get_element("nf_location_form"), "hp_location", "hp_autocomplete_value", znfdef, null, "county,state");
        return NF_autocomplete
    } else {
        AdvS_autocomplete.zip = null;
        AdvS_autocomplete.city_state = null;
        if (xb_get_element(d).value == "") {
            var a = xb_get_element("autocomplete_panel");
            if (a) {
                a.parentNode.removeChild(a)
            }
            var c = xb_get_element("ie_iframe");
            if (c) {
                c.parentNode.removeChild(c)
            }
        }
        AdvS_autocomplete[d] = new Autocomplete("adv_hp_location", d + "_ac", xb_get_element("adv_form"), d, d + "_ac_value", "", e, b);
        return AdvS_autocomplete[d]
    }
}
function stop_autocomplete(a) {
    var b = AdvS_autocomplete[a];
    if (b && b.errored) {
        if (b.value_field.value == 0 || b.value_field.value == "") {
            b.field.value = "";
            b.hide_panel()
        }
    }
    xb_get_element("city_state").onfocus = function () {
        start_autocomplete("city_state", null, "zipcode,county,state")
    };
    xb_get_element("zip").onfocus = function () {
        start_autocomplete("zip", "zipcode", null)
    }
}
function add_location() {
    var e = state = id = null;
    if (xb_get_element("hp_location")) {
        var h = trim(xb_get_element("hp_location").value);
        var d = xb_get_element("hp_autocomplete_value").value;
        if (h == znfdef) {
            return false
        }
        if (/^[^,]+,[^,]+$/.test(h)) {
            var f = "city"
        } else {
            if (/^\d{5}$/.test(h)) {
                var f = "zip"
            } else {
                if (d != "" && d != 0) {
                    var f = "nh"
                } else {
                    xb_get_element("hp_location").value = "";
                    xb_get_element("hp_autocomplete_value").value = "";
                    return false
                }
            }
        }
        var g = h.split(", ");
        switch (f) {
            case "city":
                if (g.length == 2) {
                    e = g[0];
                    state = g[1];
                    /*if (typeof (_STATES[state.toUpperCase()]) == "undefined") {
                        return false
                    }*/
                    var a = build_cookie_city(e, state)
                }
                break;
            case "nh":
                if (g.length >= 3) {
                    id = d;
                    xb_get_element("hp_autocomplete_value").value = "";
                    var a = build_cookie_nh(id)
                }
                break;
            case "zip":
                id = h;
                var a = build_cookie_zip(id);
                break
        }
        var b = build_cookie_exp_date();
        var c = rebuild_cookie(getCookie("hp_include"), a);
        setCookie("hp_include", c, b);
        var j = rebuild_cookie(getCookie("hp_exclude"), null, a);
        setCookie("hp_exclude", j, b);
        change_feed_source(e, state, id, f, null, a)
    }
    return false
}
function rebuild_cookie(a, f, b) {
    var h = 5;
    var c = "";
    if (typeof (a) != "undefined" && a != null) {
        if (a.indexOf(";") > -1) {
            var k = a.split(";")
        } else {
            var k = new Array(a)
        }
        var l = (h < k.length ? h : k.length);
        for (var g = 0; g < l - 1; g++) {
            if (trim(k[g]) != "" && (typeof (b) == "undefined") || (typeof (b) != "undefined" && k[g].toLowerCase() != b.toLowerCase())) {
                c += k[g] + ";"
            }
        }
        if (typeof (f) != "undefined" && f != null) {
            var d = true;
            for (var e = 0; e < l - 1; e++) {
                if (f.toLowerCase() == k[e].toLowerCase()) {
                    d = false;
                    break
                }
            }
            if (d) {
                return f + ";" + c
            } else {
                return c
            }
        } else {
            if (c) {
                return c
            }
        }
    } else {
        if (typeof (f) != "undefined" && f != null) {
            return f + ";"
        }
    }
    return ""
}
function remove_location(g, f) {
    switch (f) {
        case "city":
            var e = g.city;
            var a = g.state;
            var b = build_cookie_city(e, a);
            var j = e + ", " + a + "";
            break;
        case "zip":
            var b = build_cookie_zip(g);
            var j = g + ", , zip";
            break;
        case "nh":
            var b = build_cookie_nh(g);
            var j = g + ", , neigh_id";
            break
    }
    var h = rebuild_cookie(getCookie("hp_exclude"), b);
    var d = rebuild_cookie(getCookie("hp_include"), null, b);
    var c = build_cookie_exp_date();
    setCookie("hp_exclude", h, c);
    setCookie("hp_include", d, c);
    change_feed_source("All", "All", null, "city", j);
    return false
}
function clear_hidden_locations() {
    var a = build_cookie_exp_date(-1);
    setCookie("hp_exclude", "", a);
    setCookie("hp_include", "", a);
    window.location.href = window.location.href
}
function build_cookie_city(b, a) {
    return "city=" + b + "&state=" + a
}
function build_cookie_zip(a) {
    return "zip=" + a
}
function build_cookie_nh(a) {
    return "nh=" + a
}
function change_feed_source(city, state, id, type, remove, add) {
    elem_list = xb_get_element("news_feed_location_list");
    if (elem_list) {
        var more = elem_list.value
    }
    var act_http = getHTTPObject();
    var d = new Date();
    var url = site_root + "Sorgu/q_update_news_feed/?m=" + more + "&d=" + d.valueOf();
    if (city != null && state != null && type == "city") {
        url += "&c=" + city + "&s=" + state
    } else {
        if (id != null && type == "nh") {
            url += "&nh=" + id
        } else {
            if (id != null && type == "zip") {
                url += "&z=" + id
            } else {
                return false
            }
        }
    }
    if (typeof (remove) != "undefined" && remove != null) {
        url += "&r=" + remove
    }
    if (typeof (add) != "undefined" && add != null) {
        url += "&a=" + escape(add)
    }
    act_http.open("POST", url);
    act_http.onreadystatechange = function () {
        if (act_http.readyState == 4) {
            var status = act_http.responseText;
            if (status == -1) {
                window.location.href = window.location.href
            } else {
                var data = eval("(" + status + ")");
                var elem = xb_get_element("newsfeed_content");
                if (elem) {
                    elem.innerHTML = data[0]
                }
                NewsFeedAlert.update_popup(data[1], data[2])
            }
        }
    };
    act_http.send(null)
}
function NewsFeedAlert() {
    this.type = "";
    this.locations = "";
    this.process = 0;
    this.logged_in = 1;
    this.hash = ""
}
NewsFeedAlert.set_type = function (a) {
    this.type = a
};
NewsFeedAlert.show_callback = function () {
    this.process = 1;
    if (!_emlakrex_logged_in) {
        this.logged_in = 0
    }
    var a = {
        recent_listings: "new listing",
        foreclosures: "foreclosure",
        recent_sold_prop: "sold",
        open_homes: "Open House",
        reduced_price_homes: "price reduction"
    };
    var b = null;
    if (b = xb_get_element("nf_module_type")) {
        b.innerHTML = a[this.type]
    }
    xb_get_element("nfAlertFrequency").value = "gunluk";
    xb_get_element("nfAlertOpenNextDay").checked = true;
    xb_get_element("nfAlertOpenWeekend").checked = true;
    if (this.type == "open_homes") {
        remove_class("nf_email_alert_open_home_section", "hidden");
        add_class("nf_email_alert_frequencies", "hidden")
    } else {
        add_class("nf_email_alert_open_home_section", "hidden");
        remove_class("nf_email_alert_frequencies", "hidden")
    }
    this.update_popup()
};
NewsFeedAlert.validate_callback = function (d) {
    var e = "";
    var b = true;
    var a = false;
    for (i in [0, 1, 2, 3, 4]) {
        var f = xb_get_element("nf_loc_" + i);
        if (f) {
            a = true;
            if (typeof (f.checked) != "undefined") {
                if (f.checked) {
                    e += f.value + "|"
                }
                if (d) {
                    f.checked = true
                }
            }
        } else {
            b = false
        }
        if (a && !b) {
            break
        }
    }
    if (e == "" && !d) {
        unhide("nf_email_search_subscribe_status", "");
        return false
    } else {
        hide("nf_email_search_subscribe_status", "")
    }
    return e
};
NewsFeedAlert.reset_callback = function () {
    this.process = 0;
    this.logged_in = 1;
    this.hash = "";
    NewsFeedAlert.validate_callback(true);
    hide("nf_email_search_subscribe_status", "");
    add_class("nf_email_alert_open_home_section", "hidden")
};
NewsFeedAlert.login_callback = function (a) {
    if (!this.logged_in) {
        if (typeof a != "undefined" && a == "register") {
            this.hash = "nfr"
        } else {
            this.hash = "nfc"
        }
    }
    if (this.process) {
        this.set_alert(null, a)
    }
};
NewsFeedAlert.update_popup = function (b, c) {
    if (typeof (b) != "undefined" && b) {
        this.locations = b
    }
    var a = YUI.getId("nf_locations_checkboxes");
    if (a) {
        a.innerHTML = this.locations
    }
};
NewsFeedAlert.set_alert = function (j, c) {
    hide("nf_email_search_subscribe_status", "");
    var k = NewsFeedAlert.validate_callback();
    if (!k) {
        return false
    }
    var h = site_root + "Sorgu/q_search_email_subscribe/?";
    var g = xb_get_element("nfAlertOpenNextDay").checked ? 1 : 0;
    var d = xb_get_element("nfAlertOpenWeekend").checked ? 1 : 0;
    var l = xb_get_element("nfAlertFrequency");
    var f = l.value;
    var b = false;
    var e = "";
    e += "add=" + k + "&";
    e += "type=" + this.type + "&";
    if (this.type == "recent_sold_prop") {
        e += "sf=" + f + "&";
        b = true
    } else {
        e += "lf=" + f + "&"
    }
    e += "on=" + g + "&ow=" + d + "&";
    if (_emlakrex_logged_in) {
        e += "li=1&"
    } else {
        e += "li=0&"
    }
    e += "nf=1&";
    if (!this.logged_in && this.hash) {
        e += "nf_confirm=" + this.hash + "&"
    }
    var a = getHTTPObject();
    a.open("POST", h + e, true);
    a.onreadystatechange = function () {
        if (a.readyState == 4) {
            var o = a.responseXML;
            if (!o) {
                return
            }
            var q = 0;
            var p = 0;
            var r = 0;
            var n = 0;
            if (o.documentElement.getElementsByTagName("o")[0]) {
                var m = o.documentElement.getElementsByTagName("o")[0];
                q = m.getAttribute("ls");
                p = m.getAttribute("ss");
                r = m.getAttribute("ns");
                n = m.getAttribute("ws")
            }
            if (q == -1) {
                unhide("nf_email_search_subscribe_status", "");
                show_login(null, "nf_email_alert", true);
                return
            } else {
                if (q == 5) {
                    show_login(null, "nf_email_alert", true);
                    return
                } else {
                    if (q == 4) {
                        show_login(null, "nf_email_alert", true);
                        return
                    } else {
                        add_class(NewsFeedAlert.type + "_email", "hidden");
                        remove_class(NewsFeedAlert.type + "_emailed", "hidden");
                        if (!NewsFeedAlert.hash) {
                            if (typeof (c) != "undefined" && c == "register") {
                                pos_menuyu_goster(null, "email_alert_new_account_confirmation")
                            } else {
                                pos_menuyu_goster(null, "email_alert_confirmation")
                            }
                        }
                        login_reset();
                      
                    }
                }
            }
        }
    };
    a.send(null)
};

function filters_are_default() {
    return (xb_get_element("min_price").value == "min" && xb_get_element("max_price").value == "max" && xb_get_element("min_size").selectedIndex == 0 && xb_get_element("min_num_beds").selectedIndex == 0 && xb_get_element("min_num_baths").selectedIndex == 0 && xb_get_element("type").selectedIndex == 0)
}
function manage_clear_filters() {
    if (filters_are_default()) {
        hide("filter_reset_link")
    } else {
        unhide("filter_reset_link")
    }
}
function clear_recent_srch(a) {
    if (confirm("Are you sure you want to delete all your recent searches?")) {
        var c = getHTTPObject();
        var b = new Date();
        c.open("POST", site_root + "q_crp.php?tp=rs&ts=" + b.valueOf());
        c.onreadystatechange = function () {
            if (c.readyState == 4) {
                var d = a ? xb_get_element(a) : xb_get_element("recent_searches");
                if (d) {
                    d.parentNode.removeChild(d)
                }
            }
        };
        c.send(null)
    }
}
function clear_recent_props(a) {
    if (confirm("Are you sure you want to delete all your recently viewed properties?")) {
        var c = getHTTPObject();
        var b = new Date();
        c.open("POST", site_root + "q_crp.php?tp=rp&ts=" + b.valueOf());
        c.onreadystatechange = function () {
            if (c.readyState == 4) {
                var d = a ? xb_get_element(a) : xb_get_element("recent_properties");
                if (d) {
                    d.parentNode.removeChild(d)
                }
                if (nmsp && nmsp <= 0 || !nmsp) {
                    set_my_emlakrex_icon(false)
                }
            }
        };
        c.send(null)
    }
}
function validate_search_box_location_text(b) {
    if (typeof (b) == "undefined" || !b) {
        return false
    }
    var a = b.replace(/^\s+/g, "").replace(/\s+$/g, "");
    if (!a || a == zsbdef || a == zsbdef2) {
        return false
    }
    return a
}
function validate_adv_search_box(d, j) {
    var f = xb_get_element("adv_form");
    if (typeof (f) == "undefined") {
        return false
    }
    var h = f.city_state.value.replace(/^\s+/g, "").replace(/\s+$/g, "");
    var c = f.zip.value.replace(/^\s+/g, "").replace(/\s+$/g, "");
    var a = false;
    if (!h && !c) {
        alert("Please Tercih bölgenizi giriniz: either a İlçe veya Şehir Giriniz code is required at a minimum.");
        f.city_state.focus();
        a = true
    } else {
        if (c && !c.match(/\d{5}/)) {
            alert("Please enter a valid 5 digit ZIP code.");
            f.zip.focus();
            a = true
        }
    }
    if (a) {
        return false
    }
    var b = {
        city_state: "L",
        type: "P",
        st_num: "N",
        st_name: "S",
        zip: "Z",
        min_price: "Mi",
        max_price: "Ma",
        beds: "Be",
        baths: "Ba",
        filter_sqft: "Sq",
        keyword: "K"
    };
    var e = "|";
    for (var g in b) {
        if (g == "min_price") {
            if (xb_get_element(g) && xb_get_element(g).value != "min") {
                e += (xb_get_element(g).value != "") ? b[g] + "|" : ""
            }
        } else {
            if (g == "max_price") {
                if (xb_get_element(g) && xb_get_element(g).value != "max") {
                    e += (xb_get_element(g).value != "") ? b[g] + "|" : ""
                }
            } else {
                if (g == "beds" || g == "baths" || g == "filter_sqft") {
                    if (xb_get_element(g) && xb_get_element(g).value != "0") {
                        e += (xb_get_element(g).value != "") ? b[g] + "|" : ""
                    }
                } else {
                    if (xb_get_element(g)) {
                        e += (xb_get_element(g).value != "") ? b[g] + "|" : ""
                    }
                }
            }
        }
    }
   /* var k = s_gi(j);
    k.linkTrackVars = "prop8,prop11,prop13";
    k.linkTrackEvents = "";
    k.events = "";
    k.prop8 = "adv:" + k.pageName;
    k.prop11 = h + " " + c;
    k.prop13 = e;
    k.tl(d, "o", "Adv Search Page Click");*/
    return true
}
function validate_search_box(b, a) {
    var g = xb_get_element(b);
    if (!g) {
        if (typeof (document.frm) == "undefined") {
            return false
        }
        g = document.frm
    }
    if (typeof (g.search) == "undefined") {
        return false
    }
    var k = validate_search_box_location_text(g.search.value);
    if (!k) {
        alert("Lütfen adres , ilçe veya ili giriniz");
        g.search.focus();
        return false
    }
    var q = "home";
    var l = "Home Page Click";
    if (xb_get_element("foreclosure_type_select") && g.foreclosure_type) {
        q = "foreclosure center";
        l = "Foreclosure Center Click";
        var t = {
            all: "all",
            notice_of_default: "1",
            auction: "2",
            bank_owned: "3"
        }
    }
    var e = /^[$,.0-9kmKM]+$/;
    var d = g.min_price;
    var n, f = "";
    if (d && typeof (d.value) != "undefined") {
        n = d.value;
        if (n && n != "min" && !e.test(n)) {
            f += "Please enter a valid minimum price. "
        }
    }
    var p = g.max_price;
    if (p && typeof (p.value) != "undefined") {
        n = p.value;
        if (n && n != "max" && !e.test(n)) {
            f += "Please enter a valid maximum price. "
        }
    }
    if (f) {
        alert(f);
        return false
    }
   // var m = s_gi(a);
    var h = "";
 //   var j = m.pageName;
    if (q == "home") {
        switch (g.id) {
            case "for_rent_search_box_form":
               // var j = "rental";
                var c = "Rental";
                break;
            case "sold_search_box_form":
                var c = "RecSol";
               // var c = j;
                break;
            default:
            case "for_sale_search_box_form":
              //  var j = m.pageName;
                var c = "Home";
                break
        }
        h = c;
        var o = {
            min_price: "minp",
            max_price: "maxp",
            min_num_beds: "bdr",
            min_num_baths: "bath",
            type: "pt",
            min_size: "sqft",
            filter_pets: "Pets",
            srl: "lastsold"
        };
        for (var r in o) {
            if (typeof (g[r]) != "undefined") {
                h += "|" + o[r] + "[";
                if (g[r].value) {
                    h += g[r].value
                } else {
                    if (g[r].options[g[r].selectedIndex].value) {
                        h += g[r].options[g[r].selectedIndex].value
                    }
                }
                h += "]"
            }
        }
    }
   /* m.linkTrackVars = "prop8,prop10,prop11";
    m.linkTrackEvents = "";
    m.events = "";
    if (typeof (m.pageName) == "undefined") {
        m.pageName = "unset"
    }
    m.prop8 = q + ":" + j;
    m.prop10 = h;
    if (typeof (k) != "undefined") {
        m.prop11 = k
    }
    m.tl(g, "o", l);*/
    return true
}
function validate_price_reduced_search_box(b) {
    b = xb_get_element(b);
    if (!b || typeof (b.search) == "undefined") {
        return false
    }
    if (!validate_search_box_location_text(b.search.value)) {
        var a = xb_get_element("price_reduced_error_msg");
        if (a) {
            a.innerHTML = "Lütfen adres , ilçe veya ili giriniz";
            remove_class(a, "hidden")
        } else {
            alert("Lütfen adres , ilçe veya ili giriniz")
        }
        b.search.focus();
        return false
    }
    return true
}
function submit_adv_search_box(a) {
    if (!validate_adv_search_box(document.frm, a)) {
        return false
    }
    document.frm.submit()
}
function submit_search_box(a, b) {
    var c = xb_get_element(b);
    if (!c) {
        if (typeof (document.frm) == "undefined") {
            return false
        }
        c = document.frm
    }
    if (!validate_search_box(c, a)) {
        return false
    }
    c.submit()
}
function submit_price_reduced_search_box(a) {
    a = xb_get_element(a);
    if (!a) {
        return false
    }
    if (!validate_price_reduced_search_box(a)) {
        return false
    }
    a.submit()
}
function check_value(a, b) {
    if (b == "price") {
        regex = /^[$,.0-9kmKM]+$/
    } else {
        regex = /^[.,0-9]+$/
    }
    if (a != "" && !regex.test(a) || a == "") {
        return false
    } else {
        return true
    }
}
function clrerrmsg() {
    var a = xb_get_element("errmsg");
    if (a) {
        a.parentNode.removeChild(a)
    }
}
function homepage_trends_toggle(a) {
    var b = {
        homepg_trends_gainers: 1,
        homepg_trends_popular: 1,
        homepg_trends_price: 1,
        homepg_trends_foreclosures: 1
    };
    for (title in b) {
        if (a == title) {
            if (xb_get_element(title + "_title")) {
                xb_get_element(title + "_title").className = "";
                xb_get_element(title + "_title").style.fontWeight = "bold"
            }
            if (xb_get_element(title + "_data")) {
                xb_get_element(title + "_data").style.display = "block"
            }
        } else {
            if (xb_get_element(title + "_title")) {
                xb_get_element(title + "_title").style.fontWeight = "normal";
                xb_get_element(title + "_title").className = "pseudolink"
            }
            if (xb_get_element(title + "_data")) {
                xb_get_element(title + "_data").style.display = "none"
            }
        }
    }
};
var _PROP_PER_PAGE = 15;

function save_search_home_page(b, e, a) {
    var g = getHTTPObject();
    var f = new Date();
    var c = site_root + "Sorgu/q_save/?hp=hp&ts=" + f.valueOf() + "&si=" + encodeURIComponent(b);
    if (typeof (e) != "undefined" && e) {
        c += "&fr=" + encodeURIComponent(e)
    }
    if (a || has_class("save_rs_" + b, "hidden")) {
        c += "&tp=eau"
    } else {
        c += "&tp=s"
    }
    g.open("POST", c);
    g.onreadystatechange = function () {
        var d;
        if (g.readyState == 4) {
            d = g.responseText;
            if (d == "1") {
                add_class("save_rs_" + b, "hidden");
                remove_class("saved_rs_" + b, "hidden");
                if (typeof (e) != "undefined") {
                    add_class("email_rs_" + b, "hidden");
                    remove_class("emailed_rs_" + b, "hidden");
                    add_class(b + "_email", "hidden");
                    remove_class(b + "_emailed", "hidden")
                }
            }
        }
    };
    g.send(null);
}
function save_search(a, f, c) {
    var e = document.getElementById("rs_" + a);
    if (e) {
        var h = getHTTPObject();
        var g = new Date();
        var b = site_root + "Sorgu/q_save/?tp=s&ts=" + g.valueOf() + "&si=" + encodeURIComponent(a);
        if (typeof (f) != "undefined") {
            b += "&fr=" + encodeURIComponent(f)
        }
        h.open("POST", b);
        h.onreadystatechange = function () {
            var l, m;
            if (h.readyState == 4) {
                l = h.responseXML;
                m = h.responseText;
                if (!l || l && !l.documentElement) {
                    if (m == "0") {
                        if (alert_login("searches")) {
                            go_to_page("signup/")
                        } else {
                            return
                        }
                    }
                    return
                }
                if (l.documentElement) {
                    var j = l.documentElement.getElementsByTagName("v")[0];
                    var k = j.getAttribute("u");
                    var n = j.getAttribute("h");
                    var q = j.getAttribute("t");
                    var d = j.getAttribute("s");
                    var p = l.documentElement.getElementsByTagName("c")[0].childNodes[0].nodeValue;
                    if (d == "1") {
                        kill(e.id);
                        xb_get_element("saved_searches_box").innerHTML += p;
                        remove_recent_search(a);
                        add_saved_search(a);
                        if (!(typeof (c) != "undefined" && c == 1)) {
                            update_feedback(SEARCH_SAVED)
                        }
                    }
                } else {
                    var d = h.responseText;
                    if (d == "-1") {
                        alert("An error occurred while saving your search.")
                    } else {
                        if (d == "0") {
                            if (alert_login("searches")) {
                                go_to_page("signup/")
                            } else {
                                return
                            }
                        }
                    }
                }
            }
        };
        h.send(null)
    }
}
function save_all_recent_searches() {
    var c = count_recent_searches();
    if (c == 0) {
        alert("All your recent searches are saved.");
        return
    }
    var a = confirm("Are you sure you want to save all your recent searches?");
    if (a) {
        for (var b = 0; b < c; ++b) {
            save_search(_rs_hash[b], "asla", 1)
        }
    }
    clear_recent_searches(true)
}
function clear_recent_searches(b) {
    var a;
    var f = true;
    if (typeof (b) != "undefined" && b == true) {
        a = true;
        f = false
    } else {
        a = confirm("Are you sure you want to clear all your recent searches?")
    }
    if (a) {
        var e = getHTTPObject();
        var c = new Date();
        e.open("POST", site_root + "q_crp.php?tp=rs&ts=" + c.valueOf());
        e.onreadystatechange = function () {
            if (e.readyState == 4) {
                if (!f) {
                    return
                }
                var m = xb_get_element("recent_searches_box");
                var j = m.childNodes;
                var g = j.length;
                var n, l;
                var d = 0;
                var k = count_recent_searches();
                for (var h = 0; h < g; ++h) {
                    l = j[h];
                    if (l.id && l.id != "" && l.id.indexOf("rs_") == 0) {
                        n = (l.id).substr(3);
                        l = m.removeChild(j[h]);
                        remove_recent_search(n);
                        if (++d >= k) {
                            break
                        } --h
                    }
                }
            }
        };
        e.send(null)
    }
}
function count_recent_searches() {
    return _rs_hash.length
}
function is_recent_search(a) {
    return _rs_hash.contains(a)
}
function is_saved_search(a) {
    return _ss_hash.contains(a)
}
function add_saved_search(a) {
    if (!is_saved_search(a)) {
        _ss_hash.push(a)
    }
    if (_ss_hash.length > 0) {
        unhide("delete_saved_searches_link");
        hide("saved_searches_msg")
    }
    update_search_count()
}
function remove_recent_search(a) {
    _rs_hash = array_remove(a, _rs_hash);
    if (_rs_hash.length < 1) {
        hide("save_delete_searches");
        unhide("no_recent_searches")
    }
    update_search_count()
}
function update_search_count() {
    xb_get_element("main_count_0_tab").innerHTML = (_rs_hash.length + _ss_hash.length)
}
function array_remove(e, d) {
    var c = new Array();
    var b = d.length;
    var a;
    for (a = 0; a < b; ++a) {
        if (d[a] != e) {
            c.push(d[a])
        }
    }
    return c
}
function count_unsaved_properties() {
    var c = 0;
    var b = document.getElementsByTagName("div");
    var a = "";
    for (i = 0; i < b.length; ++i) {
        var d = b[i].id;
        if (d && d.substr(0, 4) == "rpr_") {
            a = d.substr(4);
            if (!xb_get_element("spr_" + a)) {
                ++c
            }
        }
    }
    return c
}
function change_contact_me(c, b) {
    var a = new Object();
    a.field = xb_get_element("new_contact_me_field");
    a.value = (a.field.checked ? 1 : 0);
   
    a.word = "contact";
    a.tp = "cm";
    a.get_var = "cm";
    a.no_form_field = "no_form_contact_me";
    a.msg = new Array();
    a.msg.error = "An error occurred. Changes not saved.";
    a.msg.exists = "";
    a.msg.nochange = "";
    if (c) {
        a.msg.ok = ""
    } else {
        a.msg.ok = "Email preferences updated."
    }
    change_info(a, false, b)
}
function change_info(e, m, j) {
    var k = e.field;
    if (!k) {
        return
    }
    var a = "save_status_msg";
    var n = xb_get_element(a);
    var l = e.value;
    if (xb_get_element("feedback_block_container")) {
        var p = xb_get_element("feedback_block");
        p.parentNode.removeChild(p);
        xb_get_element("feedback_block_container").appendChild(p)
    }
    var c = "";
    var g = getHTTPObject();
    var h = new Date();
    var f = "tp=" + e.tp + "&ts=" + h.valueOf() + "&cnf=1&" + e.get_var + "=" + encodeURIComponent(l);
    var b = site_root + "Sorgu/q_update_info/";
    if (m) {
        g.open("POST", b, true);
        g.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
        g.send(f)
    } else {
        g.open("POST", b + "?" + f)
    }
    g.onreadystatechange = function () {
        if (g.readyState == 4) {
            var d = g.responseText;
            var r = false;
            if (d == "1") {
                if (e.other_field && e.other_field_msg) {
                    e.other_field.innerHTML = e.other_field_msg
                }
                if (e.no_form_field && xb_get_element(e.no_form_field)) {
                    xb_get_element(e.no_form_field).innerHTML = (e.word == "contact" ? (l == 1 ? "Yes, " : "No, don't ") : l)
                }
                if (xb_get_element("welcome_name") && e.word == "name") {
                    var q = (l != "" ? l : pull_address(xb_get_element("no_form_email").innerHTML));
                    if (q.length <= 20) {
                        xb_get_element("welcome_name_header").innerHTML = "Welcome back, ";
                        xb_get_element("welcome_name").innerHTML = q + "!"
                    } else {
                        xb_get_element("welcome_name_header").innerHTML = "Welcome back!";
                        xb_get_element("welcome_name").innerHTML = ""
                    }
                }
                if (!j) {
                    update_feedback(SETTING_UPDATED)
                }
            } else {
                if (d == "-1") {
                    update_feedback(SETTING_ERROR, 1);
                    r = true
                } else {
                    if (d == "0") {
                        if (!j) {
                            update_feedback(SETTING_NO_CHANGE)
                        }
                    } else {
                        if (d == "-2" && e.msg.exists != "") {
                            update_feedback(SETTING_EMAIL_UNAVAILABLE, 1);
                            e.field.value = xb_get_element(e.no_form_field).innerHTML;
                            r = true
                        }
                    }
                }
            }
            if (r) {
                k.focus()
            }
        }
    };
    if (!m) {
        g.send(null)
    }
}
function send_welcome_email(a, e) {
    var f = xb_get_element("welcome_email_status");
    unhide("welcome_email_status_container", "block");
    if (f) {
        f.innerHTML = "Lütfen bekleyiniz..."
    }
    var j = getHTTPObject();
    var h = new Date();
    var b = site_root + "Sorgu/q_send_welcome_email/?ts=" + h.valueOf();
    if (typeof (a) != "undefined" && a != "") {
        b += "&u=" + a
    }
    if (typeof (e) != "undefined" && e != "") {
        b += "&ct=" + e
    }
    var g = false;
    var c = "";
    j.open("POST", b);
    j.onreadystatechange = function () {
        if (j.readyState == 4) {
            var d = j.responseText;
            if (d == "1") {
                g = true
            } else {
                if (d == "-2") {
                    c = "Your confirmation email was just sent."
                }
            }
            if (f) {
                if (g) {
                    f.innerHTML = "Your confirmation email was just sent."
                } else {
                    f.innerHTML = (c == "" ? "An error occurred while sending your confirmation email. We have been notified of the error and will address this issue as soon as possible." : c)
                }
            }
        }
    };
    j.send(null)
}
function email_my_properties(c, b) {
    var a = site_root + "email_list.php?ptype=" + b;
    build_email_div(c, "property_list", a)
}
function update_feedback(f, a) {
    var b = xb_get_element("feedback_block");
    if (!b) {
        return
    }
    var e = (typeof (a) != "undefined" && a == 1);
    if (xb_get_element("feedback_block_msg")) {
        kill("feedback_block_msg")
    }
    var c = document.createElement("div");
    if (e) {
        c.className = "feedback_block_error"
    } else {
        c.className = "feedback_block"
    }
    c.innerHTML = f + (e ? CLOSE_FEEDBACK : "");
    c.id = "feedback_block_msg";
    c.style.display = "none";
    b.style.top = (10 + get_scroll_top()) + "px";
    b.appendChild(c);
    fade_effect("feedback_block_msg", 0);
    if (!e) {
        setTimeout("kill_feedback()", 2000)
    }
}
function kill_feedback(a) {
    if (typeof (a) != "undefined" && a == true) {
        kill("feedback_block_msg")
    } else {
        fade_effect("feedback_block_msg")
    }
}
function get_scroll_top() {
    var a;
    if (window.innerHeight) {
        a = window.pageYOffset
    } else {
        if (document.documentElement && document.documentElement.scrollTop) {
            a = document.documentElement.scrollTop
        } else {
            if (document.body) {
                a = document.body.scrollTop
            }
        }
    }
    return a
}
function delete_email_alert(g, c) {
    var e, a, d;
    var b = "";
    switch (c) {
        case "property":
            e = "property email alert";
            a = "tpeat_";
            d = PROPERTY_ALERT_DELETED;
            break;
        case "question":
            e = qpn_NAMES.voices + " saved question";
            b = "  Deleting this saved question will also remove any E-Posta Uyarıları tied to it.";
            a = "tvsqat_";
            d = VOICES_SAVED_QUESTION_DELETED;
            break;
        case "voices":
        default:
            e = qpn_NAMES.voices + " email alert";
            a = "tvat_";
            d = VOICES_ALERT_DELETED
    }
    if (confirm("Are you sure you want to delete this " + e + "?" + b)) {
        var f = new QAjax("update_email_alert");
        f.set_value("tp", "d");
        if (c == "question") {
            f.set_value("stype", "qaNewAnswers");
            f.set_value("aid", 0);
            f.set_value("qid", g)
        } else {
            f.set_value("aid", g)
        }
        f.set_callback(function (h) {
            h = parseInt(h);
            switch (h) {
                case 1:
                    if (c == "question") {
                        window.location.reload()
                    } else {
                        var j = xb_get_element(a + g);
                        if (j) {
                            j.parentNode.removeChild(j)
                        }
                        update_feedback(d);
                        update_email_alert_count(c, -1)
                    }
                    break;
                case -2:
                    if (alert_login_qa("update your " + e + "s")) {
                        show_login(false, "login", false, {
                            x: 625,
                            y: 75
                        })
                    }
                    break;
                case 100:
                    alert(_QA_ERROR_LABELS.not_allowed);
                    break;
                default:
                    alert(_QA_ERROR_LABELS.default_error)
            }
        });
        f.go()
    }
}
function update_email_alert_count(c, b) {
    var a;
    if (c == "question") {
        a = 2
    } else {
        if (c == "property") {
            a = 2
        } else {
            a = 1
        }
    }
    _ct_ea[c] += b;
    if (_ct_ea[c] < 0) {
        _ct_ea[c] = 0
    }
    if (_ct_ea[c] > 0) {
        unhide("delete_" + c + "_alerts_link");
        hide("saved_" + c + "_alerts_msg")
    } else {
        hide("delete_" + c + "_alerts_link");
        unhide("saved_" + c + "_alerts_msg")
    }
    if (c == "question") {
        xp_elem_str = "profile"
    } else {
        xp_elem_str = "main"
    }
    if (!xb_get_element(xp_elem_str + "_count_" + a + "_tab")) {
        return
    } else {
        xb_get_element(xp_elem_str + "_count_" + a + "_tab").innerHTML = _ct_ea[c]
    }
}
function expand_sp_row(c, b, a) {
    b.innerHTML = "Close row";
    unhide("expanding_row_" + a);
    b.onclick = function () {
        collapse_sp_row(c, b, a)
    }
}
function collapse_sp_row(c, b, a) {
    b.innerHTML = "See details";
    hide("expanding_row_" + a);
    b.onclick = function () {
        expand_sp_row(c, b, a)
    }
}
function build_upload_picture_div(a, g, j) {
    var b = "upload";
    var d = 435;
    var h = 600;
    var c = build_popup_layer(b, d);
    var f = new QAjax();
    if (g != null) {
        f.set_value("rurl", g)
    }
    f.set_script_info({
        script: "Sorgu/q_build_pic_upload/",
        method: "get",
        output: "text"
    });
    f.set_value("ts", new Date().valueOf());
    if (typeof (j) != null) {
        for (var e in j) {
            if (j.hasOwnProperty(e)) {
                f.set_value(e, j[e])
            }
        }
    }
    f.set_callback(function (k) {
        document.body.appendChild(c);
        c.innerHTML = k;
        set_safe_popup_coords(null, b);
        unhide(b);
        DOMUtils.hide_selects_by_el(xb_get_element(b))
    });
    f.go()
}
function TPictureUpload() { }
TPictureUpload.show_user_picture_formlet = function (c, d) {
    var b = "";
    var a;
    if (typeof (d) != "undefined" && d == "property") {
        b = build_property_picture_filename(c.u.value, c.propertyHash.value, c.timestamp.value);
        a = window.parent.xb_get_element("property_upload_img_url")
    } else {
        b = build_user_picture_filename(c.u.value, c.timestamp.value);
        a = window.parent.xb_get_element("user_pic_path")
    }
    if (a) {
        a.value = b
    }
};
var sls_imgs_queue = new Array();

function sls_imgs_queue_init() {
    if (typeof (_SLS_IMGS_QUEUE) != "undefined" && _SLS_IMGS_QUEUE != "") {
        for (i in _SLS_IMGS_QUEUE) {
            sls_imgs_queue.push(_SLS_IMGS_QUEUE[i])
        }
    }
}
function add_property_img_to_preview_section() {
    var b = window.parent.xb_get_element("property_upload_img_url");
    if (b.value != "") {
        var d = window.parent.xb_get_element("photo_browse_current_preview_section");
        var a = window.parent.xb_get_element("ni");
        if (d && a) {
            hide("_pic_upload_form_container");
            var c = new QAjax();
            c.set_script_info({
                script: "q_sls_form_get_preview_img.php",
                method: "post",
                output: "text"
            });
            c.set_value("preview_img_url", b.value);
            c.set_value("preview_img_id", ++a.value);
            c.set_callback(function (e) {
                if (e != "") {
                    unhide("throbber");
                    var f = new EmlakRexPoller(b.value);
                    f.on("success", function (g) {
                        setTimeout(function () {
                            d.innerHTML += e;
                            window.parent.sls_imgs_queue.push(b.value);
                            remove_class(d, "gone");
                            record_previously_uploaded_property_img(a.value, b.value);
                            hide("throbber");
                            unhide("_pic_upload_form_container");
                            if (a.value == 2) {
                                var h = window.parent.xb_get_element("sls_img_hint_order");
                                var j = window.parent.xb_get_element("sls_img_hint_click");
                                remove_class(h, "gone");
                                remove_class(j, "gone")
                            }
                        }, 1000)
                    });
                    f.on("error_stop", function (h) {
                        b.value = "";
                        a.value--;
                        hide("throbber");
                        unhide("_pic_upload_form_container");
                        var g = xb_get_element("pic_upload_form_error");
                        if (g) {
                            remove_class(g, "gone");
                            g.innerHTML = "We are unable to upload your image. Please try again"
                        }
                    });
                    f.start()
                }
            });
            c.go()
        }
    }
}
function record_previously_uploaded_property_img(a, b) {
    var c = window.parent.xb_get_element("mul_prop_imgs_upload");
    if (c) {
        c.innerHTML += '<input type="hidden" name="property_upload_img_url_' + a + '" id="property_upload_img_url_' + a + '" value="' + b + '" />';
        if (img_updated = window.parent.xb_get_element("img_updated")) {
            img_updated.value = 1
        }
    }
}
function remove_preview_img(h, b) {
    var j = h.split("_");
    j = j[3];
    if (typeof (j) != "undefined" && delete_img_from_sls_imgs_queue(j)) {
        var q = xb_get_element("ni");
        var p = window.parent.xb_get_element("img_updated");
        var n = xb_get_element("photo_browse_" + b + "_preview_section");
        var k = xb_get_element("mul_prop_imgs_upload");
        if (q && p && n && k) {
            var l = q.value;
            q.value--;
            p.value = 1;
            if (q.value == 0) {
                add_class("photo_browse_current_preview_section", "gone");
                add_class("photo_browse_new_preview_section", "gone")
            } else {
                if (q.value <= 1) {
                    add_class("sls_img_hint_order", "gone");
                    add_class("sls_img_hint_click", "gone")
                }
            }
            var g = parseInt(j) - 1;
            for (i in sls_imgs_queue) {
                var a = parseInt(i);
                if (a >= g) {
                    var d = a + 1;
                    var c = xb_get_element("preview_img_id_" + d);
                    var e = xb_get_element("property_upload_img_url_" + d);
                    if (c && e) {
                        c.src = sls_imgs_queue[a];
                        e.value = sls_imgs_queue[a]
                    }
                }
            }
            var m = xb_get_element("preview_img_" + l);
            var f = xb_get_element("property_upload_img_url_" + l);
            if (m && f) {
                n.removeChild(m);
                k.removeChild(f)
            }
        }
    }
}
function delete_img_from_sls_imgs_queue(a) {
    if (a >= 1 && a <= sls_imgs_queue.length) {
        sls_imgs_queue.splice(a - 1, 1);
        return true
    }
    return false
}
var last_primary_photo_id = "";

function sls_make_img_main(c) {
    var b = c.split("_");
    var a = b[3];
    if (typeof (a) != "undefined") {
        if (last_primary_photo_id != "") {
            remove_class("preview_img_" + last_primary_photo_id, "photo_preview_div_main");
            add_class("preview_img_" + last_primary_photo_id + "_txt", "gone")
        }
        sls_pic_change_rank("preview_img_rank_" + a, 1);
        add_class("preview_img_1", "photo_preview_div_main");
        remove_class("preview_img_1_txt", "gone");
        last_primary_photo_id = a
    }
}
function activate_photo_web_upload() {
    var b = xb_get_element("property_upload_web_url_section");
    var a = xb_get_element("photo_browse_header");
    if (b && a) {
        if (b.style.display == "none") {
            b.style.display = "block";
            toggle_class(a, "sls_arrow_tab_opened", "sls_arrow_tab_closed")
        } else {
            b.style.display = "none";
            toggle_class(a, "sls_arrow_tab_closed", "sls_arrow_tab_opened")
        }
    }
}
var simple_valid_url_regex = /^((http|https|ftp):\/\/)[^\s]+$/;

function add_photo_web_upload() {
    var c = xb_get_element("property_upload_web_url");
    if (c.value == "") {
        alert("Please enter the URL of the photo\n(e.g. http://www.mywebsite.com/property/kitchen.jpg)")
    } else {
        if (simple_valid_url_regex.exec(c.value) == null) {
            alert("Please enter a valid URL\n(e.g. http://www.mywebsite.com/property/kitchen.jpg)");
            DOMUtils.set_value("e_uw", 0)
        } else {
            var f = xb_get_element("photo_browse_current_preview_section");
            var a = xb_get_element("ni");
            if (f && a) {
                add_class("_photo_browse_section", "gone");
                unhide("throbber");
                var e = c.value;
                var b = xb_get_element("photo_upload_web_error");
                var d = new QAjax();
                d.set_script_info({
                    script: "q_get_remote_image_size.php",
                    method: "post",
                    output: "text"
                });
                d.set_value("img_url", e);
                d.set_callback(function (h) {
                    if (h != "") {
                        if (b) {
                            DOMUtils.set_value("e_uw", 0);
                            DOMUtils.set_value("c_uw", 0);
                            hide("throbber");
                            remove_class("_photo_browse_section", "gone");
                            remove_class(b, "gone");
                            b.innerHTML = h
                        }
                    } else {
                        add_class(b, "gone");
                        b.innerHTML = "";
                        a.value++;
                        var g = new QAjax();
                        g.set_script_info({
                            script: "q_sls_form_get_preview_img.php",
                            method: "post",
                            output: "text"
                        });
                        g.set_value("preview_img_url", e);
                        g.set_value("preview_img_id", a.value);
                        g.set_callback(function (k) {
                            if (k != "") {
                                DOMUtils.set_value("c_uw", 1);
                                hide("property_upload_web_url_error");
                                f.innerHTML += k;
                                remove_class(f, "gone");
                                record_previously_uploaded_property_img(a.value, c.value);
                                sls_imgs_queue.push(c.value);
                                if (a.value == 2) {
                                    var j = xb_get_element("sls_img_hint_order");
                                    var l = xb_get_element("sls_img_hint_click");
                                    remove_class(j, "gone");
                                    remove_class(l, "gone")
                                }
                            }
                            hide("throbber");
                            remove_class("_photo_browse_section", "gone");
                            c.className = "default_text";
                            c.value = "e.g. http://www.mywebsite.com/property/kitchen.jpg"
                        });
                        g.go()
                    }
                });
                d.go()
            }
        }
    }
}
function sls_swap_imgs(d, c) {
    if (d >= 0 && d < sls_imgs_queue.length && c >= 0 && c < sls_imgs_queue.length) {
        if (d < c) {
            var b = sls_imgs_queue[c];
            sls_imgs_queue[c] = sls_imgs_queue[d];
            update_img_src(c + 1, sls_imgs_queue[d]);
            for (i = c - 1; i >= d; i--) {
                var a = sls_imgs_queue[i];
                sls_imgs_queue[i] = b;
                update_img_src(i + 1, b);
                b = a
            }
        } else {
            if (d > c) {
                var b = sls_imgs_queue[c];
                sls_imgs_queue[c] = sls_imgs_queue[d];
                update_img_src(c + 1, sls_imgs_queue[d]);
                for (i = c + 1; i <= d; i++) {
                    var a = sls_imgs_queue[i];
                    sls_imgs_queue[i] = b;
                    update_img_src(i + 1, b);
                    b = a
                }
            }
        }
        return true
    } else {
        return false
    }
}
function update_img_src(d, c) {
    var a = xb_get_element("property_upload_img_url_" + d);
    var b = xb_get_element("preview_img_id_" + d);
    if (a && b) {
        a.value = c;
        b.src = c
    }
}
function sls_pic_change_rank(c, a) {
    var b = xb_get_element("img_updated");
    if (b) {
        b.value = 1;
        var c = c.split("_");
        old_rank = c[3];
        var e = parseInt(old_rank) - 1;
        var d = parseInt(a) - 1;
        sls_swap_imgs(e, d);
        old_rank_value = xb_get_element("preview_img_rank_" + old_rank);
        old_rank_value.value = old_rank
    }
}
function build_user_picture_filename(a, b) {
    var d = new Date();
    var c = 'profile' + "_" + a + "_" + (d.getFullYear() + "" + d.getMonth() + "" + d.getDay());
    var t = "/Upload/Resimler/" + 'profile' + "/" + d.getFullYear() + "/" + d.getMonth() + "/" + d.getDay() + "/" + a + "/" + c + '.jpg';
    return t;
   // alert(t);
   // return _IMAGE_SERVER_ROOT + "userimg/" + Math.floor(a / 250) + "/" + a + "_" + b + "_m.jpg"
}
function build_property_picture_filename(a, c, b) {
    return _IMAGE_SERVER_ROOT + "propimg/" + Math.floor(a / 250) + "/" + a + "_" + c + "_" + b + "_big.jpg"
}
function try_to_submit(b) {
    try {
        b.submit();
        return true
    } catch (a) {
        return false
    }
}
TPictureUpload.handle_pic_upload_form = function (b) {
    if (trim(b.userfile.value) == "") {
        alert("Please select a picture to upload.");
        b.userfile.focus();
        return false
    }
    var a = window.parent.xb_get_element("_pic_upload_submit_btn");
    set_submit_btn_state(a, false);
    if (try_to_submit(b)) {
        return true
    } else {
        return false
    }
};
TPictureUpload.handle_property_pic_upload_form = function (a) {
    if (trim(a.userfile.value) == "") {
        alert("Please select a picture to upload.");
        a.userfile.focus();
        return false
    }
    if (try_to_submit(a)) {
        return true
    } else {
        return false
    }
};
TPictureUpload.handle_blog_pic_upload_form = function (b) {
    if (trim(b.userfile.value) == "") {
        alert("Please select a picture to upload.");
        b.userfile.focus();
        return false
    }
    xb_get_element("uploaded_blog_image").src = "#";
    hide("_pic_upload_form_container");
    unhide("throbber");
    try {
        b.submit();
        return true
    } catch (a) {
        return false
    }
    return false
};
TPictureUpload.handle_blog_pic_upload_return = function (a) {
    hide("throbber");
    unhide("_pic_upload_form_container");
    if (typeof a.errors != "undefined" && a.errors !== "") {
        xb_get_element("_pic_upload_form").userfile.value = "";
        alert(a.errors)
    } else {
        if (typeof TPictureUpload.successCallback == "function") {
            TPictureUpload.successCallback.call(this, a)
        }
        remove_class("uploaded_blog_image_container", "hidden");
        xb_get_element("_pic_upload_form").userfile.value = ""
    }
};

function set_submit_btn_state(a, b, c) {
    if (!a) {
        return false
    }
    if (!b) {
        a.disabled = true;
        a.value = "Lütfen bekleyiniz..."
    } else {
        a.disabled = false;
        a.value = typeof (c) != "undefined" ? c : "SUBMIT"
    }
}
function build_popup_layer(c, a) {
    var b;
    if (b = xb_get_element(c)) {
        b.parentNode.removeChild(b)
    }
    b = $$("div", "", c);
    b.style.display = "inline";
    b.className = "drop_shadow";
    b.style.position = "absolute";
    b.style.zIndex = "1600";
    b.style.width = a + "px";
    return b
}
function kill_layer(b) {
    var a = xb_get_element(b);
    if (a) {
        a.parentNode.removeChild(a);
        unhide_selects(a)
    }
}
function remove_property_featured(a) {
    if (confirm("Are you sure you want to remove this property from your featured list?")) {
        var b = xb_get_element("removePropertyId");
        b.value = propertyId;
        document.removePropertyForm.submit()
    }
}
function build_source_select_div(e, pid) {
    var cloned_event = clone_obj(e);
    doNothing(e);
    var ajax = new QAjax();
    ajax.set_script_info({
        script: "q_afl_source_select_div.php",
        method: "get",
        output: "text"
    });
    ajax.set_value("pid", pid);
    ajax.set_callback(function (json) {
        eval("var output=" + json);
        if (typeof (output.status) == "undefined" || output.status != 1) {
            return false
        }
        if (output.has_pro) {
            var show_me = function () {
                var cfg = {
                    width: "420px",
                    close: true,
                    classname: "my_listings_change_source",
                    id: "my_listings_change_source",
                    cache_endpoint: false
                };
                var oP = new emlakrex.Popup(cfg);
                oP.setHeader("Change listing source");
                oP.setBody(output.html);
                oP.show()
            };
            if (!YAHOO.widget.Panel) {
                YUI.use("container", show_me)
            } else {
                show_me()
            }
        } else {
            pos_menuyu_goster(cloned_event, "emlakrexpro_change_url_popup")
        }
    });
    ajax.go()
}
function source_select_save(c, b, e) {
    var a = c.sourceSelection.length;
    for (i = 0; i < a; i++) {
        if (c.sourceSelection[i].checked) {
            site_id = c.sourceSelection[i].value
        }
    }
    if (typeof (site_id) == "undefined" || site_id == e) {
        toggle_menu("", "id_doesnt_matter", 0);
        return
    }
    var d = new QAjax();
    d.set_script_info({
        script: "q_afl_source_select_save.php",
        method: "get",
        output: "text"
    });
    d.set_value("pid", b);
    d.set_value("sid", site_id);
    d.set_callback(function (f) {
        toggle_menu("", "id_doesnt_matter", 0);
        if (f != -1) {
            page_my_listings()
        }
    });
    d.go()
}
function refresh_created_listing(b, d, a) {
    if (d == "Resubmit") {
        if (remove_property_type == "For Rent") {
            go_to_page("account/listelemeler/rental/resubmit/" + a)
        } else {
            go_to_page("account/listelemeler/resubmit/" + a)
        }
        return false
    }
    var c = new QAjax();
    c.set_script_info({
        script: "q_refresh_created.php",
        method: "post",
        output: "text"
    });
    c.set_value("sid", b);
    c.set_value("pt", remove_property_type);
    c.set_callback(function (e) {
        if (e == 1) {
            page_my_listings()
        }
    });
    c.go()
}
function switch_featured_listing(c) {
    var a = document.value_pro_feature_listing.property_id.value;
    var b = document.value_pro_feature_listing.address.value;
    var d = new QAjax();
    d.set_script_info({
        script: "q_change_featured_status.php",
        method: "post",
        output: "text"
    });
    d.set_value("pid", a);
    d.set_value("switch", "y");
    d.set_value("flag", "0");
    d.set_callback(function (f) {
        if (f != -1) {
            var g = xb_get_element("featured_address_div");
            var e = xb_get_element("featured_success_message_div");
            g.innerHTML = b;
            e.innerHTML = "This listing is in a queue to be added into the set of featured listelemeler on EmlakRex. It should start enjoying greater exposure than non-featured listelemeler within 24-48 hours.";
            pos_menuyu_goster(c, "feature_listing_success_popup", 10, -10);
            page_my_listings()
        }
    });
    d.go();
    remove_property_id = ""
}
function change_featured_status(m, c, b, d, j, l, k, p) {
    is_featured = (c.checked ? 1 : 0);
    var n = clone_obj(m);
    if (max_featured == 0 && is_featured == "1") {
        pos_menuyu_goster(m, "feature_listing_promo_popup", 10, -10);
        if (c) {
            c.checked = !c.checked
        }
        return
    } else {
        if (max_featured == 1 && featured_total >= max_featured && is_featured == "1") {
            var g = xb_get_element("popup_feature_address1");
            var f = xb_get_element("popup_feature_address2");
            var e = xb_get_element("popup_feature_address3");
            var a = xb_get_element("popup_unfeature_address");
            g.innerHTML = p;
            f.innerHTML = p;
            e.innerHTML = p;
            a.innerHTML = current_address_featured;
            document.value_pro_feature_listing.property_id.value = b;
            document.value_pro_feature_listing.address.value = k;
            document.value_pro_feature_listing.elem_id.value = c.id;
            pos_menuyu_goster(m, "feature_listing_promo_popup", 10, -10);
            if (c) {
                c.checked = !c.checked
            }
            return
        } else {
            if (max_featured > 1 && featured_total >= max_featured && is_featured == "1") {
                pos_menuyu_goster(m, "feature_listing_promo_popup", 10, -10);
                if (c) {
                    c.checked = !c.checked
                }
                return
            }
        }
    }
    if (typeof (b) == "undefined") {
        if (c) {
            c.checked = !c.checked
        }
        return
    }
    var h = new QAjax();
    h.set_script_info({
        script: "q_change_featured_status.php",
        method: "post",
        output: "text"
    });
    h.set_value("pid", b);
    h.set_value("flag", is_featured);
    h.set_callback(function (r) {
        if (r != -1) {
            if (c != "1" && c != "0") {
                if (r == 3) {
                    pos_menuyu_goster(n, "my_listings_maximum_featured", 10, -10);
                    if (c) {
                        c.checked = !c.checked
                    }
                    return
                }
                var s = xb_get_element("featured_address_div");
                var q = xb_get_element("featured_success_message_div");
                s.innerHTML = k;
                if (is_featured == 1) {
                    q.innerHTML = "This listing is in a queue to be added into the set of featured listelemeler on EmlakRex. It should start enjoying greater exposure than non-featured listelemeler within 24-48 hours.";
                    featured_total = featured_total + 1
                } else {
                    q.innerHTML = "This listing is no longer featured.";
                    featured_total = featured_total - 1
                }
                pos_menuyu_goster(n, "feature_listing_success_popup", 10, -10);
                page_my_listings()
            }
        } else {
            if (c) {
                c.checked = !c.checked
            }
        }
    });
    h.go()
}
function toggleSearch(a) {
    var d = "listingSearchBox";
    var e = "arrowRight";
    var c = "arrowDown";
    var b = xb_get_element("listingSearchBox");
    if (b.style.display == "none") {
        unhide(d, "block");
        hide(e);
        unhide(c, "inline")
    } else {
        if (a) {
            hide(d);
            hide(c);
            unhide(e, "inline")
        }
    }
}
function update_filter_display() {
    var a = -1;
    elem = xb_get_element("filter_deleted");
    while (elem) {
        elem.className = (my_listings_page_filter == a ? "notlink bold" : "");
        a++;
        elem = xb_get_element("filter_" + a)
    }
}
function page_my_listings(next_page, property_type, sort, filter) {
    if (is_reporting_page) {
        page_reporting(next_page, property_type, sort, filter);
        return
    }
    if (typeof (next_page) == "undefined") {
        next_page = my_listings_page_number
    } else {
        my_listings_page_number = next_page
    }
    if (typeof (property_type) == "undefined") {
        property_type = remove_property_type
    }
    if (typeof (sort) == "undefined" || sort == "") {
        sort = my_listings_page_sort
    }
    if (typeof (filter) == "undefined" || filter == "") {
        filter = my_listings_page_filter
    }
    hide("afl_popup");
    update_filter_display();
    var ajax = new QAjax();
    var elem = xb_get_element("my_emlakrex_right_content");
    var container_elem = xb_get_element("my_listings_content");
    ajax.set_script_info({
        script: "q_update_my_listings_property_rows.php",
        method: "get",
        output: "text"
    });
    ajax.set_value("page_number", next_page);
    ajax.set_value("prop_type", property_type);
    ajax.set_value("sort", sort);
    ajax.set_value("filter", filter);
    ajax.set_callback(function (output) {
        if (output == "-1") {
            if (property_type == "For Rent") {
                go_to_page("account/listelemeler/rental/")
            } else {
                go_to_page("account/listelemeler/")
            }
            return
        }
        eval("var o = " + output);
        featured_total = o.num_fl;
        if (elem) {
            remove_ajax_feedback();
            elem.innerHTML = o.html;
            set_opac(elem, 100);
            emlakrex.ui.init()
        }
    });
    if (elem) {
        set_opac(elem, 20);
        create_ajax_feedback("", container_elem)
    }
    ajax.go()
}
function page_reporting(next_page, property_type, sort, filter) {
    hide("afl_popup");
    var container_elem = xb_get_element("stats_refresh_container");
    var elem = xb_get_element("my_emlakrex_right_content");
    var ajax = new QAjax();
    ajax.set_script_info({
        script: "q_update_my_listings_stats_rows.php",
        method: "get",
        output: "text"
    });
    ajax.set_callback(function (output) {
        eval("var o = " + output);
        if (typeof (o) != "undefined" && o.status) {
            container_elem.innerHTML = o.html;
            init_reporting_table()
        }
        if (elem) {
            remove_ajax_feedback();
            set_opac(elem, 100);
            emlakrex.ui.init()
        }
    });
    if (elem) {
        set_opac(elem, 20);
        create_ajax_feedback("", container_elem)
    }
    ajax.go()
}
function show_more_notifications_toggle() {
    var b = xb_get_element("my_listings_more_notifications");
    var a = xb_get_element("my_listings_show_more_link");
    var c = xb_get_element("my_listings_show_less_link");
    if (b && a && c) {
        if (b.style.display == "none") {
            hide(a);
            unhide(c, "block");
            unhide(b, "block")
        } else {
            unhide(a, "block");
            hide(c);
            hide(b);
            b.style.display = "none"
        }
    }
}
function my_listings_search() { }
my_listings_search.actions = [];
my_listings_search.my_listings_search_current_page = 0;
my_listings_search.afl = 0;
my_listings_search.tos_required = true;
my_listings_search.show_popup = function () {
    var d = "my_listings_find_listings";
    var b = "Find or Submit your listelemeler";
    var e = 700;
    var a = false;
    var c = function () {
        var f = {
            width: e,
            close: true,
            classname: d,
            id: d,
            cache_endpoint: a
        };
        var g = new emlakrex.Popup(f);
        g.setContentSource("Sorgu/q_show_simple_popup/?popup_name=" + d + "&popup_header=" + b);
        g.show();
        my_listings_search.popup = g
    };
    if (!YAHOO.widget.Panel) {
        YUI.use("container", c)
    } else {
        c()
    }
    return false
};
my_listings_search.add_action = function (a, c) {
    var b = {
        property_id: a,
        action: c
    };
    my_listings_search.actions[a] = b;
    return true
};
my_listings_search.process_toggle = function (f, d, b) {
    if (!f && !d && !b) {
        return false
    }
    var c = f.checked;
    var e = "";
    var a = false;
    if (c) {
        if (d == "feature") {
            e = "feature"
        } else {
            if (d == "claim") {
                e = "claim"
            }
        }
    } else {
        if (d == "feature") {
            e = "unfeature"
        } else {
            if (d == "claim") {
                e = "unclaim"
            }
        }
    }
    if (e != "") {
        a = my_listings_search.add_action(b, e);
        my_listings_search.toggle_check_box(b, c)
    }
    if (!a) {
        my_listings_search.toggle_check_box(b, !f.checked)
    }
    this.check_tos();
    return a
};
my_listings_search.check_tos = function () {
    var b = xb_get_element("additional_emails_md5");
    if (!b || b.value == "") {
        return false
    }
    var e = b.value.split(",");
    var a = false;
    var c = YUI.get("#my_listings_search_results_table .my_listings_search_pid");
    for (var d = 0; d < c.length; d++) {
        if (typeof (c[d].checked) != "undefined") {
            if (c[d].checked) {
                var f = xb_get_element("property_email_" + c[d].value);
                if (f.value != "" && !in_array(f.value, e)) {
                    a = true
                }
            }
        }
    }
    if (a) {
        unhide("my_listings_search_to_email", "inline")
    } else {
        hide("my_listings_search_to_email")
    }
};
my_listings_search.toggle_check_box = function (a, b) {
    var c = xb_get_element("my_listings_search_result_toggle_" + a);
    if (!c) {
        return false
    }
    if (b) {
        c.checked = true
    } else {
        c.checked = false
    }
};
my_listings_search.toggle_checkboxes = function () {
    var a = "my_listings_search_result_toggle_";
    for (p_id in my_listings_search.actions) {
        var b = xb_get_element(a + p_id);
        var d = my_listings_search.actions[p_id]["action"];
        var c = -1;
        if (d) {
            if (d == "unfeature" || d == "unclaim") {
                c = false
            }
            if (d == "feature" || d == "claim") {
                c = true
            }
        }
        if (c != -1 && b) {
            my_listings_search.toggle_check_box(p_id, c)
        }
    }
};
my_listings_search.check_page = function (e) {
    var b = YUI.get("#my_listings_search_results_table .my_listings_search_pid");
    var f = [];
    for (var d = 0; d < b.length; d++) {
        if (typeof (b[d].value) != "undefined" && !b[d].disabled) {
            f.push(b[d].value)
        }
    }
    var a = "my_listings_search_result_toggle_";
    if (f.length < 1) {
        return false
    }
    for (var d = 0; d < f.length; ++d) {
        var c = xb_get_element(a + f[d]);
        if (c) {
            my_listings_search.toggle_check_box(f[d], e);
            my_listings_search.process_toggle(c, "claim", f[d])
        }
    }
    if (e) {
        YUI.getId("my_listings_search_check_all").className = "bold";
        YUI.getId("my_listings_search_check_none").className = "pseudolink"
    } else {
        YUI.getId("my_listings_search_check_none").className = "bold";
        YUI.getId("my_listings_search_check_all").className = "pseudolink"
    }
    return true
};
my_listings_search.show_more = function (search_type) {
    my_listings_search.more_page_number += 1;
    var page = my_listings_search.more_page_number;
    var frm = xb_get_element("my_listings_combo_search_form");
    if (!frm) {
        return
    }
    var srchval = trim(DOMUtils.get_value(frm.search));
    if (srchval == "" || srchval.toLowerCase() == DOMUtils.get_value(frm.default_value).toLowerCase()) {
        return false
    }
    if (typeof frm.submit_btn !== "undefined") {
        frm.submit_btn.value = "Searching...";
        frm.submit_btn.disabled = true
    }
    var ajax = new QAjax();
    ajax.set_script_info({
        script: "q_my_listings_search.php",
        method: "POST",
        output: "text"
    });
    ajax.set_value("search", srchval);
    ajax.set_value("rows_only", 1);
    ajax.set_value("page", this.more_page_number);
    ajax.set_callback(function (o) {
        eval("var output=" + o);
        if (typeof (output) != "undefined" && typeof (output.header) != "undefined" && typeof (output.body) != "undefined") {
            if (output.num_returned == 0) {
                hide("my_listings_search_show_more");
                return
            } else {
                var container = YUI.getId("search_results_tbody");
                var tbl = document.createElement("div");
                tbl.innerHTML = output.body;
                var trs = YAHOO.util.Dom.getElementsBy(function (el) {
                    return true
                }, "tr", tbl);
                for (var i = 0; i < trs.length; i++) {
                    container.appendChild(trs[i])
                }
            }
            if (output.num_found <= page * output.per_page) {
                hide("my_listings_search_show_more")
            }
        }
    });
    ajax.go()
};
my_listings_search.get_selected_properties = function (c) {
    var b = Array();
    for (p_id in my_listings_search.actions) {
        var a = my_listings_search.actions[p_id]["action"];
        if (a == c) {
            b.push(p_id)
        }
    }
    return b
};
var fb_feed_claim_property_ids = Array();
my_listings_search.commit_changes = function (has_afl) {
    if (typeof (has_afl) != "undefined") {
        my_listings_search.afl = has_afl
    }
    var tos_check = YUI.getId("search_tos");
    if (this.tos_required && (typeof (tos_check) == "undefined" || !tos_check || !tos_check.checked)) {
        var error_element = xb_get_element("my_listings_search_no_actions_error_message");
        error_element.innerHTML = "You must agree to the terms of service to continue.";
        unhide(error_element, "block");
        return false
    }
    var property_ids = Array();
    if (my_listings_search.actions.length < 1) {
        var error_element = xb_get_element("my_listings_search_no_actions_error_message");
        var formObj = document.forms.property_add_form;
        var propAlreadySelected = 0;
        for (fi = 0; fi < formObj.elements.length; fi++) {
            if (formObj.elements[fi].type == "checkbox") {
                checkboxNm = formObj.elements[fi].id;
                if (checkboxNm.substr(0, 33) == "my_listings_search_result_toggle_") {
                    if (formObj.elements[fi].checked == true && formObj.elements[fi].disabled == false) {
                        propAlreadySelected = 1;
                        break
                    }
                }
            }
        }
        if (propAlreadySelected == 1) {
            error_element.innerHTML = "You have already selected this property."
        } else {
            error_element.innerHTML = "You have not selected any properties."
        }
        unhide(error_element, "block");
        return false
    }
    hide("my_listings_search_no_actions_error_message");
    property_ids = my_listings_search.get_selected_properties("claim");
    fb_feed_claim_property_ids = property_ids;
    var ajax = new QAjax();
    ajax.set_script_info({
        script: "q_my_listings_search_commit.php",
        method: "post",
        output: "text"
    });
    if (property_ids.length > 0) {
        ajax.set_value("action", "claim");
        ajax.set_value("pids", property_ids)
    } else {
        var error_element = xb_get_element("my_listings_search_no_actions_error_message");
        error_element.innerHTML = "You have not selected any properties.";
        unhide(error_element, "block");
        return false
    }
    if (typeof MyListingsPageSimple !== "undefined") {
        ajax.set_value("output_options", MyListingsPageSimple.ajax_output_commit)
    }
    ajax.set_callback(function (text) {
        eval("var rtrns = " + text);
        if (typeof (rtrns) == "undefined" || !rtrns) {
            my_listings_search.close();
            return
        }
        var error_element = xb_get_element("my_listings_search_no_actions_error_message");
        if (rtrns.success == 1) {
            if (typeof MyListingsPageSimple !== "undefined") {
                MyListingsPageSimple.post_commit.call();
                return
            }
            page_my_listings();
            my_listings_search.show_feature_confirmation(has_afl, property_ids.length)
        } else {
            if (rtrns.success == 2) {
                alert("You must accept EmlakRex's Terms of Service in order to claim properties");
                DOMUtils.fill_element(error_element, "You must accept EmlakRex's Terms of Service in order to claim properties");
                unhide(error_element, "block")
            } else {
                if (rtrns.success == 3) {
                    var error_element = xb_get_element("my_listings_search_no_actions_error_message");
                    DOMUtils.fill_element(error_element, 'Your request to claim the selected properties would exceed the 250 property limit.  Please <a href="/EmlakRex/Yardim/">contact us</a> with further questions.');
                    unhide(error_element, "block")
                } else {
                    var error_element = xb_get_element("my_listings_search_no_actions_error_message");
                    DOMUtils.fill_element(error_element, "There was an error submitting your request. Please try again.");
                    unhide(error_element, "block")
                }
            }
        }
        my_listings_search.popup.position()
    });
    ajax.go()
};
my_listings_search.upsell_popup = function () {
    YAHOO.util.Event.onAvailable("property_row_my_listings_1", function () {
        function a() {
            var b = {
                width: "230px",
                height: "150px",
                close: false,
                classname: "my_listings_claim_upsell",
                id: "my_listings_claim_upsell",
                fixedcenter: false,
                fixed_pointer: "right"
            };
            var c = new emlakrex.Popup(b);
            c.setContentSource("Sorgu/q_show_simple_popup/?popup_name=my_listings_claim_upsell&popup_header=");
            c.setPoint("feature_row_1");
            c.show()
        }
        if (!YAHOO.widget.Panel) {
            YUI.use("container", a)
        } else {
            a()
        }
    })
};
my_listings_search.show_feature_confirmation = function (b, d) {
    var f = xb_get_element("my_listings_search_feature_confirmation_content");
    var h = xb_get_element("my_listings_search_results_main_content");
    var e = xb_get_element("my_listings_search_not_featured_list_container");
    var g = xb_get_element("my_listings_search_not_featured_list");
    var c = xb_get_element("search_commit_number");
    var a = [xb_get_element("search_commit_email_1"), xb_get_element("search_commit_email_2"), xb_get_element("search_commit_email_3")];
    hide("my_listings_combo_search_form");
    hide("my_listings_search_box_already");
    if (f && h && g && e) {
        if (c) {
            c.innerHTML = d
        }
        if (a[0] && a[1]) {
            a[0].innerHTML = this.search_val;
            a[1].innerHTML = this.search_val;
            a[2].innerHTML = this.search_val
        }
        if (typeof (this.search_type) != "undefined" && this.search_type == "email" && my_listings_search.check_email_address(this.search_val)) {
            unhide("add_email_message", "block");
            hide("search_standard_buttons")
        } else {
            unhide("search_standard_buttons", "block")
        }
        if (!b) {
            hide("been_featured")
        } else {
            unhide("been_featured", "block")
        }
        hide(h);
        unhide(f, "block")
    }
};
my_listings_search.add_email = function () {
    var ajax = new QAjax();
    ajax.set_script_info({
        script: "q_my_listings_add_email.php",
        method: "get",
        output: "text"
    });
    ajax.set_value("email", this.search_val);
    ajax.set_callback(function (text) {
        eval("var o = " + text);
        if (typeof (o) != "undefined" && o.status == 1) {
            hide("my_listings_search_feature_confirmation_messages");
            hide("add_email_message");
            unhide("my_listings_search_add_email_confirmation", "block");
            unhide("search_standard_buttons", "block")
        } else {
            my_listings_search.close()
        }
    });
    ajax.go()
};
my_listings_search.is_valid_address = function (a, c, d, f, e, b) {
    var g = new Array();
    if (!c || c.value.length < 1) {
        g.street_number = 1
    }
    if (!d || d.value.length < 1) {
        g.street_name = 1
    }
    if (!a || a.value.length < 1) {
        g.unit_number = 1
    }
    if (!f || f.value.length < 1) {
        g.city = 1
    }
    if (!e || e.value.length < 1) {
        g.state = 1
    }
    if (!b || b.value.length < 5) {
        g.zip = 1
    }
    if ((g.city || g.state) && g.zip) {
        g.location = 1
    }
    if (g.street_number && g.street_name) {
        g.address = 1
    }
    return g
};
my_listings_search.reset_page_count = function () {
    my_listings_search.my_listings_search_current_page = 0;
    my_listings_search.updated = 0;
    my_listings_search.actions = []
};
my_listings_search.close_error_message = function (c) {
    if (!c) {
        return
    }
    if (c == "address") {
        var a = xb_get_element("my_listings_search_box_error_message");
        if (a) {
            hide(a)
        }
    } else {
        if (c == "email") {
            var b = xb_get_element("my_listings_search_email_error");
            if (b) { }
            hide(b)
        }
    }
};
my_listings_search.close = function (a) {
    my_listings_search.reset_page_count();
    toggle_menu(a, "id_doesnt_matter", 0);
    if (my_listings_search.updated == 1) {
        page_my_listings("1")
    }
};
my_listings_search.check_email_address = function (a) {
    var b = [];
    if (YUI.getId("additional_emails") && YUI.getId("additional_emails").value) {
        b = YUI.getId("additional_emails").value.split(",")
    }
    if (is_valid_email(a) && !in_array(a, b)) {
        return true
    } else {
        return false
    }
};
emlakrex.submit_my_listings_search = function (search_type, new_page) {
    search_type = "combo";
    var results_container = xb_get_element("find_listings_results");
    var results_container_header = xb_get_element("find_listings_results_header");
    var results_container_contents = xb_get_element("find_listings_results_contents");
    var search_box_container = null;
    var page = 1;
    if (new_page && new_page > 0) {
        page = new_page
    }
    if (my_listings_search.my_listings_search_current_page == page) {
        return
    } else {
        my_listings_search.my_listings_search_current_page = page
    }
    var frm = xb_get_element("my_listings_combo_search_form");
    if (!frm) {
        return
    }
    var srchval = trim(DOMUtils.get_value(frm.search));
    if (srchval == "" || srchval.toLowerCase() == DOMUtils.get_value(frm.default_value).toLowerCase()) {
        return false
    }
    my_listings_search.search_val = srchval;
    if (typeof frm.submit_btn !== "undefined") {
        frm.submit_btn.value = "Searching...";
        frm.submit_btn.disabled = true
    }
    var ajax = new QAjax();
    ajax.set_script_info({
        script: "q_my_listings_search.php",
        method: "POST",
        output: "text"
    });
    ajax.set_value("search", srchval);
    ajax.set_value("page", page);
    if (YUI.getId("add_user_email") && YUI.getId("add_user_email").checked) {
        ajax.set_value("add_user_email", 1)
    }
    ajax.set_callback(function (o) {
        eval("var output=" + o);
        if (typeof (output) != "undefined" && typeof (output.header) != "undefined" && typeof (output.body) != "undefined") {
            DOMUtils.fill_element(results_container_contents, output.body);
            my_listings_search.search_type = output.search_type;
            unhide(results_container);
            if (frm && typeof frm.submit_btn !== "undefined") {
                frm.submit_btn.value = "Ara";
                frm.submit_btn.disabled = false
            }
            if (output.num_found > output.num_returned) {
                my_listings_search.more_page_number = 1;
                unhide("my_listings_search_show_more", "block")
            }
        } else { }
        my_listings_search.popup.position()
    });
    ajax.go()
};

function hide_promo() {
    var a = xb_get_element("my_listings_table");
    var b = xb_get_element("my_listing_promo");
    if (a) {
        unhide("my_listings_table", "block")
    }
    if (b) {
        hide("my_listings_promo")
    }
}
function show_promo() {
    var a = xb_get_element("my_listings_table");
    var b = xb_get_element("my_listing_promo");
    if (a) {
        hide("my_listings_table")
    }
    if (b) {
        unhide("my_listings_promo", "block")
    }
}
function homepage_contact_me() {
    var a = new QAjax();
    elem = xb_get_element("left_content");
    a.set_script_info({
        script: "Sorgu/q_update_info/",
        method: "get",
        output: "text"
    });
    a.set_value("tp", "cm");
    a.set_value("cnf", "1");
    a.set_value("cm", "1");
    a.set_callback(function (d) {
        if (d == "1") {
            var c = xb_get_element("home_page_newsletter_button_content");
            var b = xb_get_element("home_page_newsletter_success_content");
            if (c && b) {
                hide(c);
                unhide(b)
            }
            return
        } else {
            alert("There was an error subscribing you to the EmlakRex Newsletter.  Please refresh the page and try again.")
        }
    });
    a.go();
}
var my_listings_options = new Array();
emlakrex.remove_listing = function (d, b, a, f) {
    if (d == "delete") {
        my_listings_options.pid = b;
        my_listings_options.agent_listing_code = a;
        my_listings_options.property_address = f;
        var e = "q_my_listings_popups.php?pop=remove_listing&pt=" + remove_property_type
    } else {
        if (d == "delete_response") {
            var e = "q_my_listings_popups.php?pop=remove_listing_success&pt=" + remove_property_type + "&address=" + my_listings_options.property_address + "&id=" + my_listings_options.pid + "&al=" + my_listings_options.agent_listing_code
        } else {
            if (d == "inbox_promo") {
                var e = "q_my_listings_popups.php?pop=inbox_promo"
            }
        }
    }
    var c = function () {
        var g = {
            width: "420px",
            close: true,
            classname: "remove_listing",
            id: "remove_listing_success_popup",
            cache_endpoint: false
        };
        var h = new emlakrex.Popup(g);
        h.setContentSource(e);
        h.show();
        if (d == "delete_response") {
            page_my_listings()
        }
    };
    if (!YAHOO.widget.Panel) {
        YUI.use("container", c)
    } else {
        c()
    }
};
emlakrex.deleted_actions = function (c, a, e) {
    if (c == "undelete") {
        my_listings_options.pid = a;
        my_listings_options.sid = e;
        var d = "q_my_listings_popups.php?pop=restore_listing&pt=" + remove_property_type
    } else {
        if (c == "undelete_response") {
            var d = "q_my_listings_popups.php?pop=restore_listing_success&pt=" + remove_property_type + "&afl=" + my_listings_options.pid + "&sls=" + my_listings_options.sid
        } else {
            if (c == "delete_forever") {
                my_listings_options.pid = a;
                my_listings_options.sid = e;
                var d = "q_my_listings_popups.php?pop=delete_forever&pt=" + remove_property_type
            } else {
                if (c == "delete_forever_response") {
                    var d = "q_my_listings_popups.php?pop=delete_forever_success&pt=" + remove_property_type + "&afl=" + my_listings_options.pid + "&sls=" + my_listings_options.sid
                } else {
                    if (c == "delete_all_forever") {
                        var d = "q_my_listings_popups.php?pop=delete_all_forever&pt=" + remove_property_type
                    } else {
                        if (c == "delete_all_forever_response") {
                            var d = "q_my_listings_popups.php?pop=delete_all_forever_success&pt=" + remove_property_type
                        }
                    }
                }
            }
        }
    }
    var b = function () {
        var f = {
            width: "420px",
            close: true,
            classname: "remove_listing",
            id: "delete_actions_popup",
            cache_endpoint: false
        };
        var g = new emlakrex.Popup(f);
        g.setContentSource(d);
        g.show();
        if (c == "undelete_response" || c == "delete_forever_response" || c == "delete_all_forever_response") {
            page_my_listings()
        }
    };
    if (!YAHOO.widget.Panel) {
        YUI.use("container", b)
    } else {
        b()
    }
};

function init_reporting_table() {
    if (!YUI.getId("stats_refresh_container")) {
        return
    }
    function a(f, e, k) {
        var j = YUI.get(".yui-dt-col-address .address a", f.getId(), 1).innerHTML;
        var h = YUI.get(".yui-dt-col-address .address a", e.getId(), 1).innerHTML;
        var g = YAHOO.util.Sort.compare;
        return g(j, h, k)
    }
    var c = new YAHOO.util.DataSource(YAHOO.util.Dom.get("reporting_weekly_data"));
    c.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
    c.responseSchema = {
        fields: [{
            key: "address"
        },
        {
            key: "leads",
            parser: "number"
        },
        {
            key: "srp",
            parser: "number"
        },
        {
            key: "pdp",
            parser: "number"
        },
        {
            key: "clicks",
            parser: "number"
        },
        {
            key: "featured"
        }]
    };
    var d = [{
        key: "address",
        label: "Address",
        sortable: true,
        width: 200,
        sortOptions: {
            sortFunction: a
        }
    },
    {
        key: "leads",
        label: "Leads",
        sortable: true,
        formatter: "number"
    },
    {
        key: "srp",
        label: "Search Results Views",
        sortable: true,
        formatter: "number"
    },
    {
        key: "pdp",
        label: "Property Detail Views",
        sortable: true,
        formatter: "number"
    },
    {
        key: "clicks",
        label: "Property Website Clicks",
        sortable: true,
        formatter: "number"
    },
    {
        key: "featured",
        label: "",
        sortable: false,
        width: 100
    }];
    var b = new YAHOO.widget.DataTable("dtable_container", d, c)
};
if (typeof (site_root) == "undefined" && typeof (_SITE_ROOT) != "undefined") {
    var site_root = _SITE_ROOT
}
var save_url = site_root + "Sorgu/q_save/?tp=pr_s&pid=";
var remove_url = site_root + "remove_property.php?propertyId=";
var view_url = site_root + "Hesabim/favorilerim/";
var the_property_id = 0;

function save_property(h, a, g, f, c, e) {
    var b = clone_obj(g);
    doNothing(g);
    if (typeof (h) === "object") {
        e = h.address_hash;
        c = h.property_type;
        propertyId = h.id
    } else {
        propertyId = h
    }
    if (!is_mutex_free(_SAVE_MUTEX)) {
        save_queue.add({
            id: propertyId,
            property_type: c,
            address_hash: e
        });
        return
    }
    if (typeof (f) == "undefined") {
        f = 1
    }
    if (typeof (c) == "undefined") {
        c = typeof (_PROPERTY_TYPE) != "undefined" ? _PROPERTY_TYPE : "For Sale"
    }
    if (typeof (e) == "undefined") {
        e = typeof (_DETAILS_PROPERTY_HASH) != "undefined" ? _DETAILS_PROPERTY_HASH : null
    }
    if (typeof (e) == "undefined") {
        alert("Missing address hash.");
        return
    }
    d = new Date();
    the_property_id = propertyId;
    var i = getHTTPObject();
    i.open("POST", save_url + encodeURIComponent(propertyId) + "&pt=" + c + "&ts=" + d.valueOf() + "&ahash=" + encodeURIComponent(e), true);
    i.onreadystatechange = function () {
        if (i.readyState == 4) {
            var j = parseInt(i.responseText);
            if (j > 0 || j == -2) {
                toggle_icon(propertyId, true, f, c);
                toggle_link(propertyId, true, f)
            } else {
                if (j == 0) {
                    release_mutex(_SAVE_MUTEX);
                    save_queue.add({
                        id: propertyId,
                        property_type: c,
                        address_hash: e
                    });
                    set_show_prefs("li_box", "li_show");
                    hide("li_box");
                    if (b) {
                        var m = getPosition(b);
                        var l = m.x + 15;
                        var k = m.y + 20;
                        show_login(b, "save_property", "", {
                            x: l,
                            y: k
                        })
                    } else {
                        show_login(null, "save_property", true)
                    }
                    return
                }
            }
            save_queue.remove(h);
            release_mutex(_SAVE_MUTEX);
            process_save_queue()
        }
    };
    i.send(null)
}
function remove_property(b) {
    d = new Date();
    var a = getHTTPObject();
    a.open("POST", remove_url + escape(b) + "&ts=" + d.valueOf(), true);
    a.onreadystatechange = function () { };
    a.send(null);
    toggle_icon(b, false)
}
function toggle_link(e, c) {
    var a = document.getElementById("save_property_link_" + e);
    liw = document.getElementById("infoWindow_save_property_link_" + e);
    if (!a) {
        return false
    }
    var b = (typeof (z_details_pg) != "undefined" && z_details_pg == 1);
    if (c) {
        if (!b) {
            a.innerHTML = z_link_labels.saved
        } else {
            a.innerHTML = z_link_labels.saved_graphic;
            a.onmouseover = function () { };
            a.onmouseout = function () { }
        }
        a.href = view_url;
        a.onclick = function () { };
        if (liw) {
            liw.innerHTML = "Saved";
            liw.href = view_url
        }
    } else {
        if (!b) {
            a.innerHTML = z_link_labels.save
        } else {
            a.innerHTML = z_link_labels.save_graphic
        }
        a.href = "javascript:void(0)";
        a.onclick = function () {
            save_property(e)
        };
        if (liw) {
            liw.innerHTML = "Save";
            liw.href = "javascript:save_property(" + e + ");"
        }
    }
}
function toggle_icon(A, w, t, q) {
    if (typeof (t) == "undefined") {
        t = 1
    }
    var f = xb_get_element("save_property_text_" + A);
    var p = xb_get_element("save_property_link_" + A);
    var y = xb_get_element("infoWindow_save_property_link_" + A);
    var r = xb_get_element("icon_" + A);
    var g = xb_get_element("icon_t_" + A);
    var z = xb_get_element("fl_icon_" + A);
    var e = xb_get_element("save_property_button_element");
    var v = xb_get_element("save_property_toolbox_element");
    var n = xb_get_element("save_sp_" + A);
    var j = xb_get_element("saved_sp_" + A);
    var x = (xb_get_element("icon_s_h") ? pull_file(xb_get_element("icon_s_h").src) : null);
    var o = (xb_get_element("icon_s_u") ? pull_file(xb_get_element("icon_s_u").src) : null);
    var m = (xb_get_element("icon_u_h") ? pull_file(xb_get_element("icon_u_h").src) : null);
    var h = (xb_get_element("icon_u_u") ? pull_file(xb_get_element("icon_u_u").src) : null);
    var b = (xb_get_element("icon_t_s") ? pull_file(xb_get_element("icon_t_s").src) : null);
    var B = (xb_get_element("icon_t_u") ? pull_file(xb_get_element("icon_t_u").src) : null);
    var s = (xb_get_element("icon_fl_u") ? pull_file(xb_get_element("icon_fl_u").src) : null);
    var u = (xb_get_element("icon_fl_s") ? pull_file(xb_get_element("icon_fl_s").src) : null);
    var c, a, k;
    if (w) {
        if (f) {
            f.innerHTML = "Kaydedildi!";
            if (f.tagName == "A") {
                f.title = "Kaydedildi!"
            }
            if (t == 3) {
                if ((c = xb_get_element("save_property_text_exp_" + A))) {
                    c.innerHTML = "Kaydedildi!";
                    if (c.tagName == "A") {
                        c.title = "Kaydedildi!"
                    }
                }
                if ((a = xb_get_element("save_property_text_map_" + A))) {
                    a.innerHTML = "Kaydedildi!";
                    if (a.tagName == "A") {
                        a.title = "Kaydedildi!"
                    }
                }
            }
        } else {
            if ((a = xb_get_element("save_property_text_map_" + A))) {
                a.innerHTML = "Kaydedildi!";
                if (a.tagName == "A") {
                    a.title = "Kaydedildi!"
                }
                if ((k = xb_get_element("save_property_text_" + A))) {
                    k.innerHTML = "Kaydedildi!";
                    if (k.tagName == "A") {
                        k.title = "Kaydedildi!"
                    }
                }
                if ((c = xb_get_element("save_property_text_exp_" + A))) {
                    c.innerHTML = "Kaydedildi!";
                    if (c.tagName == "A") {
                        c.title = "Kaydedildi!"
                    }
                }
            } else {
                if (r) {
                    r.src = site_root + "images/" + (m ? x : o);
                    r.onmouseout = null;
                    r.onmouseover = null;
                    r.onclick = function () {
                        location.href = site_root + "account/"
                    }
                }
                if (g) {
                    g.src = site_root + "images/" + b;
                    g.parentNode.parentNode.onmouseout = null;
                    g.parentNode.parentNode.onmouseover = null
                }
                if (e) {
                    remove_class(e, "save_property_button");
                    add_class(e, "saved_property_button");
                    e.parentNode.onclick = function () {
                        return false
                    };
                    e.parentNode.cursor = "default"
                }
                if (v) {
                    v.onclick = function () {
                        return true
                    };
                    v.href = site_root + "Hesabim/favorilerim/";
                    if (q == "For Rent" || q == "community") {
                        v.href += "forrent/"
                    }
                    v.cursor = "default";
                    v.innerHTML = "Kaydedildi!"
                }
                if (z && u) {
                    z.src = site_root + "images/" + u
                }
                if (xb_get_element("iwin_save_prop_link_" + A)) {
                    xb_get_element("iwin_save_prop_link_" + A).src = site_root + "images/map/saved.gif"
                }
                if (n && j) {
                    YUI.u.Dom.addClass(n, "hidden");
                    YUI.u.Dom.removeClass(j, "hidden")
                }
            }
        }
    } else {
        if (r) {
            r.src = site_root + "images/" + (x ? m : h)
        }
        if (g) {
            g.src = site_root + "images/" + B
        }
        if (z && u) {
            z.src = site_root + "images/" + s
        }
        if (xb_get_element("iwin_save_prop_link_" + A)) {
            xb_get_element("iwin_save_prop_link_" + A).src = site_root + "images/map/save.gif"
        }
    }
    if (typeof (clearCachedInfoWindow) == "function") {
        clearCachedInfoWindow(A)
    }
}
function highlight_save_icon(b, a) {
    if (b) {
        b.src = a ? xb_get_element("icon_t_h").src : xb_get_element("icon_t_u").src
    }
};
