Shadowbox.init({
    language: "nl",
    players: ["iframe"],
    skipSetup: true
});

jQuery(function($){
	
	// get hash
	function getHash() {
		var hash = window.location.hash;
		return hash.substring(1); // remove #
	}
	
	// get the index of the active video (first if there is no hash)
	function getIndex() {
		var hash = getHash();
		var startid = 1;
	
		var index = $('#medialistvideo img').index($('img[src*='+ hash +']'));
	
		if(index > -1) startid = index + 1;
		
		return startid;
	}
		
	var popup = function() {
		
		var url = $(this).attr('longdesc');
		var title = $(this).attr('alt');
		
	    Shadowbox.open({
	        content:    url,
	        player:     "iframe",
	        title:      title,
	        height:     500,
	        width:      560
	    });

	};
	
	$('#medialistvideoOverview a').click(function(evt){
		evt.preventDefault();
		
		var url = $(this).attr('href');
		var title = $(this).attr('title');
		
	    Shadowbox.open({
	        content:    url,
	        player:     "iframe",
	        title:      title,
	        height:     500,
	        width:      560
	    });
	});
	
	
	// configuration of the imageFlow instance
	var config = {
		ImageFlowID: 'medialistvideo',
		aspectRatio: 2,
		opacity: true,
		opacityArray: [10, 9, 7, 5, 3],
		imageCursor: 'pointer',
		reflections: true,
		reflectionGET: '&bgc=ffffff&fade_start=20%',
		slider: false,
		startID: getIndex(),
		onClick: popup
	};
	
	// create imageFlow
	var youtubeFlow = new ImageFlow();
	youtubeFlow.init(config);
});

