/*

	This requires core.js

*/

(function(){

	var SELECTOR = '.hideAndReveal'
	  , OPEN_CLASS = 'open'
	  , CLOSED_CLASS = 'closed';
	
	var items;
	
	init();
	

	function init() {
	
		items = core.getElements(SELECTOR);
		
		core.each(items, initAnchors);
		
	}
	
	function initAnchors(item) {
		var anchors = item.getElementsByTagName('a');
		
		core.each(anchors, function(a){
			a.nextSibling.style.display = 'none';
			core.css.addClass(a, CLOSED_CLASS);
			a.onclick = showDefinition;
		});
	}
	
	function showDefinition() {
		if (core.css.hasClass(this, CLOSED_CLASS)) {
			this.nextSibling.style.display = '';
			core.css.removeClass(this, CLOSED_CLASS);
			core.css.addClass(this, OPEN_CLASS);
		}
		else if (core.css.hasClass(this, OPEN_CLASS)) {
			this.nextSibling.style.display = 'none';
			core.css.removeClass(this, OPEN_CLASS);
			core.css.addClass(this, CLOSED_CLASS);
		}
		return false;
	}

})();
