/* -------------------------------------------------------------
	Guns & Ammo
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Description:	MOOTools Custom Classes
	Filename:		script_main.js
	Version:		1.4
	Date:			17 March 2008
	Dependencies:	script_mootools.js
------------------------------------------------------------- 

Table of Contents (subject to change):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	+ CustomCaption
	+ BubbleDialog

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
*/


/* -------------------------------------------------------------
	Custom Caption
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

// R.T.
var CustomCaption = new Class({

	/* Class Properties
	**********************************************************/

	captionWrapperClass : 'caption_wrapper', // Default
	createRoundedEdgeContainers : false, // Default
	
	adoptedClass : '',
	captionedElement : {},
	
	
	/* Class Methods
	**********************************************************/
	
	initialize : function(
						  captionedElement,
						  captionWrapperClass,
						  adoptedClass,
						  createRoundedEdgeContainers)
	{
		// Assign property values
		this.setCaptionedElement(captionedElement);
		this.setCaptionWrapperClass(captionWrapperClass);
		this.setAdoptedClass(adoptedClass);
		this.setCreateRoundedEdgeContainers(createRoundedEdgeContainers);
		
		// Generate caption
		this.generateCaption();
	},

	generateCaption : function()
	{
		var element = this.captionedElement;
		
		var elementWidth = Number(element.getCoordinates().width);
		var elementCaption = String(element.getProperty('title'));
		
		var captionWrapper = {};
		var captionElement = {};
		
		// Remove class
		element.removeClass(this.adoptedClass);
		
		// Create wrapper
		captionWrapper = new Element('div',
		{
			'class' : this.captionWrapperClass,
			
			'styles' : {
				'width' : elementWidth
			}
		});
		
		captionElement = new Element('p');
		captionElement.setHTML(elementCaption);
		
		// Append respective Float Class
		captionWrapper.addClass(this.adoptedClass);
		
		// Inject into DOM, above captionedElement
		captionWrapper.injectBefore(element);
		
		// Adopt captionedElement
		captionWrapper.adopt(element);
		
		// Inject caption element (paragraph) into wrapper
		captionElement.injectAfter(element);
		
		
		// Create containers for rounded edges?
		if (this.createRoundedEdgeContainers === true)
		{			
			this.generateRoundedEdgeContainers(captionElement);
		}
	},
	
	generateRoundedEdgeContainers : function(captionElement)
	{
		// Create header containers
		var captionHeaderLeft = new Element('span',
		{
			'class' : 'caption_header_left'
		});
		
		var captionHeaderRight = new Element('span',
		{
			'class' : 'caption_header_right'
		});

		// Create footer containers
		var captionFooterLeft = new Element('span',
		{
			'class' : 'caption_footer_left'
		});
		
		var captionFooterRight = new Element('span',
		{
			'class' : 'caption_footer_right'
		});
		
		// Inject header and footer elements
		captionHeaderLeft.injectTop(captionElement);
		captionHeaderRight.injectTop(captionElement);
		
		captionFooterLeft.injectInside(captionElement);
		captionFooterRight.injectInside(captionElement);
	},
	
	
	/* Property Accessors & Mutators
	**********************************************************/
	
	// Captioned Element
	getCaptionedElement : function()
	{
		return this.captionedElement;
	},
	
	setCaptionedElement : function(captionedElement)
	{
		try
		{
			this.captionedElement = captionedElement;
		}
		catch (exception)
		{
			console.log("Captioned element could not be set: " + exception);
		}
	},
	
	// Caption Wrapper
	getCaptionWrapperClass : function()
	{
		return this.captionWrapperClass;
	},
	
	setCaptionWrapperClass : function(captionWrapperClass)
	{
		if (captionWrapperClass != undefined)
		{
			this.captionWrappperClass = captionWrapperClass;
		}
	},
	
	// Adopted Class
	getAdoptedClass : function()
	{
		return this.adoptedClass;
	},
	
	setAdoptedClass : function(adoptedClass)
	{
		if (adoptedClass != undefined)
		{
			this.adoptedClass = adoptedClass;
		}
	},
	
	// Rouneded Edge Containers
	getCreateRoundedEdgeContainers : function()
	{
		return this.createRoundedEdgeContainers;
	},
	
	setCreateRoundedEdgeContainers : function(createRoundedEdgeContainers)
	{
		if (createRoundedEdgeContainers === true || createRoundedEdgeContainers === false)
		{
			this.createRoundedEdgeContainers = createRoundedEdgeContainers;
		}
	}
	
}); // CustomCaption Class





