//##############################################################################
//##  DOM																	  ##
//##############################################################################
$(document).ready( externalLinks );
/*###########################################
##  Dropdown Menus						   ##
###########################################*/
/* Options */
var __global_menuContainer = '#navigation';
var __global_sliderObject = '#homeSlider';
var __global_sliderPortfolioObject = '#portfolioSlider';
/* 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('#header h2', { hover: true, 
							  fontFamily: 'Myriad Pro',
							  textShadow: '3px 4px rgba(0, 0, 0, 0.5)'
							});
Cufon.replace('.heading, #breadcrumbs, .content h1, .content h2, .content h3, .content h4, .contacts h2', { fontFamily: 'Myriad Pro', hover: true });

/*###########################################
##  Content Sliders						   ##
###########################################*/
$(function() {
  //main promotion slider
  $(__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'
  });
  
  //portfolio slider
  $(__global_sliderPortfolioObject)
    .cycle({ 
      fx:		'scrollHorz', 
      timeout:	0, //how long to wait between slides
	  speed:	600, //how long transition takes
      next:	'#portfolioNext',
      prev: '#portfolioPrevious'
  });
});

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