﻿/// <summary>
/// GetCounty function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function GetCounty(thisis, objCountyList, objDistrictList, bIsCheckBox) {
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetNewCountyStaticMethod",
        data: "{nCityID:" + thisis.value + ",nSelectCountyID:0}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            var sListName = "#" + objCountyList;
            $(sListName + " option").each(function (i, option) { $(option).remove() });
            $(sListName).append(value.d);

            HiddenFieldValueNull(objCountyList);
            HiddenFieldValueNull(objDistrictList);

            RemoveOption(objDistrictList);

            if (bIsCheckBox == "true") {
                var useragent = navigator.userAgent.toLowerCase();
                if (useragent.indexOf('iphone') == -1 && useragent.indexOf('symbianos') == -1 && useragent.indexOf('ipad') == -1 && useragent.indexOf('ipod') == -1 && useragent.indexOf('android') == -1 && useragent.indexOf('blackberry') == -1 && useragent.indexOf('samsung') == -1 && useragent.indexOf('nokia') == -1 && useragent.indexOf('windows ce') == -1 && useragent.indexOf('sonyericsson') == -1 && useragent.indexOf('webos') == -1 && useragent.indexOf('wap') == -1 && useragent.indexOf('motor') == -1 && useragent.indexOf('symbian') == -1) {
                    $(sListName).dropdownchecklist("destroy");
                    $(sListName).dropdownchecklist({ firstItemChecksAll: true, maxDropHeight: 150, width: 186 });

                    $("#" + objDistrictList).dropdownchecklist("destroy");
                    $("#" + objDistrictList).dropdownchecklist({ firstItemChecksAll: true, maxDropHeight: 120, width: 186 });
                }
                else {
                    $(sListName + " option").each(function (i, option) {
                        $(option).remove();
                        exit;
                    });
                }
            }
        },
        error: function (value) {
            alert('HATA');
        }
    });
}

/// <summary>
/// GetDistrict function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function GetDistrict(thisis, objSetList, bIsCheckBox) {
    var sCountyIDs = "";
    var sCountyText = "";
    var sGetListName = "#" + thisis.id;
    var sSetListName = "#" + objSetList;
    var hdnCountyID = sGetListName + "hdnID";
    var hdnCountyText = sGetListName + "hdnText";
    $(sGetListName + " option:selected").each(function () {
        // if ($(this).attr('value') != "-1") {
        if (sCountyIDs != "") sCountyIDs += ",";
        sCountyIDs += $(this).attr('value');
        if (sCountyText != "") sCountyText += ",";
        sCountyText += $(this).attr('text');
        // }
    });

    HiddenFieldValueNull(thisis.id);
    HiddenFieldValueNull(objSetList);

    $(hdnCountyID).val(sCountyIDs);
    $(hdnCountyText).val(sCountyText);

    if (sCountyIDs != "" && objSetList != "") {
        $.ajax({
            type: "POST",
            url: "/Json.aspx/GetDistrictStaticMethod",
            data: "{sCountyIDs:'" + sCountyIDs + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (value) {
                $(sSetListName + " option").each(function (i, option) { $(option).remove() });
                $(sSetListName).append(value.d);
                $(sSetListName).disabled = "";
                if (bIsCheckBox == "true") {
                    var useragent = navigator.userAgent.toLowerCase();
                    if (useragent.indexOf('iphone') == -1 && useragent.indexOf('symbianos') == -1 && useragent.indexOf('ipad') == -1 && useragent.indexOf('ipod') == -1 && useragent.indexOf('android') == -1 && useragent.indexOf('blackberry') == -1 && useragent.indexOf('samsung') == -1 && useragent.indexOf('nokia') == -1 && useragent.indexOf('windows ce') == -1 && useragent.indexOf('sonyericsson') == -1 && useragent.indexOf('webos') == -1 && useragent.indexOf('wap') == -1 && useragent.indexOf('motor') == -1 && useragent.indexOf('symbian') == -1) {
                        $(sSetListName).dropdownchecklist("destroy");
                        $(sSetListName).dropdownchecklist({ firstItemChecksAll: true, maxDropHeight: 120, width: 186 });
                    }
                    else {
                        $(sSetListName + " option").each(function (i, option) {
                            $(option).remove();
                            exit;
                        });
                    }
                }
            },
            error: function (value) {
                alert('HATA');
            }
        });
    }
}

