/**
 * @fileoverview JavaScript functions used for form pages.
 * Most functions use the DOMAssistant utility library for efficiency.
 * More information: http://www.domassistant.com/
 */

/**
 * @requires DOMAssistant
 * Validate user input in forms.
 */
var seFormValidation = function () {
	var config = {
		sValidateClass: 'validate',
		sHiddenClass: 'hidden',
		sRequiredClass: 'required',
		sErrorClass: 'error',
		sConfirmedClass: 'confirmed',
		sDisabledClass: 'disabled',
		sMakeRequiredPrefix: 'require-'
	};
	/**
	 * Initialise form validation triggers.
	 */
	function init(props) {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		// If any properties were supplied, apply them to the config Object.
		for (var key in props) {
			if (config.hasOwnProperty(key)) {
				config[key] = props[key];
			}
		}
		var arrValidateForms = $("form." + config.sValidateClass);
		var sErrorText;
		var oForm;
		var arrTitledElements;
		var oTitledElement;
		var sTagName;
		var oRegExp = new RegExp(config.sMakeRequiredPrefix + '([^\s"]+)');
		var sInputId;
		for (var i = 0, len = arrValidateForms.length; i < len; i++) {
			oForm = arrValidateForms[i];
			// Find all checkboxes in the form
			$(oForm).elmsByAttribute('type', 'checkbox', 'input').each(function () {
				// If the checkbox requires a text field to be filled in
				if (this.className.match(oRegExp)) {
					// Get the id of the input field to make required and check that it exists
					sInputId = oRegExp.exec(this.className)[1];
					oInput = document.getElementById(sInputId);
					if (oInput) {
						// Toggle the validate and required class names when the checkbox is activated
						$(this).addEvent('click', function () {
							if ($(oInput).hasClass(config.sValidateClass)) {
								$(oInput).removeClass(config.sValidateClass);
								$(oInput).removeClass(config.sRequiredClass);
							} else {
								$(oInput).addClass(config.sValidateClass);
								$(oInput).addClass(config.sRequiredClass);
							}
						});
					}
				}
			});
			$(oForm).addEvent('submit', function (e) {
				if (!validateForm(this)) {
					DOMAssistant.preventDefault(e);
				}
			});
		}
	}
	/**
	 * Perform validation of input fields.
	 */
	function validateForm(oForm) {
		var oFieldContainers;
		var oFields;
		var iFields;
		var oField;
		var sTagName;

		// Check that required text fields aren't empty
		oFields = $(oForm).elmsByClass(config.sRequiredClass);
		for (var i = 0, len = oFields.length; i < len; i++) {
			oField = oFields[i];
			if (!$(oField).hasClass(config.sDisabledClass)) {
				sTagName = oField.tagName.toLowerCase();
				if (((sTagName === 'input') && (oField.type === 'text') || (sTagName === 'textarea')) && (oField.value === '')) {
					displayError(oField, oField.parentNode);
					oField.focus();
					return false;
				} else {
					removeError(oField.parentNode);
				}
			}
		}

		// Check length and format of passwords
		oFields = $(oForm).elmsByAttribute('type', 'password', 'input');
		for (i = 0, len = oFields.length; i < len; i++) {
			oField = oFields[i];
			if ((oField.value !== '') || (/\brequired\b/.exec(oField.className))) {
				if (!/[a-zA-Z0-9]{6,}/.exec(oField.value)) {
					displayError(oField, oField.parentNode);
					oField.focus();
					return false;
				} else  {
					removeError(oField.parentNode);
				}
			}
		}

		// Check for identical values in fields that require it
		oFields = document.getElementsByTagName('input');
		var temp = [];
		var compareFieldToId;
		for (i = 0, len = oFields.length; i < len; i++) {
			oField = oFields[i];
			// Find all input elements with 'compare-' in their class attribute
			if (/compare-/.test(oField.className)) {
				// Get the id of the input element to compare with
				temp = oField.className.substring(oField.className.indexOf('compare-') + 8, oField.className.length).split(' ');
				compareFieldToId = temp[0];
				if (document.getElementById(compareFieldToId).value !== oField.value) {
					displayError(oField, oField.parentNode);
					oField.focus();
					return false;
				}
			} else {
				removeError(oField.parentNode);
			}
		}

		// Check that required select fields aren't empty
		oFields = $(oForm).elmsByClass('required', 'select');
		for (i = 0, len = oFields.length; i < len; i++) {
			oField = oFields[i];
			if (oField.selectedIndex === 0) {
				displayError(oField, oField.parentNode);
				oField.focus();
				return false;
			} else {
				removeError(oField.parentNode);
			}
		}

		// If all checks passed, return true to let the form submit
		return true;
	}
	/**
	 * Display a validation error by creating a new label element with the error text.
	 */
	function displayError(objTitle, objErrorContainer) {
		var sTagName = objTitle.tagName.toLowerCase();
		var sErrorMessage = objTitle.title;
		if (sErrorMessage === '') {
			sErrorMessage = 'This field is required or needs a different kind of value. Please recheck what you have entered.';
		}
		if ($(objTitle).hasClass(config.sValidateClass)	&& ((sTagName === 'input') || (sTagName === 'select') || (sTagName === 'textarea') || (sTagName === 'fieldset')) && !$(objErrorContainer).hasClass(config.sErrorClass)) {
			var oError = document.createElement('p');
			oError.className = config.sErrorClass;
			var oErrorLabel = document.createElement('label');
			oErrorLabel.htmlFor = objTitle.id;
			oErrorLabel.appendChild(document.createTextNode(sErrorMessage));
			oError.appendChild(oErrorLabel);
			if (objTitle.tagName.toLowerCase() === 'fieldset') {
				objTitle.appendChild(oError);
			}
			else {
				objTitle.parentNode.appendChild(oError);
			}
		}
		$(objErrorContainer).addClass(config.sErrorClass);
		$(objErrorContainer).removeClass(config.sConfirmedClass);
	}
	/**
	 * Remove a validation error by removing the element.
	 */
	function removeError(obj) {
		if ($(obj).hasClass(config.sErrorClass)) {
			$(obj).removeClass(config.sErrorClass);
			$(obj).addClass(config.sConfirmedClass);
			var oError = $(obj).elmsByClass(config.sErrorClass)[0];
			if ($(oError).hasClass(config.sErrorClass)) {
				oError.parentNode.removeChild(oError);
			}
		}
	}
	function checkLength(str, min, max) {
		if ((str.length >= min) && (str.length <= max)) {
			return true;
		}
		return false;
	}
	function containsNumber(str) {
		if (/[0-9]/.exec(str)) {
			return true;
		}
		return false;
	}
	function isAlphaNumeric(str) {
		if (/^[0-9a-zA-Z.-]+$/.exec(str)) {
			return true;
		}
		return false;
	}
	return {
		init: init,
		removeError: removeError
	};
}();

