// JavaScript Document
$(document).ready(function() {
   // put all your jQuery goodness in here.
   
   
   //$('#disqus_thread').addClass('ccb');
   
	/* --  Set rounded corders  ---------------------------------------------------------------------- */
	cbb.init();
	
	/* --  Music Thumbs  ----------------------------------------------------------------------------- */
	$.each($('.thumb a'), function(){
		if(!$(this).parent().hasClass('selected')){
			$(this).fadeTo(200, 0);
			$(this).parent().find("img").fadeTo(200, 0.7);
			$(this).parent().find(".song_title").fadeTo(200, 0);
		}
	});
	$(".thumb a").mouseenter( function(){
		if(!$(this).parent().hasClass('selected')){
			$(this).fadeTo(200, 1);
			$(this).parent().find("img").fadeTo(200, 1);
			$(this).parent().find(".song_title").fadeTo(200, 1);
		}
	});
	$(".thumb a").mouseleave( function(){
		if(!$(this).parent().hasClass('selected')){
			$(this).fadeTo(200, 0);
			$(this).parent().find("img").fadeTo(200, 0.7);
			$(this).parent().find(".song_title").fadeTo(200, 0);
		}
	});
	$(".thumb a").click(function(){
		if(!$(this).parent().hasClass('selected')){
			// Fade out and remove class of current song
			$('.selected a').fadeTo(200, 0);
			$('.selected img').fadeTo(200, 0.7);
			$('.selected .song_title').fadeTo(200, 0);
			$('.selected').removeClass('selected');

			// Add class and load content into player area
			$(this).parent().addClass('selected');
			
			artworkHolder = $(this).parent().parent().parent().find(".artwork");
			
			
			player 				= document.createElement('div');
			player.className 	= 'player';
			player.innerHTML	= $(this).attr("href");
			
			img 				= new Image();
			img.width			= 445;
			img.height			= 445;
			img.src				= $(this).attr("image");
			
			title 				= document.createElement('div');
			title.className 	= 'song_title';
			title.innerHTML 	= $(this).attr("title");

			artworkHolder.html('');
			if($(this).attr("title")){ artworkHolder.append(title); }
			artworkHolder.append(img);
			if($(this).attr("href") != "#"){ artworkHolder.append(player); }
		}
		return false;
	});
	
	/* --  Photos & Videos  ---------------------------------------------------------------------- */
	$(".gallery-icon a").mouseenter( function(){
		$(this).find(".gallery-caption").fadeTo(200, 1);
	});
	$(".gallery-icon a").mouseleave( function(){
		$(this).find(".gallery-caption").fadeTo(200, 0);
	});
	
	/* --  Lightbox  ----------------------------------------------------------------------------- */
	$("a[rel=lightbox]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'padding'			: 5,
		'overlayColor'		: '#000',
		'overlayOpacity'	: .5
		//'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {}
	});

	/* --  Shop Button  --------------------------------------------------------------------------- */	
	$("#menu-main-navigation li:last-child a").attr('target','_blank');
	$("#menu-main-navigation li:last-child").css({
		'marginRight' : '0px'
	})

}); //$(document).ready(function() {