/* -------------------------------------------------------------
	Bubble Dialog
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

// R.T.
var BubbleDialog = new Class({

	/* Class Properties
	**********************************************************/
	
	bubbleStyleClass : 'bubble_dialog', // Default
	bubbleHeaderStyleClass : 'bubble_header',
	bubbleFooterStyleClass : 'bubble_footer',
	bubbleInverseHorizontalStyleClass : 'bubble_inverse_horizontal',
	bubbleInverseVerticalStyleClass : 'bubble_inverse_vertical',
	hideTriggerStyleClass : 'close_button',
	useAnimation : false, // Default : Value is ignored in IE6 and set to false
	skipInitialAnimation : true, // Default
	isVisible : false, // Default
	animationSpeed : 300, // In milliseconds
	alignAbove : false,
	alignRight : false,
	autoAdjustAlignment : true,
	xOffset : 0, // Default : Becomes negative if 'alignRight' is 'true'
	yOffset : 0, // Default : Becomes negative if 'alignAbove' is 'true'
	
	bubbleTrigger : {},
	bubbledElement : {},
	bubbleAnimationObject : null,
	innerHTMLValue : '',
	alignWithElement : null,
	
	
	/* Class Methods
	**********************************************************/
	
	// Constructor
	initialize : function(
						  bubbleTrigger,
						  bubbledElement,
						  bubbleStyleClass,
						  useAnimation,
						  isVisible,
						  alignAbove,
						  alignWithElement,
						  innerHTMLValue)
	{
		// Assign property values
		this.setBubbleTrigger(bubbleTrigger);
		this.setInnerHTMLValue(innerHTMLValue);
		this.setBubbledElement(bubbledElement);
		this.setBubbleStyleClass(bubbleStyleClass);
		this.setAlignAbove(alignAbove);
		this.setAlignWithElement(alignWithElement);
		this.setUseAnimation(useAnimation);
		
		// Define bubble properties before element is hidden
		this.defineBubbleDialogProperties(this.getBubbledElement());
		
		this.setIsVisible(isVisible);
		
		// Create Bubble Dialog
		this.createBubbleDialog();
		
		// Push to static instanc array member
		BubbleDialog.instanceArray.push(this);
	},
	
	createBubbleDialog : function()
	{
		var bubbledElement = this.getBubbledElement();
		var bubbleTrigger = this.getBubbleTrigger();
		var bubbleStyleClass = this.getBubbleStyleClass();
		var hideTriggerStyleClass = this.hideTriggerStyleClass;
		
		var triggerParent = bubbleTrigger.parentNode;
		var superObject = this;
		
		// Create header / footer elements
		var bubbleHeader = new Element('div');
		bubbleHeader.addClass(this.bubbleHeaderStyleClass);
		
		var bubbleFooter = new Element('div');
		bubbleFooter.addClass(this.bubbleFooterStyleClass);
		
		// Inject header and footer into bubbled element
		bubbleHeader.injectTop(bubbledElement);
		bubbleFooter.injectInside(bubbledElement);
		
		// Inject bubbled element into document body
		bubbledElement.injectInside(document.body);

		// Define animation if applicable
		this.defineBubbleAnimation();
		
		// Show / hide bubble dialog
		if (this.getIsVisible() === false)
		{
			this.hideBubbleDialog(bubbledElement, this.skipInitialAnimation);
		}
		else if (this.getIsVisible() === true)
		{
			this.showBubbleDialog(bubbledElement, this.skipInitialAnimation);
		}
		
		// Define trigger 'click' event
		bubbleTrigger.addEvent('click', function(e)
		{
			// Cancel default event
			var e = new Event(e).stop();
			
			// Show / Hide bubble dialog
			if (superObject.getIsVisible() === false)
			{
				superObject.showBubbleDialog(bubbledElement);
			}
			else if (superObject.getIsVisible() === true)
			{
				superObject.hideBubbleDialog(bubbledElement);
			}
		});
		
		// Create hide trigger element
		var hideTrigger = new Element('span');
		hideTrigger.addClass(hideTriggerStyleClass);
		hideTrigger.setHTML('close');
		
		// Inject into bubbled element
		hideTrigger.injectTop(bubbledElement);
		
		// Assign Bubble hide state to new element
		this.defineBubbleHideTrigger(hideTrigger);
	},
	
	defineBubbleDialogProperties : function(bubbledElement)
	{
		var bubbledElement = bubbledElement || this.getBubbledElement();
		
		// Assign bubble style class
		bubbledElement.addClass(this.getBubbleStyleClass());
		
		// Inject bubbled element into document body and temporarily hide
		bubbledElement.injectInside(document.body);
		bubbledElement.setStyles({ left : '-9000px' });
	},
	
	positionBubbleDialog : function(bubbledElement)
	{
		var bubbledElement = bubbledElement || this.getBubbledElement();
		var alignmentElement = this.getBubbleTrigger(); // alignWithElement
		var alignWithElement = this.getAlignWithElement();
		
		// Verify that alignment should be to trigger element
		if (alignWithElement !== null)
		{
			alignmentElement = alignWithElement;
		}
		
		var alignmentProperties = alignmentElement.getCoordinates();
		
		var alignAbove = this.getAlignAbove();
		var alignRight = this.alignRight;
		var autoAdjustAlignment = this.autoAdjustAlignment;
		
		var windowWidth = window.getScrollWidth();
		var windowHeight = window.getScrollHeight();
		
		var bubbleInverseVerticalStyleClass = this.bubbleInverseVerticalStyleClass;
		var bubbleInverseHorizontalStyleClass = this.bubbleInverseHorizontalStyleClass;
		
		var bubbleProperties;
		
		// Assign temporary hidden positioning
		bubbledElement.setStyles({
			top : '-9000em',
			left : '-9000em'
		});
		
		// Make visible so that coordinates can be gathered
		//this.bubbleAnimationObject.set(1);
		this.setIsVisible(true);
		
		// Gather properties
		bubbleProperties = bubbledElement.getCoordinates();
		
		// Values assigned, hide element
		//this.bubbleAnimationObject.set(0);
		this.setIsVisible(false);
		
		
		// Assign default positioning
		bubbledElement.setStyles({
			top : alignmentProperties.top + (alignmentProperties.height + this.yOffset),
			left : alignmentProperties.left + this.xOffset
		});
		
		// Define extreme right and bottom boundaries
		var bubbleTotalX = alignmentProperties.left + bubbleProperties.width;
		var bubbleTotalY = alignmentProperties.top + bubbleProperties.height;
		
		// Verify that Bubble does not exceed horizontal boundaries
		if (bubbleTotalX > windowWidth && 
			autoAdjustAlignment === true &&
			alignRight === false)
		{
			bubbledElement.addClass(bubbleInverseHorizontalStyleClass);
			
			// Element exceeds boundaries, adjust alignment
			alignRight = true;
		}
		else if (bubbleTotalX < 0 &&
				 autoAdjustAlignment === true &&
				 alignRight === true)
		{
			bubbledElement.addClass(bubbleInverseHorizontalStyleClass);
			
			// Element exceeds boundaries, adjust alignment
			alignRight = false;
		}
		
		// Verify that Bubble does not exceed vertical boundaries
		if (bubbleTotalY > windowHeight && 
			autoAdjustAlignment === true &&
			alignAbove === false)
		{
			bubbledElement.addClass(bubbleInverseVerticalStyleClass);
			
			// Element exceeds boundaries, adjust alignment
			alignAbove = true;
		}
		else if (bubbleTotalY < 0 &&
				 autoAdjustAlignment === true &&
				 alignAbove === true)
		{
			bubbledElement.addClass(bubbleInverseVerticalStyleClass);
			
			// Element exceeds boundaries, adjust alignment
			alignAbove = false;
		}
		
		// Align dialog above or below trigger?
		if (alignAbove === true)
		{
			bubbledElement.setStyles({
				top : alignmentProperties.top - (bubbleProperties.height + this.yOffset)
			});
			console.log(alignmentProperties.top);
			console.log(bubbleProperties.height);
		}
		
		// Align dialog to left or right?
		if (alignRight === true)
		{
			bubbledElement.setStyles({
				left : alignmentProperties.left - (bubbleProperties.width + this.xOffset) + alignmentProperties.width
			});
		}
	},
	
	defineBubbleHideTrigger : function(bubbleHideTrigger)
	{
		var superObject = this;
		
		// If hide trigger is undefined, bubble element becomes trigger
		if (bubbleHideTrigger === undefined)
		{
			var bubbleHideTrigger = this.getBubbledElement();
		}
		
		bubbleHideTrigger.addEvent('click', function(e)
		{
			var e = new Event(e).stop();
			
			// Hide bubble dialog
			superObject.hideBubbleDialog();
		});
	},
	
	defineBubbleAnimation : function()
	{
		var superObject = this;
		
		if (this.bubbleAnimationObject === null)
		{
			var bubbledElement = this.getBubbledElement();
			this.bubbleAnimationObject = new Fx.Style(bubbledElement, 'opacity',
			{
				duration : superObject.animationSpeed,
				
				onComplete : function()
				{
					var hiddenValue = 0;
					var visibleValue = 1;
					var opacityValue = Number(bubbledElement.style.opacity);
					
					// Modify visibility value
					if (opacityValue === hiddenValue)
					{
						superObject.setIsVisible(false);
					}
					else if (opacityValue === visibleValue)
					{
						superObject.setIsVisible(true);
					}
				}
			});
		}
	},
	
	showBubbleDialog : function(bubbledElement, skipAnimation)
	{
		// Hide currently open dialogs
		this.hideOpenDialogs();
		
		// Verify that bubbled element is defined
		if (bubbledElement === undefined)
		{
			var bubbledElement = this.getBubbledElement();
		}
		
		// Reposition
		this.positionBubbleDialog(bubbledElement);
		
		// Show animation?
		if (this.getUseAnimation() === true && 
			skipAnimation !== true && 
			this.bubbleAnimation !== null)
		{
			// Set to transparent to prevent flicker
			this.bubbleAnimationObject.set(0);
			this.setIsVisible(true);
			
			// Initiate animation
			this.bubbleAnimationObject.start(0, 1);
		}
		else
		{
			// Change visibility property			
			this.setIsVisible(true);
		}
	},
	
	hideBubbleDialog : function(bubbledElement, skipAnimation)
	{
		// Verify that bubbled element is defined
		if (bubbledElement === undefined)
		{
			var bubbledElement = this.getBubbledElement();
		}
		
		// Show animation?
		if (this.getUseAnimation() === true && 
			skipAnimation !== true &&
			this.bubbleAnimation !== null)
		{
			// Set to visible to prevent flicker
			this.bubbleAnimationObject.set(1);
			
			// Initiate animation
			this.bubbleAnimationObject.start(1, 0);
		}
		else
		{
			// Change visibility property
			this.setIsVisible(false);
		}
	},
	
	generateBubbledElement : function()
	{
		// If bubbled element is not passed in to constructor, 
		// create new element and pass back to class property
		var newBubbledElement = new Element('div');
		newBubbledElement.setHTML(this.getInnerHTMLValue());
		
		this.setBubbledElement(newBubbledElement);
	},
	
	hideOpenDialogs : function()
	{
		var instanceArray = BubbleDialog.instanceArray;
		var instanceArrayLength = instanceArray.length;
		
		// Loop through instances
		for (var i = 0; i < instanceArrayLength; i++)
		{
			var currentBubble = instanceArray[i];
			
			// Close all instances except this
			if (currentBubble !== this)
			{
				currentBubble.hideBubbleDialog();
			}
		}
	},
	
	
	/* Property Accessors & Mutators
	**********************************************************/
	
	// Bubble Trigger
	getBubbleTrigger : function()
	{
		return this.bubbleTrigger;
	},
	
	setBubbleTrigger : function(bubbleTrigger)
	{
		// Is bubbledElement value string or object?
		if ($type(bubbleTrigger) === 'string')
		{
			bubbleTrigger = $(bubbleTrigger);
		}
		
		this.bubbleTrigger = bubbleTrigger;
	},
	
	// Bubbled Element
	getBubbledElement : function()
	{
		return this.bubbledElement;
	},
	
	setBubbledElement : function(bubbledElement)
	{
		// Is bubbledElement value string or object?
		if ($type(bubbledElement) === 'string')
		{
			bubbledElement = $(bubbledElement);
		}
		
		// Verify that value is not null or undefined
		if (bubbledElement != undefined && 
			bubbledElement != null)
		{
			this.bubbledElement = bubbledElement;
		}
		else
		{
			// Bubbled Element is null, create new on
			this.generateBubbledElement();
		}
	},
	
	// Bubble Class
	getBubbleStyleClass : function()
	{
		return this.bubbleStyleClass;
	},
	
	setBubbleStyleClass : function(bubbleStyleClass)
	{
		// Verify that value is not null or undefined
		if (bubbleStyleClass != undefined &&
			bubbleStyleClass != null)
		{
			this.bubbleStyleClass = bubbleStyleClass;
		}
	},
	
	// Visibility
	getIsVisible : function()
	{
		return this.isVisible;
	},
	
	setIsVisible : function(isVisible)
	{
		// Verify that value is boolean
		if (isVisible === true)
		{
			// Show element
			this.isVisible = isVisible;
			this.getBubbledElement().setStyle('display', 'block');
			this.getBubbledElement().setStyle('visibility', 'visible');
			this.getBubbledElement().setStyle('opacity', '100');
		}
		else if (isVisible === false)
		{
			// Hide element
			this.isVisible = isVisible;
			this.getBubbledElement().setStyle('display', 'none');
			this.getBubbledElement().setStyle('visibility', 'hidden');
			this.getBubbledElement().setStyle('opacity', '0');
		}
	},
	
	// Inner HTML Value
	getInnerHTMLValue : function()
	{
		return this.innerHTMLValue;
	},
	
	setInnerHTMLValue : function(innerHTMLValue)
	{
		// Verify that value is not null or undefined
		if (innerHTMLValue != undefined && 
			innerHTMLValue != null)
		{
			this.innerHTMLValue = innerHTMLValue;
		}
	},
	
	// Animate bubbles?
	getUseAnimation : function()
	{
		return this.useAnimation;
	},
	
	setUseAnimation : function(useAnimation)
	{
		// If browser is IE6, do not use animation
		if (window.ie6)
		{
			this.useAnimation = false;
		}
		else
		{
			// Verify that value is not null or undefined
			if (useAnimation != undefined && 
				useAnimation != null)
			{
				this.useAnimation = useAnimation;
			}
		}
	},
	
	// Align above?
	getAlignAbove : function()
	{
		return this.alignAbove;
	},
	
	setAlignAbove : function(alignAbove)
	{
		// Verify that value is boolean
		if (alignAbove === true || 
			alignAbove === false)
		{
			if (this.alignAbove !== alignAbove)
			{
				this.getBubbledElement().addClass(this.bubbleInverseVerticalStyleClass);
				this.alignAbove = alignAbove;
			}
		}
	},
	
	// Element to use as alignment instead of trigger
	getAlignWithElement : function()
	{
		return this.alignWithElement;
	},
	
	setAlignWithElement : function(alignWithElement)
	{
		// Verify that value is boolean
		if (alignWithElement !== undefined && 
			alignWithElement !== null)
		{
			this.alignWithElement = alignWithElement;
		}
	}
	
}); // BubbleDialog Class
BubbleDialog.instanceArray = []; // BubbleDialog static member



