function clearText(thefield){
  if (thefield.defaultValue==thefield.value)
    thefield.value = ""
} 

function toggle_idea_transcript(transcript) {
  var transcript_text = $('transcriptText');
  if(transcript_text.visible()) {
    transcript.parentNode.removeClassName('open');
    Element.hide(transcript_text);
  } else {
    transcript.parentNode.addClassName('open');
    Element.show(transcript_text);
  }
}

function set_rating_stars(i) {
  $$("#stars a").slice(0, i+1).each(function(star) { star.addClassName("user-rated") })
}

function show_rating_stars(i) {
  $$("#stars a").slice(0, i+1).each(function(star) { star.addClassName("display-rating-hover") })
}

function clear_rating_stars() {
  $$("#stars a").each(function(star) { star.removeClassName("display-rating-hover") })
}

function toggle_experts_interview_list(link, video_path) {
  var id = link.parentNode.id;
  var table_id = id + "-table";

  if(!$(table_id).visible()) {
    experts_interview_unselect_videos();
    $$("#vid h3.open").each(function(x) { x.removeClassName("open"); });
    $$("#vid div.interviewList").each(function(x) { 
        if(x.visible()) { Element.hide(x); }
      });
  
    $(id).addClassName("open");
    Element.show(table_id);
    ajax_replace_video("mainPlayer", video_path, 516);
  }
}

function experts_interview_replace_video(element, video_path) {
  ajax_replace_video("mainPlayer", video_path, 516);
  experts_interview_unselect_videos();
  element.parentNode.parentNode.addClassName("selected");
}

function experts_interview_unselect_videos() {
  $$("#vid div.interviewList tr.selected").each(function(x) {
      x.removeClassName("selected");
    });
}

function ajax_replace_video(video_id, video_path, width) {
  new Ajax.Updater(video_id, video_path, 
      {method: 'get', parameters: {width: width}});
}

function ajax_external_js(src, parent_id) {
  var e = document.createElement("script");
  e.src = src;
  e.type="text/javascript";
  $(parent_id).appendChild(e);
}
