﻿function Removenums(s) {
    result = ""; //nums = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];    
    for (var i = 0; i < s.length - 8; i++)
    //if(!(s.charAt(i) in nums))
        result += s.charAt(i);
    return result;
}
function getPriceStatment(p1, p2, pt) {
    if (p1 != "" && p2 == "")
        return " حداقل " + pt + p1;
    if (p1 == "" && p2 != "")
        return " حداکثر " + pt + p2;
    if (p1 != "" && p2 != "")
        return pt + p1 + " تا " + p2;
    return "";
}
function getMT(i) {
    if (i == "")
        return "";
    if (i == 0)
        return " متراژ  کمتر از 50 متر ";
    else
        if (i == 1)
            return " متراژ بين 50 تا 60 متر ";
        else
            if (i == 2)
                return " متراژ بين 60 تا 70 متر ";
            else
                if (i == 3)
                    return " متراژ بين 70 تا 80 متر ";
                else
                    if (i == 4)
                        return " متراژ بين 80 تا 90 متر ";
                    else
                        if (i == 5)
                            return " متراژ بين 90 تا 100 متر ";
                        else
                            if (i == 6)
                                return " متراژ بين 100 تا 120 متر ";
                            else
                                if (i == 7)
                                    return " متراژ بين 120 تا 140 متر ";
                                else
                                    if (i == 8)
                                        return " متراژ بين 140 تا 170 متر ";
                                    else
                                        if (i == 9)
                                            return " متراژ بين 170 تا 200 متر ";
                                        else
                                            if (i == 10)
                                                return " متراژ بيشتر از 200 متر ";
return "";
}



function UpdateConditions() {
    if (document.forms[0].txtnum.value != "") {
        document.forms[0].txtConditions.value = "ملک با شماره: " + document.forms[0].txtnum.value;
        return;

    }
    arMstatus = ["", "رهن و اجاره", "خريد", "پيش خريد", "معاوضه"];
    Conditions = "";
    if (document.forms[0].ddest.value != "-1")
        Conditions += " " + "استان " + document.forms[0].ddest.options[document.forms[0].ddest.selectedIndex].text;
    if (document.forms[0].txtct.value != "")
        Conditions += " " + "شهر " + document.forms[0].txtct.value;
    sslvl = arMstatus[document.forms[0].ddslvl.value];
    smtp = document.forms[0].ddmtp[document.forms[0].ddmtp.selectedIndex].text;
    sSleep = "";
    if (document.forms[0].ddslp.value != "")
        sSleep = document.forms[0].ddslp.value + "خوابه ";
    if (document.forms[0].ddbld[document.forms[0].ddbld.selectedIndex].text != "")
        sSleep += document.forms[0].ddbld[document.forms[0].ddbld.selectedIndex].text;
    sSleep += getMT(document.forms[0].ddmt.value);
    if (smtp != "")
        ss = " نوع ملک " + smtp + sSleep;
    else
        ss = sSleep;
    if (document.forms[0].ddag.value == -10) {
        if (sslvl != "")
            Conditions += ss + " جهت " + sslvl;
        else
            Conditions += ss;
    }
    else
        if (document.forms[0].ddag.value == -20)
            Conditions += ss + " " + sslvl + " موردهاي بي واسطه ";
        else {
            var s = sslvl + document.forms[0].ddag.options[document.forms[0].ddag.selectedIndex].text;
            if (s.length > 3)
                Conditions += ss + " " + " ملکهاي " + s;
        }
bNoRegionSelected = 1;
if (document.forms[0].txtrgn.value != "") {
    Conditions += " محدوده " + document.forms[0].txtrgn.value;
    bNoRegionSelected = 0;
}


Conditions += getPriceStatment(document.forms[0].ddsprs1[document.forms[0].ddsprs1.selectedIndex].text, document.forms[0].ddsprs2[document.forms[0].ddsprs2.selectedIndex].text, " قيمت کل ");
Conditions += getPriceStatment(document.forms[0].ddrn1[document.forms[0].ddrn1.selectedIndex].text, document.forms[0].ddrn2[document.forms[0].ddrn2.selectedIndex].text, " مبلغ رهن ");
Conditions += getPriceStatment(document.forms[0].ddls1[document.forms[0].ddls1.selectedIndex].text, document.forms[0].ddls2[document.forms[0].ddls2.selectedIndex].text, " مبلغ اجاره ");

document.forms[0].txtConditions.value = Conditions;

}