/**
 * @requires DOMAssistant
 * Converts an incoming value to a different unit or currency, and
 * populates an output field with the resulting value.
 */
var seCF = function() {
    var config = {
        sContainerClass: 'converter-form', // className for the elements the function should look inside
        sSubmitClass: 'convert', // className for the buttons that trigger the script
        sValueClass: 'value', // className for the input field that receives user input
        sConvClass: 'conversion', // className for select elements deciding the conversion type
        sResultClass: 'result', // className for the input field that holds the result
        sErrorMessage: 'Please enter a numeric value.', // Error message displayed on incorrect input
        sErrorClass: 'error' // className that indicates incorrect input
    };
    var arrC = Array(20); // Array that holds conversion rates
    function init(props) {
        // Check for DOM support
        if (!document.getElementById || !document.createTextNode) {
            return;
        }
        // If any properties were supplied, apply them to the config Object.
        for (var key in props) {
            if (config.hasOwnProperty(key)) {
                config[key] = props[key];
            }
        }
        // Unit conversion rates
        arrC[0] = 0.454;
        arrC[1] = 2.2;
        arrC[2] = 0.3046;
        arrC[3] = 1 / arrC[2];
        arrC[4] = 2.47;
        arrC[5] = 1 / arrC[4];
        arrC[6] = 1.1;
        arrC[7] = 1 / arrC[6];
        arrC[8] = 1.48;
        arrC[9] = 1 / arrC[8];
        var arrForms = DOMAssistant.$(document).elmsByClass(config.sContainerClass); // Find the container elements
        var oSubmit;
        for (var i = 0, len = arrForms.length; i < len; i++) { // Look inside each container element
            (function() {
                var oForm = arrForms[i];
                // Find the submit button and attach an onclick event handler to it
                oSubmit = DOMAssistant.$(oForm).elmsByClass(config.sSubmitClass, 'input')[0];
                DOMAssistant.$(oSubmit).addEvent('click', function() {
                    convert(oForm);
                });
            })();
        }
    }
    /**
    * Performs the conversion
    * @param {Object} oForm The container element (as a standard DOM form)
    */
    function convert(inForm) {
        // the "oXxx" assigned here are all DOMAssistant augmented objects
        var oForm = DOMAssistant.$(inForm);
        var oValue = oForm.elmsByClass(config.sValueClass)[0];
        var oConvType = oForm.elmsByClass(config.sConvClass)[0];
        var oResult = oForm.elmsByClass(config.sResultClass)[0];
        var oValueParentNode = DOMAssistant.$(oValue.parentNode);
        if (oValue && oConvType && oResult) { // Make sure all necessary form elements exist
            var fResult;
            var fValue = parseFloat(oValue.value.replace(',', '.')); // Allow , or . as decimal point
            var iConvType = oConvType[oConvType.selectedIndex].value;
            if (iConvType == 10) { // Celsius - Fahrenheit
                fResult = (fValue * 9 / 5) + 32;
            }
            else if (iConvType == 11) { // Fahrenheit - Celsius
                fResult = (fValue - 32) * 5 / 9;
            }
            else {
                fResult = parseFloat(arrC[iConvType] * fValue);
            }
            fResult = roundOff(fResult, 4);
            if (fResult === false) {
                if (!oValueParentNode.hasClass(config.sErrorClass)) {
                    var oError = document.createElement('p');
                    oError.className = config.sErrorClass;
                    var oLabel = document.createElement('label');
                    oLabel.htmlFor = oValue.id;
                    oLabel.appendChild(document.createTextNode(config.sErrorMessage));
                    oError.appendChild(oLabel);
                    oValue.errorMessage = oError;
                    oValue.parentNode.appendChild(oError);
                    oValueParentNode.addClass(config.sErrorClass);
                    oResult.value = '';
                    oValue.focus();
                    oValue.select();
                }
            }
            else {
                // Populate the result field
                oResult.value = fResult;
                // Remove error message if it exists
                if (oValueParentNode.hasClass(config.sErrorClass)) {
                    oValueParentNode.removeClass(config.sErrorClass);
                    oValue.parentNode.removeChild(oValue.errorMessage);
                }
            }
        }
    }
    /**
    * Rounds the result to 4 decimals and returns a warning message if the result is not a number
    * @param {Number} value The result value
    * @param {Number} precision The rounding precision
    */
    function roundOff(value, precision) {
        if (isNaN(value)) {
            return false;
        }
        var decimal = Math.pow(10, precision);
        if (value * decimal >= 1 || value * -1 * decimal >= 1) {
            temp = Math.round(value * decimal);
            return (temp / decimal);
        }
        return 0;
    }
    return {
        init: init,
        arrC: arrC
    };
} ();

