$(function() {
	$('#accordion').accordion({
		autoHeight: false,
		collapsible: true
	});

	$('#accordion.hidden').accordion({
		autoHeight: false,
		collapsible: true,
		active: false
	});
	
	$('#faq_accordion').accordion({
		header: 'h3',
		autoHeight: false,
		active: false,
		collapsible: true,
		icons: { 'header': 'ui-icon-plus',
		'headerSelected': 'ui-icon-minus' }
	});

	//$('#content h3:first').before('<div id="faq_accordion">');
	//$('<div>').insertAfter('#content h3');
});

function dynamicAccordion() {
	$(function() {
		$('p + hr').each(function() {
			if($(this).length>0) {
				$(this).prev().remove();
			}
		});
		$('hr + p').each(function() {
			if($(this).length>0) {
				$(this).remove();
			}
		});
	     $('hr + h3').each(function() {
     		$(this).prev().nextUntil('hr').wrapAll('<div id="faq_accordion" class="accord">');
     		$('hr').each(function() {
     			$(this).remove();
	     	});
     	});
	     $('#faq_accordion h3').each(function() {
	     	//$(this).nextUntil('h2').wrapAll('<div>');
	     	$(this).nextUntil(':header').wrapAll('<div>');
	     });
		$('.accord').each(function() {
			$(this).accordion({
				header: 'h3',
				autoHeight: false,
				active: false,
				collapsible: true,
				icons: { 'header': 'ui-icon-plus',
				'headerSelected': 'ui-icon-minus' }
			});
		});
	});
}
