$(document).ready(function()
{
	$.extend($.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){
				$(this).bind('selectstart',function(){return false;});
			}else{
				$(this).mousedown(function(){return false;});
			}
		});
	});
	$('.lyrics').disableTextSelect();
});

$(document).ready(function(){
//Auction tabs
//	$(".tab_content").hide(); 
	$(".tab_content").addClass("hidden");
	$("ul.tabs li:first").addClass("active").show(); 
	$(".tab_content:first").removeClass("hidden");
	$(".tab_content:first").addClass("visible");
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); 
		$(this).addClass("active"); 
		$(".tab_content").addClass("hidden"); 
		$(".tab_content").removeClass("visible"); 
		var activeTab = $(this).find("a").attr("rel"); 
		$(activeTab).addClass("visible"); 
		$(activeTab).removeClass("hidden");
		(activeTab).fadeIn();
		return false;
	});

	$('.more').show();
// Show then re-hide the highlighted sections
	$('.highlightedSection').show().css('display','none');

    $('.more').click(function(){
    	//Get metadata
    	if(!$(this).data('loaded')){
	    	$(this).data('loaded', true);
	    	var artist = $(this).data('artist_album').artist;
	    	var album = $(this).data('artist_album').album;
	    	
	    	var blurbArea = $(this).parent().children('.highlightedSection');
	        var blurb = $.ajax({
		            url: "/Content/album-blurb/artist/"+artist+"/album/"+album,
		            dataType: "json",
		            success: function(msg){
	        			if(msg != null && msg.blurb != undefined) {
	        				var link = '<a href="'+msg.url+'" target="_blank">More at '+msg.source+'</a>';
	        				blurbArea.html(msg.blurb+'<br/>'+link);
	        			}
	        			else blurbArea.html('No content available');
		            }
		         }
		      ).responseText;
    	}
    	$(this).parent().children('.highlightedSection').slideDown('fast');
        $(this).hide();
        $(this).parent().children('.less').show();
    });
    
    $('.less').click(function(){
        $(this).parent().children('.highlightedSection').slideUp('fast');
        $(this).hide();
        $(this).parent().children('.more').show();
    });


// The code to handle targeting the youtube thumbnails and inject the embed code...


    $('.individualVideo').children('div.buttonVideo').click(function(){
        $('.individualVideo').children('div.buttonVideo').show();
        $(this).hide();

        // show all video thumbnails:
        $('.individualVideo').children('img[alt~="thumbnail"]').show();
        // hide the selected video thumbnail:
        $(this).parent().children('img[alt~="thumbnail"]').hide();
        // it would be better to give the img node a classname
        // and do things more like this:
        // $(this).parent().children('.thumbnail').hide();

        $('.individualVideo').children('.video').hide();
        var videoDiv = $(this).parent().children('.video').get(0);
        var embedTest = jQuery.data(videoDiv, "embedded");
		    if(embedTest==undefined){embedVideo(videoDiv);}
        $(this).parent().children('.video').fadeIn('slow');
    });
    
    $('.newsContent').hide();  
    $('.newsListing').click(function() {
      $(this).children('.newsContent').slideToggle('fast');
    });
    
    $('#moreNewsContent').hide();
    $('#moreLinkNewsContent').click(function() {
    	$('#moreLinkNewsContent').hide();
    	$('#moreNewsContent').slideToggle('fast');
    });
    $('#moreNewsContent a.lessLinkNewsContent').click(function() {
    	$('#moreLinkNewsContent').show();
    	$('#moreNewsContent').hide();
    });
	
	$('#moreconcerts').hide();
    $('#moreLinkconcerts').click(function() {
    	$('#moreLinkconcerts').hide();
    	$('#moreconcerts').slideToggle('fast');
    });
	
    $('#moreconcerts a.lessLinkconcerts').click(function() {
    	$('#moreLinkconcerts').show();
    	$('#moreconcerts').hide();
    });	
});

/* The embed code should look like this:
  <object width="320" height="265">
    <param name="movie" value="http://www.youtube.com/v/%%VARIABLE%%&hl=en_US&fs=1&rel=0"></param>
    <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/%%VARIABLE%%&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed>
  </object>
*/
function embedVideo(videoDiv){
  var embedURL = videoDiv.innerHTML;
  var embedHTML = '<a href="#" class="closeVideo">Close X</a><object width="225" height="192"><param name="movie" value="'+embedURL+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+embedURL+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="225" height="192"></embed></object>';
  videoDiv.innerHTML = embedHTML;

  // have to do this here cause the dom for these elements is only just been created:
  $('.individualVideo .video .closeVideo').click(function(){
    $(this).parent().hide();
    $(this).parent().parent().children('div.buttonVideo').show();
    $(this).parent().parent().children('img[alt~="thumbnail"]').show();
  });

	jQuery.data(videoDiv, "embedded", "true");
}

/* more/less scripts*/


$(document).ready(function() {
  $('div.description p').expander({
    slicePoint:       40, 
    expandText:         'more',
	expandPrefix:     ' ... ',
	userCollapseText: 'less',
	userCollapsePrefix: ' ',
  });
  $('div.albumInfo p').expander({
    slicePoint:       40, 
    expandText:         'more',
	expandPrefix:     ' ',
	userCollapseText: 'less',
	userCollapsePrefix: ' ',
  });
  $('div.bioExpand p').expander({
    slicePoint:       580, 
    expandText:         'more',
	expandPrefix:     ' ... ',
	userCollapseText: 'less',
	userCollapsePrefix: '',
  });
});

/* Expand/Contract News
$(document).ready(function() {
        $('div.newsListing:eq(0)> div').hide();  
        $('div.newsListing:eq(0)> h3').click(function() {
          $(this).next().slideToggle('fast');
        });
      });
/*

/* Expand/Contract Articles */
 $(document).ready(function() {
        $('div.articleListing:eq(0)> div').hide();  
        $('div.articleListing:eq(0)> h3').click(function() {
          $(this).next().slideToggle('fast');
        });
      });

/* Alternate Background Color of Concerts */
$(document).ready(function()
{
  $("tr:even").css("background-color", "#fff");
  $("tr:odd").css("background-color", "#efefef");
});
