(function($){
	$.fn.accorDion = function(item_class, title, content){
		$(this).children(item_class).each(function(){
			if ($(this).hasClass(':not(.selected)'))
				$(this).children(content).hide();

			$(this).children(title).click(function(){
				$(this).parent().children(content).slideToggle('slow');
			});
		});
	}
})(jQuery);

jQuery(document).ready(function($) {
	/* LavaLamp */
	$('#navigation ul').lavaLamp({
		//fx: 'easeInOutBack',
		fx: 'easeInOutCirc',
		speed: 500
	});

	/* Acordion */
	$('#secondary .xoxo').accorDion('.accordion', 'h3', '.inner');

	/* Tooltips */
	$(".tip").tooltip();

	$('a.tip').hover(function(e){
		var current_tip = $(this).parent().children('.tooltip');
		var width = $(current_tip).width() - 24;
		var height = $(current_tip).height() - 21;
		$(current_tip).children('.tooltip-bt').width(width);
		$(current_tip).children('.tooltip-bb').width(width);
		$(current_tip).children('.tooltip-bl').height(height);
		$(current_tip).children('.tooltip-br').height(height);
	});
	$('a.tip').click(function(e){
		e.preventDefault();
	});
	/* Slideshow */
	$('#slideshow-items').cycle({next:'#next', prev:'#prev', height:'auto', pause:true});

	$('#select .selected').click(function(){
		$('#select ul').slideDown('slow').animate({opacity: 1.0}, 5000).slideUp('slow');
	});
});