$(document).ready(function() {
  
  var url = window.location;
  var path = url.pathname;
  
  // if this is the home page
  if (path == '/') {
    // set up the tabbed content on the home page
    $('#callouts').tabs({ fxSlide: false, fxFade: true, fxSpeed: 'fast', fxAutoHeight: true });
  }
  
  /**
   * @note Fade effects on the sidebar specials on hover
   */
  $("#callout-main-svcs h2 a").hover(function() {

    // add span with link and fade it in
    var ctaLink = $(this).attr("href");
    // add span with link and fade it in
    var ctaText = $(this).text();
    
    $('<span class="box"><a href="' + ctaLink + '">' + ctaText + '</a></span>').prependTo(this);
    
    $(this).children("span").fadeIn("normal");
    
    }, function () {
    // fade out span and remove it when finished
    $(this).children("span").fadeOut("normal", function(){
      $(this).remove();
    });
  
  });
  
  // for each of the gallery thumbnail image links
  $('.gallery .gallery-item dt a').each(function() {
    // add a span over top of each image for styling
    $(this).prepend('<span class="obscured"></span>');    
    
    $('.obscured', this).css({
      'opacity' : 0.48
    });
    
    // ...
    $(this).hover(
      function() {
        $('.obscured', this).animate({
          opacity: 0
        }, 333);
      },
      function() {
        $('.obscured', this).animate({
          opacity: 0.48
        }, 333);
      }
    );
    
  });
  
  // set some CSS values that *should* only get picked up in IE and Firefox 3.0 w/ scripting
  $('.gallery .gallery-item:nth-child(4n+4)').css({
     'margin-right' : 0
  });
  
  // colorize the boxes for IE and Firefox 3.0
  $('.box:nth-child(1n+0)').css({
     'background-color': '#4f381a'
  });
  $('.box:nth-child(2n+0)').css({
     'background-color': '#515b47'
  });
  $('.box:nth-child(3n+0)').css({
     'background-color': '#76a667'
  });
  
  /**
   * @note IE hackaroos: They're delicious!
   */
  if($.browser.msie && $.browser.version >= 7.0) {
    // alert("Im the annoying IE");// see if this test works...
    
    // alternate table row colors
    $('tr:odd').addClass('odd');
    
    // callout links need to be
    $('.callout a').each(function() {
      $(this).css({
        'color' : '#ffffff',
        'opacity' : '0.60'
      });
    });
    
  }/*end IE hacks*/
  
});

function hasCSS() {
  var _d = document.createElement('div');
  _d.id = 'css_test';
  $('body').append(_d);
  $('#css_test').css({width:'1px',height:'1px',display:'none'});
  var _v = ($('#css_test').width() != 1) ? false : true;
  $('#css_test').remove();
  return _v;
}