﻿var SiteClass = new Class({
    initialize : function() {
        window.addEvent('domready', this.domReady.bind(this));
	   
    },
    domReady : function() {
        this.attachAccordian();
        //this.attachInnerAccordian();
    },
    attachAccordian : function() {
        var questions = $$('.question');
		if (questions.length > 0)
		{
			var answers = $$('.answer');
			var myAccordion = new Accordion(questions, answers, {
			display: false,
			alwaysHide: true,
			height: true,
			onActive: function(el) { el.addClass('question-open'); },
			onBackground: function(el) { el.removeClass('question-open'); },
			
			
			start: 'all-closed',
			
			onComplete: function(el) {
				(el) = $(this.elements[this.previous]);
				if ((el).offsetHeight > 0) (el).setStyle('height', 'auto');
				}
			});
		}
    
    
		var innerquestions = $$('.inner-question');
		if (innerquestions.length > 0)
		{
			var inneranswers = $$('.inner-answer');
			var myAccordion = new Accordion(innerquestions, inneranswers, {
			display: false,
			alwaysHide: true,
			height: true,
			onActive: function(el) { (el).addClass('inner-question-open'); },
			onBackground: function(el) { (el).removeClass('inner-question-open'); }
			
			});
		}    
    
    }
 
    
    
});

var Site = new SiteClass();