// JavaScript Document

x = 0;

var faq_wrapper = window.document.getElementById("faq");
var faq_question = faq_wrapper.getElementsByTagName("dt");
var faq_answer = faq_wrapper.getElementsByTagName("dd");
var faq_total = faq_answer.length;
var height = new Array;
var id = '';
loop_timeout = '';

for(i=0; i<faq_total; i++) {
	height[i] = faq_answer[i].clientHeight;
	faq_answer[i].style.height = 0;
	faq_question[i].onclick = function() {
		showAnswer(this.id);
	}
}

function showAnswer(value) {
	value = value.split("_");
	value = value[1];
	if(x==0) {
		hideAnswer();
		faq_question[value].className = "active";
	}
	if(loop_timeout!='') clearTimeout(loop_timeout);
	var target = height[value];
	if(x<target) {
		x = x+5;
		faq_answer[value].style.height = x+"px";
		loop_timeout = setTimeout("showAnswer('answer_"+value+"')",50);
	} else {
		faq_answer[value].style.height = target+"px";
		x = 0;
	}
}

function hideAnswer() {
	for(i=0; i<faq_total; i++) {
		faq_answer[i].style.height = 0;
		faq_question[i].className = '';
	}
}
