function disableForm(theform)
{
	if (document.all || document.getElementById)
	{
		for (i = 0; i < theform.length; i++) 
		{
			var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
				tempobj.disabled = true;
		}
	}
}

function complyCheck()
{
	if (document.turboSpeedbid.username.value == "")
		{alert('Username is required.'); return false;}
	else if (document.turboSpeedbid.password.value == "")
		{alert('Password is required.'); return false;}

	for (i = 1; i <= parseInt(document.turboSpeedbid.lotCount.value); i++)
	{
		var lotNameField = eval("document.turboSpeedbid.lotName" + i);
		if (lotNameField.value != "")
		{
			var categoryField = eval("document.turboSpeedbid.categoryID" + i);
			var categoryID = categoryField.value;
			var lotLocation = eval("document.turboSpeedbid.lotLocation" + i).value;
			var lotDescription = eval("document.turboSpeedbid.lotDescription" + i).value;
			var complyWithLawField = eval("document.turboSpeedbid.complyWithLaw" + i);
			var lotSummary = eval("document.turboSpeedbid.lotSummary" + i).value;
			var lotSummary_badges = eval("document.turboSpeedbid.lotSummary_badges" + i).value;
			var lotPaymentOptionField = eval("document.turboSpeedbid.lotPaymentOption" + i);
			var lotIsOfferField = eval("document.turboSpeedbid.lotIsOffer" + i);
			var lotReservePrice = eval("document.turboSpeedbid.lotReservePrice" + i).value;
			var lotOpeningBid = eval("document.turboSpeedbid.lotOpeningBid" + i).value;
			var lotSellPrice = eval("document.turboSpeedbid.lotSellPrice" + i).value;
			var lotSellPrice_offer = eval("document.turboSpeedbid.lotSellPrice_offer" + i).value;
			var lotOfferAutoAccept = eval("document.turboSpeedbid.lotOfferAutoAccept" + i).value;
			var lotOfferAutoReject = eval("document.turboSpeedbid.lotOfferAutoReject" + i).value;

			if (categoryID == 0)
				{alert('Item ' + i + ': Category is required.'); return false;}
			else if ((categoryID == 27 || categoryID == 28) && complyWithLawField.checked == false) // Ammunition or Arms & Armour
				{alert('Item ' + i + ': You need to confirm this sale complies with all laws.'); return false;}
			else if ((categoryID == 71 || categoryID == 93) && lotSummary == "") // Orders, Medals & Plaques or Civilian Medals
				{alert('Item ' + i + ': Medal condition is required.'); return false;}
			else if ((categoryID == 29 || categoryID == 89 || categoryID == 91 || categoryID == 92) && lotSummary_badges == "") // Badges (Civilian or Military)
				{alert('Item ' + i + ': Badge condition is required.'); return false;}
			else if (lotLocation == "")
				{alert('Item ' + i + ': Location is required.'); return false;}
			else if (lotDescription == "")
				{alert('Item ' + i + ': Description is required.'); return false;}
			else if (lotPaymentOptionField[0].checked == false && lotPaymentOptionField[1].checked == false && lotPaymentOptionField[2].checked == false && lotPaymentOptionField[3].checked == false && lotPaymentOptionField[4].checked == false && lotPaymentOptionField[5].checked == false && lotPaymentOptionField[6].checked == false && lotPaymentOptionField[7].checked == false && lotPaymentOptionField[8].checked == false)
				{alert('Item ' + i + ': You must select at least one payment type.'); return false;}
			else if (lotIsOfferField[0].checked == true) // auction
			{
				if (parseFloat(lotReservePrice) > 0 && parseFloat(lotReservePrice) <= parseFloat(lotOpeningBid))
					{alert('Item ' + i + ': Reserve price must be greater than the starting bid.'); return false;}
				else if (lotSellPrice != "" && parseFloat(lotSellPrice) <= parseFloat(lotOpeningBid))
					{alert('Item ' + i + ': Buy-it-now price must be greater than the starting bid.'); return false;}
				else if (lotSellPrice != "" && lotReservePrice != "" && parseFloat(lotSellPrice) <= parseFloat(lotReservePrice))
					{alert('Item ' + i + ': Buy-it-now price must be greater than the reserve price.'); return false;}
			}
			else // offer facility
			{
				if (lotSellPrice_offer != parseFloat(lotSellPrice_offer) || parseFloat(lotSellPrice_offer) <= 0)
					{alert('Item ' + i + ': Displayed buy-it-now price is required.'); return false;}
				else if (lotOfferAutoAccept != "" && (parseFloat(lotOfferAutoAccept) <= 0 || parseFloat(lotOfferAutoAccept) > parseFloat(lotSellPrice_offer)))
					{alert('Item ' + i + ': Auto-accept price must be less than the buy-it-now price.'); return false;}
				else if (lotOfferAutoReject != "" && (parseFloat(lotOfferAutoReject) < 0 || parseFloat(lotOfferAutoReject) > parseFloat(lotSellPrice_offer)))
					{alert('Item ' + i + ': Auto-reject price must be less than the buy-it-now price.'); return false;}
				else if (lotOfferAutoAccept != "" && lotOfferAutoReject != "" && parseFloat(lotOfferAutoAccept) <= parseFloat(lotOfferAutoReject))
					{alert('Item ' + i + ': Auto-reject price must be less than the optional auto-accept price.'); return false;}
			}
		}
	}
}

function paypalFeeCheck()
{
	alert('If you accept PayPal, please state in your description any additional processing fees you may charge.');
	return true;
}

function copyLocation ()
{
	for (i = 2; i <= parseInt(document.turboSpeedbid.lotCount.value); i++)
	{
		var lotLocationField = eval("document.turboSpeedbid.lotLocation" + i);

		if (lotLocationField.value == "")
			lotLocationField.value = document.turboSpeedbid.lotLocation1.value;
	}
}

function toggleCategoryWarning (count)
{
	var categoryIDField = eval("document.turboSpeedbid.categoryID" + count);
	var categoryID = categoryIDField.value;

	document.getElementById("ordersMedalsPlaguesDiv" + count).style.display = "none";
	document.getElementById("badgesDiv" + count).style.display = "none";
	document.getElementById("ammunitionDiv" + count).style.display = "none";

	if (categoryID == 71 || categoryID == 93) // Orders, Medals & Plaques or Civilian Medals
		document.getElementById("ordersMedalsPlaguesDiv" + count).style.display = "inline";
	else if (categoryID == 29 || categoryID == 89 || categoryID == 91 || categoryID == 92) // Badges (Civilian or Military)
		document.getElementById("badgesDiv" + count).style.display = "inline";
	else if (categoryID == 27 || categoryID == 28) // Ammunition or Arms & Armour
		document.getElementById("ammunitionDiv" + count).style.display = "inline";
}

function toggleOffer (count)
{
	var lotIsOfferField = eval("document.turboSpeedbid.lotIsOffer" + count);

	document.getElementById("auctionDiv" + count).style.display = "none";
	document.getElementById("offerDiv" + count).style.display = "none";

	if (lotIsOfferField[0].checked == true)
		document.getElementById("auctionDiv" + count).style.display = "block";
	else
		document.getElementById("offerDiv" + count).style.display = "block";
}