/* -------------------------------------------------------------
	Custom Select
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

// R.T.
var CustomSelect = new Class({
							 
/* --- Class Properties: Static --- */

	customSelectClass : 'custom_select',
	customSelectID : 'customSelect_',
	
/* --- Class Properties: Dynamic --- */

	element : {},
	parent : {},
	customSelectElement : {},
	optionsList : null,
	currentState : null,
	currentIndex : 0,
	instanceID : null,
	width : null,
	height : null,
	isOpen : false,
	
/* --- Class Methods --- */
	
	// Constructor
	initialize : function(element, instanceID)
	{
		this.element = element;
		this.instanceID = instanceID;
		
		// Collect element properties
		this.gatherElementProperties();
	},
	
	hideSelectElement : function()
	{
		this.element.setStyle('display', 'none');
	},
	
	gatherElementProperties : function()
	{
		var elementProperties = this.element.getCoordinates();
		var nodeArray = this.gatherElementValues(this.element.getChildren());
		
		this.parent = this.element.getParent();
		
		this.width = elementProperties.width;
		//this.height = elementProperties.height + this.heightBuffer;
		
		// Hide select element
		this.hideSelectElement();
		
		// Generate custom select
		this.generateCustomSelect(nodeArray);
	},
	
	gatherElementValues : function(elementChildren)
	{
		var nodeArray = [];
		// Push child nodes to values array
		elementChildren.each(function(childElement, i)
		{
			nodeArray.push({
				name : String(childElement.innerHTML),
				value : String(childElement.value),
				index : Number(i),
				selected : childElement.selected
			});
		});
		
		return nodeArray;
	},
	
	checkElementWidth : function()
	{
		var parentElement = this.parent;
		
		var initialElementWidth = this.width;
		var parentElementWidth = Number(parentElement.getCoordinates().width);
		var newWidth = 0;
		
		// Store width value for select element width
		this.initialWidth = initialElementWidth;
		
		if (initialElementWidth > parentElementWidth)
		{
			newWidth = parentElementWidth;
		}
		else
		{
			newWidth = initialElementWidth;
		}
		
		// Adjust width
		this.width = newWidth;
	},
	
	generateCustomSelect : function(nodeArray)
	{
		var superObject = this;
		
		// Check element width before generation
		this.checkElementWidth();
		
		this.customSelectElement = new Element('div',
		{
			'id' : superObject.customSelectID + superObject.instanceID,
			'class' : superObject.customSelectClass,
			
			'styles' : {
				'width' : superObject.width
				//height : this.height
			}
			
		});
		
		var currentState = new Element('strong',
		{
			'styles' : {
				'overflow-y' : 'hidden'
			},
									   
			events : {
				
				'click' : function()
				{
					// Check open state
					if (superObject.isOpen === true)
					{
						superObject.showSelectOptions(false);
					}
					else
					{
						superObject.showSelectOptions(true);
					}
				}
				
			} // events
			
		});
		
		var optionsList = new Element('ul',
		{
			styles : {
				'display' : 'none',
				'width' : superObject.initialWidth
			}, // styles
			
			events : {
				
				'mouseleave' : function()
				{
					// Check open state
					if (superObject.isOpen === true)
					{
						superObject.showSelectOptions(false);
					}
				}
				
			} // events
			
		}); // new Element
		
		// Define child elements
		nodeArray.each(function(valueElement, i)
		{
			// Set currentIndex
			if (valueElement.selected)
			{
				superObject.currentIndex = i;
			}
			
			// Create new item
			var newChildElement = new Element('li',
			{
				styles : {
					'width' : superObject.initialWidth
				},
				
				rel : valueElement.value || valueElement.name || 0,
				
				selected : valueElement.selected,
				
				events : {
					
					'click' : function()
					{
						superObject.setActiveOption(valueElement);
					}
					
				} // events
				
			});
			
			newChildElement.setText(valueElement.name);
			
			newChildElement.injectInside(optionsList);
		});
		
		this.optionsList = optionsList;
		
		// Inject first item
		currentState.injectInside(this.customSelectElement);
		
		this.currentState = currentState;
		
		this.setActiveOption(nodeArray[this.currentIndex]);
		
		// Inject options list element
		optionsList.injectInside(this.customSelectElement);
		
		// Inject into DOM
		this.customSelectElement.injectBefore(this.element);
	},
	
	showSelectOptions : function(showOptions)
	{
		if (showOptions === true)
		{
			this.optionsList.setStyle('display', 'block');
			
			// Set state to Open
			this.isOpen = true;
		}
		else
		{
			this.optionsList.setStyle('display', 'none');
			
			// Set state to Close
			this.isOpen = false;
		}
	},
	
	setActiveOption : function(option)
	{
		this.currentState.setText(option.name);
		this.currentState.value = option.value;
		
		if (this.element.selectedIndex !== option.index)
		{
			this.element.selectedIndex = option.index;
			
			if (this.element.onchange)
			{
				this.element.onchange();
			}
		}
		
		this.showSelectOptions(false);
	}
	
}); // Class