function SetComboEnabled() {

    el = document.forms[0].ddslvl;
    document.forms[0].ddrn1.disabled = "";
    document.forms[0].ddrn2.disabled = "";
    document.forms[0].ddls1.disabled = "";
    document.forms[0].ddls2.disabled = "";
    document.forms[0].ddsprs1.disabled = "";
    document.forms[0].ddsprs2.disabled = "";
    if (el.value == 1) {
        document.forms[0].ddsprs1.disabled = "disabled";
        document.forms[0].ddsprs2.disabled = "disabled";
    }
    else
        if (el.value == 2 || el.value == 3) {
            document.forms[0].ddrn1.disabled = "disabled";
            document.forms[0].ddrn2.disabled = "disabled";
            document.forms[0].ddls1.disabled = "disabled";
            document.forms[0].ddls2.disabled = "disabled";
        }
UpdateConditions();
}
function EstateChange() {
    UpdateConditions();
    document.forms[0].txtct.value = "";
    document.forms[0].txtrgn.value = "";
}


function searchestate(agency) {
    if (document.getElementById('txtnum') != null)
        prename = '';
    else
        prename = 'ctl00_content_';
    var loc = ' ';
    var s = '', est = '';
    if (document.getElementById('datefrom') == null)
        _date = 30;
    else
        _date = document.getElementById('datefrom').value;

    if (document.getElementById(prename + 'txtnum').value != '') {

        num = document.getElementById(prename + 'txtnum').value;
        //window.open("Deteils.aspx?AutoNumber=" + num, '', '', '');
        //return;
    }
    if (document.getElementById(prename + 'ddest') != null) {
        s = document.getElementById(prename + 'ddest')[document.getElementById(prename + 'ddest').selectedIndex].text;
        est = document.getElementById(prename + 'ddest').value;
    }
    //        if (sEstate == 'undefined')
    //                sEstate = 'تهران';
    if (s != '')
        loc += 'استان ' + s + ' ';
    var c = '';
    if (document.getElementById(prename + 'txtct') != null)
        c = document.getElementById(prename + 'txtct').value
    if (c != '')
        loc += 'شهر ' + c + ' ';
    var agn = '';
    if (document.getElementById(prename + 'hfagn') != null)
        agn = document.getElementById(prename + 'hfagn').value
    var bld = '', agnN = _title = agency, rgn = '',  mt = '';
    if (document.getElementById(prename + 'ddbld') != null)
        document.getElementById(prename + 'ddbld')[document.getElementById(prename + 'ddbld').selectedIndex].text;
    if (document.getElementById(prename + 'ddag') != null) {
        agn = document.getElementById(prename + 'ddag').value;
        agnN = document.getElementById(prename + 'ddag')[document.getElementById(prename + 'ddag').selectedIndex].text;
    }
    if (document.getElementById(prename + 'txtrgn') != null)
        rgn = document.getElementById(prename + 'txtrgn').value;
    if (document.getElementById(prename + 'ddmt') != null)
        mt = document.getElementById(prename + 'ddmt').value;
    var s = 'sr.aspx?ag=' + agn +
                '&agnn=' + agnN + '&est=' + est + '&ct=' + c + '&loc=' + loc + '&rgn1=' + rgn + '&num=' + num +
                '&mtp=' + document.getElementById(prename + 'ddmtp')[document.getElementById(prename + 'ddmtp').selectedIndex].text +
                '&bld=' + bld +
                '&slp=' + document.getElementById(prename + 'ddslp')[document.getElementById(prename + 'ddslp').selectedIndex].text +
                '&rhn1=' + document.getElementById(prename + 'ddrn1')[document.getElementById(prename + 'ddrn1').selectedIndex].text +
                '&rhn2=' + document.getElementById(prename + 'ddrn2')[document.getElementById(prename + 'ddrn2').selectedIndex].text +
                '&les1=' + document.getElementById(prename + 'ddls1')[document.getElementById(prename + 'ddls1').selectedIndex].text +
                '&les2=' + document.getElementById(prename + 'ddls2')[document.getElementById(prename + 'ddls2').selectedIndex].text +
                '&sprs1=' + document.getElementById(prename + 'ddsprs1')[document.getElementById(prename + 'ddsprs1').selectedIndex].text +
                '&sprs2=' + document.getElementById(prename + 'ddsprs2')[document.getElementById(prename + 'ddsprs2').selectedIndex].text +
                '&slvl=' + document.getElementById(prename + 'ddslvl').value +
                '&dt=' + _date +
                '&mt=' + mt +
                '&nslc=0';
    //s.replace('\n', ' ');  
    window.open(s, '', '', '');

}



