
function testOpt(theOpt, theName)
{
	if (theOpt.selectedIndex == 0 && theOpt.options[theOpt.selectedIndex].text.indexOf('Choose') != -1)
	{
		alert('Please choose a '+theName);
		return false;
	}
}

function CheckForm(f)
{
	with (f)
	{
		var CountUp		= 0;
		var qty 		= 0;
		var hasInput	= false;
		var qty 		= eval('f.QTY0');
		var	opt1 		= eval('f.OPT10');
		var	opt2 		= eval('f.OPT20');
		var	opt3 		= eval('f.OPT30');
		var	opt4 		= eval('f.OPT40');
		var	opt5 		= eval('f.OPT50');
		var	opt6 		= eval('f.OPT60');

		var	opt1Lbl	= eval('f.opt10Label');
		var	opt2Lbl	= eval('f.opt20Label');
		var	opt3Lbl	= eval('f.opt30Label');
		var	opt4Lbl	= eval('f.opt40Label');
		var	opt5Lbl	= eval('f.opt50Label');
		var	opt6Lbl	= eval('f.opt60Label');

		var	prod 		= eval('f.PROD0');
		var qtyTagType  = document.getElementById("QTY0");

		if (opt1 && opt1Lbl) { if (testOpt(opt1, opt1Lbl.value) == false) return false; }
		if (opt2 && opt2Lbl) { if (testOpt(opt2, opt2Lbl.value) == false) return false; }
		if (opt3 && opt3Lbl) { if (testOpt(opt3, opt3Lbl.value) == false) return false; }
		if (opt4 && opt4Lbl) { if (testOpt(opt4, opt4Lbl.value) == false) return false; }
		if (opt5 && opt5Lbl) { if (testOpt(opt5, opt5Lbl.value) == false) return false; }
		if (opt6 && opt6Lbl) { if (testOpt(opt6, opt6Lbl.value) == false) return false; }

		if (qtyTagType)
		{
			if (qtyTagType.tagName == "INPUT")  	qty = eval('f.QTY0');
			if (qtyTagType.tagName == "SELECT")  	qty = eval('f.QTY0.options[f.QTY0.selectedIndex]');
		}

		if (qty.value.length > 0)
		{
			if (isNaN(qty.value/2))
			{
				window.alert('One or more of the fields contains invalid characters');
				return false;
			}
		}
		else
		{
			alert('Please choose a quantity for product ID:'+prod.value);
			return false;
		}

		CountUp += (qty.value - 0);

		if (qty.value < 0)
		{
			alert('Surprisingly you cannot purchase a negative number of items');
			return false;
		}
	}
	if (CountUp == 0)
	{
		window.alert('You must select more than 0 items');
		return false;
	}
}
function CheckThisForm(f, i)
{
	with (f)
	{
		var CountUp		= 0;
		var qty 		= 0;
		var hasInput	= false;
		var qty 		= eval('f.QTY'+i);
		var	opt1 		= eval('f.OPT1'+i);
		var	opt2 		= eval('f.OPT2'+i);
		var	opt3 		= eval('f.OPT3'+i);
		var	opt4 		= eval('f.OPT4'+i);
		var	opt5 		= eval('f.OPT5'+i);
		var	opt6 		= eval('f.OPT6'+i);

		var	opt1Label	= eval('f.opt1'+i+'Label');
		var	opt2Label	= eval('f.opt2'+i+'Label');
		var	opt3Label	= eval('f.opt3'+i+'Label');
		var	opt4Label	= eval('f.opt4'+i+'Label');
		var	opt5Label	= eval('f.opt5'+i+'Label');
		var	opt6Label	= eval('f.opt6'+i+'Label');

		var	prod 		= eval('f.PROD'+i);
		var qtyTagType  = document.getElementById("QTY0");

		if (opt1 && opt1Label) { if (testOpt(opt1, opt1Label.value) == false) return false; }
		if (opt2 && opt2Label) { if (testOpt(opt2, opt2Label.value) == false) return false; }
		if (opt3 && opt3Label) { if (testOpt(opt3, opt3Label.value) == false) return false; }
		if (opt4 && opt4Label) { if (testOpt(opt4, opt4Label.value) == false) return false; }
		if (opt5 && opt5Label) { if (testOpt(opt5, opt5Label.value) == false) return false; }
		if (opt6 && opt6Label) { if (testOpt(opt6, opt6Label.value) == false) return false; }

		if (qtyTagType)
		{
			if (qtyTagType.tagName == "INPUT")  	qty = eval('f.QTY'+i);
			if (qtyTagType.tagName == "SELECT")  	qty = eval('f.QTY'+i+'.options[f.QTY'+i+'.selectedIndex]');
		}

		if (qty.value.length > 0)
		{
			if (isNaN(qty.value/2))
			{
				window.alert('One or more of the fields contains invalid characters');
				return false;
			}
		}
		else
		{
			alert('Please choose a quantity for product ID:'+prod.value);
			return false;
		}

		CountUp += (qty.value - 0);

		if (qty.value < 0)
		{
			alert('Surprisingly you cannot purchase a negative number of items');
			return false;
		}
	}
	if (CountUp == 0)
	{
		window.alert('You must select more than 0 items');
		return false;
	}
}