var faq = new function() {		
	this.init = function() {			
		//init is used because we want to show all the answers
		//if the user has javascript disabled.
		
		//find all the questions
		//toggle them to shown
		var questions = document.getElementsByTagName("div");
		var match = /question/;
		for(var elem=0;elem<questions.length;elem++) {
			if(match.test(questions[elem].className)) {			
				questions[elem].className = questions[elem].className + " on";				
				//add onclick handlers to questions
				questions[elem].onclick = faq.showAnswer;
			}
		}
		
		//find all the answers
		//toggle them to hidden
		var answers = document.getElementsByTagName("div");
		var match = /answer/;
		for(var elem=0;elem<answers.length;elem++) {
			if(match.test(answers[elem].className)) {
				Effect.BlindUp(answers[elem], {duration:0});
			  
			}
		}
		
		//add event hooks close buttons
		var closeBtns = document.getElementsByTagName("div");
		var match = /close_button/;
		for(var elem=0;elem<closeBtns.length;elem++) {
			if(match.test(closeBtns[elem].className)) {
				closeBtns[elem].onclick = faq.hideAnswer;
			}
		}
		
	}
	
	this.showAnswer = function() {
		var match = /answer/;
				
		//find the answer to display
		var grouper = this.parentNode.getElementsByTagName("div");
		for(var elem=0;elem<grouper.length;elem++) {
			if(match.test(grouper[elem].className)) {
				Effect.SlideDown(grouper[elem], {duration:0.5});
			}
		}
		
		//now hide the called
		Effect.BlindUp(this,{duration:0.2});	
	}
	
	this.hideAnswer = function() {
		//find the answer to display
		var grouper = this.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("div");
		match = /question/;
		for(var elem=0;elem<grouper.length;elem++) {
			if(match.test(grouper[elem].className)) {
				Effect.BlindDown(grouper[elem],{duration:0.2});
			}
		}
		//now hide the called
		match = /answer/;
		for(var elem=0;elem<grouper.length;elem++) {
			if(match.test(grouper[elem].className)) {
					Effect.SlideUp(grouper[elem], {duration:0.5});
			}
		}			
	return false;
	}
}
Event.addEvent(window,"load",faq.init)