window.addEvent('domready', function(){


	if(true !== window.ie6)
	{
		
		//list of target elements
		var list = $$('.details');
		//list elements to be clicked on
		var headings = $$('.show_details');
		//array to store all of the collapsibles
		var collapsibles = new Array();

		headings.each( function(heading, i) {

		  //for each element create a slide effect
			var collapsible = new Fx.Slide(list[i], {
				duration: 400,
				onStart: function() {
					headings[i].innerHTML = headings[i].innerHTML == "show details" ? "hide details" : "show details";
				}
			});

			//and store it in the array
			collapsibles[i] = collapsible;

			//add event listener
			heading.addEvent('click', function(e){
				new Event(e).stop();
				collapsible.toggle();
			});

			//collapse all of the list items
			collapsible.hide();
		});

		$('togAll').innerHTML = "SHOW ALL DETAILS";
		$('togAll').addEvent('click', function(e){
			new Event(e).stop();

			var stack = this.innerHTML;

			if(stack != "HIDE ALL DETAILS")
			{
				headings.each( function(heading, i) {
	              collapsibles[i].show();
								heading.innerHTML = "hide details";
	      });
				this.innerHTML = "HIDE ALL DETAILS";
			} else {
				headings.each( function(heading, i) {
	              collapsibles[i].hide();
								heading.innerHTML = "show details";

	      });
				this.innerHTML = "SHOW ALL DETAILS";
			};
		});


	}
	
});