$(document).ready(


	function()

	{


		initCalendars();

		initPlayButtons();

		initArtistCarousel();


		initReleaseSlide();

		initAgendaNavigation();

		initCarousel();


		initLuisterpaal();

		initCarousel( ".tiny-carousel", ".carousel-container", 138, 1 );

		initTrackList();

		initAudioPlayer();

		

		initExternalLinks();	

		initPopup();

	

	

		//


		initArtistSpotlight();

	

		initBigCarousel();

	}

);

/*


*/


function initLuisterpaal() {

	

	  $('a[rel="luisterpaal"]').click(function(e){

		window.open(this.href, 'luisterpaal_um', 'width=574,height=578,toolbar=no,location=no,directories=no,status=0,resizable=no,scrollbars=no,menubar=no');

		e.preventDefault();

	  });

}

function gotoSearch() {

	var searchterm = $('#keyword').val();


	//forward


	window.location.href = '/page/zoekresultaten/' + searchterm;	

	return false;

}

function initExternalLinks()

{

	$("a[rel='external']").attr( { target: "_blank" } );

}

function initAudioPlayer()

{

	id = "audioplayer";


	if ( document.getElementById(id) )


	{


		var flashvars = {  };


		


		var params = { wmode: "transparent" };

		var attributes = {};


		


		swfobject.embedSWF("/static/flash/audioplayer.swf", id, "762", "32", "9.0.0", "/static/flash/expressInstall.swf", flashvars, params, attributes );

	}


}


var audioItems = new Array();

function initTrackList1()


{


	$(".playlist").each(


	


		function( pi )


		{


			$(this).find(".button a").each(


		


				function(i)


				{


					var id = 'audioItem' + pi + "_" + i;


		


					audioItems.push( id );			


		


					$(this).attr( { id: id } );


		


					var path = escape( $(this).attr("href") );


		


					var flashvars = { path: path, playlist_index : pi, track_index: i };


		


					var params = { wmode: "transparent" };


		


					var attributes = {};


		


					swfobject.embedSWF("/static/flash/audiocaller.swf", id, "24", "18", "9.0.0", "static/flash/expressInstall.swf", flashvars, params, attributes );


				}


			);


		}


	);


}

function initTrackList()


{


	$(".playlist .button a").each(


	


		function(i)


		{


			var id = 'audioItem' + i;

			audioItems.push( id );			

			$(this).attr( { id: id } );

			var path = escape( $(this).attr("href") );

			var flashvars = { path: path };

			var params = { wmode: "transparent" };

			var attributes = {};

			swfobject.embedSWF("/static/flash/audiocaller.swf", id, "24", "18", "9.0.0", "static/flash/expressInstall.swf", flashvars, params, attributes );


		}


	);


}

function hiliteTrack( playlist_index, track_index )


{


	$(".playlist tr").removeClass('hilite');


	


	var exp = ".playlist:eq(" + playlist_index + ") tr:eq(" + track_index + ")";


		


	$(".playlist:eq(" + playlist_index + ") tr:eq(" + track_index + ")" ).addClass('hilite');


}

function turnOnPlayer(url)


{


	//stopAudioItems();


	


	MM_findObj( "audioplayer" ).load(url);


}

function turnOffPlayer()


{


	//stopAudioItems();


	


	MM_findObj( "audioplayer" ).stop();


}

function stopAudioItems()


{


	for( var i = 0; i < audioItems.length; i++)


	{


		MM_findObj( audioItems[i] ).stopAudio();


	}


}

function MM_findObj(n, d) { //v3.0

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;

}

/*


*/

function initCarousel( amain, acontainer, adist, avisible )