/// <summary>
/// SetDistrict function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function SetDistrict(thisis) {
    var sDistrictIDs = "";
    var sDistrictText = "";
    var sListName = "#" + thisis.id;
    var hdnDistrictID = sListName + "hdnID";
    var hdnDistrictText = sListName + "hdnText";
    $(sListName + " option:selected").each(function () {
        // if ($(this).attr('value') != "-1") {
        if (sDistrictIDs != "") sDistrictIDs += ",";
        sDistrictIDs += $(this).attr('value');
        if (sDistrictText != "") sDistrictText += ",";
        sDistrictText += $(this).attr('text');
        // }
    });

    $(hdnDistrictID).val(sDistrictIDs);
    $(hdnDistrictText).val(sDistrictText);
}

/// <summary>
/// GetDistrict function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function GetArea(thisis, objSetList, bIsCheckBox) {
    var sCountyIDs = "";
    var sCountyText = "";
    var sGetListName = "#" + thisis.id;
    var sSetListName = "#" + objSetList;
    var hdnCountyID = sGetListName + "hdnID";
    var hdnCountyText = sGetListName + "hdnText";
    $(sGetListName + " option:selected").each(function () {
        // if ($(this).attr('value') != "-1") {
        if (sCountyIDs != "") sCountyIDs += ",";
        sCountyIDs += $(this).attr('value');
        if (sCountyText != "") sCountyText += ",";
        sCountyText += $(this).attr('text');
        // }
    });

    if (sCountyIDs == $(hdnCountyID).val()) {
        return;
    }

    HiddenFieldValueNull(thisis.id);
    HiddenFieldValueNull(objSetList);

    $(hdnCountyID).val(sCountyIDs);
    $(hdnCountyText).val(sCountyText);

    if (objSetList != "") {
        $.ajax({
            type: "POST",
            url: "/Json.aspx/GetAreaStaticMethod",
            data: "{sCountyIDs:'" + sCountyIDs + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (value) {
                $(sSetListName + " option").each(function (i, option) { $(option).remove() });
                $(sSetListName).append(value.d);
                $(sSetListName).disabled = "";
                if (bIsCheckBox == "true") {
                    var useragent = navigator.userAgent.toLowerCase();
                    if (useragent.indexOf('iphone') == -1 && useragent.indexOf('symbianos') == -1 && useragent.indexOf('ipad') == -1 && useragent.indexOf('ipod') == -1 && useragent.indexOf('android') == -1 && useragent.indexOf('blackberry') == -1 && useragent.indexOf('samsung') == -1 && useragent.indexOf('nokia') == -1 && useragent.indexOf('windows ce') == -1 && useragent.indexOf('sonyericsson') == -1 && useragent.indexOf('webos') == -1 && useragent.indexOf('wap') == -1 && useragent.indexOf('motor') == -1 && useragent.indexOf('symbian') == -1) {
                        $(sSetListName).dropdownchecklist("destroy");
                        $(sSetListName).dropdownchecklist({ firstItemChecksAll: true, maxDropHeight: 120, width: 186 });
                    }
                    else {
                        $(sSetListName + " option").each(function (i, option) {
                            $(option).remove();
                            exit;
                        });
                    }
                }
            },
            error: function (value) {
                alert('HATA');
            }
        });
    }
}

