// faqlist
// Created by Juda van Mourik, 2008

$(document).ready(function() {
	$("div.faq").faqlist();
});

function closeAll(container){
	$(container).find("img").attr("src", "/theme/AccountAble/images/icons/toggler_plus.gif");
	$(container).find("dd").hide();	
}

// options are not implemented in this release
jQuery.fn.faqlist = function(options) {

	// Create a styling div
	$(this).find("select").wrap("<div class=\"selector\"></div>");

	// Generate change action
	$(this).find("select").change(function() {
		submitMe(this);
	});
	
	var container = this;
	
	// Don;t show any at startup
	closeAll(container);
	
	// Show one faq
	$(this).find("dl dt").click(function() {
		closeAll(container);
		if ($(this).attr("expanded") == "true") {
			$(this).find("img").attr("src", "/theme/AccountAble/images/icons/toggler_plus.gif");
			$(this).next('dd').hide();
			$(this).attr("expanded", "false");
		} else {
			$(this).find("img").attr("src", "/theme/AccountAble/images/icons/toggler_minus.gif");
			$(this).next('dd').show();
			$(this).attr("expanded", "true");
		}
	});
}