{


	var main = amain || ".carousel";


	var container = main + " " + ( acontainer || ".carousel-container" );


	var visible = avisible || 4;


	


	var numItems = $( container + " .item").size();


	


	


	if ( numItems <= visible )


	{


		


		$( main + " .older").hide();


		$( main + " .newer").hide();


		


	} else {


		/*


			settings


		*/


		


		var duration = 300;


		var scrollEaseType = "easeInOutExpo";


		var distance = adist || 156;


		var currentIndex = 0;


		var previousIndex = 0;

		var max = numItems - visible;


	


		var dimmed = "dimmed";


		


		function scroll()


		{	


			var x = -(currentIndex * distance) + "px";


				


			$( main + " .older").removeClass(dimmed);


			$( main + " .newer").removeClass(dimmed);


			


			if ( currentIndex == 0 ) $( main + " .older").addClass( dimmed );


			if ( currentIndex == max ) $( main+ " .newer").addClass( dimmed );


			


			$( container + " .scroller").animate( { left: x }, { duration: duration, easing: scrollEaseType } );


		}


		


	


		


		/*


			next & previous


		*/


		


		$( main + " .older").addClass("dimmed");


		


		$( main + " .older").click(


			


			function(e)


			{


				previousIndex = currentIndex;


				currentIndex--;


				currentIndex = currentIndex <= 0 ? 0 : currentIndex;


				


				scroll();


				


				e.preventDefault();


			}


		);


		


		$( main + " .newer").click(


			


			function(e)


			{


				previousIndex = currentIndex;


				currentIndex++;


				currentIndex = currentIndex >= max ? max : currentIndex;


				


				scroll();


				


				e.preventDefault();


			}


		);


	


	


		/*


			rollovers


		*/


		


		$( container + " .item").each(


		


			function(i)


			{


				$(this).css( { position: "absolute", top: 0, left: (i * distance ) + "px" } );


			}


		);


		


	


		scroll();


	}


}


function initAgendaNavigation() {

	

	$('.filter select').change( function() {

		

		var selectedMonth = $('#month').val();

		var month = selectedMonth.substr(0,2);

		var year = selectedMonth.substr(2,4);

		var artist = $('#artist').val();

	

		document.location.href = '/page/agenda/' + month + '/' + year + '/' + artist;						 

	});	

}


function initReleaseSlide()


{


	var releases = $("#release_items div[id^='release']");


	var thumbs = $('#release_thumbs li');


	thumbs.each(


		function(i)


		{


			$(this).click(


				function(e)


				{


					var release = $("#release_items div[id^='release']:eq(" + i + ")");


					


					releases.addClass('hide');


					release.removeClass('hide');


					


					thumbs.removeClass('hidden');


					


					$(this).addClass('hidden');


					


					e.preventDefault();


				}


			);


			


		}


	);	


}

function initReleaseSlideOld() {

	$('#release_thumbs a').click(function() {

		//get visible item

		var detailed_item_id = $('#release_items div:visible').attr("id");

		//hide visible item

		$('#' + detailed_item_id).addClass("hide");

		$('#' + detailed_item_id).hide();

		var thumbid = $(this).attr("id");	

		var div_id = thumbid.slice(6);		


		

		var hid_thumb_src = $('#release_thumbs a:hidden').find("img").attr("src");

		var hid_thumb_alt = $('#release_thumbs a:hidden').find("img").attr("alt");

		//replaced thumb details

		var rep_thumb_src = $('#thumb_' + div_id).find("img").attr("src");

		var rep_thumb_alt = $('#thumb_' + div_id).find("img").attr("alt");

		//set new hidden thumb image 

		$('#release_thumbs a:hidden').find("img").attr("src", rep_thumb_src);

		$('#release_thumbs a:hidden').find("alt").attr("src", rep_thumb_alt);

		$('#release_thumbs a:hidden').attr("id" ,thumbid);

		$('.new-releases #' + div_id).show();

		$('.new-releases #' + div_id).removeClass("hide");

		//change thumbnail details


		$('#thumb_' + div_id).find("img").attr("src", hid_thumb_src);

		$('#thumb_' + div_id).find("img").attr("alt", hid_thumb_alt);


		$('#thumb_' + div_id).attr("id", "thumb_" + detailed_item_id);

		return false;


	});

}


function initArtistSpotlight()

{

	var id = "spotlight-carousel";

	

	if ( document.getElementById(id) )

	{	

		var flashvars = { dataUrl: "" };


		var params = { wmode: "transparent" };


		var attributes = {};

		

		swfobject.embedSWF("/static/flash/artist_spotlight.swf", id, "762", "132", "9.0.0", "/static/flash/expressInstall.swf", flashvars, params, attributes );

	}


}


function initBigCarousel()

{

	var id = "big-carousel";

	

	if ( document.getElementById(id) )

	{	

		var flashvars = { dataUrl: "" };


		var params = { wmode: "transparent" };


		var attributes = {};

		

		swfobject.embedSWF("/static/flash/artist_carousel_big.swf", id, "762", "336", "9.0.0", "/static/flash/expressInstall.swf", flashvars, params, attributes );

	}


}

function initArtistCarousel()

{

	var id = "artist-carousel";

	

	if ( document.getElementById(id) )

	{				

		var flashvars = { dataUrl: "" };


		var params = { wmode: "transparent" };


		var attributes = {};

		

		swfobject.embedSWF("/static/flash/artist_carousel.swf", id, "762", "444", "9.0.0", "/static/flash/expressInstall.swf", flashvars, params, attributes );

	}

}

