function setJobPosition(title) {
    var frm = document.getElementById('resumeForm');
    for (i = 0; i < frm.position.options.length; i++) {
        if (frm.position.options[i].value == title) {
            frm.position.options[i].selected = true;
        }
    }
}

// HTML Classes
var cs_description = "description";
var cs_title = "title";
var cs_active_description = "title active";
var cs_inactive_description = "title inactive";

// Scan for the description associated with the given title
function getdesc(title) {
    do {
        title = title.nextSibling;
        if (!title) return false;
    } while (title.className != cs_description)
    return title;
}

// Event handler to hide the previous description and display the next
var lastTitle = false;
var effect_locked = false;
function toggleTitle() {
    if (!effect_locked) {
        // lock toggling untill all effects complete
        effect_locked = true;
        if (lastTitle) {
            lastTitle.className = cs_inactive_description;
            // getdesc(lastTitle).style.display = "none";
            // Effect.toggle(getdesc(lastTitle),'blind');
            // scaleTo option scales to 1% of the elements size to prevent flickering in IE
            // queue option associates the effect with a queue of effects with a max size of 2
            // afterFinish option provides a function that will run on completion
            // afterFinish function will unlock effects if it is the last effect in the queue
            Effect.BlindUp(getdesc(lastTitle), {scaleTo:.5, queue:{scope:'jobs', limit: 2}, afterFinish: function(effect) {
                if (Effect.Queues.get('jobs').effects.length == 0) {
                    effect_locked = false;
                }
            }});
        }
        if (lastTitle == this) {
            lastTitle = false;
        }
        else {
            this.className = cs_active_description;
            // getdesc(this).style.display = "block";
            // scaleFrom option scales from 1% of the elements size to prevent flickering in IE
            // queue option associates the effect with a queue of effects with a max size of 2
            // afterFinish option provides a function that will run on completion
            // afterFinish function will unlock effects if it is the last effect in the queue
            Effect.BlindDown(getdesc(this), {scaleFrom:.5, queue:{scope:'jobs', position:'end', limit: 2}, afterFinish: function(effect) {
                if (Effect.Queues.get('jobs').effects.length == 0) {
                    effect_locked = false;
                }
            }});
            lastTitle = this;
        }
    }
}

// Prepare document for Dynamic Case Study behavior, invoke from window onload
function initCareers() {

    // Disable DOM behavior in non-compliant browsers
    if (!document.getElementsByTagName) return;

    // Find all elements of class "title" with a matching "description"
    elements = document.getElementsByTagName("*");
    for (var i = 0; i < elements.length; ++i) {
        var element = elements[i];

        if (element.className == cs_title) {
            var description = getdesc(element);
            if (description) {

                // Add onclick event and alter appearance of title
                element.onclick = toggleTitle;
                element.className = cs_inactive_description;
                // Add hover effect for ie
                element.onmouseover = function() {
                    this.className += " over";
                }
                element.onmouseout = function() {
                    this.className = this.className.replace(" over", "");
                }

                // Hide answer
                description.style.display = "none";

            }
        }
    }
}

addLoadEvent(initCareers);