function searchchanged(el) {
    document.getElementById("minprice").disabled = "";
    document.getElementById("maxprice").disabled = "";
    premin = '<select name="minprice" id="minprice" class="garycolor">';
    premax = '<select name="maxprice" id="maxprice" class="garycolor">';
    post = '</select>';
    pricetext = "<option value=''></option><option value='1ميليون'>1ميليون</option><option value='3ميليون'>3ميليون</option><option value='5ميليون'>5ميليون</option><option value='10ميليون'>10ميليون</option><option value='15ميليون'>15ميليون</option><option value='20ميليون'>20ميليون</option><option value='30ميليون'>30ميليون</option><option value='40ميليون'>40ميليون</option><option value='50ميليون'>50ميليون</option><option value='60ميليون'>60ميليون</option><option value='70ميليون'>70ميليون</option><option value='80ميليون'>80ميليون</option><option value='90ميليون'>90ميليون</option><option value='100ميليون'>100ميليون</option><option value='120ميليون'>120ميليون</option><option value='150ميليون'>150ميليون</option><option value='180ميليون'>180ميليون</option><option value='200ميليون'>200ميليون</option><option value='250ميليون'>250ميليون</option><option value='300ميليون'>300ميليون</option><option value='350ميليون'>350ميليون</option><option value='400ميليون'>400ميليون</option><option value='450ميليون'>450ميليون</option><option value='500ميليون'>500ميليون</option><option value='600ميليون'>600ميليون</option><option value='700ميليون'>700ميليون</option><option value='800ميليون'>800ميليون</option><option value='900ميليون'>900ميليون</option><option value='1ميليارد'>1ميليارد</option><option value='2ميليارد'>2ميليارد</option><option value='10ميليارد'>10ميليارد</option><option value='50ميليارد'>50ميليارد</option><option value='100ميليارد'>100ميليارد</option><option value='1000ميليارد'>1000ميليارد</option>";
    rahntext = "<option value=''></option><option value='100تومان'>100تومان</option><option value='1ميليون'>1ميليون</option><option value='3ميليون'>3ميليون</option><option value='5ميليون'>5ميليون</option><option value='10ميليون'>10ميليون</option><option value='15ميليون'>15ميليون</option><option value='20ميليون'>20ميليون</option><option value='25ميليون'>25ميليون</option><option value='30ميليون'>30ميليون</option><option value='35ميليون'>35ميليون</option><option value='40ميليون'>40ميليون</option><option value='45ميليون'>45ميليون</option><option value='50ميليون'>50ميليون</option><option value='60ميليون'>60ميليون</option><option value='70ميليون'>70ميليون</option><option value='80ميليون'>80ميليون</option><option value='90ميليون'>90ميليون</option><option value='100ميليون'>100ميليون</option>"
    leasetext = "<option value=''></option>	<option value='50تومان'>50تومان</option><option value='100تومان'>100تومان</option><option value='120تومان'>120تومان</option><option value='140تومان'>140تومان</option><option value='150تومان'>150تومان</option><option value='170تومان'>170تومان</option><option value='190تومان'>190تومان</option><option value='200تومان'>200تومان</option><option value='220تومان'>220تومان</option><option value='240تومان'>240تومان</option><option value='250تومان'>250تومان</option><option value='300تومان'>300تومان</option><option value='350تومان'>350تومان</option><option value='400تومان'>400تومان</option><option value='450تومان'>450تومان</option><option value='500تومان'>500تومان</option><option value='600تومان'>600تومان</option><option value='700تومان'>700تومان</option><option value='750تومان'>750تومان</option><option value='800تومان'>800تومان</option><option value='950تومان'>950تومان</option><option value='900تومان'>900تومان</option><option value='1ميليون'>1ميليون</option><option value='10ميليون'>10ميليون</option><option value='100ميليون'>100ميليون</option>";
    minel = document.getElementById("mindiv");
    maxel = document.getElementById("maxdiv");
    if (el.value == 0) {
        document.getElementById("minprice").disabled = "disabled";
        document.getElementById("maxprice").disabled = "disabled";
    }
    else
        if (el.value == 2) {
            document.getElementById("mincap").innerHTML = "حداقل رهن";
            document.getElementById("maxcap").innerHTML = "حداکثر رهن";
            minel.innerHTML = premin + rahntext + post;
            maxel.innerHTML = premax + rahntext + post;
        }
        else
            if (el.value == 3) {
                document.getElementById("mincap").innerHTML = "حداقل اجاره";
                document.getElementById("maxcap").innerHTML = "حداکثر اجاره";
                minel.innerHTML = premin + leasetext + post;
                maxel.innerHTML = premax + leasetext + post;
            }
            else {
                document.getElementById("mincap").innerHTML = "حداقل قیمت";
                document.getElementById("maxcap").innerHTML = "حداکثر قیمت";
                minel.innerHTML = premin + pricetext + post;
                maxel.innerHTML = premax + pricetext + post;
            }


}


