$(document).ready(function() {
/* LINK MANIPULATION */
  $("a[class=internal]").click(function(event) {
    event.preventDefault();
    if(currentPage != $(this).attr("id")) {
      currentPage = $(this).attr("id");
      $("#boxed").hide();
      $("a").css("cursor", "pointer");
      if(subdir=='h')
        getThis = "_page.php?title=" + currentPage + "&s=" + subdir;
      else
        getThis = "../_page.php?title=" + currentPage + "&s=" + subdir;
      $.get( getThis,
        function(data) {
          $("#boxed").html(data);
          $("#boxed").fadeIn(700);
          $("#" + currentPage).css("cursor", "default"); }
      );
    }
  });

$("a[class=self]").click(function(event) {
  if(currentPage == $(this).attr("id")) {
    event.preventDefault();
  }
});

  $("#" + currentPage).css("cursor", "default");



/* CSS CONTROL */
  $("#css_control").css("visibility", "visible");
  $("#w").hide();

  var switching;
  var color = $.cookie('color');
  var size = $.cookie('size');
  control(color);
  control(size);

  $("a[class=control]").click(function(event) {
    event.preventDefault();
    switching = $(this).attr("id");
    control(switching);
  });



/* FLASHCARDS */
  if(currentPage=="flashcard") {
    gennew(span.length);
    $("#show").click(function() {
      $("#display2").show();
      $("#show").hide();
      $("#right").show();
      $("#wrong").show();
    });
    $("#right").click(function() {
      span.splice(currloc, 1);
      engl.splice(currloc, 1);
      gennew(span.length);
    });
    $("#wrong").click(function() {
      gennew(span.length);
    });
  }
});