var SearchForm = {

    fetchResorts: function(countryId) {
        if (countryId && countryId != "") {
            dojo.xhrGet({
                url: dojo.moduleUrl("","../search/resorts").toString(),
                handleAs: "text",
                content: {
                    "countryId": countryId
                },
                load: function(response) {
                    var select = dojo.byId('searchFormResortPlaceholder');
                    select.innerHTML = response;
                }
            });
        } else {
            dojo.byId("searchFormResortPlaceholder").innerHTML =
                "<select name=\"resortId\" id=\"searchFormResortId\">"
                + "<option value=\"\"></option>"
                + "</select>"
        }
    },

    handleAdvanced: function() {
        if (dojo.byId("searchFormAdvanced").checked) {
            dojo.byId("searchFormAdvancedPart").className = "";
        } else {
            dojo.byId("searchFormAdvancedPart").className = "hidden";
        }
    },

    redraw: function() {
        this.fetchResorts();
        this.handleAdvanced();
    },

    setOrder: function() {
        window.location.href = dojo.byId("orderSelect").value;
    }

}