function initArtistNavigation(dataUrl, currentPage )

{

	var id = "sub-navigation";

	if ( document.getElementById(id) )


	{				

		var flashvars = { dataUrl: dataUrl, currentPage:currentPage };

		var params = { wmode: "transparent" };

		var attributes = {};

		swfobject.embedSWF("/static/flash/artist_navigation.swf", id, "762", "30", "9.0.0", "/static/flash/expressInstall.swf", flashvars, params, attributes );

	}

}



function initPlayButtons()

{

	$("a.play").each(

		function()

		{

			var arrow = $("<strong></strong>").html("play");


			$(this).append( arrow );

		}

	);

}


function initCalendars()

{

	$(".agenda-upcoming strong").each(

		function()

		{

			var num = parseInt( $(this).text() ) - 1;

			var x = 10 - ( num * 36 );

			var pos = x + "px 15px";


			$(this).css( { backgroundPosition : pos } );

		}

	);

}

var bellgothic =

{

	src: '/static/flash/bellgothic.swf',

	ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01]

};

sIFR.activate( bellgothic );


// sIFR.debug.ratios( { src: 'static/flash/bellgothic.swf', selector : ".sub-navigation li" } );

sIFR.replace( 

	bellgothic,

	{

		selector: 'h1, .sidebar .section-header',

		css:

		{			

			'.sIFR-root': 

			{

				'color': '#1a1a1a' ,

				'display':'inline',

				'text-transform' : 'uppercase'

			},

			'a': 

			{ 

				'color': '#1a1a1a',

				'text-decoration': 'none' 

			},

			'a:hover': 

			{ 

				'color': '#1a1a1a',

				'text-decoration': 'underline'

			}

		},

		ratios : [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],

		offsetTop: 0,		

		tuneHeight: -1,		

		wmode: "transparent"		

	}     

);


sIFR.replace( 

	bellgothic,

	{

		selector: '.sub-navigation li',

		css:

		{			

			'.sIFR-root': 

			{

				'color': '#1a1a1a' ,

				'display':'inline',

				'text-transform' : 'uppercase'

			},

			'a': 

			{ 

				'color': '#1a1a1a',

				'text-decoration': 'none' 

			},

			'a:hover': 

			{ 

				'color': '#1a1a1a',

				'text-decoration': 'underline'

			}

		},

		ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],

		offsetTop: 0,		

		tuneHeight: 0,		

		forceSingleLine : 1,

		useDomLoaded : 1,

		wmode: "transparent"		

	}     

);


function openWindow(pad,naam,breed,hoog)


{


	var top  = ( (screen.height/2)-(hoog/2) );


	var left = ( (screen.width/2)-(breed/2) );


	window.open(pad, naam, "width=" + breed + ",height=" + hoog +", top=" + top + "px, left=" + left + "px, toolbar=no,location=no,directories=no,status=0,resizable=no,scrollbars=no,menubar=no");


}


function initPopup() 

{

	$("a.popup").each(


		function(i)

		{

			$(this).click(

	


				function()

				{

					var poplink = $(this).attr('href');


									


					/*openWindow(poplink, i, 480, 420);	*/

					openWindow(poplink, i, 965, 825);


					


					return false;


				}


			);


			


		}


	);


}

sIFR.replace( 
	bellgothic,
	{
		selector: '.home .section-header, .content .section-header',
		css:
		{			
			'.sIFR-root': 
			{
				'color': '#ef4136' ,
				'display':'inline',
				'text-transform' : 'uppercase'
			},
			'a': 
			{ 
				'color': '#1a1a1a',
				'text-decoration': 'none'
			},
			'a:hover': 
			{
				'color': '#1a1a1a',
				'text-decoration': 'underline'
			}
		},
		offsetTop: 0,		
		tuneHeight: -1,		
		wmode: "transparent"		
	}
);
/*
sIFR.replace( 
	bellgothic,
	{
		selector: '#artist-navigation ul li',
		css:
		{			
			'.sIFR-root': 
			{
				'color': '#ebe9ea' ,
				'display':'inline',
				'text-transform' : 'uppercase'
			},
			'a': 
			{ 
				'color': '#ebe9ea',
				'text-decoration': 'none'
			},
			'a:hover': 
			{
				'color': '#f4f3f3',
				'text-decoration': 'none'
			}
		},
		offsetTop: 0,		
		tuneHeight: -1,		
		wmode: "transparent"		
	}     
);
*/