

function createATag(element, aTag){
	var firstElement = $E('h2', element);
	$(aTag).injectBefore(firstElement);
	$(aTag).addClass('close');
	$(aTag).setProperty('href', '#');
	$(aTag).setProperty('onclick', 'return false');/*fix later*/
	}
	

function addOpenBtn(element){
	$(element).addEvent('click', function(e){
		var e = new Event(e);
		this.slide.slideIn();
		this.setStyle('background', '#ccc');
		$E('a', this).setStyle('visibility', 'visible');
		$E('h2', this).setStyle('background', 'url(/images/general/glossary_triangleIcon_down.gif) 5px no-repeat');
		e.stop();
	});
	$E('h2', element).addEvent('mouseenter', function(e){
		this.setStyle('background', 'url(/images/general/glossary_triangleIcon.gif) 5px no-repeat #ccc');
		document.body.style.cursor = 'Hand';
	});
	$E('h2', element).addEvent('mouseleave', function(e){
		this.setStyle('background', 'url(/images/general/glossary_triangleIcon.gif) 5px no-repeat');
		document.body.style.cursor = 'default';
	});
	}


function addCloseBtn(aTag){
	$(aTag).addEvent('click', function(e){
		var e = new Event(e);
		this.slide.slideOut();
		var theDiv = this.getParent();
		theDiv.setStyle('background', '#fff');
		this.setStyle('visibility', 'hidden');
		e.stop();
	});
	}	
	
	
window.addEvent('domready', function() {						 
	
	var list = $$('#column1 li');
	var halfList = (list.length/2).round();
	
	list.each(function(element, i) {
		//for the 2nd colume
		if(i >= halfList){
			var clone = $(element).clone().injectInside('column2');
			$(element).remove();
			var element = clone;
		}

		var theP = $(element).getElement('p')
		theP.addClass('ready');		
		var theSlide = new Fx.Slide(theP, {duration:400, wait:false});
		theSlide.hide();
		$(element).slide = theSlide;
		var aTag = document.createElement('a');
		var txt = document.createTextNode('Close');
		aTag.appendChild(txt);
		createATag(element, aTag);
		addOpenBtn(element);
		$(aTag).slide = theSlide;
		addCloseBtn(aTag);
	});

});





























