$.easing.def = "easeOutQuad";

$(document).ready(function()
{
	var hiliteStyle = {
		color:      "#000",
		cursor:     "normal",
		fontWeight: "bold"
	};
	var clickStyle = {
		color:      "#2866af",
		cursor:     "pointer",
		fontWeight: "normal"
	};

	$("#accordion h3.faq-section").click(function()
	{
		$("#accordion h3.faq-section").removeClass("faq-section-on").siblings("ol").hide();
		$(this).addClass("faq-section-on").next("ol").show();
	});

	$("#accordion div.element").each(function(){
		var height = 0;
		$(this).children().each(function()
		{
			if ($(this).css("float") != "right")
			{
				var elHeight      = $(this).height();
				var marginTop     = parseInt($(this).css("marginTop"));
				var marginBottom  = parseInt($(this).css("marginBottom"));
				var paddingTop    = parseInt($(this).css("paddingTop"));
				var paddingBottom = parseInt($(this).css("paddingBottom"));

				height = isNaN(elHeight)      ? height : height + elHeight ;
				height = isNaN(marginTop)     ? height : height + marginTop ;
				height = isNaN(marginBottom)  ? height : height + marginBottom ;
				height = isNaN(paddingTop)    ? height : height + paddingTop ;
				height = isNaN(paddingBottom) ? height : height + paddingBottom ;
			}
		});
		if ($(this).height() > height)
		{
			height = $(this).height();
		}
		$(this).css("height", height + "px").css("padding", "0px");
	}).hide();
	$("#accordion li.toggler").css(clickStyle).click(function()
	{
		if ($(this).css("fontWeight") != "bold")
		{
			// Remove styles and hide other questions
			$("#accordion li.toggler").css(clickStyle).children("div.element").slideUp();
			$("#accordion li.toggler").find("a:first").css(clickStyle);
			
			// Add styles and show clicked question
			$(this).css(hiliteStyle).children("div.element").slideDown();
			//$(this).find("a:first").css(hiliteStyle);
		}
	});

	$("#expand").click(function()
	{
		$("#accordion h3.faq-section").siblings("ol").show();
		$("#accordion li.toggler").css(hiliteStyle).children("div.element").slideDown();
		//$("#accordion li.toggler").find("a:first").css(hiliteStyle);
	});

	$("#collapse").click(function()
	{
		$("#accordion h3.faq-section").removeClass("faq-section-on").siblings("ol").hide();
		$("#accordion h3.faq-section:first").addClass("faq-section-on").next("ol").show();
		$("#accordion li.toggler").css(clickStyle).children("div.element").slideUp();
		//$("#accordion li.toggler").find("a:first").css(clickStyle);
	});

	$("#accordion h3.faq-section:first").click();
	$("#accordion li.toggler:first").click();
});