/**
 * @requires DOMAssistant
 */
var seZF = function () {
	var config = {
		sContainerClass: 'download-form', // className for the element the function should look inside
		sSizeClass: 'size', // className for the elements displaying calculated size
		sSizeTotalId: 'size-total', // id for the element displaying total size
		sSizeCompressedId: 'size-compressed', // id for the element displaying compressed size
		sSizeTotal: ' kB, total file size', // String displayed after total size
		sSizeCompressed: ' kB, total compressed file size (estimated)' // String displayed after compressed size
	};
	function init(props) {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		// If any properties were supplied, apply them to the config Object.
		for (var key in props) {
			if (config.hasOwnProperty(key)) {
				config[key] = props[key];
			}
		}
		var oForm = $(document).elmsByClass(config.sContainerClass)[0]; // Find the container element
		if (!oForm) {
			return;
		} // Abort if no form container is found
		var oTable = oForm.getElementsByTagName('table')[0];
		if (!oTable) {
			return;
		} // Abort if no table is found in the form container
		var arrCheckboxes = oTable.getElementsByTagName('input');
		var iCheckboxes = arrCheckboxes.length;
		if (!iCheckboxes) {
			return;
		} // Abort if no input elements are found
		// Create the elements that display calculated file size
		var oSize1 = document.createElement('div');
		oSize1.className = config.sSizeClass;
		var oSizeCounter1 = document.createElement('span');
		oSizeCounter1.appendChild(document.createTextNode('0'));
		oSizeCounter1.id = config.sSizeTotalId;
		oSize1.appendChild(oSizeCounter1);
		oSize1.appendChild(document.createTextNode(config.sSizeTotal));
		oForm.insertBefore(oSize1, oTable.nextSibling);

		var oSize2 = document.createElement('div');
		oSize2.className = config.sSizeClass;
		var oSizeCounter2 = document.createElement('span');
		oSizeCounter2.appendChild(document.createTextNode('0'));
		oSizeCounter2.id = config.sSizeCompressedId;
		oSize2.appendChild(oSizeCounter2);
		oSize2.appendChild(document.createTextNode(config.sSizeCompressed));
		oForm.insertBefore(oSize2, oSize1.nextSibling);

		var oCheckbox;
		var oSize;
		var iSize;
		var oExt;
		var sExt;
		var zipRatio;
		var zipSize;
		for (var i = 0; i < iCheckboxes; i++) {
			oCheckbox = arrCheckboxes[i];
			oSize = $(oCheckbox.parentNode.parentNode).elmsByClass('size', 'td')[0].getElementsByTagName('span')[0];
			oExt = $(oCheckbox.parentNode.parentNode).elmsByClass('ext', 'td')[0];
			if (oSize && oExt && (oCheckbox.type == 'checkbox')) {
				iSize = parseInt(oSize.innerHTML);
				sExt = oExt.innerHTML.toLowerCase();
				switch(sExt) {
					case "pdf":
						zipRatio = 0.7;
						break;
					case "ppt":
						zipRatio = 0.8;
						break;
					case "txt":
						zipRatio = 0.2;
						break;
					case "doc":
						zipRatio = 0.4;
						break;
					case "xsl":
						zipRatio = 0.3;
						break;
					default:
						zipRatio = 0.5;
				}
				oCheckbox.fileSize = iSize;
				oCheckbox.zipSize = Math.round(iSize * zipRatio);
				$(oCheckbox).addEvent('click', calculate);
				// If the checkbox is checked when the page loads, calculate
				if (oCheckbox.checked) {
					calculate(oCheckbox);
				}
			}
		}
	}
	function calculate(oCheckbox) {
		if (arguments[0].type == 'click') {
			oCheckbox = this;
		}
		var oCounter1 = document.getElementById(config.sSizeTotalId);
		var oCounter2 = document.getElementById(config.sSizeCompressedId);
		var iSize1 = parseInt(oCounter1.innerHTML);
		var iSize2 = parseInt(oCounter2.innerHTML);
		oCounter1.innerHTML = oCheckbox.checked ? iSize1 + oCheckbox.fileSize : iSize1 - oCheckbox.fileSize;
		oCounter2.innerHTML = oCheckbox.checked ? iSize2 + oCheckbox.zipSize : iSize2 - oCheckbox.zipSize;
	}
	return {
		init: init
	};
}();

