function validate_bid(formObject, minBid, retail, bidPlaced, auctionTypeId, errorId) {

		/*		
		<div id="bidLow" class="marginBottomSmall textRed textBold" style="display:none;">Your bid amount must be equal or exceed the minimum bid amount, which currently is ${smarty_dollar_format value=$auction.current_minimum_bid}.<br>Please place your bid again.</b></div>
		<div id="bidFormat" class="marginBottomSmall textRed textBold" style="display:none;">Your bid amount must be a whole dollar equal or exceed the minimum bid amount, which currently is ${smarty_dollar_format value=$auction.current_minimum_bid}.<br>Please place your bid again.</div>
		<div id="bestShotBlock" class="marginBottomSmall textRed textBold" style="display:none;">Per the Best Shot Auction rules, you may bid only once.</div>
		*/
		
//	gebi(errorId).innerHTML = 'Your bid amount must be equal or exceed the minimum bid amount, which currently is $' + minBid + '.<br>Please place your bid again.</b>';
//	return false;

	var badBid;
	var pattern = /^\d+(\.0*)?$/;
	retail=parseInt(retail);
	var max_bid = parseInt(retail * 2.5);
	var commas;
	var bidAmtLength;

	bidAmt = formObject.bidamount.value;
	bidAmt = bidAmt.replace(/\$/g, '');   						// remove $ 
	bidAmt = bidAmt.replace(/^\s*/, '').replace(/\s*$/, '');	// remove left and right whitespace

	bidAmtLength = bidAmt.length;

	commas = bidAmt.match(/,/g) ? bidAmt.match(/,/g).length : 0;

	if ((commas > 1) || ((commas == 1) && (bidAmtLength > 3) && (bidAmt.charAt((bidAmtLength - 3) - 1) != ','))) {
		gebi(errorId).innerHTML = 'Your bid amount was invalid.  Please try again.';
		return false;
	}

	bidAmt = bidAmt.replace(/,/g,''); 							// remove ,

	if (bidPlaced && auctionTypeId == 2) {
		gebi(errorId).innerHTML = 'Per the Best Shot Auction rules, you may bid only once.';
		return false;
	} 
	if (!bidAmt.match(pattern) || parseInt(bidAmt)!=bidAmt) {
		gebi(errorId).innerHTML = "We're sorry, but your bid must be a whole dollar amount equal to, or exceeding, the current minimum bid of " + formatCurrencyUSD(minBid) + '.<br />Please change your amount and place your bid again.';
		return false;
	}
	if (parseInt(bidAmt) < parseInt(minBid)) {
		gebi(errorId).innerHTML = 'Your bid amount must be equal or exceed the minimum bid amount, which currently is ' + formatCurrencyUSD(minBid) + '.<br>Please place your bid again.</b>';
		return false;
	}
	if (parseInt(bidAmt) > parseInt(max_bid)) {
		gebi(errorId).innerHTML = 'Your current bid of ' + formatCurrencyUSD(bidAmt) + ' is over the maximum allowable bid amount for this offer.  Please adjust the amount and resubmit your bid.';
		return false;
	}
	if (parseInt(bidAmt) > retail) {
		var answer = confirm ("Warning! Your current bid of " + formatCurrencyUSD(bidAmt) + " is over the retail price of the package. Are you sure you want to continue?");
		if (!answer) {
			return false;
		}
	}


	formObject.bidamount.value = parseInt(bidAmt);

	// the jquery listener for the auction form will submit the auction
	//formObject.submit();

}

function formatCurrencyUSD(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if (isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	num = Math.floor(num/100).toString();
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+',' + num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num);
}