function search2(agency, acode, form) {
    var pre = ''; //'ctl00_content_';
    var loc = ' ';
    var num = '';
    if (document.getElementById('datefrom') == null)
        _date = 30;
    else
        _date = document.getElementById('datefrom').value;
    if (acode == 7110001)
        _date = 366;

    _province = document.getElementById(pre + 'Province');    
    if (document.getElementById(pre + 'txtnum') != null && document.getElementById(pre + 'txtnum').value != '') {

        num = document.getElementById(pre + 'txtnum').value;
        //window.open("Deteils.aspx?Owner=" + acode + "&AutoNumber=" + num, '', '', '');
        //return;
    }
    if (_province == null)
        s = document.getElementById(pre + 'EstateID').value;

    _city = document.getElementById(pre + 'City');
    if (_city == null)
        _city = document.getElementById(pre + 'City');

    if (document.getElementById(pre + 'Province') != null)
        if (document.getElementById(pre + 'Province').selectedIndex == -1)
            estt = "";
        else
            estt = document.getElementById(pre + 'Province')[document.getElementById(pre + 'Province').selectedIndex].text;

    if (document.getElementById(pre + 'ag') != null) {
        ag = document.getElementById(pre + 'ag').value;
        agnn = document.getElementById(pre + 'agnn').value;
    }
    else {
        ag = -10;
        agnn = '';

    }


    //        if (sEstate == 'undefined')
    //                sEstate = 'تهران';
    if (estt != '')
        loc += 'استان ' + estt + ' ';
    c = _city.value.replace(/^\s+|\s+$/g, '');
    if (c == 'شهر')
        c = '';
    if (c != '')
        loc += 'شهر ' + c + ' ';
    var mtype = document.getElementById(pre + 'MType').value;
    if (mtype == 'همه موارد' || mtype == 'همه')
        mtype = '';
    el = document.getElementById("SearchType").value;
    sumprice1 = "";
    sumprice2 = "";
    rahnprice1 = "";
    rahnprice2 = "";
    leaseprice1 = "";
    leaseprice2 = "";
    if (document.getElementById(pre + 'minprice').selectedIndex != -1)
        price1 = document.getElementById(pre + 'minprice')[document.getElementById(pre + 'minprice').selectedIndex].text;
    else
        price1 = "";
    if (document.getElementById(pre + 'maxprice').selectedIndex != -1)
        price2 = document.getElementById(pre + 'maxprice')[document.getElementById(pre + 'maxprice').selectedIndex].text;
    else
        price2 = "";

    if (el == 2) {
        rahnprice1 = price1;
        rahnprice2 = price2;
    }
    else
        if (el == 3) {
            leaseprice1 = price1;
            leaseprice2 = price2;
        }
        else {
            sumprice1 = price1;
            sumprice2 = price2;
        }

    if (document.getElementById(pre + 'Region').value.replace(/^\s+|\s+$/g, '') == 'محدوده')
        region = '';
    else
        region = document.getElementById(pre + 'Region').value;
    searchtype = document.getElementById('SearchType').value;
    if (document.getElementById(pre + 'Province') != null)
        estid = document.getElementById(pre + 'Province').value;
    else
        estid = document.getElementById(pre + 'EstateID').value;
    if (document.getElementById(pre + 'hfagn') != null)
        agn = document.getElementById(pre + 'hfagn').value
    if (estid == '-1')
        estid = '';
    var s = 'sr.aspx?ag=' + ag +
                '&agnn=' + agnn +
                '&est=' + estid +
                '&ct=' + c +
                '&loc=' + loc +
                '&rgn1=' + region +
                '&num=' + num +
                '&mtp=' + mtype +
                '&bld=' +
                '&slp=' + document.getElementById(pre + 'sleepcnt')[document.getElementById(pre + 'sleepcnt').selectedIndex].text +
                '&rhn1=' + rahnprice1 +
                '&rhn2=' + rahnprice2 +
                '&les1=' + leaseprice1 +
                '&les2=' + leaseprice2 +
                '&sprs1=' + sumprice1 +
                '&sprs2=' + sumprice2 +
                '&slvl=' + searchtype +
                '&dt=' + _date +
                '&mt=&nslc=0';
    if (form == 'sr')
        window.location.replace(encodeURI(s));
    else
        window.open(encodeURI(s), '', '', '');

}



