jQuery(function($) 
{ 
	//if(/Safari\/(312|125|100)/.test(navigator.userAgent))
	//#when primary nav link hovered over, ensure all other links are greyed out (given class inactive)
	$('#nav li').hover(
		function () {
			$(this).siblings().children('a').addClass('inactive');
  		},
  		function () {
			$(this).siblings().children('a').removeClass('inactive');
  		}
	);
	
	//#portfolio image gallery swapping
	$('#content').cycle({ 
		fx:    'scrollHorz', 
		speed:  500,
		timeout: 0,
		random: 0,
		pager: '#paging',
		pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#">p' + (idx+1) + '</a></li>'; 
    } 
	});
	
	//#hide image captions, reveal them on hover
	setupCaptions(); 
	$('#content').pngFix();
	
	//#when paging link hovered over, ensure that link is the only one with the location marker over it
	$('#paging li').livequery(function(){ 
    // use the helper function hover to bind a mouseover and mouseout event 
        $(this) 
            .hover(function() { 
                $(this).children('a').addClass('active');
				$(this).siblings().children('a').addClass('inactive');
            }, function() { 
                $(this).children('a').removeClass('active');
				$(this).siblings().children('a').removeClass('inactive');
            }); 
    }, function() { 
        // unbind the mouseover and mouseout events 
        $(this) 
            .unbind('mouseover') 
            .unbind('mouseout'); 
    }); 
	
	//#ensure that last paging link li has class last so that lines will not be after it
	$('#paging li:last').livequery(function(){
				$(this).addClass('last');
	});
	
	//#open external links in new windows (those with rel=external)
	$('a[rel="external"]').attr('target','_blank');
}); 

//#redefine Cycle's updateActivePagerLink function 
//#ie override Cycle's default behaviour so that the li for the current slide link gets class current
$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
    $(pager).find('li').removeClass('current') 
        .filter('li:eq('+currSlideIndex+')').addClass('current'); 
}; 
