// populate the contest browser with the url #video_id=, if this doesn't exist then populate with +video_id+
function populate_contest_browser(entry_id) {
  url_entry_id = window.location.hash.replace("#entry_id=", "");
  if (url_entry_id != "") {
    ajax_request_contest_show(url_entry_id, false);
  } else {
    ajax_request_contest_show(entry_id, false);
  }
  return true;
}

function get_contest_id() {
  return window.location.pathname.replace("/contests/", "");
}

function ajax_request_contest_show(entry_id, autoplay) {
  new Ajax.Request('/contest_browser/show/'+get_contest_id()+'?entry_id='+entry_id+'&autoplay='+autoplay, {evalScripts:true, method:'get'});
}

function set_url_and_request_contest_show(entry_id, autoplay) {
  setURLEntryId(entry_id);
  ajax_request_contest_show(entry_id, autoplay);
}

function reset_and_populate_contest_browser(entry_id) {
  window.location.hash = "#";
  return ajax_request_contest_show(entry_id, false);
}

function setURLEntryId(entry_id) {
  window.location.hash = 'entry_id='+entry_id;
}