$(function(){
	$('#menu.fp a').click(function(e){
		var speed = 1000;
		var anim = 'swing';
		
		$(this).addClass('open');
		
		$('#menu-worklist').animate({
			left: '20px',
			top: '151px'
		}, speed, anim);
		$('#menu-news').animate({
			left: '98px',
			top: '204px'
		}, speed * 0.7, anim);
		$('#menu-performances').animate({
			left: '605px',
			top: '135px'
		}, speed * 0.3, 'linear', function(){
			$('#menu-performances').animate({
				left: '49px',
				top: '239px'
			}, speed, anim);
		});
		$('#menu-recordings').animate({
			left: '66px',
			top: '279px'
		}, speed * 0.4, anim);
		$('#menu-gallery').animate({
			left: '118px',
			top: '312px'
		}, speed, anim);
		$('#menu-cv').animate({
			left: '111px',
			top: '338px'
		}, speed * 0.5, anim);
		$('#menu-contact').animate({
			left: '120px',
			top: '354px'
		}, speed * 1.2, anim);
		$('#menu-interviews').animate({
			left: '99px',
			top: '375px'
		}, speed * 0.8, anim);
		$('#menu-links').animate({
			left: '116px',
			top: '397px'
		}, speed * 1.1, anim);
		
		$('#menu').addClass('fixed').find('a').unbind();
		
		setTimeout(function(){
			document.location.href = e.target;
		}, speed * 1.35);
		
		return false;
	});
	
	$.Lightbox.construct({
		show_linkback: false,
		opacity: 0.8,
		files: {
			js: {
				lightbox:	URL_LIB+'jquery/jquery.lightbox.js',
				colorBlend:	URL_LIB+'jquery/jquery.color.js'
			},
			css: {
				lightbox:	URL_LIB+'jquery/css/jquery.lightbox.css'
			},
			images: {
				prev:		URL_LIB+'jquery/images/prev.gif',
				next:		URL_LIB+'jquery/images/next.gif',
				blank:		URL_LIB+'jquery/images/blank.gif',
				loading:	URL_ADMIN+'css/g/ajax-loading.gif'
			}
		}
	});
	
	$('.gallery a[rel]').lightbox().each(function(){
		var that = $(this);
		$('<img>').attr('src', that.attr('rel'));
		that.mouseover(function(){
			a = $(this);
			$('.bigpic img').attr('src', a.attr('rel'));
			$('.bigpic a').attr('href', a.attr('href')).attr('title', a.attr('title'));
			$('.bigpic span.title').text(a.attr('title'));
			$('.gallery .bigpic a').lightbox();
			$('.gallery a.open').removeClass('open');
			a.addClass('open');
			return false;
		});
	});
	$('.gallery .bigpic a').lightbox();
	
	var soundplayer = $('<div id="soundplayer" style="position:absolute;left:0;top:0;width:1px;height:1px;"></div>');
	$('body').append(soundplayer);
	soundplayer.mp3sound({swf: URL_LIB+'jquery/sound/Player.swf'});
	
	$('a[rel*=play]').click(function(){
		if($(this).hasClass('playing')) {
			$(this).removeClass('playing').addClass('paused');
			soundplayer.mp3pause($(this).attr('href'));
		} else if($(this).hasClass('paused')) {
			$(this).removeClass('paused').addClass('playing');
			soundplayer.mp3play($(this).attr('href'));
		} else {
			$('a.playing').removeClass('playing');
			$(this).addClass('playing');
			soundplayer.mp3load($(this).attr('href'));
		}
		return false;
	});
	
	$('.opener').toggle(function(){
		$(this).parents('.bar').addClass('open').next().show();
		return false;
	}, function(){
		$(this).parents('.bar').removeClass('open').next().hide();
		return false;
	});
});