$(document).ready(function() {
  setupBuckets();
  $("#vendors #content .vendors h3 a").bind("click", function(e) {
    var parent = this.parentNode.parentNode;
    $("#" + parent.id + " ul").toggle();
  });
  $("#media #content .videos .video .thumb").fancybox({
		'overlayShow'    : false
	});
});

$.fn.equalHeights = function(minHeight, maxHeight) {
  var tallest = (minHeight) ? minHeight : 0;
  $(this).each(function() {
    if($(this).height() > tallest) {
      tallest = $(this).height();
    }
  });
  if ((maxHeight) && tallest > maxHeight) tallest = maxHeight;
  return $(this).each(function() {
    $(this).height(tallest);
    //$(this).height(tallest).css("overflow","auto");
  });
}

function setupBuckets() {
  $('#home #buckets > .box').equalHeights();
  $('#home #buckets > .box').bind("click", function(e) {
    if ($(this).attr("target") == "_blank") {
      window.open($(this).attr("href"), "pecan");
    }
    else {
      window.location = $(this).attr("href");
    }
  });
  $('#home #buckets > .box').bind("mouseover", function(e) {
    $(this).addClass("faded");
  });
  $('#home #buckets > .box').bind("mouseout", function(e) {
    $(this).removeClass("faded");
  });
}
