$(function () {
  var crayonTimer;
  var posNav = function () {
    var scroll = $.browser.safari? window.pageYOffset : document.documentElement.scrollTop;
    var windowHeight = $.browser.msie? document.documentElement.clientHeight : window.innerHeight;
    var nav = $('#bottom-nav'),
    top = windowHeight + scroll - nav.height(); 
    nav.css({'top' : top});
    /*$('#crayon-open, #crayonmenu')
      .css({marginLeft : (nav.width() / 2) - 107, left : 0 });*/
  };
  
  
  if ( $.browser.msie ) {
    $('#bottom-nav').css("position", "absolute");
    posNav();
    $(window).resize(posNav).scroll(posNav);
  }

  $('#crayon-open, #crayonmenu').hover(function () {
    if (typeof crayonTimer === 'number') clearTimeout(crayonTimer);
    $('#crayonmenu').animate({marginTop: 20})
  }, function () {
    crayonTimer = setTimeout(function () {
      $('#crayonmenu').animate({marginTop: -210})
    }, 200);  
  });


  if ($('#polaroids')[0]) {

  $('#polaroids').click(function () {
    $('#darkness').css({opacity : 0.5}).fadeIn()
    $('#overlay').fadeIn('slow');
  });

    $('#overlay').click(function () {
      $('#darkness').hide();
      $('#overlay').hide();
    });

    $('.BossMedia').children().appendTo('#slides').end().remove();

    $('#next').click(function () {
      if ($('#slides').css('marginLeft').split('px')[0] > -(275 * 2) ) $('#slides').animate({marginLeft:"-=275"})
      return false;
    });

    $('#prev').click(function () {
      if ($('#slides').css('marginLeft').split('px')[0] < 0 ) $('#slides').animate({marginLeft:"+=275"})
      return false;
    });  

  }
  

});