var m_strNewDefaultText = "";
function DeleteDefaultText(el, strDefaultText) {

    if (el.value == strDefaultText || el.value == m_strNewDefaultText) {
        el.value = '';
        el.onclick = '';
        el.onkeypress = '';
    }
}
function ChangeDefaultText(strText) {
    var txtSearch = document.getElementById("HomepageSearch_RMX1_txtSearch_txtCSZ");

    if (strText == "") {
        strText = "Search by City or County and State, or ZIP";
    }
    txtSearch.value = strText;
    m_strNewDefaultText = strText;
}


function searchchanged(el) {
    document.getElementById("minprice").disabled = "";
    document.getElementById("maxprice").disabled = "";
    premin = '<select name="minprice" id="minprice" class="garycolor">';
    premax = '<select name="maxprice" id="maxprice" class="garycolor">';
    post = '</select>';
    pricetext = "<option value=''></option><option value='1ميليون'>1ميليون</option><option value='3ميليون'>3ميليون</option><option value='5ميليون'>5ميليون</option><option value='10ميليون'>10ميليون</option><option value='15ميليون'>15ميليون</option><option value='20ميليون'>20ميليون</option><option value='30ميليون'>30ميليون</option><option value='40ميليون'>40ميليون</option><option value='50ميليون'>50ميليون</option><option value='60ميليون'>60ميليون</option><option value='70ميليون'>70ميليون</option><option value='80ميليون'>80ميليون</option><option value='90ميليون'>90ميليون</option><option value='100ميليون'>100ميليون</option><option value='120ميليون'>120ميليون</option><option value='150ميليون'>150ميليون</option><option value='180ميليون'>180ميليون</option><option value='200ميليون'>200ميليون</option><option value='250ميليون'>250ميليون</option><option value='300ميليون'>300ميليون</option><option value='350ميليون'>350ميليون</option><option value='400ميليون'>400ميليون</option><option value='450ميليون'>450ميليون</option><option value='500ميليون'>500ميليون</option><option value='600ميليون'>600ميليون</option><option value='700ميليون'>700ميليون</option><option value='800ميليون'>800ميليون</option><option value='900ميليون'>900ميليون</option><option value='1ميليارد'>1ميليارد</option><option value='2ميليارد'>2ميليارد</option><option value='10ميليارد'>10ميليارد</option><option value='50ميليارد'>50ميليارد</option><option value='100ميليارد'>100ميليارد</option><option value='1000ميليارد'>1000ميليارد</option>";
    rahntext = "<option value=''></option><option value='100تومان'>100تومان</option><option value='1ميليون'>1ميليون</option><option value='3ميليون'>3ميليون</option><option value='5ميليون'>5ميليون</option><option value='10ميليون'>10ميليون</option><option value='15ميليون'>15ميليون</option><option value='20ميليون'>20ميليون</option><option value='25ميليون'>25ميليون</option><option value='30ميليون'>30ميليون</option><option value='35ميليون'>35ميليون</option><option value='40ميليون'>40ميليون</option><option value='45ميليون'>45ميليون</option><option value='50ميليون'>50ميليون</option><option value='60ميليون'>60ميليون</option><option value='70ميليون'>70ميليون</option><option value='80ميليون'>80ميليون</option><option value='90ميليون'>90ميليون</option><option value='100ميليون'>100ميليون</option>"
    leasetext = "<option value=''></option>	<option value='50تومان'>50تومان</option><option value='100تومان'>100تومان</option><option value='120تومان'>120تومان</option><option value='140تومان'>140تومان</option><option value='150تومان'>150تومان</option><option value='170تومان'>170تومان</option><option value='190تومان'>190تومان</option><option value='200تومان'>200تومان</option><option value='220تومان'>220تومان</option><option value='240تومان'>240تومان</option><option value='250تومان'>250تومان</option><option value='300تومان'>300تومان</option><option value='350تومان'>350تومان</option><option value='400تومان'>400تومان</option><option value='450تومان'>450تومان</option><option value='500تومان'>500تومان</option><option value='600تومان'>600تومان</option><option value='700تومان'>700تومان</option><option value='750تومان'>750تومان</option><option value='800تومان'>800تومان</option><option value='950تومان'>950تومان</option><option value='900تومان'>900تومان</option><option value='1ميليون'>1ميليون</option><option value='10ميليون'>10ميليون</option><option value='100ميليون'>100ميليون</option>";
    minel = document.getElementById("mindiv");
    maxel = document.getElementById("maxdiv");
    if (el.value == 0) {
        document.getElementById("minprice").disabled = "disabled";
        document.getElementById("maxprice").disabled = "disabled";
    }
    else
        if (el.value == 2) {
            document.getElementById("mincap").innerHTML = "حداقل رهن";
            document.getElementById("maxcap").innerHTML = "حداکثر رهن";
            minel.innerHTML = premin + rahntext + post;

            maxel.innerHTML = premax + rahntext + post;
        }
        else
            if (el.value == 3) {
                document.getElementById("mincap").innerHTML = "حداقل اجاره";
                document.getElementById("maxcap").innerHTML = "حداکثر اجاره";
                minel.innerHTML = premin + leasetext + post;
                maxel.innerHTML = premax + leasetext + post;
            }
            else {
                document.getElementById("mincap").innerHTML = "حداقل قیمت";
                document.getElementById("maxcap").innerHTML = "حداکثر قیمت";
                minel.innerHTML = premin + pricetext + post;
                maxel.innerHTML = premax + pricetext + post;
            }


}
function WebForm_FireDefaultButton(event, target) {

    if (event.keyCode == 13) {
        search2()
    }

    return true;

}