/// <summary>
/// SetDistrict function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function SetAreaHidden(thisis) {
    var sDistrictIDs = "";
    var sDistrictText = "";
    var sListName = "#" + thisis.id;
    var hdnDistrictID = sListName + "hdnID";
    var hdnDistrictText = sListName + "hdnText";
    $(sListName + " option:selected").each(function () {
        // if ($(this).attr('value') != "-1") {
        if (sDistrictIDs != "") sDistrictIDs += ",";
        sDistrictIDs += $(this).attr('value');
        if (sDistrictText != "") sDistrictText += ",";
        sDistrictText += $(this).attr('text');
        // }
    });

    $(hdnDistrictID).val(sDistrictIDs);
    $(hdnDistrictText).val(sDistrictText);
}

/// <summary>
/// HiddenFieldValueNull function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function HiddenFieldValueNull(sListName) {
    var sHiddenFieldValueID = "#" + sListName + "hdnID";
    var sHiddenFieldValueText = "#" + sListName + "hdnText";

    $(sHiddenFieldValueID).val('');
    $(sHiddenFieldValueText).val('');
}

/// <summary>
/// RemoveOption function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function RemoveOption(ListName) {
    if (ListName != "") {
        var sRemoveListName = "#" + ListName;
        $(sRemoveListName + " option").each(function (i, option) { $(option).remove() });
        $(sRemoveListName).append("<option value='-1' selected='selected'>Seçiniz</option>");
    }
}

/// <summary>
/// SelectedCountyByDistrictName function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function SelectedCountyByDistrictName(DistrictName, lstCountyName, lstDistrictName) {
    if (DistrictName != "") {
        $.ajax({
            type: "POST",
            url: "/Json.aspx/GetCountyByDistrictName",
            data: "{sDistrictName:'" + DistrictName + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (value) {
                var sListCountyName = "#" + lstCountyName;
                var sListDistrictName = "#" + lstDistrictName;
                var sCountyID = value.d.split(';')[1];
                var sDistrictID = value.d.split(';')[0];
                $(sListCountyName + " option").each(function (i, option) {
                    if ($(option).attr('value') == sCountyID) {
                        $(option).attr("selected", "selected");
                    }
                });
                $(sListDistrictName + " option").each(function () {
                    if ($(sListDistrictName).attr('value') == sDistrictID) {
                        $(sListDistrictName + " option").attr("selected", "selected");
                    }
                });
            },
            error: function (value) {
            }
        });
    }
}

// toggles search divs on realtydetail page
function togglePoiSearch(type) {
    if (type == 1) {
        SelectedPois();
        SetPoiMarkerDefault();
    }
    else {

        var txt = '';
        $("input:checked").each(function (i, checked) {
            if (this.id.indexOf('chkPoiCategory') == 0) {
                txt += $(this).attr('value') + ',';
            }
        });

        // clean last comma
        if (txt != '') {
            txt = txt.substring(0, txt.length - 1);
        }

        $('#hdnPoiSubCategory').val(txt);
        SetPoiMarkerDefault();
    }
}

// collected selected pois from listbox
function SelectedPois() {
    var txt = '';
    $("#lstSelectedPois  option").each(function () {
        txt += $(this).val() + ',';
    });

    // clean last comma
    if (txt != '') {
        txt = txt.substring(0, txt.length - 1);
    }
    $('#hdnPoiSubCategory').val(txt);
}

/// <summary>
/// Set Map Marker function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function SetMapMarker() {
    //remove foursquare check
    $('#foursquare').removeClass('selected');

    var sCategoryIDs = '';
    $("input:checked").each(function (i, checked) {
        if (this.id.indexOf('chkPoiCategory') == 0) {
            if (sCategoryIDs != "") sCategoryIDs += ",";
            sCategoryIDs += $(this).attr('value');
        }
    });

    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetPOILocation",
        data: "{sCoordinates:'" + $("#hdnPoiCoordinates").val() + "',sCategoryIDs:'" + sCategoryIDs + "',nRowCount:5}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            GetPOISuccess(value);
        },
        error: function (value) {
        }
    });
}

