var questionArray = new Array();
questionArray[0] = {"visibility": "FEATURED", "name": "How would you describe your dream job in 10 words or less", "id": 682};
questionArray[1] = {"visibility": "FEATURED", "name": "Myspace or Facebook (or neither)", "id": 681};
questionArray[2] = {"visibility": "FEATURED", "name": "What kind of job are you looking for", "id": 603};
questionArray[3] = {"visibility": "PROMOTED", "name": "What's your ideal work environment", "id": 662};
questionArray[4] = {"visibility": "PROMOTED", "name": "What's your ideal role within an organization", "id": 661};
questionArray[5] = {"visibility": "PROMOTED", "name": "What was your most memorable summer job", "id": 615};
questionArray[6] = {"visibility": "PROMOTED", "name": "Who was your most influential mentor and what did they teach you", "id": 602};
questionArray[7] = {"visibility": "PROMOTED", "name": "What profession other than yours would you like to try", "id": 599};
questionArray[8] = {"visibility": "PROMOTED", "name": "What was your first job", "id": 598};
questionArray[9] = {"visibility": "PROMOTED", "name": "What advice do you have for someone who wants a job like yours", "id": 591};
questionArray[10] = {"visibility": "PROMOTED", "name": "What path did you take to your current career", "id": 590};
questionArray[11] = {"visibility": "PROMOTED", "name": "What are you most passionate about", "id": 589};
questionArray[12] = {"visibility": "PROMOTED", "name": "Who are your role models", "id": 588};
questionArray[13] = {"visibility": "PROMOTED", "name": "How would your co-workers describe you", "id": 587};
questionArray[14] = {"visibility": "PROMOTED", "name": "How would your boss describe you", "id": 586};
questionArray[15] = {"visibility": "PROMOTED", "name": "What was your best interview experience like", "id": 584};
questionArray[16] = {"visibility": "PROMOTED", "name": "What are the most rewarding aspects of your job", "id": 583};
questionArray[17] = {"visibility": "PROMOTED", "name": "What are the most challenging aspects of your job", "id": 582};
questionArray[18] = {"visibility": "VISIBLE", "name": "Are you willing to relocate", "id": 684};
questionArray[19] = {"visibility": "VISIBLE", "name": "What are your hobbies", "id": 641};
questionArray[20] = {"visibility": "VISIBLE", "name": "Where do you hope to be in 10 years", "id": 620};
questionArray[21] = {"visibility": "VISIBLE", "name": "If you could choose, what city would you most like to live/work in?  Why", "id": 617};
questionArray[22] = {"visibility": "VISIBLE", "name": "What was the last really difficult interview question you were asked?  How did you respond", "id": 616};
questionArray[23] = {"visibility": "VISIBLE", "name": "What advice do you have for someone looking for their first job out of college", "id": 610};
questionArray[24] = {"visibility": "VISIBLE", "name": "What companies would you most like to work for", "id": 608};
questionArray[25] = {"visibility": "VISIBLE", "name": "What have your past employers loved about you", "id": 607};
questionArray[26] = {"visibility": "VISIBLE", "name": "What makes you a great employee", "id": 606};
questionArray[27] = {"visibility": "VISIBLE", "name": "What makes you a great coworker", "id": 605};
questionArray[28] = {"visibility": "VISIBLE", "name": "What's your dream job", "id": 597};
questionArray[29] = {"visibility": "VISIBLE", "name": "What blogs do you visit regularly", "id": 596};
questionArray[30] = {"visibility": "VISIBLE", "name": "What are your favorite web sites", "id": 595};
questionArray[31] = {"visibility": "VISIBLE", "name": "What are the three things that provide you satisfaction in your work", "id": 594};
questionArray[32] = {"visibility": "VISIBLE", "name": "What's the toughest problem you've had to solve", "id": 593};
questionArray[33] = {"visibility": "VISIBLE", "name": "What do you do for fun", "id": 592};
var current = 0;
var max = questionArray.length;

function displayQuestion(question) {
  var e = $('featured_question_text');
  var id_field = $('form_question_id');

  e.innerHTML = question.name + '?';
  id_field.value = question.id;
}

function thisQuestion() {
  displayQuestion(questionArray[current]);
}

function nextQuestion() {
  if ( abortAbandonQuestion('next') ) { return; }

  if (current+1 == max) {
    displayQuestion(questionArray[0]);
    current = 0;
  } else {
    displayQuestion(questionArray[current + 1]);
    current++;
  }
}

function prevQuestion() {
  if ( abortAbandonQuestion('previous') ) { return; }

  if (current == 0) {
    displayQuestion(questionArray[max - 1]);
    current = max - 1;
  } else {
    displayQuestion(questionArray[current - 1]);
    current--;
  }
}

function abortAbandonQuestion(direction) {
  var confirmText = 'Do you really want to go to the ' + direction + ' question? Your current answer will not be saved.';


  if ( $F('form_text') != $('form_text').defaultValue && !confirm(confirmText) ) {
    return true;
  } else {
    return false;
  }
}

function hideFormCompanyInput() {
  // if the company name textfield is visible (because we came to this page from a company detail page, for example)
  // hide it.
  if ($('form_company_name') != undefined) {
    $('form_company_name').hide();
  }
}

