//##############################################################################
//##  DOM																	  ##
//##############################################################################
$(document).ready( externalLinks );
$(document).ready( shadowboxClassLinks );
$(document).ready( pdfExternalLinks );

/*###########################################
##  Dropdown Menus						   ##
###########################################*/
/* Options */
var __global_menuContainer = '.navigation';
var __global_promoContainer = '#promotionRotation';
/* Controls */
$(document).ready(function() {
	var lis = $(__global_menuContainer).children('li').get();
    $.each(lis, function(){
      $(this).hover(
	    function () { //on
	      $(this).addClass("sfhover")
	    }, 
	    function () { //off
	      $(this).removeClass("sfhover")
	    }
	  );
    });
});

/*###########################################
##  Cufón Init							   ##
###########################################*/
Cufon.replace('.navigation a, #search label', { fontFamily: 'Frutiger LT Std', hover: true });
Cufon.replace('#promotionRotation .text a', { fontFamily: 'Frutiger LT Std', hover: true });
Cufon.replace('#promotionSocial .contents p', { fontFamily: 'Frutiger LT Std', hover: true });
Cufon.replace('#staticNav h2', { fontFamily: 'ArnoPro', hover: false });
Cufon.replace('.heading', { fontFamily: 'Frutiger LT Std', hover: true });
Cufon.replace('#breadcrumbs', { fontFamily: 'Frutiger LT Std', hover: true });
Cufon.replace('.content h1, .content h2o, .content h3, .content h4', { fontFamily: 'Frutiger LT Std', hover: true });
Cufon.replace('#search_results strong, #calendarYear th', { fontFamily: 'ArnoPro', hover: false });

/*###########################################
##  Feature Slideshow					   ##
###########################################*/
var loc = window.location.pathname; loc = loc.toString();
var inside = (loc.length >= 2)?true:false;
if (!inside) {
  $(__global_promoContainer).cycle({ 
		fx:    'fade',  
		timeout: 6000, //how long to wait between slides
		speed:  1000, //how long transition takes
		pause: 1 //stop on mouseover
  });
}

/*###########################################
##  Legacy Transparency					   ##
###########################################*/
$(document).ready(function() {
  /* Body */
  $("img").each(function(){ //fix legacy transparency
    var fileExtension = $(this).attr("src").substr($(this).attr("src").lastIndexOf(".png"));
    if (fileExtension == ".png") { $(this).addClass("transparent"); }
  });
});

//##############################################################################
//##############################################################################
//##  User Handler Functions												  ##
//##############################################################################
function externalLinks() {
  var exs = $('a[rel=external]');
  $.each(exs, function() {
    if ($(this).attr('href')) { $(this).attr('target','_blank'); }
  });
}

function shadowboxClassLinks() {
  var exs = $('a[class=shadowbox]');
  $.each(exs, function() {
    if ($(this).attr('href')) { $(this).attr('rel','shadowbox'); }
  });
}

function pdfExternalLinks() {
  var exs = $("a[href$='.pdf']");
  $.each(exs, function() {
    if ($(this).attr('href')) { $(this).attr('target','_blank'); }
  });
}
//##############################################################################
//##############################################################################

/*###########################################
##  Shadowbox Init						   ##
###########################################*/
Shadowbox.init({
	players: ["iframe", "html", "img"]
});