/// <summary>
/// Set Map Marker function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function SetFoursquare() {
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetPOIFoursquare",
        data: "{sCoordinates:'" + $("#hdnPoiCoordinates").val() + "',nDistance:5,nLimit:10}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            GetPOISuccess(value);
        },
        error: function (value) {
        }
    });
}

/// <summary>
/// SetPoiMarker function Beytullah TAŞKIN 11.08.2011
/// </summary>
function SetPoiMarkerDefault() {
    var objSubCategory = $("#hdnPoiSubCategory").val();
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetPOILocation",
        data: "{sCoordinates:'" + $("#hdnPoiCoordinates").val() + "',sCategoryIDs:'" + objSubCategory + "',nRowCount:5}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            GetPOISuccess(value);
        },
        error: function (value) {
        }
    });
}

/// <summary>
/// SetPoiMarker function Beytullah TAŞKIN 11.08.2011
/// </summary>
function SetPoiMarker(objSubCategory) {
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetPOILocation",
        data: "{sCoordinates:'" + $("#hdnPoiCoordinates").val() + "',sCategoryIDs:'" + objSubCategory.value + "',nRowCount:20}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            GetPOISuccess(value);
        },
        error: function (value) {
        }
    });
}


function GetPOISuccess(value) {
    if (document.getElementById('hdnTabIndex').value == "1") {
        //if (subgurim_GMap1 != null) {
        subgurim_GMap1.clearOverlays();

        //// İlanın bulundugu noktayı set ediyoruz.
        var store = new Store('subgurim_GMap1_Store');
        subgurim_icon = new GIcon(G_DEFAULT_ICON);
        subgurim_icon.image = "http://www.hurriyetemlak.com/images/mapIcon.png";
        if (store.Get("1") != undefined) {
            var marker_subgurim = new GMarker(new GLatLng(store.Get("1").split(',')[0], store.Get("1").split(',')[1]), { icon: subgurim_icon });
            marker_subgurim.id = 'marker_realty_map';
            marker_subgurim.gtype = 'marker';

            if (store.Get("2") != undefined) {
                var tooltip = new Tooltip(marker_subgurim, store.Get("2"), 3);
                marker_subgurim.tooltip = tooltip;
                subgurim_GMap1.addOverlay(tooltip);
            }

            subgurim_GMap1.setCenter(new GLatLng(store.Get("1").split(',')[0], store.Get("1").split(',')[1]), 13);
            subgurim_GMap1.addOverlay(marker_subgurim);
            GEvent.addListener(marker_subgurim, 'mouseover', function () { this.tooltip.show(); });
            GEvent.addListener(marker_subgurim, 'mouseout', function () { this.tooltip.hide(); });
        }

        if (value.d != null) {
            for (var i = 0; i < value.d.length; i++) {
                subgurim_icon = new GIcon(G_DEFAULT_ICON);
                subgurim_icon.image = value.d[i].POIIcon;
                var marker_subgurim = new GMarker(new GLatLng(value.d[i].POILocationLatitude, value.d[i].POILocationLongtitude), { icon: subgurim_icon });
                marker_subgurim.id = 'marker_subgurim';
                marker_subgurim.gtype = 'marker';
                subgurim_GMap1.addOverlay(marker_subgurim);

                var myElement = document.createElement('div');
                myElement.setAttribute('style', 'white-space:normal;width:150px');
                var myTitle = document.createElement('b');
                myTitle.setAttribute('style', 'display:block;margin-bottom:5px');
                myTitle.appendChild(document.createTextNode(value.d[i].POIContent));
                myElement.appendChild(myTitle);
                if (typeof (value.d[i].POIAddress) == 'string') {
                    myElement.appendChild(document.createTextNode(value.d[i].POIAddress));
                    myElement.appendChild(document.createElement('p'));
                }

                if (typeof (value.d[i].POIInfo) == 'string') {
                    myElement.appendChild(document.createTextNode(value.d[i].POIInfo));
                }

                var tooltip = new Tooltip(marker_subgurim, myElement, 3);
                marker_subgurim.tooltip = tooltip;
                subgurim_GMap1.addOverlay(marker_subgurim);
                subgurim_GMap1.addOverlay(tooltip);
                GEvent.addListener(marker_subgurim, 'mouseover', function () { this.tooltip.show(); });
                GEvent.addListener(marker_subgurim, 'mouseout', function () { this.tooltip.hide(); });
            }
        }
    }
}


