var len = featured_auctions.length;
var i;
var j;
var swap;

for (i=0; i<len; i++) {
	j = Math.floor(Math.random() * len);
	swap = featured_auctions[i];
	featured_auctions[i] = featured_auctions[j];
	featured_auctions[j] = swap;
}

function featured_auction_html (i) {

	var auction = featured_auctions[i];

	if (!auction) { return "&nbsp;"; }

	var url = auction.url || cgi_server + '/auction/view?id=' + auction.id;
	
	var str = ""
	str += "<table border='0' width='150' height='100'>";
	str += "	<tr>";
	str += '		<td align="center" valign="middle">';
	str += '			<a href="' + url + '">';
	str += '				<img src="' + images_server + '/images/featured/' + auction.id + '.' + auction.ext + '" width="100" height="100" border="0" />';
	str += '			</a>';
	str += '		</td>';
	str += '		</tr>';
	str += '		<tr>';
	str += "		<td align='center' valign='center'><a class='ablue' style='text-decoration: none;' href='" + url + "'>" + auction.title + "</a>"; 
	str += "			<br />";
	str += "<font class='arial12'><b>Quantity in Lot:</b>&nbsp;&nbsp;";
	str += 				auction.qty + "<br />";
	str += "<nobr><b>Price Per Unit Bid:</b>&nbsp;&nbsp;$";
	str += 				auction.ppb + "</font></nobr><br /><br />";
	str += "		</td>";
	str += "	</tr>";
	str += "</table>";
	
	
	return str;		
}

function featured_auctions_display (rows, cols) {

	var total = rows * cols;

	var str = "";

	for (var i = 0; i < total; i++) {
		
		if (i % cols == 0)  {
			str += "<tr>";
		}
	
		if (featured_auctions[i] != null) {
			str += '<td align="center" valign="top">';
			
						str += '	<table align="center" border="0" width="125" height="100" CELLPADDING="0" CELLSPACING="0">';
			str += '		<tr><td align="center" valign="top" width="125" height="100">' + featured_auction_html(i) + '</td>';
			str += '		</tr>';
			str += '		</table>';
			str += '</td>';
		}
	}	

	document.write(str);

	return;
}