/**
 * @requires DOMAssistant
 * Disables certain text input fields when the document loads.
 * Adds functionality to enable them when a certain option element is selected.
 */
var toggleInputs = function () {
	var config = {
		sDisabledClassName: 'disabled', // className for input fields that are disabled by the function
		sEnableClassName:'enable' //className for select elements that can enable the disabled input fields
	};
	function init(props) {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		// If any properties were supplied, apply them to the config Object.
		for (var key in props) {
			if (config.hasOwnProperty(key)) {
				config[key] = props[key];
			}
		}
		var arrInputs = $(document).elmsByClass(this.sDisabledClassName, 'input'); // Get all input fields with the given className
		for (var i = 0, len = arrInputs.length; i < len; i++) {
			arrInputs[i].disabled = true; // Disable each field
		}
		// Get all select elements with the given className
		var arrSelects = $(document).elmsByClass(config.sEnableClassName, 'select');
		var oSelect, oInput, sInputId;
		var reRegExp = /enable-([^\s"]+)/;
		for (var i = 0, len = arrSelects.length; i < len; i++) {
			oSelect = arrSelects[i];
			// Get the id of the input field to enable and check that it exists
			sInputId = reRegExp.exec(oSelect.className)[1];
			oInput = document.getElementById(sInputId);
			if (!oInput) {
				continue;
			}
			oSelect._enableInput = oInput;
			// Add an onchange event handler to the select elements
			$(oSelect).addEvent('change', function() {
				toggle(this);
			});
			// Run toggle on init in case the option that enables the input is preselected
			toggle(oSelect);
		}
	}
	/**
	 * @requires DOM Assistant
	 * @param {Object} oSelect The select element that has triggered onchange
	 * @param {String} sInputId The id of the input the select element should affect
	 */
	function toggle(oSelect) {
		// If the selected option should enable the input, do so and give the input focus
		if ($(oSelect.options[oSelect.selectedIndex]).hasClass(config.sEnableClassName)) {
			oSelect._enableInput.disabled = false;
			$(oSelect._enableInput).removeClass(config.sDisabledClassName);
			oSelect._enableInput.focus();
		}
		// If not, make sure the input is disabled in case it had previously been enabled.
		// If an error message exists, remove it.
		else {
			oSelect._enableInput.disabled = true;
			$(oSelect._enableInput).addClass(config.sDisabledClassName);
			if(seFormValidation) {
				seFormValidation.removeError(oSelect._enableInput.parentNode);
			}
		}
	}
	return {
		init: init
	};
}();

/**
 * @requires DOMAssistant
 * Copy the value of an input field's title attribute to its value attribute.
 * Clear the input field on focus if its value is the same as its title.
 * Repopulate the input field on blur if it is empty.
 * Hide the input field's associated label if it has one.
 */
var autoPopulate = function () {
	var config = {
		sInputClass:'populate', // Class name for input elements to autopopulate
		sHiddenClass:'structural', // Class name that gets assigned to hidden label elements
		bHideLabels:false // If true, labels are hidden
	};
	/**
	 * Main function
	 */
	function init(props) {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		// If any properties were supplied, apply them to the config Object.
		for (var key in props) {
			if (config.hasOwnProperty(key)) {
				config[key] = props[key];
			}
		}
		// Find all input elements with the given className
		var arrInputs = $(document).elmsByClass(config.sInputClass, 'input');
		var oInput;
		for (var i = 0, len = arrInputs.length; i < len; i++) {
			oInput = arrInputs[i];
			// Make sure it's a text input
			if (oInput.type != 'text') {
				continue;
			}
			// Hide the input's label
			if (config.bHideLabels) {
				hideLabel(oInput.id);
			}
			// If value is empty and title is not, assign title to value
			if ((oInput.value == '') && (oInput.title != '')) {
				oInput.value = oInput.title;
			}
			// Add event handlers for focus and blur
			$(oInput).addEvent('focus', function() {
				// If value and title are equal on focus, clear value
				if (this.value == this.title) {
					this.value = '';
					this.select(); // Make input caret visible in IE
				}
			});
			$(oInput).addEvent('blur', function() {
				// If the field is empty on blur, assign title to value
				if (!this.value.length) { this.value = this.title; }
			});
		}
	}
	function hideLabel(sId) {
		var arrLabels = document.getElementsByTagName('label');
		var oLabel;
		for (var i = 0, len = arrLabels.length; i < len; i++) {
			oLabel = arrLabels[i];
			if (oLabel.htmlFor == sId) {
				$(oLabel).addClass(config.sHiddenClass);
			}
		}
	}
	return {
		init: init
	};
}();

/**
 * @requires DOMAssistant
 * Automatically submit a form when the value of a select element is changed.
 * Remove submit buttons associated with the select element.
 */
var autoSubmit = function () {
	var config = {
		sContainerClass:'autosubmit', // Class name for elements containing selects that trigger reload
		sHiddenClass:'structural' // Class name that gets assigned to hidden elements
	};
	/**
	 * Main function
	 */
	function init(props) {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		// If any properties were supplied, apply them to the config Object.
		for (var key in props) {
			if (config.hasOwnProperty(key)) {
				config[key] = props[key];
			}
		}
		// Find all container elements with the given className
		var arrContainers = $(document).elmsByClass(config.sContainerClass);
		var oContainer;
		var oSelect;
		for (var i = 0, len = arrContainers.length; i < len; i++) {
			oContainer = arrContainers[i];
			oSelect = oContainer.getElementsByTagName('select')[0];
			if (!oSelect) {
				return;
			}
			$(oSelect).addEvent('change', function() {
				if (this.form) {
					this.form.submit();
				}
			});
			$(oContainer).elmsByClass('submit-area').addClass(config.sHiddenClass);
		}
	}
	return {
		init: init
	};
}();

/**
 * @requires DOMAssistant
 * Display a loading symbol when an option is selected.
 * To be used in combination with an Ajax script.
 */
var loadingIndicator = function () {
	var config = {
		sContainer: '.product-details-search .form', // CSS selector matching the form container
		sImgURL: '../Images/indicator_medium.gif',
		sImgAlt: 'Please wait.',
		sMessage: ' The Product Finder is evaluating your selection…',
		sMessageId: 'loading-indicator',
		sMaskId: 'mask',
		sHiddenClass: 'hidden',
		sMaskedBodyClass: 'masked'
	};
	var oIframe;
	var oMask;
	var oDiv;
	var oBody;
	function show() {
		$(oBody).addClass(config.sMaskedBodyClass);
		$(oMask).removeClass(config.sHiddenClass);
		$(oDiv).removeClass(config.sHiddenClass);
		
	}
	function hide() {
		$(oBody).removeClass(config.sMaskedBodyClass);
		$(oMask).addClass(config.sHiddenClass);
		$(oDiv).addClass(config.sHiddenClass);
	}
	function init(props) {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		// If any properties were supplied, apply them to the config Object.
		for (var key in props) {
			if (config.hasOwnProperty(key)) {
				config[key] = props[key];
			}
		}
		// Find the form container
		var oContainer = $(config.sContainer)[0];
		if (oContainer) {
			// Create the mask
			oMask = document.createElement('div');
			oMask.id = config.sMaskId;
			$(oMask).addClass(config.sHiddenClass);
			oMask.onclick = hide;
			// Create the message container
			oDiv = document.createElement('div');
			oDiv.id = config.sMessageId;
			oDiv.className = config.sHiddenClass;
			var oImg = document.createElement('img');
			oImg.src = config.sImgURL;
			oImg.alt = config.sImgAlt;
			oDiv.appendChild(oImg);
			oDiv.appendChild(document.createTextNode(config.sMessage));
			oBody = document.getElementsByTagName('body')[0];
			oBody.appendChild(oMask);
			oBody.appendChild(oDiv);
		}		
	}
	return {
		init: init,
		show: show,
		hide: hide
	};
}();

/**
 * @requires DOMAssistant
 * A quick hack to add loadingIndicator functionality to select elements
 * in the product details search form. Not to be used in production.
 */
var toggleLoading = function () {
	function init() {
		var arrSelects = $('.product-details-search .form')[0].getElementsByTagName('select');
		var oSelect;
		for (i = 0, len = arrSelects.length; i < len; i++) {
			oSelect = arrSelects[i];
			oSelect.onclick = function () {
				loadingIndicator.show();
			}
		}
	}
	return {
		init: init
	};
}();

/**
 * @requires DOMAssistant
 * Emulate disable options for Internet Explorer
 */
var emulateDisabledOptions = function () {
	var config = {
		sContainer: '.product-details-search .form',
		sDisabledClass: 'disabled'
	};
	function init(props) {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		// If any properties were supplied, apply them to the config Object.
		for (var key in props) {
			if (config.hasOwnProperty(key)) {
				config[key] = props[key];
			}
		}
        var arrSelects = $(config.sContainer + ' select');
		var arrCurrentOptions = [];
		var oSelect;
		for (var i = 0, len = arrSelects.length; i < len; i++) {
			oSelect = arrSelects[i];
			$(oSelect).addEvent('focus', function () {
				arrCurrentOptions[this.id] = this.selectedIndex;
			});
			//$(oSelect).addEvent('change', function () {
			//	restoreEmulateDisabled(this);
			//});
			emulateDisabled(oSelect);
		}
	}
	function emulateDisabled(selectBox) {
		var oOption;
		for (var i = 0, len = selectBox.options.length; i < len; i++) {
			oOption = selectBox.options[i];
			if (oOption.disabled) {
				$(oOption).addClass(config.sDisabledClass);
	        } else {
				$(oOption).removeClass(config.sDisabledClass);
			}
		}
	}
	function restoreEmulateDisabled(selectBox) {
		var oOption;
		for (var i = 0, len = selectBox.options.length; i < len; i++) {
			oOption = selectBox.options[i];
			if (oOption.selected && oOption.disabled) {
				oOption.selected = false;
			}
		}
	}
	return {
		init: init
	};
}();

DOMAssistant.DOMReady(
	'seFormValidation.init()',
	'seCF.init()',
	'seZF.init()',
	'autoPopulate.init()',
	'autoSubmit.init()',
	'toggleInputs.init()',
	// 'toggleLoading.init()'
	'emulateDisabledOptions.init()'
);
