$(function() {

	// Dropdown Navigation
	$("#header ul.nav li").hover(function(){

		$(this).addClass("hover");
		$('ul:first',this).css('visibility', 'visible');

	}, function(){

		$(this).removeClass("hover");
		$('ul:first',this).css('visibility', 'hidden');

	});

	$("#header ul.nav li ul li:has(ul)").find("a:first").append(" &raquo; ");

	// http://j.mp/jquery-target-blank
	$('a[href^="http://"]').attr({
		  target: "_blank"
		, title: "Opens in a new window"
	});
	
	// Fancybox
	$("#slides-nav a, .slide-photos a").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	// Initialize Home Slideshow
	$('#home-slideshow #slides').cycle({
		fx: 'fade',
	    timeout: 3000,
		cleartype: false
	});

	// Initialize Portfolio Slideshow 
	$('#portfolio-slideshow #slides').cycle({
		fx: 'scrollHorz',	
		speed:  '500',
		timeout: 0,
		pause: 0,
		pager:  '#portfolio-slideshow ul',
		pagerEvent: 'mouseover',
		pagerAnchorBuilder: function(idx, slide) {
			// return sel string for existing anchor
			return '#portfolio-slideshow ul li:eq(' + (idx) + ') a';
		}
	});
	

});
