﻿$(document).ready(function(){
//  // Hide default homepage quote
//  var container = $("#intro_books");
////  container.empty();
  
  // Setup fade rollover for the preorder button
  makeRollover("callout_indiebound_highlight", "callout_indiebound");
  
  // Setup order dropdown
  var select = $("#order_select");
  if (select.length == 1) {
    select[0].selectedIndex = 0;
    select[0].disabled = false;
    
    var click_function = function() {
      if (this.value == null || this.value == "")
        return;
      
      window.location.href = this.value;
      select[0].blur();
      select[0].disabled = true;
    };
    
    for (var i=0; i<select[0].options.length; i++)
      $(select[0].options).click(click_function);
  }
});

function makeRollover(divId, containerID) {
    var div = document.createElement("div");
    div.id = divId;
    
    $(div).appendTo("#" + containerID + " a");
    $(div).css({opacity: 0.0});
    
    $("#" + containerID).hover(
        function() {
            var div = $("#" + divId);
            div.stop();
            div.animate({opacity: 1.0}, 150);
        },
        function() {
            var div = $("#" + divId);
            div.stop();
            div.animate({opacity: 0.0}, 400);
        }
    );
}
