﻿//Towns Listener -------------------------------------------------
function TownsListener(oLoadingDiv, ErrorBoxID, oJobSearchForm, oLocPlaceholder, oSalPlaceholder, ValidMaxSalary, ValidMinSalary, ValidSalaryOrder, LocationBox) {
    this.TownslistenerLoadingDiv = oLoadingDiv;
    this.ErrorPopupID			 = ErrorBoxID;
    this.JobSearchForm			 = oJobSearchForm;
    this.Locplaceholder			 = oLocPlaceholder;
    this.Salplaceholder			 = oSalPlaceholder;
    this.ValidMaxSalary			 = ValidMaxSalary;
    this.ValidMinSalary			 = ValidMinSalary;
    this.ValidSalaryOrder		 = ValidSalaryOrder;
    this.LocationBox			 = LocationBox;
}

TownsListener.prototype.recieveResponse = function(townsHTML) {

    this.TownslistenerLoadingDiv.style.display = "none";

    if ((townsHTML == "MATCH") && (this.ValidMinSalary && this.ValidMaxSalary && this.ValidSalaryOrder)) {
        //this.JobSearchForm.onsubmit = null;
        this.JobSearchForm.submit();
    }
    else {
        holder = this.Locplaceholder;
        if (!(this.ValidMinSalary && this.ValidMaxSalary && this.ValidSalaryOrder) && (townsHTML == "MATCH")) {
            holder = this.Salplaceholder;
        }
        ErrorPopup = new ErrorBox(this.ErrorPopupID, holder, !this.ValidMaxSalary, !this.ValidMinSalary, !this.ValidSalaryOrder, townsHTML != "MATCH", townsHTML != "NONEFOUND", townsHTML, this.LocationBox);
        ErrorPopup.Display();
    }
}
//Towns Listener -------------------------------------------------