
		
	// Class for managing accordian.
	function Stretchbar()
	{
		// Public properties.
	  this.arrowDirection
	,	this.previousCategory
	,	this.serverAddress
	
		// Public methods - Interface.
	,	this.clearAll = clearAll
	,	this.isSelected = isSelected
	,	this.isSelectedValue = isSelectedValue
	,	this.resetSelection = resetSelection
	,	this.removeReset = removeReset
	,	this.setArrowIcon = setArrowIcon
	, this.setClearIcon = setClearIcon
	,	this.setDisabled = setDisabled
	
	
		// Local properties.
		var _arrowRight = 1;
		var _arrowDown = 2;
			
		
		// Methods implementation.						
		
						
		// Remove selections from all categories.
		function clearAll()
		{
			var counter = document.getElementsByName("checkbox").length;
			for (var index=0; index <= counter - 1; index++)
			{
				// Display unselected clear icon.
				this.setClearIcon(document.getElementsByName("checkbox")[index].id, false);
			}		
		}
		
		// Determine whether any items are selected.
		function isSelected(groupElementName)
		{
			var selected = false;
			var count = document.getElementsByName(groupElementName).length
			for(var index=0; index <= count - 1; index++)
			{
				if(document.getElementsByName(groupElementName).item(index).checked)
				{				
					selected = true
				}
			}
			return selected;
		}
		 
		//	Purpose:	Determine whether the specified element is selected.
		//	Inputs:		groupElementName: The name of the Html element, including collectons.
		//						elementValue: The element value to match e.g. 'concert'.
		//	Returns:	True when the element is selected.
		function isSelectedValue(groupElementName, elementValue)
		{
			var selected = false;
			var count = document.getElementsByName(groupElementName).length
			for(var index=0; index <= count - 1; index++)
			{
				var element = document.getElementsByName(groupElementName).item(index);
				if(element.value.toLowerCase() == elementValue.toLowerCase() && element.checked)
				{				
					selected = true
				}
			}
			return selected;
		}
		
		// De-select the 'ignore' checkbox and display 'reset' icon when items selected.
		function removeReset(groupElementName, ignoreElementId, clearElementId)
		{
			// Determine whether any items are selected.
			if (isSelected(groupElementName))
			{
				// De-selected the 'ignore' checkbox.
				document.getElementById([ignoreElementId]).checked = "";
				
				// Display selected clear icon.
				this.setClearIcon(clearElementId, true);
			}
			else
			{
				// Display unselected clear icon.
				this.setClearIcon(clearElementId, false);
			}
		}
		
		// Purpose:	Clear all selections and select the 'ignore' checkbox and display 'unselected' clear icon.
		function resetSelection(groupElementName, ignoreElementId, clearElementId)
		{
			// Remove previous selections.
			var count = document.getElementsByName(groupElementName).length;
			for(var index=0; index <= count - 1; index++)
			{
				document.getElementsByName(groupElementName).item(index).checked = "";
			}
			
			// Selected the 'ignore' checkbox.
			document.getElementById([ignoreElementId]).checked = "checked";
			
			// Display unselected clear icon.
			this.setClearIcon(clearElementId, false);	
		}
						
		// Toggle arrow direction in heading: either right or down.
		function setArrowIcon(categoryIndex, categoryCount, arrowImageGroupId)
		{		
			// Display right-arrow on all categories.
			var counter = categoryCount;
			for (var index=0; index <= counter - 1; index++)
			{
				document.getElementById([index + arrowImageGroupId]).src = this.serverAddress + "/images/search/arrow-right.gif"; // ArrowImageGroupId References Stretchbar.asp.
			}
			
			// Toggle the arrow for the selected category.
			var currentImage = document.getElementById([categoryIndex + arrowImageGroupId]);
			var arrowDownFileName = this.serverAddress + "/images/search/arrow-down.gif";
			var arrowRightFileName = this.serverAddress + "/images/search/arrow-right.gif";
						
			if (parseInt(categoryIndex) == parseInt(this.previousCategory))
			{	
				if (parseInt(this.arrowDirection) == parseInt(_arrowRight))
				{
					currentImage.src = arrowDownFileName;
					this.arrowDirection = _arrowDown;	
				}
				else
				{
					currentImage.src = arrowRightFileName;
					this.arrowDirection = _arrowRight;
				}
			}
			else
			{
				this.arrowDirection = _arrowRight; // Initialise default.	
				if (parseInt(this.arrowDirection) == parseInt(_arrowRight))
				{
					currentImage.src = arrowDownFileName;	
					this.arrowDirection = _arrowDown;
				}
				else
				{
					currentImage.src = arrowRightFileName;
					this.arrowDirection = _arrowRight;
				}
			}
			
			// Remember the current category selection.
			this.previousCategory = categoryIndex;
		}
		
		// Purpose:	Display the clear icon.
		// Inputs:	clearElementId: The clear checkbox icon: either checked or unchecked.
		//					selected: Display the checked icon when true; otherwise unchecked.
		function setClearIcon(clearElementId, selected)
		{				
			if (selected)
			{
				document.getElementById([clearElementId]).src = this.serverAddress + "/images/search/checkbox-checked.gif";
			}
			else
			{				
				document.getElementById([clearElementId]).src = this.serverAddress + "/images/search/checkbox-unchecked.gif";
			}
		}
			
		// Set the 'disabled' property of the specified element.
		function setDisabled(elementName, disabledText)
		{
			// Enable or disabled the specified element.
			var length = document.getElementsByName(elementName).length;
			for (var index=0; index <= length - 1; index++)
			(
				document.getElementsByName(elementName).item(index).disabled = disabledText
			)
		}

	}