(function($) {
	$.fn.youtubeplayer = function () {
		return this.each(function () {
			
			function loadVid(vidID) {
				// Obtain video
				$product = $("#youtubeplayer .videos").find(".video-"+vidID);
				// Hide visible videos
				$("#youtubeplayer .video:visible").hide();
				// Show this video
				$product.show();
			}
				
			$("#youtubeplayer .thumbnails a").click(function () {
				// obtain video id
				var vidID = $(this).attr('class').replace("video-","");
				loadVid(vidID);
				
				return false;
			});
			
			$("#youtubeplayer .views-field-field-thumbnail-fid").hover(function () {
				$(this).next().show();
			}, function () {
				$(this).next().hide();
			});
	
		});
	};

 
 
})(jQuery);

$(document).ready(function () {
	
  $('.homepage-videos-thumbs .views-row').click(function (e) {
    e.preventDefault();
    
    $row = $(this);

    $row.parent().find('.views-row').removeClass('testimonial-thumb-selected');
    $row.addClass('testimonial-thumb-selected');
    var nodeid = $row.attr('id').substr(10);

    if (nodeid != undefined) {
      $('.vid-player:visible').hide();
      $('#vid-player-'+nodeid).show();
    }
    
    return false;
  });

  
  $('.homepage-videos-thumbs .views-row').hover(function () {
    $(this).find('.views-field-field-video-embed').css('opacity',0.35);
    $(this).find('.views-field-title').show();
  }, function () {
    $(this).find('.views-field-field-video-embed').css('opacity',1);
    $(this).find('.views-field-title').hide();
  });
});
