var questionArray = new Array();
questionArray[0] = {"visibility": "FEATURED", "name": "What's the secret to getting hired at", "id": 541};
questionArray[1] = {"visibility": "FEATURED", "name": "How would you describe what you did at", "id": 521};
questionArray[2] = {"visibility": "FEATURED", "name": "What are the most challenging aspects of your job at", "id": 502};
questionArray[3] = {"visibility": "FEATURED", "name": "What's the toughest problem you've had to solve at", "id": 501};
questionArray[4] = {"visibility": "FEATURED", "name": "What are the three best things about working at", "id": 261};
questionArray[5] = {"visibility": "FEATURED", "name": "What did you learn along the way at", "id": 16};
questionArray[6] = {"visibility": "FEATURED", "name": "What advice would you give to a new employee at", "id": 11};
questionArray[7] = {"visibility": "PROMOTED", "name": "How did you find your job at", "id": 281};
questionArray[8] = {"visibility": "PROMOTED", "name": "What's the best team you worked with at", "id": 262};
questionArray[9] = {"visibility": "PROMOTED", "name": "What blogs are people reading at", "id": 221};
questionArray[10] = {"visibility": "PROMOTED", "name": "What's the funniest thing that ever happened to you at", "id": 161};
questionArray[11] = {"visibility": "PROMOTED", "name": "What's unique about working at", "id": 141};
questionArray[12] = {"visibility": "PROMOTED", "name": "What are people reading at", "id": 63};
questionArray[13] = {"visibility": "PROMOTED", "name": "What do you miss most about ", "id": 24};
questionArray[14] = {"visibility": "VISIBLE", "name": "How long did it take for you to land your job at", "id": 563};
questionArray[15] = {"visibility": "VISIBLE", "name": "What was the main reason for accepting your job (location, opportunity, money) at", "id": 562};
questionArray[16] = {"visibility": "VISIBLE", "name": "What was your major and how applicable is it to your position at", "id": 561};
questionArray[17] = {"visibility": "VISIBLE", "name": "What's the interview process like at", "id": 181};
questionArray[18] = {"visibility": "VISIBLE", "name": "What's one of the projects you worked on at", "id": 61};
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();
  }
}

