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 CheckQuoteForm(f)
{
	with (f)
	{
		var CountUp		= 0;
		var qty 		= 0;
		var hasInput	= false;
		var qty 		= eval('f.QQTY0');
		var	opt1 		= eval('f.QOPT10');
		var	opt2 		= eval('f.QOPT20');
		var	opt3 		= eval('f.QOPT30');
		var	opt4 		= eval('f.QOPT40');
		var	opt5 		= eval('f.QOPT50');
		var	opt6 		= eval('f.QOPT60');

		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.QPROD0');
		var qtyTagType  = document.getElementById("QQTY0");

		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;
	}
}

function resetListItemSelect(f)
{
	f.PROD0.value				= f.OPT50.options[1].value;
	f.PRICE0.value				= f.OPT50.options[1].title;
 //	document.getElementById('thePrice').innerHTML		= '$'+number_format_list(document.getElementById('originalPrice').value, 2, '.',',');
//	if (document.getElementById('rentMePerYearPrice'))	document.getElementById('rentMePerYearPrice').innerHTML		= '$'+document.getElementById('originalrentMePerYearPrice').value
/*
	if (document.getElementById('hireMePerDayPrice'))
	{
		if (document.getElementById('originalhireMePerDayPrice').value > 0)
		{
			document.getElementById('hireMePerDayPrice').innerHTML		= '$'+document.getElementById('originalhireMePerDayPrice').value
			document.getElementById('hireMe').style.display = 'block';
			document.getElementById('hirePricing').style.display = 'block';
		}
		else
		{
			document.getElementById('hireMe').style.display = 'none';
			document.getElementById('hirePricing').style.display = 'none';
		}
	}
	*/
}
function changeListItemSelect(f, i)
{
	var vals										= f.OPT50.options[f.OPT50.selectedIndex].value.split("|");

	f.PROD0.value									= vals[0];
	f.PRICE0.value			   						= f.OPT50.options[f.OPT50.selectedIndex].title;
	listPrice										= f.OPT50.options[f.OPT50.selectedIndex].title.split(".");

	document.getElementById('listPrice'+i).innerHTML	= "$" + listPrice[0] + "<div class=\"cents\">." + listPrice[1] + "</div>";

/*
	document.getElementById('thePrice').innerHTML  		= '$'+number_format_list(f.OPT50.options[f.OPT50.selectedIndex].title, 2, '.',',');
	if (document.getElementById('rentMePerYearPrice'))	document.getElementById('rentMePerYearPrice').innerHTML	= '$'+number_format_list(sizeRentArray[f.OPT50.selectedIndex-1], 2, '.',',');
	if (document.getElementById('hireMePerDayPrice'))
	{
		if (!document.getElementById('preOrderMe'))
		{
			if (sizeHireArray[f.OPT50.selectedIndex+1] > 0)
			{
				document.getElementById('hireMePerDayPrice').innerHTML	= '$'+number_format_list(sizeHireArray[f.OPT50.selectedIndex-1], 2, '.',',');
				document.getElementById('hireMe').style.display = 'block';
				temp = document.getElementById('hireMe').href;
				document.getElementById('hireMe').href = temp.substring(0,temp.lastIndexOf('/')+1)+sizeIDArray[f.OPT50.selectedIndex-1];
				document.getElementById('hireIconLink').href = temp.substring(0,temp.lastIndexOf('/')+1)+sizeIDArray[f.OPT50.selectedIndex-1];
				document.getElementById('reserveMe').href = temp.substring(0,temp.lastIndexOf('/')+1)+sizeIDArray[f.OPT50.selectedIndex-1];
				document.getElementById('hireMe').style.display = 'block';
				document.getElementById('hirePricing').style.display = 'block';

			}
			else
			{
				document.getElementById('hireMe').style.display = 'none';
				document.getElementById('hirePricing').style.display = 'none';
			}
		}
	}
	*/
}

function number_format_list(number, decimals, dec_point, thousands_sep)
{
    number = (number+'').replace(',', '').replace(' ', '');
    var n = !isFinite(+number) ? 0 : +number,
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }    return s.join(dec);
}
