$(document).ready(function() {
	// Settings
	var defOpen = 0; // set default open panel... use "null" for none - starts counting at 0
	var defHeight = 'auto'; // PANEL HEIGHT i.e. '150px' or 'auto' to open to content height

	//set up
	$('.accordian').children('div').wrap('<div class="panelWrap"></div>').parent().height('0'); // wrap all divs.. and close them
	$('.accordian').children('.panelWrap:eq('+defOpen+')').addClass("open").height('auto').prev('.title').addClass('active');// set default panel to open
	// panel animation
	$('.title').click(function() {
		close($('.accordian').children(".open")); // close all open panels
		if ( $(this).next('div').height() == 0 ) { // open panel
			if ( defHeight == "auto") { var panelHeight = $(this).next('div').children("div").height(); } else { var panelHeight = defHeight; } // set content height
			$(this).removeClass("title").addClass("active").next('div').animate({height: panelHeight}, 250).addClass("open"); // open panel
		}
	});
});	

function close(target) { target.removeClass("open").animate({height: '0px'}, 250, function(){ target.prev(".active").removeClass("active").addClass("title") }); } // panel close function