// JavaScript Document
//Functions
function sendToActionScript() {
	var listSongInHtml = [];
	$(".listSong li").each(function() {
		listSongInHtml.push($(this).attr("title"));						
	});
	return listSongInHtml;
}

function setElement(whatElement) {
	$(".listSong li").each( function() {
		$(this).removeAttr("class");						
		if($(this).attr("title") == whatElement) {
			$(this).addClass("active");		
		}						
	});
	
	
}

function traceFlashMessage(traceMessage) {
		console.log(traceMessage);
}


//Init Fonts
Cufon.set('fontFamily', 'trebuchet-aliasing').replace('#navigation li a',{hover: true})("#content .colDroite h4");

$(document).ready(function () {
	
	//music player
	$(".listSong li").click(function() {
		$(".listSong li").each(function() {
			if($(this).hasClass("active")) {
			$(this).removeAttr("class");		
			}
			
		});
	$(this).addClass("active");	
	$("#controlPlayer").get(0).commandPlayer($(this).attr("title"));
	});
	

	
	//Carousel
	if(typeof $("#focus").carousel == 'function') {
	$('#focus').carousel('#previous','#next');
	function slide(){
		  $('#next').click();
	}
	var intervalId = window.setInterval(slide, 10000);
	}
	
	//player audio
  function animPlayer() {
	  var pas = parseFloat($("#player").css("width"));
	  if((parseFloat($("#blocPlayer").css("left")) < 0)&&(!$("#player").hasClass("openPlayer"))) {
		   $('#blocPlayer').animate({"left": "+="+pas+"px"}, "slow");
		   $("#player").addClass("shadowAction");
		   $("#player").addClass("openPlayer");				   
	  }
	  else if($("#player").hasClass("openPlayer")) {
		$("#blocPlayer").animate({"left": "-="+pas+"px"}, "slow");				  
		$("#player").removeClass("openPlayer");
		$("#blocPlayer").queue(function () {
			$("#player").removeClass("shadowAction");
			$.dequeue( this );
		});
  }
}
	
	
	$("#titlePlayer").click(animPlayer);
	$("#listenToMusic").click(animPlayer);
	
	//Accordeon artiste
	$(".blocArchiveBand h2 a").click(
								function() {
							if(!$(this).parent().parent(".blocArchiveBand").hasClass("open")) {		 
									$(".blocArchiveBand").each(
															  function() {
																if($(this).hasClass("open")){
																	$(this).children("ul").slideUp('slow', function() {
																		$(this).parent(".blocArchiveBand").removeClass("open");
																  		});
																	}
															  });
									$(this).parent().parent(".blocArchiveBand").addClass("open");
									$(this).parent().parent(".blocArchiveBand").children("ul").slideDown('slow', function() {});
								}
							});
	
	//calage des listes d'albums
	$(".listArchiveDisc li").each(
								  function() {
									tempHeight = $(this).height();
									if (typeof(maxHeight) == "undefined") {
										maxHeight = 0;
									}
									if(maxHeight < tempHeight) {
										maxHeight =  tempHeight; 
									}
									  
								  });								  
	
	$(".listArchiveDisc li a").each( 
									function() {
										$(this).css("height",maxHeight);
									});
	
	//pagemaker
	$(".pagebar").children().last().prev().addClass("noBackground");
	
	//colonnes
	$(".colonne:even").addClass("impair");
	$(".colonne:odd").addClass("pair");
		
});

