$(document).ready(function(){
  
  var $container = $("#div_outer");
  var $innerContainer = $("#contentContent");
  
  $(window).resize(doResize);
  doResize();
  initCalendar();
  
  if((navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    adjustForIpad();
  };
  
  var resizeTimer = null;

  function doResize() {
    clearTimeout(resizeTimer);
    resizeTimer = setTimeout(resizeComplete, 200);
  };
  
  function resizeComplete() {
    var cont = $("#div_outer");
    var $html = $("html");
    var $body = $("body");
    var winWidth = $(window).width();
    var maxWidth = 1528;
    var medWidth = ($.browser.msie ? 1250 : 1260) //- scrollbarWidth; //IE adds in extra padding
    var minWidth = 995;  

    if(winWidth > maxWidth){
      cont.removeClass("small").removeClass("medium").addClass("large");
      $html.removeClass("small").removeClass("medium").addClass("large");
    } else if(winWidth >= medWidth){
      cont.removeClass("small").removeClass("large").addClass("medium");
      $html.removeClass("small").removeClass("large").addClass("medium");
    } else {
      cont.removeClass("large").removeClass("medium").addClass("small");
      $html.removeClass("large").removeClass("medium").addClass("small");
    };
    $(document).trigger("resizeComplete");
    $container.show();
  };

  function initCalendar() {
    var myDate = new Date();
    var myMonths = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
    var myDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
    $("#calendar_month").text(myMonths[myDate.getMonth()]);
    $("#calendar_date").text(myDate.getDate());
    $("#calendar_day").text(myDays[myDate.getDay()]); 
  };
  
  function adjustForIpad() {
    //replace elements with smaller image sizes
    var image1 = "/ImageGen.ashx?image=" + $("#img1").attr("src") + "&width=768&Constrain=true";
    $("#img1").attr("src",image1);
  };
                       
});
