/**
 * Controls the UI, displaying the steps in the usage process
 * @title		Step Controller
 * @author		Colin Nolan
 * @version		v1.0.0
 * @created		27/09/11
 *
 * @param	{string} openOnStart	Name of step to be open when started
 * @param	{EventLogger} eventLogger	(Optional) Able to log when steps are opened on the server
 */
var StepController = function(openOnStart, eventLogger)
{
	/*
	 * Instance variables
	 */
	var steps = new Array();					// Steps that are being controlled



	// Mutators
	/**
	 * Register a new step
	 * @param	{string} name	Name of the step
	 * @param	{HTMLElement} container	Element that contains all content of the step UI
	 */
	this.registerStep = function(name, container)
	{
		var step = new Step(name, container);
		if(name == openOnStart) {
			step.expand();
		}
		else {
			step.collapse();
		}
		steps.push(step);
	};


	/**
	 * Toggle the showing of a step
	 * @param	{string} name	Name of the step to toggle
	 */
	this.toggle = function(name)
	{
		var i = 0;
		while(i < steps.length) {
			var step = steps[i++];
			if(step.getName() == name) {
				step.toggleDisplay();
				if(eventLogger) {
					if(step.isShown()) {
						eventLogger.log("Open section: "+ name);
					}
				}
			}
			else {
				step.collapse();
			}
		}
	};
};
