jQuery().ready(function(){

	// second simple accordion with special markup
	if(!jQuery.browser.safari)
	{
		jQuery('#secondary-nav').accordion({
			active: false,
			header: '.head',
			navigation: true,
			event: 'mouseover',
			fillSpace: true,
			animated: 'easeslide'
		});
	}
	

	var wizard = $("#wizard").accordion({
		header: '.title',
		event: false
	});
	
	var wizardButtons = $([]);
	$("div.title", wizard).each(function(index) {
		wizardButtons = wizardButtons.add($(this)
		.next()
		.children(":button")
		.filter(".next, .previous")
		.click(function() {
			wizard.accordion("activate", index + ($(this).is(".next") ? 1 : -1))
		}));
	});
	
	// bind to change event of select to control first and seconds accordion
	// similar to tab's plugin triggerTab(), without an extra method
	var accordions = jQuery('#secondary-nav, #wizard');
	
	jQuery('#switch select').change(function() {
		accordions.accordion("activate", this.selectedIndex-1 );
	});
	jQuery('#close').click(function() {
		accordions.accordion("activate", -1);
	});
	jQuery('#switch2').change(function() {
		accordions.accordion("activate", this.value);
	});
	jQuery('#enable').click(function() {
		accordions.accordion("enable");
	});
	jQuery('#disable').click(function() {
		accordions.accordion("disable");
	});
	jQuery('#remove').click(function() {
		accordions.accordion("destroy");
		wizardButtons.unbind("click");
	});
});
