$(function() {

	// ShareThis
	stLight.options({
		publisher: '688f505b-bed3-41b6-9eaa-74840b0bf77a',
		'image': 'http://www.blackriverimaging.com/img/black_river_imaging_logo.gif',
		onhover: false
	});

    // Highlight Current Page and Parents        
    var url = window.location.href.split("#")[0];
    url = url.substr(url.lastIndexOf("/") + 1);
    $(".nav").find("a[href='" + url + "']").parents("li").each(function() {
        $(this).addClass("active");
    });

	// http://j.mp/jquery-target-blank
	$('a[rel*="external"]').attr({
		target: "_blank",
		title: "Opens in a new window"
	});

	// Slideshows w/ Cycle Plugin
	$('.slideshow ul').cycle({
		fx: 'fade', 
		prev: '#slide-prev',
		next: '#slide-next',
		timeout: 6000,
		pause: true
	});
	
	$('#product-slideshow ul').after('<div id="pager">').cycle({
		fx: 'fade',
		pager: '#pager',
		timeout: 6000,
		pause: true
	});

	// Fancybox
	$("a.fancybox, .design-gallery a").fancybox();
		
	$("a.gallery, a.fancybox-gallery").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside">' + (title && title.length ? '<strong>' + title + '</strong>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</span>';
		}
	});

	$("a.featured-video").fancybox({
		'titleShow'			: false,
		'margin'			: 0,
		'padding'		 	: 0
	});	

	// Fancybox Videos
	$(".video-link").click(function() {
		$.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn': 'none',
			'transitionOut' : 'none',
			'title' : this.title,
			'width' : 720,
			'height' : 405,
			'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' : 'swf',
			'swf' : {
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});

		return false;
	});


	// Team Rollovers
	$(".team-gallery img").hover(
		function() {this.src = this.src.replace("_off","_on");},
		function() {this.src = this.src.replace("_on","_off");}
	);



});