/// <summary>
/// SetMapCenter function A.Hakan BEŞTAŞ 26.04.2011
/// </summary>
function SetMapCenter(nCityID, nCountyID, nZoomSize) {
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetGoogleMapsLocation",
        data: "{nCityID:" + nCityID + ",nCountyID:" + nCountyID + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            if (subgurim_GMap1 != null) {
                subgurim_GMap1.setCenter(new GLatLng(value.d[0], value.d[1]), nZoomSize);
            }
        },
        error: function (value) {
        }
    });
}


/// <summary>
/// SelectedLocationByAutoComplete function A.Hakan BEŞTAŞ 12.05.2011
/// </summary>
function SelectedLocationByAutoComplete(objCountyList, objDistrictList, sCountyIDs, nDistrictID, objIncludeVillage) {
    var sCountyText = "";
    /// County
    var sCountyListName = "#" + objCountyList;
    var hdnCountyID = sCountyListName + "hdnID";
    var hdnCountyText = sCountyListName + "hdnText";
    /// District
    var sDistrictListName = "#" + objDistrictList;
    var hdnDistrictID = sDistrictListName + "hdnID";
    var hdnDistrictText = sDistrictListName + "hdnText";
    var sVillage = "#" + objIncludeVillage;

    $(sCountyListName + " option").each(function () {
        if ($(this).attr('value') == sCountyIDs) {
            $(this).attr("selected", "selected");
            sCountyText += $(this).attr('text');
        }
        else {
            $(sCountyListName).attr("selected", "");
        }
    });

    HiddenFieldValueNull(objCountyList);
    HiddenFieldValueNull(objDistrictList);

    $(hdnCountyID).val(sCountyIDs);
    $(hdnCountyText).val(sCountyText);

    if (sCountyIDs != "" && objDistrictList != "") {
        $.ajax({
            type: "POST",
            url: "/Json.aspx/GetNewDistrictStaticMethod",
            data: "{nCountyID:" + sCountyIDs + ",nSelectDistrictID:0,bHasVillage:" + $(sVillage).is(':checked') + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (value) {
                $(sDistrictListName + " option").each(function (i, option) { $(option).remove() });
                $(sDistrictListName).append(value.d);

                $(sDistrictListName + " option").each(function () {
                    if ($(this).attr('value') == nDistrictID) {
                        $(this).attr("selected", "selected");
                        hdnDistrictText += $(this).attr('text');
                    }
                    else {
                        $(sDistrictListName).attr("selected", "");
                    }
                });

                $(hdnDistrictID).val(nDistrictID);
                $(hdnDistrictText).val(hdnDistrictText);
            },
            error: function (value) {
                alert('HATA');
            }
        });
    }
}

//// POI 

/// <summary>
/// GetPoiCategory function Beytullah TAŞKIN 11.08.2011
/// </summary>
function GetPOISubCategory(objCategory, objSubCategory) {
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetPOISubCategory",
        data: "{nCategoryID:" + objCategory.value + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            var sListName = "#" + objSubCategory;
            $(sListName + " option").each(function (i, option) { $(option).remove() });
            $(sListName).append(value.d);
        },
        error: function (value) {
            alert('HATA');
        }
    });
}


//// NEW LOCATION

