﻿// searsh.js
// written by Alex for BellSystems Services Limited
// 5-3-08

$(document).ready(
    function()
        {
            //######################
            //run search
            //######################
            $('#btnSearch').click(
                function()
                    {
                    $('#loader').removeAttr('style');
                    $('#btnSearch').attr('disabled', 'disabled');
                        $.ajax(
                                {
                                    type: "POST",
                                    cache: false,
                                    url: "/AjaxCallback/_runSearch.aspx",
                                    data: "type=" + $('#ddlType').val() + "&minBeds=" + $('#ddlBedrooms').val() + "&minPrice=" + $('#ddlMinPrice').val() + "&maxPrice=" + $('#ddlMaxPrice').val() + "&location=" + $('#txtLocation').val(),
                                    timeout: 10000,
                                    success: function(msg){
                                        $('#searchresults').html(msg);
                                        $('#btnSearch').removeAttr('disabled');
                                        $('#loader').attr('style', 'display:none;');
                                        },
                                    error: function(msg){alert(msg);}
                                }
                        );
                    }
            );
        }
    );
    
    function viewDetails(id)
    {
        $('#loader').removeAttr('style');
        $.ajax(
            {
                type: "POST",
                cache: false,
                url: "/AjaxCallback/_propertyDetails.aspx",
                data: "listing=" + id,
                timeout: 10000,
                success: function(msg){
                    $('#loader').attr('style', 'display:none;');
                    $('#searchresults').attr('style', 'display:none;');
                    $('#details').html(msg).removeAttr('style');
                },
                error: function(msg){alert(msg);}
            }
        )
    }
    
    function backToResults()
    {
        $('#searchresults').removeAttr('style');
        $('#details').attr('style', 'display:none;').html('');
    }
