/*******************************************************************************************
 * optionMenu
 * Written by Craig Francis
 * If there is a <select> field being used for navigation (causing accessibility problems),
 * then this JavaScript will make this drop down "work".
 *******************************************************************************************/

	var optionMenu = new function () {

		//--------------------------------------------------
		// Do not allow older browsers to run this script

			if (!document.getElementById || !document.getElementsByTagName) {
				return;
			}

		//--------------------------------------------------
		// Initialisation function used for setup

			this.init = function () {

				//--------------------------------------------------
				// Process all the <selects>'s on this page

					var selects = document.getElementsByTagName('select');

					for (var i = (selects.length - 1); i >= 0; i--) {
						if (cssjs('check', selects[i], 'jsOptionMenu')) {

							selects[i].onchange = function () {
								var form = getParent(this, 'form');
								if (form) {
									form.submit();
								}
							}

						}
					}

			}

		//--------------------------------------------------
		// Set JS specific styles ready for page load

			addCssRule('form input.jsOptionMenuSubmit { position: absolute; left: -5000px; width: 10em; }');

		//--------------------------------------------------
		// When the page has loaded, run the init function

			addLoadEvent (function() {
				optionMenu.init();
			});

	}
