//##############################################################################
//##  DOM																	  ##
//##############################################################################
$j(document).ready( externalLinks );
/*###########################################
##  Dropdown Menus						   ##
###########################################*/
/* Options */
var __global_menuContainer = '.mainNav';
var __global_sliderObject = '#mainSlider';
/* Controls */
$j(document).ready(function() {
	var lis = $j(__global_menuContainer).children('li').get();
    $j.each(lis, function(){
      $j(this).hover(
	    function () { //on
	      $j(this).addClass("sfhover")
	    }, 
	    function () { //off
	      $j(this).removeClass("sfhover")
	    }
	  );
    });
});

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

/*###########################################
##  Cufón Init							   ##
###########################################*/
Cufon.replace('#navigation li a, #promo1 p, #promo2 small, #breadcrumbs .title, #bodyContent h1, #bodyContent h2, #bodyContent h3, #bodyContent h4', { fontFamily: 'Calibri', hover: true });
Cufon.replace('.heading, #subnav a, #breadcrumbs .active, .promo h1, .promo h2, .promo h3, .promo h4, .cell h3, .productDetails h2', { fontFamily: 'Calibri', hover: true });
Cufon.replace('#promo1 h1, #promo1 h2, #promo2 h1, #promo2 h2, #promo2 b', { fontFamily: 'Candara', hover: true });


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

/*###########################################
##  Product Detail Tabs					   ##
###########################################*/
/* Options */
var __global_tabsObject = '#tabbedDetails';
/* Controls */
$j(function() {
  if ($j(__global_tabsObject).exists()) {
    $j('#tabbedDetails > ul').tabs({ selected: 0, fx: { height: 'toggle', opacity: 'toggle', duration: 'fast' } });
  }
});

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


//##############################################################################
//##############################################################################
//##  Globals																  ##
//##############################################################################
jQuery.fn.exists = function(){return jQuery(this).length>0;}
//##############################################################################
//##############################################################################

/* html select nav */
function select_nav(elm) {
  elm.change(function() {
    window.location = elm.val();
  });
}

