$(document).ready(function() {
    var houseId;
    var objectId;
    var address;

    $('.showA44_3').click(function() {
        houseId = $(this).parents('.action').find('input[name$=hndHouseId]').val();
        objectId = $(this).parents('.action').find('input[name$=hdnObjectId]').val();
        address = $(this).parent().parent().find('.house a[id$=lnkAddress]').html();

        SetInitialStateA44_3(houseId, objectId, address);
    });

    $('.p4showA44_3').click(function() {
        houseId = $(this).parents('.right').find('input[name$=hndHouseId]').val();
        objectId = $(this).parents('.right').find('input[name$=hdnObjectId]').val();
        address = $(this).parents('.right').find('a[id$=lnkAddress]').html();

        SetInitialStateA44_3(houseId, objectId, address);
    });
    
    $('.p15showA44_3').click(function() {
        houseId = $('.p4HouseData').find('input[name$=hndHouseId]').val();
        objectId = $('.p4HouseData').find('input[name$=hdnObjectId]').val();
        address = $('.p4HouseData').find('a[id$=lnkAddress]').html();

        SetInitialStateA44_3(houseId, objectId, address);
    });    
        
    GetPlaceNames();

    function SetInitialStateA44_3(houseId, objectId, address) {
        //Reset values of controls
        $('#lblA44_3_Address').html(address);

        //Set value of hidden fields
        $('input[id$=hdnA44_3_HouseId]').val(houseId);
        $('input[id$=hdnA44_3_ObjectId]').val(objectId);

    }

    function GetPlaceNames() {
        $.ajax({
            type: 'POST',
            url: '/_vti_bin/PortalSearchService.asmx/GetPlaceNames',
            contentType: "application/json; charset=utf-8",
            data: "{}",
            dataType: 'json',
            success: function(cities) {
                $(".autocomplete-place").autocomplete(cities.d);
            }
        });
    }

});

