// If the user is on a small browser, redirect to the mobile site.
if ($(window).width() < 1024) {
  window.location.replace( "/m" );
}






var on_screen = 0;
var screen_transition_delay = 500;

function fixUpWidthAndHeight() {
  $("#movetotopright").unbind("click");

  // Fix up all the css widths/heights
  var wwidth = $(window).width();
  var wheight = $(window).height();

  var uber_width = wwidth * 2;
  var uber_height = wheight * 2;

  $("#pagewrapper").css("width", uber_width).css("height", uber_height);
  $(".scrolling_content").css("width", wwidth).css("height", wheight);
  
  switch(on_screen) {
    case 0:
      $("#scrollwrapper").css("left", 0).css("top", 0);
      break;
    case 1:
      $("#scrollwrapper").css("left", -wwidth).css("top", 0);
      break;
    case 2:
      $("#scrollwrapper").css("left", 0).css("top", -wheight);
      break;
    case 3:
      $("#scrollwrapper").css("left", -wwidth).css("top", -wheight);
      break;
  }

  bind_nav(wwidth, wheight);
}

function bind_nav(wwidth, wheight) {
  $("#movetotopleft").bind("click", function() {
    $("#scrollwrapper").animate({ left:"0px", top:"0px" }, { duration:screen_transition_delay, easing:"linear" });
    on_screen = 0;
  });
  $("#movetotopright").bind("click", function() {
    $("#scrollwrapper").animate({ left:-wwidth, top:"0px" }, { duration:screen_transition_delay, easing:"linear" });
    on_screen = 1;
  });
  $("#movetobottomleft").bind("click", function() {
    $("#scrollwrapper").animate({ left:"0px", top:-wheight }, { duration:screen_transition_delay, easing:"linear" });
    on_screen = 2;
  });
  $("#movetobottomright").bind("click", function() {
    $("#scrollwrapper").animate({ left:-wwidth, top:-wheight }, { duration:screen_transition_delay, easing:"linear" });
    on_screen = 3;
  });
}

$(document).ready(function() {
  on_screen = 0;
  fixUpWidthAndHeight();
  $(window).resize(fixUpWidthAndHeight);
  
  $('.applogo').tooltip({
    track:true,
    delay:0,
    showURL:false,
    showBody:" - ",
    fade:250
  });
});