
$().ready(function(){




	
	$(".tracklist:not(.tracklist_header) li .title").each(function(i){
		$(this).prepend($('<span class="order">'+(i+1)+'.</span>'));
	});

//	$(".tracklist:not(.tracklist_header) .download").append($('<span class="bytes"> Mb</span>'));


	$(".tracklist:not(.tracklist_header) li").each(function(i){
		$(this).attr("href", '/musics/'+$(this).attr("id")+'_92.mp3');

		$(this).children(".quality_medium").click(  function(){ window.location = '/musics/'+$(this).parent().attr("id")+'_192.mp3';}  );
		
		$(this).children(".quality_medium").text(  $(".connector li[id^='"+$(this).attr("id")+"_192']").text()  );
		
		$(this).children(".quality_high").click(  function(){ window.location = '/musics/'+$(this).parent().attr("id")+'_320.mp3';}  );
		
		$(this).children(".quality_high").text(  $(".connector li[id^='"+$(this).attr("id")+"_320']").text()  );
	});


	$("div.tracklist:not(.tracklist_header)").each(function(i){
		$(this).children(".quality_medium").click(  function(){ window.location = '/musics/'+$(this).parent().attr("id")+'_192.zip';}  );
		
		$(this).children(".quality_medium").text(  $(".connector li[id^='"+$(this).attr("id")+"_192']").text()  );
		
		$(this).children(".quality_high").click(  function(){ window.location = '/musics/'+$(this).parent().attr("id")+'_320.zip';}  );
		
		$(this).children(".quality_high").text(  $(".connector li[id^='"+$(this).attr("id")+"_320']").text()  );
	});









	$f("div.player", { src: '/js/flowplayer.swf', wmode: 'opaque' }, {
		canvas: {
			backgroundColor: "transparent"
		},
		plugins: {
			audio: {
			},
			controls: {
				playlist: false,
				mute: false,
				volume: false,
				fullscreen: false,
				
				buttonOverColor: '#728B94',
				volumeSliderGradient: 'medium',
				borderRadius: '0',
				volumeSliderColor: '#000000',
				bufferColor: '#445566',
				progressColor: '#112233',
				progressGradient: 'medium',
				bufferGradient: 'none',
				durationColor: '#ffffff',
				timeBgColor: '#555555',
				sliderColor: '#000000',
				sliderGradient: 'none',
				backgroundGradient: 'medium',
				timeColor: '#01DAFF',
				tooltipColor: '#5F747C',
				buttonColor: '#5F747C',
				tooltipTextColor: '#ffffff',
				backgroundColor: '#f1f1f1',
				height: 20,
				opacity: 0.99
			}
		},
		clip: {
			baseUrl: '/musics/',
			autoPlay: false
		},
		playlist: [ {
			// our song
			url: 'empty.mp3'
			// when music starts grab song's metadata and display
//			onStart: function(song) {
//				var meta = song.metaData;
//			}
		}]
	});
	
	$f("playertracklist").playlist('ul.tracklist');



	/* chained call: scrollable().find("a").tooltip().overlay().gallery(); */
	$(".scrollable").scrollable().find("a").overlay({
		target: '#gallery', // each trigger uses the same overlay with id "gallery"
		expose: '#888888', // optional exposing effect with color
		size: 3
	}).gallery({
		// do not use the same disabled class name as scrollable
		disabledClass: 'inactive'
	});



	$("#gallery").pngFix({ blankgif: '/images/blank.gif' }); 



	$(".zebra li:even").addClass("even");

	$("a[href^=http://]").attr('target','_blank');

});


