﻿/// <reference path="jquery-1.2.6-vsdoc.js" />

var Search = function(config) {
    this.areaArr = [];
    this.locArr = [];
    this.config = config;
    this.pageNo = 0;
    this.queryString = "";
};

Search.prototype.clearSearch = function() {
    this.areaArr = [];
    this.locArr = [];
};

Search.prototype.setAreas = function(areas) {
    this.areaArr = areas;
};

Search.prototype.setLocations = function(locations) {
    this.locArr = locations;
};

Search.prototype.setPageNo = function(pageNo) {
    this.pageNo = pageNo;
};

Search.prototype.setQueryString = function(queryString) {
    this.queryString = queryString;
};

Search.prototype.doSearch = function(onComplete) {
$.getJSON(this.config.resultUrl,
              {
                  locations: this.locArr,
                  areas: this.areaArr,
                  pageNo: this.pageNo,
                  textSearch: this.queryString
              },
              function(json) {
                  onComplete(json);
              });
};


Search.prototype.getCount = function(onComplete) {
    $.getJSON(this.config.countUrl,
    {
        locations: this.locArr,
        areas: this.areaArr,
        textSearch: this.queryString
    },
    function(json) {
        onComplete(json);
    });
};

