//##############################################################################
//##  DOM																	  ##
//##############################################################################
$(document).ready( externalLinks );
/*###########################################
##  Dropdown Menus						   ##
###########################################*/
/* Options */
var __global_menuContainer = '.navigation';
var __global_winnerContainer = '#jumpToWinnerSelect';
/* 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")
	    }
	  );
    });
});

/*###########################################
##  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"); }
  });
});

/*###########################################
##  Cuf—n Init							   ##
###########################################*/
Cufon.replace('#navigation h2', { hover: true, 
								  fontFamily: 'Myriad Pro',
								  textShadow: '2px 2px rgba(0, 0, 0, 0.5)'
								});
Cufon.replace('#introduction h2, #news h4', { hover: true, 
								  			  fontFamily: 'Myriad Pro',
											  textShadow: '2px 2px rgba(0, 0, 0, 0.3)'
											});
Cufon.replace('#nextBanquet h2, #nextBanquet h3, #nextBanquet h4', { fontFamily: 'Myriad Pro', hover: false });
Cufon.replace('#winners .details h2, #winners .details h3, #winners .details h4', { fontFamily: 'Myriad Pro', hover: false });
Cufon.replace('#insideBodyHeader #breadcrumbs', { fontFamily: 'Myriad Pro', hover: true });
Cufon.replace('#previousWinners .header h2', { hover: false,
											   fontFamily: 'Adobe Garamond Pro',
											   textShadow: '2px 2px rgba(0, 0, 0, 0.8)'
											 });
Cufon.replace('.heading, #insideBody h1, #insideBody h2, #insideBody h3, #insideBody h4', { fontFamily: 'Adobe Garamond Pro', hover: false });
Cufon.replace('.headingShadow', { hover: false,
								  fontFamily: 'Adobe Garamond Pro',
								  textShadow: '2px 2px rgba(0, 0, 0, 0.5)'
								});

/*###########################################
##  Previous Winners					   ##
###########################################*/
$('#winners').cycle({ 
    fx:     'scrollHorz', 
    speed:  'fast', 
    timeout: 0, 
    next:   '#nextWinner', 
    prev:   '#previousWinner' 
});
$(document).ready(function() { //reset to no choice selected
  target = $('#jumpToWinnerSelect');
  return target.each(function() {
    var tag = this.tagName.toLowerCase();
    if (tag == 'select') this.selectedIndex=0;
  });
});

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

//##############################################################################
//##############################################################################
//##  User Handler Functions												  ##
//##############################################################################
function externalLinks() {
  var exs = $('a[rel=external]');
  $.each(exs, function() {
    if ($(this).attr('href')) { $(this).attr('target','_blank'); }
  });
}
//##############################################################################
//##############################################################################
//##  Previous Winner Jump Menu Controller									  ##
//##############################################################################
$(document).ready(function() {
	if('#jumpToWinnerSelect'){
		$('#jumpToWinnerSelect').change(function(){
			var optionSelectedValue = $('#jumpToWinnerSelect option:selected').val();
			top.location.href = optionSelectedValue;
		});
	}
});
//##############################################################################
//##############################################################################


