function submitSearch() {
	document.AdvancedSearchForm.searchTerm.value = document.AdvancedSearchForm.searchTerm.value.replace(/s+$/g, '');
	var searchTerm = $.trim(document.AdvancedSearchForm.searchTerm.value.toLowerCase());
	if (searchTerm == 'treadmills') {
			searchTerm= 'treadmill';
		} else if (searchTerm == 'ellipticals') {
			searchTerm = 'elliptical';
		} else if (searchTerm == 'bikes') {
			searchTerm = 'bike';
		} else if (searchTerm == 'exercise bikes') {
			searchTerm = 'exercise bike';
		} else if (searchTerm == 'systems') {
			searchTerm = 'system';
		} else if (searchTerm == 'strength systems') {
			searchTerm = 'strength system';
		}
		//search for above items
		else if(searchTerm.match(/^[rlrj]{1,}$/)) {
			document.AdvancedSearchForm.sku.value = searchTerm;//searched item (sku) if it matches the regex
			document.AdvancedSearchForm.searchTerm.value = ''; 	// set to nothing if regex is matched 
		}
		else if (searchTerm.match(/^([A-Za-z]{3,7})[0-9]{1,}$/)) {
		document.AdvancedSearchForm.sku.value = searchTerm;//searched item (sku) if it matches the regex
		document.AdvancedSearchForm.searchTerm.value = ''; 	/* set to nothing if regex is matched 
															or get 2 messages that something is not found*/
	}else{ //if none of the above happen simply search for what is entered in the search box.
		document.AdvancedSearchForm.searchTerm.value = searchTerm;
	}
	document.AdvancedSearchForm.submit();
}






var submitCompareBusy = false;
function submitCompare(form) {
	if (!submitCompareBusy) {
		submitCompareBusy = true;
		var count = 0;
		if (form.compare.length == null) {
			if (form.compare.checked) {
				count++;
			}
		} else {
			for (var i=0, length=form.compare.length; i<length; i++) {
				if (form.compare[i].checked) {
					count++;
				}
			}
		}	
		if (count == 0) {
			alert('Please select up to 3 products to compare!');
		} else if (count > 3) {
			alert('You may only select a maximum of 3 products to compare!');
		} else {
			form.submit();
		}
	}
}

/* 
  ***
  * This javascript function is used by the address 'Submit' button.
  * It is used to ensure that the entered value does not exceed the maximum number of bytes allowed.
  * This function makes use of isValidUTF8length function.  Details about that function can be fund in utilities.js.
  ***
 */
 /*
function submitForm(form) {
	if     (!isValidUTF8length(form.address1.value     , 50 )) { alert("<fmt:message key="ERROR_AddressTooLong"       bundle="${storeText}"/>"); }
	else if(!isValidUTF8length(form.address2.value     , 50 )) { alert("<fmt:message key="ERROR_AddressTooLong"       bundle="${storeText}"/>"); }
	else if(!isValidUTF8length(form.city.value         , 128)) { alert("<fmt:message key="ERROR_CityTooLong"          bundle="${storeText}"/>"); }
	else if(!isValidUTF8length(form.state.value        , 128)) { alert("<fmt:message key="ERROR_StateTooLong"         bundle="${storeText}"/>"); }
	else if(!isValidUTF8length(form.country.value      , 128)) { alert("<fmt:message key="ERROR_CountryTooLong"       bundle="${storeText}"/>"); }
	else if(!isValidUTF8length(form.zipCode.value      , 40 )) { alert("<fmt:message key="ERROR_ZipCodeTooLong"       bundle="${storeText}"/>"); }

	else if(!isValidUTF8length(form.phone1.value       , 32 )) { alert("<fmt:message key="ERROR_PhoneTooLong"         bundle="${storeText}"/>"); }

	else {
		//verify address fields #1-#2, if #2 is filled and not #1 then move the data for the user
		if (form.address1.value == "") {
			if (form.address2.value != "") {
				form.address1.value = form.address2.value;
				form.address2.value = "";
			}
		}

	 	form.submit();
	 }
}*/

/* 
  ***
  * This javascript function is used by the registration 'Submit' button.
  * This store does not prompt users for the logon ID during registration. 
  * The email address is treated as the logon ID in our case.
  * This function will set the logon ID and the email address to the same value.
  * Also, receiveEmail is set to true if sendMeEmail check box is checked.
  ***
*/

/*
function prepareSubmit(form)
{
	<flow:ifEnabled  feature="EmailOption">
	if (form.sendMeEmail.checked) form.receiveEmail.value = true
	else form.receiveEmail.value = false;
	</flow:ifEnabled>
	form.submit()
}

/* 
 ***
 * This javascript function is used when "Age" option is changed.
 * This will show one alert message if the user age is under 13. 
 ***
*/
/*
function checkAge(form)
{
	if(form.age.value==1) alert("<fmt:message key="AGE_WARNING_ALERT" bundle="${storeText}"/>");
}
*/
