(function($){

    $(document).ready(function() {


      $('.roundcorner').corner();
      $('.roundcorner-top').corner("top");

      if ($.support.opacity)
        $('.book').hide().delay(1500).show('bounce');
      stickyFooter();
      $(window).resize(stickyFooter);

      var buyMouseEnter = function() {
        $(this).unbind('mouseenter')
          .bind('mouseleave', function() {
                      $(this).unbind('mouseleave').animate({width: 38}, 700, function() {
                          $(this).bind('mouseenter', buyMouseEnter);
                        });
          }).animate({width: 176}, 700, function() {
        });
      }

      $('#buy-now').bind('mouseenter', buyMouseEnter);

    });

})(this.jQuery);

/* Get the database id from an element id (foo-bar-id) */
String.prototype.getid = function() {
  return this.substr(this.lastIndexOf('-') + 1);
}


function stickyFooter(wrap) {
  wrap = true;

  var viewport = $(window).height();
  var footer = $('footer').outerHeight();
  var head = $('header').outerHeight(true) + $('#nav-head').outerHeight(true);

  var content = $('#main').outerHeight(true);

  var full = footer + content;

  //log('viewport: ', viewport, 'footer: ', footer, 'content: ', content, 'full: ', full);

  if (viewport > full + head) {
    $('#wrapper-main').height(viewport);
  } else {
    var toadjust = wrap?'#wrapper-main':document;
    //console.log(toadjust);
    $(toadjust).height(full + head);
  }

}