function Removenums(s) {
    result = "";
    for (var i = 0; i < s.length - 8; i++)

        result += s.charAt(i);
    return result;
}
function getPriceStatment(p1, p2, pt) {
    if (p1 != "" && p2 == "")
        return " حداقل " + pt + p1;
    if (p1 == "" && p2 != "")
        return " حداکثر " + pt + p2;
    if (p1 != "" && p2 != "")
        return pt + p1 + " تا " + p2;
    return "";
}
function getMT(i) {
    if (i == "")
        return "";
    if (i == 0)
        return " متراژ  کمتر از 50 متر ";
    else
        if (i == 1)
            return " متراژ بين 50 تا 60 متر ";
        else
            if (i == 2)
                return " متراژ بين 60 تا 70 متر ";
            else
                if (i == 3)
                    return " متراژ بين 70 تا 80 متر ";
                else
                    if (i == 4)
                        return " متراژ بين 80 تا 90 متر ";
                    else
                        if (i == 5)
                            return " متراژ بين 90 تا 100 متر ";
                        else
                            if (i == 6)
                                return " متراژ بين 100 تا 120 متر ";
                            else
                                if (i == 7)
                                    return " متراژ بين 120 تا 140 متر ";
                                else
                                    if (i == 8)
                                        return " متراژ بين 140 تا 170 متر ";
                                    else
                                        if (i == 9)
                                            return " متراژ بين 170 تا 200 متر ";
                                        else
                                            if (i == 10)
                                                return " متراژ بيشتر از 200 متر ";
    return "";
}