/// <summary>
/// SetDistrict function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function SetNewDistrict(thisis) {
    var sDistrictIDs = "";
    var sDistrictText = "";
    var sListName = "#" + thisis.id;
    var hdnDistrictID = sListName + "hdnID";
    var hdnDistrictText = sListName + "hdnText";
    $(sListName + " option:selected").each(function () {
        // if ($(this).attr('value') != "-1") {
        if (sDistrictIDs != "") sDistrictIDs += ",";
        sDistrictIDs += $(this).attr('value');
        if (sDistrictText != "") sDistrictText += ",";
        sDistrictText += $(this).attr('text');
        // }
    });

    $(hdnDistrictID).val(sDistrictIDs);
    $(hdnDistrictText).val(sDistrictText);
}

/// <summary>
/// GetCounty function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function GetNewCounty(thisis, objCountyList, objDistrictList) {
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetNewCountyStaticMethod",
        data: "{nCityID:" + thisis.value + ", nSelectCountyID:0}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            var sListName = "#" + objCountyList;
            $(sListName + " option").each(function (i, option) { $(option).remove() });
            $(sListName).append(value.d);

            HiddenFieldValueNull(objCountyList);
            HiddenFieldValueNull(objDistrictList);

            RemoveOption(objDistrictList);
            $("#lblArea").html("");
            $("#trArea").hide();
        },
        error: function (value) {
            alert('HATA');
        }
    });
}

/// <summary>
/// GetDistrict function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function GetNewDistrict(thisis, objSetList, objIncludeVillage) {
    var sCountyIDs = "";
    var sCountyText = "";
    var sGetListName = "#" + thisis;
    var sSetListName = "#" + objSetList;
    var sVillage = "#" + objIncludeVillage;
    var hdnCountyID = sGetListName + "hdnID";
    var hdnCountyText = sGetListName + "hdnText";
    $(sGetListName + " option:selected").each(function () {
        // if ($(this).attr('value') != "-1") {
        if (sCountyIDs != "") sCountyIDs += ",";
        sCountyIDs += $(this).attr('value');
        if (sCountyText != "") sCountyText += ",";
        sCountyText += $(this).attr('text');
        // }
    });

    HiddenFieldValueNull(thisis);
    HiddenFieldValueNull(objSetList);

    $("#lblArea").html("");
    $("#trArea").hide();

    $(hdnCountyID).val(sCountyIDs);
    $(hdnCountyText).val(sCountyText);

    if (sCountyIDs != "" && objSetList != "") {
        $.ajax({
            type: "POST",
            url: "/Json.aspx/GetNewDistrictStaticMethod",
            data: "{nCountyID:" + sCountyIDs + ",nSelectDistrictID:0,bHasVillage:" + $(sVillage).is(':checked') + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (value) {
                $(sSetListName + " option").each(function (i, option) { $(option).remove() });
                $(sSetListName).append(value.d);
                $(sSetListName).disabled = "";
            },
            error: function (value) {
                alert('HATA');
            }
        });
    }
}

/// NewLocationPair function A.Hakan BEŞTAŞ 04.05.2011
/// </summary>
function NewLocationPair(thisis) {
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetNewLocationPairMethod",
        data: "{nDistrictID:" + thisis.value + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (ui) {
            SelectedNewLocation('lstNewRealtyCountyID', 'lstNewRealtyDistrictID', ui.d[0].LocationCityID, ui.d[0].LocationCountyID, ui.d[0].LocationID);
            $("#lstNewRealtyDistrictIDhdnID").val(ui.d[0].LocationID);
        }
        ,
        error: function (value) {
            alert('HATA');
        }
    });
}

