/* boxCloser.js */
var boxCloserClass = Class.create();
boxCloserClass.prototype = {
	//Properties
	h4: null,
	div: null,

	//Constructor
	initialize: function(el) {
		this.h4 = el;
		this.div = el.parentNode;
		this.observeh4();
	},

	clickh4: function(e) {
		if (Element.hasClassName(this.div,'closed')) {
			Element.removeClassName(this.div,'closed');
			Element.addClassName(this.h4, 'open');
  		}
		else{
			Element.addClassName(this.div,'closed');
			Element.removeClassName(this.h4, 'open');
		}
	},
	observeh4: function () {
		Event.observe(this.h4, 'click', this.clickh4.bind(this));
	}
};

var boxCloser_Rules= {
	'div.closeable h5' : function(el){
		new boxCloserClass(el);
	},
	'div.closeable h4' : function(el){
		new boxCloserClass(el);
	},
	'div.closeable h3' : function(el){
		new boxCloserClass (el);
	}

};
Behaviour.register(boxCloser_Rules);