// Default configuration follows structure:
// div[#uniqueId] h3 tag[.toggle]

// The below lines let you re-configure
// but .toggle click event must be nested 
// inside ID container

// From your container id use a > for
// each level down the toggle switch is.
togglePath ="> >";

// Path which points from .toogle
// to container with ID
parentPath ='.parent("h3").parent("div")';

// Define the tag you want to show/collapse 
// Use a tag name or class within your container
hideObjectType =".hide";

// Set the appended button text
closeText = "Close";
openText = "Open";

// SlickerBox as default will display a close state
// Add in ID's which you wish to set to default as open
var defaultIdsSetOpen = new Array("introduction","ebit");

// Add arrow images to click event?
// Attach via css bakground-image
// Without JavaScript degrades gracefully

$(document).ready(function(){	  
   	var toggleClass = new Array();	
	toggleClass = $(".toggle");	
	for (i=0; i<toggleClass.length; i++)
	{		
		var toggleClassIds = null;
		eval('toggleClassIds =$(toggleClass[i])'+parentPath+'.attr("id")');
		if (toggleClassIds == defaultIdsSetOpen[i])
		{
			$("#"+toggleClassIds+" .toggle").text(closeText)
			$("#"+toggleClassIds+" .toggle").addClass("open");
		}
		else
		{
			$('#'+toggleClassIds+' '+hideObjectType).hide();
			$("#"+toggleClassIds+" .toggle").addClass("closed");
			$("#"+toggleClassIds+' .toggle').text(openText);
		}
	}		   
	$('.toggle').click(function(){									
		var qid = null;
		eval('qid=$(this)'+parentPath+'.attr("id")');
		return slickerBox(qid);
		return false;
	}); 	
});

function slickerBox(qid){
	var textLocation = $("#"+qid+" "+togglePath+" .toggle").text();	
	if (textLocation == openText)
	{
		$("#"+qid + togglePath + ".toggle").text(closeText);
		$("#"+qid + togglePath + ".toggle").removeClass("closed");
		$("#"+qid + togglePath + ".toggle").addClass("open");
	}
	else if (textLocation == closeText)
	{
		$("#"+qid + togglePath + ".toggle").text(openText);
		$("#"+qid + togglePath + ".toggle").removeClass("open");
		$("#"+qid + togglePath + ".toggle").addClass("closed");
	}	
	$('#'+qid+' '+hideObjectType).slideToggle(400);
	return false;
}