//##############################################################################
//##  DOM																	  ##
//##############################################################################
$(document).ready( externalLinks );
/*###########################################
##  Dropdown Menus						   ##
###########################################*/
/* Options */
var __global_menuContainer = '.mainNav';
var __global_sliderObject = '#homeSlider';
/* 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', { hover: false, 
								 fontFamily: 'Museo Sans 500',
								 textShadow: '2px 2px rgba(3, 42, 136, 0.7)'
							   });
Cufon.replace('#navigation b', { hover: false, 
								 fontFamily: 'Museo Sans 900',
								 textShadow: '2px 2px rgba(3, 42, 136, 0.7)'
							   });
Cufon.replace('#rx li a, #rx h2', { hover: false, 
									fontFamily: 'Museo Sans 500',
									textShadow: '2px 2px rgba(107, 0, 0, 0.4)'
								  });
Cufon.replace('#rx b', { hover: true, 
						 fontFamily: 'Museo Sans 900',
						 textShadow: '2px 2px rgba(107, 0, 0, 0.4)'
					   });
Cufon.replace('#stores .middle h2', { hover: false, 
									 fontFamily: 'Museo Sans 500',
									 textShadow: '2px 2px rgba(3, 42, 136, 0.4)'
								   });
Cufon.replace('#stores .middle h2 b, #stores .middle h2 strong', { hover: true, 
						 			   							   fontFamily: 'Museo Sans 900',
									   							   textShadow: '2px 2px rgba(3, 42, 136, 0.4)'
					   				 							 });
					   				 							 
Cufon.replace('.heading, #insideBody h1, #insideBody h2, #insideBody h3, #insideBody h4', { fontFamily: 'Museo Sans 500', hover: true });
Cufon.replace('.promo .sale h2, .promo .product h2, .promo .weekly h4', { fontFamily: 'Museo Sans 500', hover: true, textShadow: '2px 2px rgba(0, 0, 0, 0.2)' });
Cufon.replace('.heavyheading', { fontFamily: 'Museo Sans 900', hover: true });
Cufon.replace('.promo .sale h1, .promo .product h3, .promo .weekly h3', { fontFamily: 'Museo Sans 900', hover: true, textShadow: '2px 2px rgba(0, 0, 0, 0.2)' });

/*###########################################
##  Content Sliders						   ##
###########################################*/
$(function() {
  //main promotion slider
  $(__global_sliderObject)
    .before('<div id="sliderNav">')
    .cycle({ 
      fx:		'fade', 
      timeout:	6000, //how long to wait between slides
	  speed:	600, //how long transition takes
	  pause:	1, //stop on mouseover
      pager:	'#sliderNav'
  });
});

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