(function($) {
	$.fn.accordion = function(options) {
		var defaults = {};
        var options = $.extend(defaults, options);
		var object = $(this).children('li');
		object.children('div').hide().css('overflow','hidden').data('visible','no');
		if(document.location.hash != ''){
			var hash = document.location.hash;
			$(hash).next('div').show().data('visible','yes');
		}

		object.children('h3').hover(function(){
			$(this).css({
				'cursor':'pointer',
				'text-decoration':'underline'
			});
		},function(){
			$(this).css({
				'cursor':'auto',
				'text-decoration':'none'
			});
		});

		object.children('h3').click(function(){
			if($(this).next('div').data('visible') == 'yes'){
				$(this).next('div').hide().data('visible','no');
			}else{
				object.children('div').each(function(){
					if($(this).data('visible') == 'yes'){
						$(this).hide().data('visible','no');
					}
				});
				$(this).next('div').show().data('visible','yes');
			}
		});
		
    };
})(jQuery);

$(document).ready(function(){
	$('ul#accordion').accordion();
});

