jQuery(document).ready(function(){

// Add separator to main navigation

jQuery('ul#main-nav li').not('ul#main-nav li:last-child').after('<li class="nav-divider">/</li>');

// Add separator to upperbar social links

jQuery('ul#upperbar-social li').not('ul#upperbar-social li:last-child').after('<li class="us-social-divider">&nbsp;&nbsp;&#124;&nbsp;&nbsp;</li>');

// Grid spacing for video thumbs

jQuery('.videos-grid .video-thumb:nth-child(3n)').css("margin-right", "0").after('<div class="vid-spacer"></div>');


// Grid spacing for might-also thumbs

jQuery(".related-posts li:nth-child(3n)").css("margin-right", "0");

// Print link on single video page

jQuery(".print-link").click(function() {
	alert('Come on, now, Shep. You can\'t print a video.');
});


// Hover effect for Video thumbs

jQuery('span.video-thumb-meta').show();
jQuery('span.video-thumb-meta').css('opacity', 0);

jQuery(".video-thumb").hover(function(){

    jQuery(this).find("img").stop().animate({"opacity": .1}, 150, 'swing');
    jQuery(this).find("span.video-thumb-meta").stop().animate({"opacity": 1},150, 'swing');
   	

}, function() {

    jQuery(this).find("img").stop().animate({"opacity": 1});
    jQuery(this).find("span.video-thumb-meta").stop().animate({"opacity": 0}); 

});

// Sprites hovers for single video

jQuery('.img-roll img').css('opacity', 0);

jQuery('.img-roll').hover(function(){

    jQuery(this).find("img").stop().animate({"opacity": 1});

}, function() {

     jQuery(this).find("img").stop().animate({"opacity": 0});

});


// Hover fade effect for general thumbs

jQuery('.img-fade').hover(function() {

    jQuery(this).find("img").stop().animate({"opacity": .8},150, 'swing');
    jQuery(this).find('.mightalso-meta a').animate({color:'#e56a00'});

}, function() {

     jQuery(this).find("img").stop().animate({"opacity": 1});
     jQuery(this).find('.mightalso-meta a').animate({color:'#333333'});

});

// Hover fade effect for tags

jQuery('.single-video-cats ul li a, .wp-tag-cloud li a').hover(function() {

	jQuery(this).stop().animate({backgroundColor: '#e56a00', color: '#fff'},150, 'swing');
	
}, function() {

	jQuery(this).stop().animate({backgroundColor: '#ececec', color: '#4C4747'});
});

// Hover fade effect for main nav

jQuery('#main-nav li a').not('.current-page').hover(function() {

	jQuery(this).stop().animate({color: '#e56a00'});
	
}, function() {

	jQuery(this).stop().animate({color: '#7F7F7F'});
});


// Hover background fade for tags list

jQuery('.backroll').hover(function() {

	jQuery(this).stop().animate({backgroundColor: '#fafafa', paddingLeft:'20px'});
	jQuery(this).find("h2 a").stop().animate({color:'#e56a00'});

}, function() {

	jQuery(this).stop().animate({backgroundColor: '#fff', paddingLeft:'0px'});
	jQuery(this).find("h2 a").stop().animate({color:'#333333'});

});

// Hover text fade

jQuery('.textfade').hover(function() {

	jQuery(this).find('p').stop().animate({color: '#4c4747'});

}, function() {

	jQuery(this).find('p').stop().animate({color: '#7f7f7f'});

});



// Set up tabs on music page.
	
	jQuery(function () {

			var tabContainers = jQuery('div.tabs > div');
			tabContainers.hide().filter(':first').show();
			
			jQuery('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).fadeIn();
				
				jQuery('div.tabs ul.tabNavigation a').removeClass('tab-selected');
				jQuery(this).addClass('tab-selected');
				// window.location.hash = jQuery(this).attr('href'); // Added to change hash in url.
				return false;
			}).filter(':first').click();
		});
		

// Reveal Videos page tag list 
	
	//Hide (Collapse) the toggle containers on load
	// jQuery("#video-tags-expand").hide(); 

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	jQuery("#video-tags-expand-link").click(function(){
		jQuery(this).toggleClass("active");
		jQuery("#video-tags-expand").slideToggle("slow");
		return false; //Prevent the browser jump to the link anchor
	});

// Detect Internet Explorer and display warning in upperbar.

if (jQuery.browser.msie) {
	jQuery("#upperbar .msie-warning").show();

}

});
