function validateQty(theQuantityBox, minQty, fractionQtyName)
{
	var checkValue;
	var testValue;
	var shouldQtyBeInteger;
	
	if (minQty.length == 0)
	{
		checkValue = 1;
	}else{
		checkValue = minQty;
	}
	if (isNumber(checkValue))
	{
		shouldQtyBeInteger= true;
	}else{
		if (fractionQtyName.length = 0)
		{
			shouldQtyBeInteger= true;
		}else{
			shouldQtyBeInteger= false;
		}
	}
	
	if (shouldQtyBeInteger)
	{
		if (!isInteger(theQuantityBox, true, 'Please enter an integer for the quantity'))
		{
			return false;
		}
	}else{
		if (!isFloat(theQuantityBox, true, 'Please enter a valid number for the quantity'))
		{
			return false;
		}
	}

	if (fractionQtyName.length > 0)
	{
		var testValue = new Number(getElementValue(theQuantityBox, 0));
		var testFraction = new Number(getElementValue(document.getElementById(fractionQtyName), 0));
		testValue = testValue + testFraction;
		//alert(testValue);
	}else{
		var testValue = new Number(getElementValue(theQuantityBox, 0))
	}
	
	if (testValue < checkValue)
	{
		alert("The minimum quantity for this product is " + checkValue + ".");
		if (fractionQtyName.length = 0)
		{
			theQuantityBox.value = checkValue;
		}
		theQuantityBox.select();
		return false;
	}
	
	return true;
}

function xvalidateForm(theForm)
{
	if (theForm.QUANTITY.type == "text"){theForm.QUANTITY.quantityBox=true;}
	if (theForm.QUANTITY.type == "select-one"){theForm.selQUANTITY.optional=true;}
	if (theForm.QUANTITY.type == undefined)
	{
		var theQty = theForm.QUANTITY;
		var blnQtySelected = false;
		for (var i = 0;  i < theQty.length;  i++)
		{
			if ((!blnQtySelected) && (theQty[i].value != ""))
			{
				blnQtySelected = true;
			}
			theQty[i].quantityBox=false;
			theQty[i].optional=true;
		}
		
		if (!blnQtySelected)
		{
			theQty[0].focus();
			alert("Please select a quantity.");
			return false;
		}
		
	}

	return sfCheck(theForm);
}

<% If getProductInfo(txtProdId, enProduct_Exists) Then Response.Write "prodBasePrice =" & getProductInfo(txtProdId, enProduct_SellPrice) & ";" & vbcrlf %>

function validateForm(theForm, theFormName)
{
	if (validateQty(theForm.QUANTITY, '<%= getProductInfo(txtProdId, enProduct_prodMinQty) %>', '<% If prodIncrement > 1 Then Response.Write "QUANTITY_FRACTION." & txtProdId %>'))
	{
		if(ajaxAddToCart(theFormName))
		{
			return false;
		}else{
			return true;
		}
	}else{
		return false
	}
}

function addToWishList(theForm, theFormName)
{
	if (validateQty(theForm.QUANTITY, '<%= getProductInfo(txtProdId, enProduct_prodMinQty) %>', '<% If prodIncrement > 1 Then Response.Write "QUANTITY_FRACTION." & txtProdId %>'))
	{
	    theForm.ajaxSaveCart.value = 1;
		theForm.submit();
	    theForm.ajaxSaveCart.value = '';
	}
	return false;
}

function submitReviewVote(value)
{
    var theForm = document.getElementById('frmProductReview');
    theForm.ReviewAction.value = value;
    theForm.submit();
    return false;
}

function validateReviewSumbission(theForm)
{

var blnFound = false;

	if (theForm.contentAuthorName.value == "")
	{
		alert("Please enter your name");
		theForm.contentAuthorName.focus();
		return false;
	}
	
	if (theForm.contentAuthorEmail.value == "")
	{
		alert("Please enter your email address");
		theForm.contentAuthorEmail.focus();
		return false;
	}
	
	if (!emailCheck(theForm.contentAuthorEmail.value))
	{
		theForm.contentAuthorEmail.focus();
		return false;
	}
	
	for (var i = 0;  i < theForm.contentAuthorRating.length;  i++)
	{
		if (theForm.contentAuthorRating[i].checked)
		{
			blnFound = true;
		}
	}
	
	if (!blnFound)
	{
		alert("Please select a rating.");
		theForm.contentAuthorRating[theForm.contentAuthorRating.length-1].focus();
		return false;
	}

	<% If isRecaptchaEnabled Then %>
	if (theForm.recaptcha_response_field != undefined)
	{
	    if (theForm.recaptcha_response_field.value == "")
	    {
		    alert("Please enter the image text");
		    theForm.recaptcha_response_field.focus();
		    return false;
	    }
	}
	<% End If %>
	
	ajaxSubmitProductReview('frmSubmitReview');
	return false;
}
