function MultiAuctionCometClient(auctionIds, options)
{
	this.options = $.extend(MultiAuctionCometClient.DefaultOptions, options);
	this.auctionIds = auctionIds;
	this.cometUrl = this.options.cometUrl + auctionIds.join(',');	// URL to get streaming updates
	this.maxBids = {};

	var thisReference = this;
	var cometClientOptions = { onUpdate: function(streamData) { thisReference.OnUpdate(streamData); } };
	this.cometClient = new CometClient(this.cometUrl, cometClientOptions);
}

MultiAuctionCometClient.DefaultOptions =
{
	cometUrl: '/fcgi-bin/stream-wrapper?Action=ShowActive&Items=',
        onUpdate: null
};

MultiAuctionCometClient.prototype.OnUpdate = function(streamData)
{
	// If no one's listening, don't do anything.
	if (!this.options.onUpdate) { return; }

	// Extract the bids from html and package the userbids in an object to be passed to listener
	var bidData = MultiAuctionCometClient.ExtractBidData(streamData);

	// Check new bid data against our stored copy.  We're looking to mark the new bids for any auctions that have them.
	for (var i = 0; i < bidData.length; i++)
	{
		var auctionId = bidData[i].auctionId;
		if (!this.maxBids[auctionId]) { this.maxBids[auctionId] = bidData[i].bidAmount; }

		if (bidData[i].bidAmount > this.maxBids[auctionId]) { bidData[i].newBid = true; }
		else { bidData[i].newBid = false; }

		this.maxBids[auctionId] = bidData[i].bidAmount;
	}


	if (this.options.onUpdate) { this.options.onUpdate(bidData); }

	return bidData;
}

// The function strips out extraneous STT and END blocks and returns only the html in the last (freshest) block
// The resulting html is then parsed into a JS array of objects.
MultiAuctionCometClient.ExtractBidData = function(streamData)
{
	streamData = streamData.replace("\n", '', 'g');

	// Sample:   @STT@146735:196#171763:702@END@
	var regexWrapper = new RegExp('@STT@(.*?)@END@', 'gmi');
	var matches = null;
	var bidHtml = null;

	// Keep matching until we cant anymore.  We only want the last chunk of data between "@STT@" and "@END@" delimiters
	while ((matches = regexWrapper.exec(streamData)) != null) { bidHtml = matches[1]; }

	if (!bidHtml) { bidHtml = streamData; }

	var bidData = [];

	// We can skip the regex this time, a simple split will work for this data.
	var auctionElements = bidHtml.split('#');
	for (var i = 0; i < auctionElements.length; i++)
	{
		var elementPair = auctionElements[i].split(':');
		bidData.push({auctionId:elementPair[0], bidAmount:elementPair[1]});
	}

	return bidData;
}

