
/** TABS **/

function showTab($tabId) {
    // get parent container
    $tabContainer = $('button_' + $tabId).up('.tab_container');
    // loop thru buttons to set the active one
    $buttons = $tabContainer.down('.tab_button_container').childElements();
    for ($i = 0; $i < $buttons.length; $i++) {
        $button = $buttons[$i];
        if (('button_' + $tabId) == $button.id) {
            $button.addClassName('active');
        } else {
            $button.removeClassName('active');
        }
    }
    // loop thru contents to set the visible one
    $contents = $tabContainer.down('.tab_content_container').childElements();
    for ($i = 0; $i < $contents.length; $i++) {
        $content = $contents[$i];
        if (('content_' + $tabId) == $content.id) {
            $content.removeClassName('hidden');
        } else {
            $content.addClassName('hidden');
        }
    }
}

/** MODALBOX **/

// pops up a vacancy reaction form
function showVacancyReactForm(publicationId) {
    Modalbox.show($ROOT + 'vacancy-react-form-popup?publication_id=' + publicationId, {
        title: 'Laat weten dat je ge&iuml;nteresseerd bent',
        width: 600
    });
}
// posts a vacancy reaction form
function postVacancyReaction($url) {
    Modalbox.show($ROOT + 'vacancy-react-form-popup', {
        title: 'Laat weten dat je ge&iuml;nteresseerd bent',
        params: Form.serialize('frm_vacancy_react'),
        afterHide: function() { closeAndReplacePage() }
    });
}
// closes modalbox
function cancel() {
    Modalbox.hide();
}
// closes modalbox and redirect parent page
function closeAndReplacePage($replace_url) {
    if ($replace_url.length > 0) {
        window.location.replace($replace_url);
    }
}
// closes modalbox and reloads parent page
function closeAndReloadPage() {
    Modalbox.hide();
    window.location.reload();
}

