var myrules = {
    //false = stop script errors from showing any error message. 
	'body' : function(e){
		window.onerror = function(){
			return false;
		}
	},
	
	'#faq h2' : function(el){
        Accordian(el,"h2");
	},
	
	'#faq dl dt' : function(el){
	    Accordian(el,"dl");
	},
	
	'.fade' : function(el) {
		Fat.fade_element(el.id,null,1000,"#FFFF33","#082a09","transparent");
	},
	
	'input.selectall' : function(el) {
	    //toggle the checked status of all the checkboxs in the form. 
	    el.onclick = function() {
            for (var i = 0; i < document.forms[0].elements.length; i++) {
                var element = document.forms[0].elements[i];
                if ((element.type == 'checkbox') && (element != el)) {
                    if (el.checked == true) {
                        element.click();
                    }
                    element.checked = el.checked;
                }
            }
	    }
	},
	
	'.hovertable tr' : function(el) {
	    el.onmouseover = function() {
	        Element.addClassName(el,'rowhover');
	    }
	    el.onmouseout = function() {
	        Element.removeClassName(el,'rowhover');
	    }
	}
};

//Behaviour.register(myrules);

function Accordian(el, group) {
        //stash the hash of groups somewhere
        if(!this.AccordianGroups) this.AccordianGroups = {};

        //setup an array. 
        var el_group = this.AccordianGroups[group] || [];
        var el_group_clickers = this.AccordianGroups[group+"clickers"] || [];        
        

        //get the next node - to toggle. 
        var next = Element.find(el, 'nextSibling');

        var opts = {opacity: true, duration: 400};
        opts.onComplete = function(){
    		    if (next.offsetHeight > 0) {
    		        next.style.offsetHeight = "auto"; 
    		        next.style.height = "auto"; 
    		    }
    	}

    	next.fx = new fx.Combo(next, opts);

        //hide that bad boy. 
		next.fx.hide();

        //save the node. 
		el_group.push(next);

        el_group_clickers.push(el);

        //toggle the other things in the group off if they're on.
        el.onclick = function() {
            el_group.each(function(e) {
                if(e != next && e.offsetHeight > 0) e.fx.toggle();
            });

            //turn off the other clickers
		    el_group_clickers.each(function(e) {
		        Element.removeClassName(e,"expanded");
		    });

    		next.fx.toggle();
    		if(next.offsetHeight == 0) Element.addClassName(el,"expanded");
		}
				
		//save the list. 
		this.AccordianGroups[group] = el_group;
		this.AccordianGroups[group+"clickers"] = el_group_clickers;
}
