function selectedOptionsNotValid(formObj) {
	var result = true;
	var tempLength = 0;
	var tempSelectedIndex = -1;
	var tempSelectBoxName = '';
	var tempCombination = '';
	var i = 0;
	
	if ((null == formObj.selectboxnames) && (null == formObj.combinations)) {
		result = false;
	} else if ((null == formObj.selectboxnames) || (null == formObj.combinations)) {
		/* MD, 2004-03-16
		If this condition is true, then something's wrong with the
		ASP code. That's why we don't allow the user to continue.
		*/
		result = true;
	} else {
		if (null == formObj.selectboxnames.length) {
			/* MD, 2004-03-16
			If this condition is true, then there's only one select box.
			*/
			result = false;
		} else {
			tempLength = formObj.selectboxnames.length;
			for (i = 0; i < tempLength; i++) {
				tempSelectBoxName = formObj.selectboxnames[i].value;
				tempSelectedIndex = formObj[tempSelectBoxName].selectedIndex;
				
				tempCombination = tempCombination + formObj[tempSelectBoxName][tempSelectedIndex].value;
			}
			
			if (null == formObj.combinations.length) {
				/* MD, 2004-03-16
				If this condition is true, then there's more than one select box,
				but each box contains only one value. Thus, there's only one
				combination available, and this is already selected.
				*/
				result = false;
			} else {
				tempLength = formObj.combinations.length;
				for (i = 0; i < tempLength; i++) {
					if (tempCombination == formObj.combinations[i].value) {
						result = false;
					}
				}
			}
		}
	}
	
	return result;
}

function checkOptions(formObj, outputBoxObj) {
	var i = 0;
	var tempLength = 0;
	var msg = '';
	var invalidSelections = true;
	
	invalidSelections = selectedOptionsNotValid(formObj)
	
	if (invalidSelections) {
		if (null == formObj.selectboxlabels) {
			/* MD, 2004-03-16
			If this condition is true, then something's wrong with the
			ASP code. That's why we don't allow the user to continue.
			*/
			msg = 'We\'re sorry for the inconvenience. An unknown error has occured.'
				+ ' We are currently unable to add this item to your shopping bag.'
				+ ' Please <a class="light" href="/contact_us.asp">contact us</a>'
				+ ' to order this item.'
		} else {
			msg = 'The combination of ';

			tempLength = formObj.selectboxlabels.length;
			for (i = 0; i < tempLength; i++) {
				if ((1 == i) && (i == (tempLength - 1))) {
					msg = msg + ' and ' + formObj.selectboxlabels[i].value;
				} else if ((1 < i) && (i == (tempLength - 1))) {
					msg = msg + ', and ' + formObj.selectboxlabels[i].value;
				} else if (0 < i) {
					msg = msg + ', ' + formObj.selectboxlabels[i].value;
				} else {
					msg = msg + formObj.selectboxlabels[i].value;
				}
			}
		
			msg = msg + ' you have chosen is unavailable. Please choose a'
				+ ' different combination before adding this item to your shopping cart.';
		}
	} else {
		msg = '&nbsp;';
	}
	
	outputBoxObj.innerHTML = msg;
	return !invalidSelections;
}

function addToCart(formObj, outputBoxObj) {
	var msg = '';

	if (checkOptions(formObj, outputBoxObj)) {
		msg = 'Please wait a moment. We\'re adding this item to your shopping bag.'
			+ ' <br /><br />'
			+ ' Please do NOT click <b>Add To Cart</b> again.'
			+ ' If you do, then an incorrect qty of this item may appear'
			+ ' in your shopping bag. You may always adjust this quantity'
			+ ' later by viewing your shopping bag.';
		outputBoxObj.innerHTML = msg;
			
		formObj.action = '/cart/addtocart.asp';
		formObj.submit();
	}
}

function showEnlargedImage(normalImageBoxObj, enlargedImageBoxObj, targetImgObj, imgSrc) {
	//normalImageBoxObj.style.display = 'none';
	targetImgObj.src = imgSrc;
	enlargedImageBoxObj.style.display = 'block';
	//targetImgObj.scrollIntoView();
	//enlargedImageBoxObj.scrollIntoView();
	window.scrollTo(0, 0);
}

function hideEnlargedImage(normalImageBoxObj, enlargedImageBoxObj) {
	enlargedImageBoxObj.style.display = 'none';
	//normalImageBoxObj.style.display = 'block';
	window.scrollTo(0, 0);
}
