﻿

function LoadSpecialties(combo, eventArqs) {
    debugger
    var item = eventArqs.get_item();
    specialtiesCombo.set_text("Loading...");
    statesCombo.clearSelection();
    citiesCombo.clearSelection();

    // if a discipline is selected
    if (item.get_index() > 0) {
        // this will fire the ItemsRequested event of the 
        // Specialities combobox passing the specialtyID as a parameter
        specialtiesCombo.requestItems(item.get_value(), false);
    }
    else {
        // the -Select a specialty- item was chosen
        statesCombo.set_text(" ");
        statesCombo.clearItems();

        citiesCombo.set_text(" ");
        citiesCombo.clearItems();
    }
}


function LoadStates(combo, eventArqs) {
    var item = eventArqs.get_item();
    var val = (eventArqs == null ? "" : item.get_value());
    statesCombo.set_text("Loading...");
    citiesCombo.clearSelection();

    // if a continent is selected
    if (item.get_index() > 0) {
        // this will fire the ItemsRequested event of the 
        // States combobox passing the stateID as a parameter 
        statesCombo.requestItems(item.get_value(), false);
    }
    else {
        // the -Select a state- item was chosen
        citiesCombo.set_text(" ");
        citiesCombo.clearItems();
    }
}

function LoadCities(combo, eventArqs) {
    var item = eventArqs.get_item();
    var val = (eventArqs == null ? "" : item.get_value());
    citiesCombo.set_text("Loading...");
    // this will fire the ItemsRequested event of the
    // cities combobox passing the countryID as a parameter 
    citiesCombo.requestItems(val, false);
}

function RefreshGrid(args) {
}


function DisciplinesLoaded(combo, eventArqs) {
    ItemLoaded(combo, eventArqs);
    SpecialtiesLoaded(combo, eventArqs);
}

function SpecialtiesLoaded(combo, eventArqs) {
    ItemLoaded(combo, eventArqs);
    LoadStates(combo, eventArqs);
}

function StatesLoaded(combo, eventArqs) {
    ItemLoaded(combo, eventArqs);
    LoadCities(combo, eventArqs);
}

function ItemLoaded(combo, eventArqs) {
    if (combo.get_items().get_count() > 0) {
        // pre-select the first item
        combo.set_text(combo.get_items().getItem(0).get_text());
        combo.get_items().getItem(0).highlight();
    }
    //combo.showDropDown();
}

function goBack() {
    window.location.href = "../jobs/jobs.aspx";
    //window.history.go(-1);
}

function applyNow(jobId) {
    window.location.href = "../forms/apply_now.aspx?id=" + jobId;
}

