// JavaScript Document
var FAQ = {
	start: function(){
		if ($('faq_ct')) FAQ.parsefaq_ct();
	},
	
	parsefaq_ct: function(){
		var boxes = $$('#faq_ct .faqItem .faqQuestion');
		var content = $$('#faq_ct .faqItem .faqAnswer');
		var open = false;
		var fx = new Fx.Elements(content, {wait: false, duration:350, transition: Fx.Transitions.Quart.easeOut});
		
		boxes.each(function(box, i){
			box.open = false;
			box.addEvent('click', function(){
				var obj = {};
				if(!this.open){
					obj[i] = {'height': [content[i].getStyle('height').toInt(), content[i].scrollHeight]};
					box.style.color = '#4579af';
					this.open = true;
				}
				else{
					obj[i] = {'height': [content[i].getStyle('height').toInt(), 0]};
					box.style.color = '#4579af';
					this.open = false;
				}
				boxes.each(function(other, j){
					if (other != box){
						var w = content[j].getStyle('height').toInt();
						if (w != 0) {
							obj[j] = {'height': [w, 0]};
							other.style.color = '#666666';
							boxes[j].open = false;
						}
					}
				});
				fx.start(obj);
			});
		});
	}
}
