
/* View document page */
  function expand_flash() {
    $('embedded_flash').style.width='780px';
    $('embedded_flash').style.height='860px';
    $('expand_button_div').hide();
    $('collapse_button_div').show();
    document.location = "#embedded_flash";
  }
  function shrink_flash() {
    $('embedded_flash').style.width='450px';
    $('embedded_flash').style.height='500px';
    $('expand_button_div').show();
    $('collapse_button_div').hide();
    window.scrollTo(0,0);
  }

  function toggle_vote(updown, num) {
    var base = updown;
    var concat_hide = base.concat(num.toString());
    var other_one = 1 - num;
    var concat = base.concat(other_one.toString());
    $(concat_hide).hide();
    $(concat).show();
  }
  
  /* Rails has a cool tag that's supposed to do this for us automatically.  That would be great, but it doesn't work right with AJAX forms. */
  function disableButton(button) {
    button.disabled=true;
    button.value='Saving...';
  }

  function toggle_upvote(num) {
/*    $('downvote_0').show(); */
/*    $('downvote_1').hide(); */
    toggle_vote("upvote_", num);
  }

  function toggle_downvote(num) {
    $('upvote_0').show();
    $('upvote_1').hide();
    toggle_vote("downvote_", num);
  }

  function pageHeight() {
    return window.innerHeight!=null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : 0;
  }

  function flashHeight() {
    var pHeight = pageHeight();
    if (pHeight < 400) {
      return 400;
    }
    return pHeight-30;
  }

  function simHeight() {
    return flashHeight()-300;
  }


  function thisMovie(movieName) {
    if (navigator.appName.indexOf('Microsoft') != -1) {
      return window[movieName];
    } else {
      return document[movieName];
    }
  }

  function flashNextPage() {
    thisMovie("flashpaper").setCurrentPage(3);
  }

  function similarity_tab(num) {
    var num_tabs = 2;
    for (var i = 0; i < num_tabs; i++) {
      if (i==num)  {
        $("sim_tab_"+i.toString()).show();
        Element.removeClassName("similarity_tab_"+i.toString(), "unselected");
        Element.addClassName("similarity_tab_"+i.toString(), "selected");
      }
      else {
        $("sim_tab_"+i.toString()).hide();
        Element.removeClassName("similarity_tab_"+i.toString(), "selected");
        Element.addClassName("similarity_tab_"+i.toString(), "unselected");
      }
    }
  }

  function toggle_tag_length() {
    if ($('lengthened_tags').style.display=="none") {
      $('lengthened_tags').show();
      $('shortened_tags').hide();
      $('toggle_tag_length').innerHTML = "(less)";
    } else {
      $('lengthened_tags').hide();
      $('shortened_tags').show();
      $('toggle_tag_length').innerHTML = "(more)";
    }
  }

  function toggle_description_length() {
    if ($('lengthened_description').style.display=="none") {
      $('lengthened_description').show();
      $('shortened_description').hide();
    } else {
      $('lengthened_description').hide();
      $('shortened_description').show();
    }
  }

function show_tab(tab_num) {
  $('graph_tab_1').className="graph_unselected";
  $('graph_tab_2').className="graph_unselected";
  $('graph_tab_3').className="graph_unselected";
  $('graph_tab_4').className="graph_unselected";
  $('graph_tab_5').className="graph_unselected";
  $('graph_tab_6').className="graph_unselected";
  var graph_tab_base = "graph_tab_";
  var tab_name = graph_tab_base.concat(tab_num.toString());
  $(tab_name).className="graph_selected";
  refresh_log = (tab_num == 4);
}

function toggle_analytics() {
  if (Element.visible('inner_analytics')) {
    $('analytics_switch').innerHTML="Show detailed analytics";
    $('inner_analytics').hide();
  } else {
     $('analytics_switch').innerHTML="Hide analytics"; 
    $('inner_analytics').show(); 
  }
}

function toggle_statistics() {
  if (Element.visible('text_statistics_internal')) {
    $('statistics_switch').innerHTML="Show text statistics";
    $('text_statistics_internal').hide();
  } else {
     $('statistics_switch').innerHTML="Hide text statistics"; 
    $('text_statistics_internal').show(); 
  }
}


function initial_show_analytics() {
  $('show_analytics').hide();
  $('analytics_switch').show();
  $('inner_analytics').show();
}