/// <summary>
/// SelectedNewLocation function A.Hakan BEŞTAŞ 12.05.2011
/// </summary>
function SelectedNewLocation(objCountyList, objDistrictList, nCityID, nCountyID, nDistrictID) {
    var sCityListName = "#lstNewRealtyCityID";
    var sCountyText = "";
    /// County
    var sCountyListName = "#" + objCountyList;
    var hdnCountyID = sCountyListName + "hdnID";
    var hdnCountyText = sCountyListName + "hdnText";
    /// District
    var sDistrictListName = "#" + objDistrictList;
    var hdnDistrictID = sDistrictListName + "hdnID";
    var hdnDistrictText = sDistrictListName + "hdnText";

    //// Selected City
    $(sCityListName + " option").each(function (i, option) {
        if ($(option).attr('value') == nCityID) {
           c
        }
        else {
            $(option).attr("selected", "");
        }
    });
    ////    End Selected City

    ////    Selected County
    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetNewCountyStaticMethod",
        data: "{nCityID:" + nCityID + ", nSelectCountyID:" + nCountyID + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            $(sCountyListName + " option").each(function (i, option) { $(option).remove() });
            $(sCountyListName).append(value.d);

            HiddenFieldValueNull(objCountyList);
            HiddenFieldValueNull(objDistrictList);

            RemoveOption(objDistrictList);

            $(hdnCountyID).val(nCountyID);
            $(hdnCountyText).val(sCountyText);
            ////    End Selected County

            ////    Selected District
            if (nCountyID != "" && objDistrictList != "") {
                $.ajax({
                    type: "POST",
                    url: "/Json.aspx/GetNewDistrictStaticMethod",
                    data: "{nCountyID:" + nCountyID + ",nSelectDistrictID:" + nDistrictID + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (value) {
                        $(sDistrictListName + " option").each(function (i, option) { $(option).remove() });
                        $(sDistrictListName).append(value.d);

                        $(hdnDistrictID).val(nDistrictID);
                        $(hdnDistrictText).val(hdnDistrictText);
                    },
                    error: function (value) {
                        alert('HATA');
                    }
                });
            }

        },
        error: function (value) {
            alert('HATA');
        }
    });
    ////    End Selected District
}

/// <summary>
/// SetArea function A.Hakan BEŞTAŞ 27.07.2011
/// </summary>
function SetArea(thisis, sText) {
    var nDistrictID;
    if (parseInt(thisis) == thisis) {
        nDistrictID = thisis;
    }
    else {
        nDistrictID = thisis.value;
    }

    $.ajax({
        type: "POST",
        url: "/Json.aspx/GetArea",
        data: "{nDistrictID:" + nDistrictID + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (value) {
            $("#lblArea").html(sText.replace('{0}', value.d));
            $("#trArea").show();
        }
        ,
        error: function (value) {
        }
    });
}

/// <summary>
/// GetPOIUniversity function Ali Yüztaş 05.10.2011
/// </summary>
function GetUniversity(thisIs, objUniversityList) {
    var nCityID = "";
    var sGetListName = "#" + thisIs.id;
    var sSetListName = "#" + objUniversityList;

    $(sGetListName + " option:selected").each(function () {
        nCityID = $(this).attr('value');
    });

    if (nCityID != "" && objUniversityList != "") {
        $.ajax({
            type: "POST",
            url: "/Json.aspx/GetPOIUniversity",
            data: "{nCityID:'" + nCityID + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (value) {
                $(sSetListName + " option").each(function (i, option) {
                    $(option).remove();
                });

                $(sSetListName).append(value.d);
            },
            error: function (value) {
                alert('HATA');
            }
        });
    }
}

/// <summary>
/// SetUniversityHidden function Ali Yüztaş 06.10.2011
/// </summary>
function SetUniversityHidden(thisIs, objUniversityHidden) {
    var sGetListName = "#" + thisIs.id;
    var sSetHiddenName = "#" + objUniversityHidden;
    var nUniversityID = "";

    $(sGetListName + " option:selected").each(function () {
        nUniversityID = $(this).attr('value');
    });

    HiddenFieldValueNull(sSetHiddenName);
    $(sSetHiddenName).val(nUniversityID);
}


