var selectedCountry = "";

Event.observe(window, "load", initVacancies);

function initVacancies(){
    var country = $("countryCode");
    selectedCountry = country.value;
    Event.observe(country, "change", resetCareersCountrySelection);

    Event.observe($('searchVacancies'), "click",
                            function(event) {
                                $('searchVacanciesForm').submit();
                                Event.stop(event);
                                return false;
                            });
}

function resetCareersCountrySelection(){
    var country = $("countryCode");
    if(country.value != selectedCountry){
        $("jobCityId").value = -1;
        $("category").value = -1;
        $("jobType").value = -1;
        selectedCountry = country.value;
        $("searchVacanciesForm").submit();
    }
}