function UpdateConditions() {
    if (document.forms[0].txtnum.value != "") {
        document.forms[0].txtConditions.value = "ملک با شماره: " + document.forms[0].txtnum.value;
        return;

    }
    arMstatus = ["", "رهن و اجاره", "خريد", "پيش خريد", "معاوضه"];
    Conditions = "";
    if (document.forms[0].ddest.value != "-1")
        Conditions += " " + "استان " + document.forms[0].ddest.options[document.forms[0].ddest.selectedIndex].text;
    if (document.forms[0].txtct.value != "")
        Conditions += " " + "شهر " + document.forms[0].txtct.value;
    sslvl = arMstatus[document.forms[0].ddslvl.value];
    smtp = document.forms[0].ddmtp[document.forms[0].ddmtp.selectedIndex].text;
    sSleep = "";
    if (document.forms[0].ddslp.value != "")
        sSleep = document.forms[0].ddslp.value + "خوابه ";
    if (document.forms[0].ddbld[document.forms[0].ddbld.selectedIndex].text != "")
        sSleep += document.forms[0].ddbld[document.forms[0].ddbld.selectedIndex].text;
    sSleep += getMT(document.forms[0].ddmt.value);
    if (smtp != "")
        ss = " نوع ملک " + smtp + sSleep;
    else
        ss = sSleep;
    if (document.forms[0].ddag.value == -10) {
        if (sslvl != "")
            Conditions += ss + " جهت " + sslvl;
        else
            Conditions += ss;
    }
    else
        if (document.forms[0].ddag.value == -20)
            Conditions += ss + " " + sslvl + " موردهاي بي واسطه ";
        else
            Conditions += ss + " " + " ملکهاي " + sslvl + document.forms[0].ddag.options[document.forms[0].ddag.selectedIndex].text;
    bNoRegionSelected = 1;
    if (document.forms[0].txtrgn.value != "") {
        Conditions += " محدوده " + document.forms[0].txtrgn.value;
        bNoRegionSelected = 0;
    }


    Conditions += getPriceStatment(document.forms[0].ddsprs1[document.forms[0].ddsprs1.selectedIndex].text, document.forms[0].ddsprs2[document.forms[0].ddsprs2.selectedIndex].text, " قيمت کل ");
    Conditions += getPriceStatment(document.forms[0].ddrn1[document.forms[0].ddrn1.selectedIndex].text, document.forms[0].ddrn2[document.forms[0].ddrn2.selectedIndex].text, " مبلغ رهن ");
    Conditions += getPriceStatment(document.forms[0].ddls1[document.forms[0].ddls1.selectedIndex].text, document.forms[0].ddls2[document.forms[0].ddls2.selectedIndex].text, " مبلغ اجاره ");

    document.forms[0].txtConditions.value = Conditions;

}


function SetComboEnabled() {

    el = document.forms[0].ddslvl;
    document.forms[0].ddrn1.disabled = "";
    document.forms[0].ddrn2.disabled = "";
    document.forms[0].ddls1.disabled = "";
    document.forms[0].ddls2.disabled = "";
    document.forms[0].ddsprs1.disabled = "";
    document.forms[0].ddsprs2.disabled = "";
    if (el.value == 1) {
        document.forms[0].ddsprs1.disabled = "disabled";
        document.forms[0].ddsprs2.disabled = "disabled";
    }
    else
        if (el.value == 2 || el.value == 3) {
            document.forms[0].ddrn1.disabled = "disabled";
            document.forms[0].ddrn2.disabled = "disabled";
            document.forms[0].ddls1.disabled = "disabled";
            document.forms[0].ddls2.disabled = "disabled";
        }
    UpdateConditions();
}
function EstateChange() {
    UpdateConditions();
    document.forms[0].txtct.value = "";
    document.forms[0].txtrgn.value = "";
}



function initjs() {
    document.forms[0].ddag.onchange = UpdateConditions;
    document.forms[0].ddslvl.onchange = SetComboEnabled;
    document.forms[0].ddest.onchange = EstateChange;
    document.forms[0].txtct.onchange = UpdateConditions;
    document.forms[0].ddmtp.onchange = UpdateConditions;
    document.forms[0].txtrgn.onchange = UpdateConditions;
    document.forms[0].ddbld.onchange = UpdateConditions;
    document.forms[0].ddslp.onchange = UpdateConditions;
    document.forms[0].ddrn1.onchange = UpdateConditions;
    document.forms[0].ddrn2.onchange = UpdateConditions;
    document.forms[0].ddls1.onchange = UpdateConditions;
    document.forms[0].ddls2.onchange = UpdateConditions;
    document.forms[0].ddsprs1.onchange = UpdateConditions;
    document.forms[0].ddsprs2.onchange = UpdateConditions;
    document.forms[0].txtnum.onchange = UpdateConditions;
    document.forms[0].ddmt.onchange = UpdateConditions;
}

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

