var _auctiondata_js_loaded = 1;
var equips_on_page = new Array();
var checked = new Array();
var upcomingItemCount = 0;
var extensionMin = 3;
var atleastOneConverted = 0;
var lastCurrency = "";
var currencyCount = 0;

function AuctionData_toTableRow(props)
{
	var i;
	var tmp = '<tr>';

	for (i in props) {
		tmp += '<td>' + this[props[i]] + '</td>';
	}

	return tmp + '</tr>';
}

function AuctionData_getURL()
{
	if (this.url != null)
		return this.url;
	return '/jsp/s/item/' + this.equipId + '?h=' + crumb;
}

function AuctionData_makeCube()
{
	if (this.reserveType > 0 || this.strikePrice > 0)
		return this.makeReserveCube();

	var out = "";
	var location = this.location;

	if (location && location.length > 10)
		location = '&nbsp;';

	var isBidder = (loggedIn && this.bidCount > 0 && containsEq(this.equipId));
	var isWinner = (loggedIn && (loggedIn == this.highBidder));
	var isLoser = (isBidder && ! isWinner);
	var moneyColor = isWinner ? "green" : "black";
	var cubeColor = isBidder ? "#FFFFCC" : "#FFFFFF";
	var borderColor = isBidder ? moneyColor : "#CCCCCC";

	out += '<table width="370" cellpadding="1" style="border: 2px solid '+borderColor+';" cellspacing="0" ID="IP$' + this.equipId + '_OuterTable"><tbody>';
	out += '<tr><td>';
	out += '<table width="100%" border="0" cellspacing="0" bgcolor="#CCCCCC"><tbody>';
	out += '<tr ID="IP$' + this.equipId + '_Title"><td width="1" valign=top class=b style="font-size:12px;"><b>&nbsp;<nobr>' + this.displayId + '</nobr></b></td>';
	out += '<td align=center valign=top class=b style="font-size:12px;"><b>' + this.description + '</b></td>';
	out += '<td width="1" valign=top align=right class=b style="font-size:12px;"><b>' + location + "&nbsp;</b></td></tr></tbody></table>\n\t";

	out += '<table width="100%" cellspacing="0"';
	if( !isPractice || isBidder) 
		out += ' bgcolor=' + cubeColor;
		
	out += ' ID="IP$' + this.equipId + '_InnerTable"><tbody>';
	out += '<tr><td rowspan="4" width="98" height=70 valign="middle" align=center bgcolor="#F0F0F0">';
	out += '<a onMouseOver="showCubeDetails('+this.equipId+')" onMouseOut="hideCubeDetails('+this.equipId+')" href="' + this.getURL() + '" onClick="return showRegistration(\'document.location.href=\\\'' + this.getURL() + '\\\'\', ' + this.equipId + ', false)">';

	if (this.pictureUrl != "" && this.pictureUrl != null)
	{
		var width = this.width;
		// Film photos can vary slightly in aspect ratio
		if (width >= 103 && width <= 110)
			width = 106;
		if (width <= 0)
			width = 1;
		out += '<img src="' + this.pictureUrl + '" width=' + width + ' height=' + (this.height > 0 ? this.height : 1) + ' style="border:1px solid black;" alt="' + JS_auctiondat_Clickim_8649 +'" valign="center">';
	}
	else
	{
		out += '<p class=a><font color="red">'+JS_cube_NoImage_1940+'</font></p>';
	}

	out += "</a></td>\n\t";
	out += '<td align="right" class=b id="ClosesIn' + this.equipId + '">';
	if (this.extFlags < 2)
		out += JS_auctiondat_Bidding_8608;
	else
		out += '&nbsp;';
	out += '</td><td align="left"><b><span class=red ID="IP$' + this.equipId + '_TimeLeftString">' + this.timeLeft() + '</span></b></td></tr>';
	out += '<tr><td ID="IP$' + this.equipId + '_PriceLabelCell" bgcolor="#CCCCCC" align=center valign=bottom width="94">';

	out += '<font color=black><span class=b ID="IP$' + this.equipId + '_pricelabel">';
	if (this.extFlags == 2)
		out += JS_auctiondat_Winning_8609;
	else if (this.bidCount > 0)
		out += JS_auctiondat_Highest_8610;
	else
		out += JS_auctiondat_Opensat_8611;
	out += "</span></font></td>\n\t";

	out += '<td rowspan="2" style="text-align:center; vertical-align:middle;" id="SubmitCell' + this.equipId + '"';

	if (this.extFlags == 2)
		out += '><b class=red><font size="+1">' + JS_ir_SOLD_6299 + '</font></b>';
	else if (this.extFlags > 2)
		out += '><b class=red>' + JS_auctiondat_Gone_8653 + '</b>';
	else
	{
		out += '><input type="button" id="bidButton' + this.equipId + '" name="bidButton' + this.equipId + '" value="';
		if (isWinner && !showStaticBidButton)
			out += JS_auctiondat_Increas_8612;
		else if(showStaticBidButton)
			out += JS_pricing_PlaceBi_5632;
		else
			out += JS_auctiondat_Bid_8613 + dollarString(this.nextPrice(), this.currency);
		out+= '" onclick="placeBid(indexList[' + this.equipId + ']);">';
	}

	out += '</td></tr>';
	out += '<tr><td ID="IP$' + this.equipId + '_PriceCell" bgcolor="#CCCCCC" width="94" valign=top align=center class=a>';
	out += '<font color="' + moneyColor + '"><span style="font-weight:bold;font-size:14px;white-space:nowrap;" ID="IP$' + this.equipId + '_price">' + dollarString(this.price, this.currency) + '</span></font>';
	out += '</td></tr>';
	
	if (lastCurrency != this.currency)
	{
		lastCurrency = this.currency;
		currencyCount++;
	}


	out += '<tr><td align=center width="94" class=b><span ID="IP$' + this.equipId + '_shortbidcount">';

	if (this.bidCount != 1)
		out += '' + this.bidCount + " "+JS_auctiondat_bids_8617;
  	else
 		out += JS_auctiondat_1bid_8618;

	out += "</span></td>\n\t";

	out += '<td align=center><img ID="IP$' + this.equipId + '_winnerimage" border=0 src="/images/';
	if (isWinner)
		out += 'notice';
	else
		out += 'transparent';
	out += '.gif" align=ABSMIDDLE width=14 height=14><b><font ID="IP$' + this.equipId + '_winnerstring" color=';
	if (isWinner)
		out += 'green>'+JS_auctiondat_Highest_8616;
	else if (isLoser)
		out += 'red>'+JS_auctiondat_Youvebe_8637;
	else
		out += 'red>&nbsp;';
	out += '</font></b></td>';

	out += '</tr></tbody></table>';
	out += '</td></tr>';
	out += '</tbody></table>';
	out += '<table cellspacing=0 cellpadding=0 style="position: relative; top: -3px;text-align: left; width:370px; height: 0px;"><tr><td>'
	out += '<div id="cubeDetails'+ this.equipId +'" style="padding:5px; position:absolute; width: 356px;border-bottom: 2px solid '+borderColor+'; border-left: 2px solid '+borderColor+'; border-right: 2px solid '+borderColor+';visibility: hidden; overflow:hidden; background-color: white;">'; 	
	out += '<div id="cubeDetailsInner'+ this.equipId +'">'; 
		
	out += '<span id="cubeDetailsFeatures'+ this.equipId +'"></span>';
	out += '<table><tr><td style="vertical-align: middle; width:'+ (this.isIronClad ? '320px' : '100%') + ';">';
	out += '<table><tr>'
	out += '<td class="previewFieldLabel">'+JS_meterMeternb_2430+' </td><td id="cubeDetailsUsage'+ this.equipId +'"></td></tr>';
	out += '<td class="previewFieldLabel">'+JS_serialNumbSerialn_1830+' </td><td id="cubeDetailsSerial'+ this.equipId +'"></td></tr>';
	out += '<td class="previewFieldLabel">'+JS_locationLiLocatio_1133+' </td><td>'+this.longLocation+'</td></tr>';
	out += '<td class="previewFieldLabel" colspan="2" id="cubeDetailsWarr'+ this.equipId +'"></td></tr>';
	out += '</table></td>';
	if(this.isIronClad) {
		out += '<td style="vertical-align:middle;"><img src="/n_images/i_iron_g.gif"/></td>';
	}
	out += '</tr></table>';
	out += '</div></div>';
	out += '</td></tr></table>';

	return out;
}

function showCubeDetails(equipId) {
	if(document.getElementById('cubeDetailsFeatures'+equipId).innerHTML == '') {
		postAjax('/jsp/equip/getEquipInfo.jsp', 'equipId='+equipId);
	}
	var finalHeight = document.getElementById('cubeDetailsInner'+equipId).offsetHeight;
	slidedownCubeDetails(equipId, 0, finalHeight);
}

function rgbToHex(rgbval){
	var s = rgbval.match(/rgb\s*\x28((?:25[0-5])|(?:2[0-4]\d)|(?:[01]?\d?\d))\s*,\s*((?:25[0-5])|(?:2[0-4]\d)|(?:[01]?\d?\d))\s*,\s*((?:25[0-5])|(?:2[0-4]\d)|(?:[01]?\d?\d))\s*\x29/);
	if(s){
		s=s.splice(1);
		if(s && s.length==3){
			var d='';
			for(rgbInd in s){
				var e=parseInt(s[rgbInd],10).toString(16);
				if(e.length == 1){
					e == '0' ? d+='00' : d+= ('0' + e);
				}else{
					d+=e;
				}
			} 
			return '#'+d;
		}else{
			return rgbval;
		}
	}else{
		return rgbval;
	}
}

function slidedownCubeDetails(equipId, detailHeight, finalHeight) {

	var cubeDetails = document.getElementById('cubeDetails'+equipId);
	if(cubeDetails != null) {
		if(detailHeight == 0) {
			var outerTable = document.getElementById('IP$'+equipId+'_OuterTable');
	
			if(rgbToHex(outerTable.style.borderColor) == '#cccccc') {
				outerTable.style.borderColor = "#333333";
				cubeDetails.style.borderColor = "#333333";
			}
			cubeDetails.style.visibility = 'visible';
		}
		if(detailHeight < finalHeight) {
			cubeDetails.style.height = detailHeight + 'px'; 
			var newHeight = detailHeight + 4;
			setTimeout('slidedownCubeDetails('+equipId+', '+newHeight+', '+finalHeight+')', 5);
		}
	}
}

function hideCubeDetails(equipId) {
	var cubeDetails = document.getElementById('cubeDetails'+equipId);
	var outerTable = document.getElementById('IP$'+equipId+'_OuterTable');
	if(rgbToHex(outerTable.style.borderColor) == '#333333') { 
		cubeDetails.style.borderColor = "#CCCCCC";
		outerTable.style.borderColor = "#CCCCCC";
	}
	cubeDetails.style.visibility = 'hidden';

}


function AuctionData_makeReserveCube()
{
	var out = "";
	var location = this.location;

	if (location && location.length > 10)
		location = '&nbsp;';

	var isBidder = (loggedIn && this.bidCount > 0 && containsEq(this.equipId));
	var isWinner = (loggedIn && (loggedIn == this.highBidder));
	var isLoser = (isBidder && ! isWinner);
	var moneyColor = isWinner ? "green" : "black";
	var cubeColor = isBidder ? "#FFFFCC" : "#FFFFFF";
	var borderColor = isBidder ? moneyColor : "#CCCCCC";

	out += '<table width="370" style="border: 2px solid '+borderColor+';" cellspacing="0" cellpadding="1" ID="IP$' + this.equipId + '_OuterTable"><tbody>';
	out += '<tr><td>';
	out += '<table width="100%" border="0" cellspacing="0" bgcolor="#CCCCCC"><tbody>';
	out += '<tr ID="IP$' + this.equipId + '_Title"><td width="1" valign=top class=b style="font-size:12px;"><b>&nbsp;<nobr>' + this.displayId + '</nobr></b></td>';
	out += '<td align=center valign=top class=b style="font-size:12px;"><b>' + this.description + '</b></td>';
	out += '<td width="1" valign=top align=right class=b style="font-size:12px;"><b>' + location + "&nbsp;</b></td></tr></tbody></table>\n\t";

	out += '<table width="100%" cellspacing="0" bgcolor=' + cubeColor + ' ID="IP$' + this.equipId + '_InnerTable"><tbody>';
	out += '<tr><td rowspan="4" width="98" height=70 valign="middle" align=center bgcolor="#F0F0F0">';
	out += '<a onMouseOver="showCubeDetails('+this.equipId+')" onMouseOut="hideCubeDetails('+this.equipId+')" href="' + this.getURL() + '" onClick="return showRegistration(\'document.location.href=\\\'' + this.getURL() + '\\\'\', ' + this.equipId + ', false)">';

	if (this.pictureUrl != "" && this.pictureUrl != null)
	{
		var width = this.width;
		// Film photos can vary slightly in aspect ratio
		if (width >= 103 && width <= 110)
			width = 106;
		if (width <= 0)
			width = 1;
		out += '<img src="' + this.pictureUrl + '" width=' + width + ' height=' + (this.height > 0 ? this.height : 1) + ' style="border:1px solid black;" alt="' + JS_auctiondat_Clickim_8649 + '" valign="center">';
	}
	else
	{
		out += '<p class=a><font color="red">'+JS_cube_NoImage_1940+'</font></p>';
	}

	out += "</a></td>\n\t";
	out += '<td align="right" class=b id="ClosesIn' + this.equipId + '">';
	if (this.extFlags < 2)
		out += JS_auctiondat_Bidding_8608;
	else
		out += '&nbsp;';
	out += '</td><td align="left"><b><span class=red ID="IP$' + this.equipId + '_TimeLeftString">' + this.timeLeft() + '</span></b></td></tr>';
	out += '<tr><td ID="IP$' + this.equipId + '_PriceLabelCell" bgcolor="#CCCCCC" align=center valign=bottom width="94">';

	out += '<font color=black><span class=b ID="IP$' + this.equipId + '_pricelabel">';
	if (this.extFlags == 2)
		out += JS_auctiondat_Winning_8609;
	else if (this.bidCount > 0)
		out += JS_auctiondat_Highest_8610;
	else
		out += JS_auctiondat_Opensat_8611;
	out += "</span></font></td>\n\t";

	out += '<td rowspan="2" style="text-align:center; vertical-align:middle;">';
	out += '<span id="SubmitCell' + this.equipId + '">';
	if (this.extFlags == 2)
		out += '<b class=red><font size="+1">' + JS_ir_SOLD_6299 + '</font></b></span>';
	else if (this.extFlags > 2)
		out += '<b class=red>' + JS_auctiondat_Gone_8653 + '</b></span>';
	else
	{
		out += '<input type="button" id="bidButton' + this.equipId + '" name="bidButton' + this.equipId + '" value="';
		if (isWinner && !showStaticBidButton)
			out += JS_auctiondat_Increas_8612;
		else if(showStaticBidButton) 
			out += JS_pricing_PlaceBi_5632;
		else
			out += JS_auctiondat_Bid_8613 + dollarString(this.nextPrice(), this.currency);
		out+= '" onclick="placeBid(indexList[' + this.equipId + ']);"></span>';
			
		if (this.reserveType != 0) {
			out += '<br>';
	    	if (self.showReserve) {
		    	out += '<a id="IP$' + this.equipId + '_resvText" href="javascript:var w=window.open(' + "'/pop/open_reserve_price.jsp','helpWindow','width=490,height=485,scrollbars');" + '">';
			} else {
				out += '<a id="IP$' + this.equipId + '_resvText" href="javascript:var w=window.open(' + "'/pop/reserve_price.jsp','helpWindow','width=490,height=485,scrollbars');" + '">';
			}
			if (this.reserveType == 1) {  
		    	if (self.showReserve) {
		        	out += JS_auctiondat_ReserveWord_8619 + ': ' + dollarString(this.reservePrice, this.currency);
		    	} else {
					out += JS_auctiondat_Reserve_8619;
				}
	    	} else if (this.reserveType == 2)
				out += JS_auctiondat_Nextbid_8620;
			else if (this.reserveType == 3)
				out += JS_auctiondat_Reserve_8621;
			out += '</a>';
		}

		if (this.strikePrice > 0) {
			out += '<br><a href="javascript:var w=window.open(' + "'/pop/WiN_price.jsp','helpWindow','width=425,height=190,scrollbars');" + '">'+JS_auctiondat_WinItNo_8622;
			out += dollarString(this.strikePrice, this.currency);
			out += '</a>';
		}
		out += "</td>";
	}

	out += '</td></tr>';
	out += '<tr><td ID="IP$' + this.equipId + '_PriceCell" bgcolor="#CCCCCC" width="94" valign=top align=center class=a>';
	out += '<font color="' + moneyColor + '"><span style="font-weight:bold;font-size:14px;white-space:nowrap;" ID="IP$' + this.equipId + '_price">' + dollarString(this.price, this.currency) + '</span></font>';
	out += '</td></tr>';
	
	out += '<tr><td align=center width="94" class=b><span ID="IP$' + this.equipId + '_shortbidcount">';

	if (this.bidCount != 1)
		out += '' + this.bidCount + " "+JS_auctiondat_bids_8617;
  	else
 		out += JS_auctiondat_1bid_8618;

	out += "</span></td>\n\t";

	out += '<td align=center><img ID="IP$' + this.equipId + '_winnerimage" border=0 src="/images/';
	if (isWinner)
		out += 'notice';
	else
		out += 'transparent';
	out += '.gif" align=ABSMIDDLE width=14 height=14><b><font ID="IP$' + this.equipId + '_winnerstring" color=';
	if (isWinner)
		out += 'green>'+JS_auctiondat_Highest_8616;
	else if (isLoser)
		out += 'red>'+JS_auctiondat_Youvebe_8637;
	else
		out += 'red>&nbsp;';
	out += '</font></b></td>';
	
	
	out += '</tr></tbody></table>';
	out += '</td></tr>';
	out += '</tbody></table>';

	out += '<table cellspacing=0 cellpadding=0 style="position: relative; top: -3px;text-align: left; width:370px; height: 0px;"><tr><td>'
	out += '<div id="cubeDetails'+ this.equipId +'" style="padding:5px; position:absolute; width: 356px;border-bottom: 2px solid '+borderColor+'; border-left: 2px solid '+borderColor+'; border-right: 2px solid '+borderColor+';visibility: hidden; overflow:hidden; background-color: white;">'; 	
	out += '<div id="cubeDetailsInner'+ this.equipId +'">'; 
		
	out += '<span id="cubeDetailsFeatures'+ this.equipId +'"></span>';
	out += '<table><tr><td style="vertical-align: middle; width:'+ (this.isIronClad ? '320px' : '100%') + ';">';
	out += '<table><tr>'
	out += '<td class="previewFieldLabel">'+JS_meterMeternb_2430+' </td><td id="cubeDetailsUsage'+ this.equipId +'"></td></tr>';
	out += '<td class="previewFieldLabel">'+JS_serialNumbSerialn_1830+' </td><td id="cubeDetailsSerial'+ this.equipId +'"></td></tr>';
	out += '<td class="previewFieldLabel">'+JS_locationLiLocatio_1133+' </td><td>'+this.longLocation+'</td></tr>';
	out += '</table></td>';
	if(isIPRealm && this.isIronClad && this.rating != "(Pending)") {
		out += '<td style="vertical-align:middle;"><img src="/n_images/i_iron_g.gif"/></td>';
	}
	out += '</tr></table>';
	out += '</div></div>';
	out += '</td></tr></table>';

	return out;
}

function plural(n,s)
{
	if (n == 1)
		return "" + n + " " + s;
	return "" + n + " " + s + "s";
}

function plural(n,s,p)
{
	if (n == 1)
		return "" + n + " " + s;
	return "" + n + " " + p;
}

function tbdDollarString(value, currency)
{
	var ic = currency;
	if (value) {
		var s = dollarString(value, currency);
		var pc = getCurrInfo();
		
		if (currency.match(/^EURO/)) 
			ic = "EUR";
		
		if (ic != pc) {
			atleastOneConverted = 1;
			s += '<br><i>*' + convDollarStr(value, ic, pc)+'</i>';
		}
		return s;
	}
	else
		return JS_auctiondat_TBD_8623;
}

function currencyName(currency)
{
	if (currency == "AUD")
		return JS_auctiondat_AUDolla_8652;
	if (currency == "CAD")
		return JS_auctiondat_CADolla_8021;
	if (currency == "GBP")
		return JS_auctiondat_British_8650;
	if (currency.match(/^EURO/))
		return JS_auctiondat_Euros_8651;
	return JS_auctiondat_USDolla_8652;
}

function getConvRate(fromCurrency, toCurrency)
{
	var d = 0.0;
	var usdEQ = 1;
	
	if ("USD" != fromCurrency) {
		if ("AUD" == fromCurrency)
			usdEQ = 1 / currRates["AUD"];
		else if ("EUR" == fromCurrency)
			usdEQ = 1 / currRates["EUR"];
		else if ("GBP" == fromCurrency)
			usdEQ = 1 / currRates["GBP"];
		else if ("CAD" == fromCurrency)
			usdEQ = 1 / currRates["CAD"];
	}
	
	if ("USD" != toCurrency) {
		if ("AUD" == toCurrency)
			d = usdEQ * currRates["AUD"];
		else if ("EUR" == toCurrency)
			d = usdEQ * currRates["EUR"];
		else if ("GBP" == toCurrency)
			d = usdEQ * currRates["GBP"];
		else if ("CAD" == toCurrency)
			d = usdEQ * currRates["CAD"];
	}
	else {
		d = usdEQ;
	}
	
	return d;
}

function convDollarStr(value, ic, pc)
{
	var convRate = getConvRate(ic, pc);
	var newValue = Math.floor(value * convRate);
	return dollarString(newValue, getPrefCurrency());
}

function getPrefCurrency() {
	pc = getCookie("curr");
	if (pc == null) {
		return realmCurrency;
	}
	
	if (pc.indexOf("US") != -1) {
		return "USD";
	}
	else if (pc.indexOf("GB") != -1) {
		return "GBP";
	}
	else if (pc.indexOf("AU") != -1) {
		return "AUD";
	}
	else if (pc.indexOf("CA") != -1) {
		return "CAD";
	}
	else if (pc.indexOf("IE") != -1) {
		return "EURO-IE";
	}
	else if (pc.indexOf("NL") != -1) {
		return "EURO-NL";
	}
	else if (pc.indexOf("DE") != -1) {
		return "EURO-DE";
	}
	else if (pc.indexOf("FR") != -1) {
		return "EURO-FR";
	}
}

function convDollarString(value)
{
	var newValue = Math.floor(value * convRate);
	return dollarString(newValue, realmCurrency);
}

function AuctionData_timeLeft()
{
	if (irEnabled)
	{
		var nowInMillis = new Date().valueOf() + UTC_Diff;
		return timeSpellOut(this.endTime - nowInMillis, this.extFlags, "*");
	}

	var out = "";
	var mins = Math.floor((this.endTime - sTime) / 60000);

	if (this.extFlags >= 2)
		return JS_auctiondat_Gone_8653;
	if (mins < 1)
		return JS_auctiondat_Lesstha_8654;
	if (mins < 60)
		return plural(mins, "minute");

	if (mins < 1440)
		return plural(Math.floor(mins / 60), "hour") + ", " +
			plural(mins % 60, "min");
	

	return plural(Math.floor(mins / 1440), "day") + ", " +
		plural(Math.floor((mins % 1440) / 60), "hour");
}

function getTZInfo()
{
	var tz = getCookie("tz");
	if (! tz)
		tz = realmTZ;
		
	var info = timezones[tz];
	if (! info) 
		return timezones[realmTZ];
	return info;
}

function getTZOffset()
{
	if (self.dstOffset)
		return getTZInfo()[2] * 3600000;
	return getTZInfo()[0] * 3600000;
}

function getTZName()
{
   if (self.dstOffset)
      return getTZInfo()[3];
	return getTZInfo()[1];
}

function getCurrInfo()
{
	var cvc = getCookie("curr");
	if (cvc == null) {
		cvc = realmCurrency;
		if (cvc.match(/^EURO/))
			return 'EUR';
		else 
			return cvc;
	}
	
	var pc = '';
	if (cvc.indexOf("EURO") != -1) 
		pc = 'EUR';
	else if (cvc.indexOf("GB") != -1)
		pc = 'GBP';
	else if (cvc.indexOf("AU") != -1)
		pc = 'AUD';
	else if (cvc.indexOf("CA") != -1)
		pc = 'CAD';
	else
		pc = "USD";
	
	return pc;
}

function formatSGTime()
{
	return fmtDTstr;
}

function formatTime(time, doSeconds, doTZName)
{
	var theTime = new Date(time + getTZOffset());
	
	var hour = theTime.getUTCHours();
	var min = theTime.getUTCMinutes();
	var sec = theTime.getUTCSeconds();
	var ampm = "";
	var out;
	
	// If the time format is AM/PM
	if(JS_auctiondat_timePattern.search(/([^\']*a[^\']*)/gi) >= 0) {

		if (hour > 11)
		{
			ampm = " " + JS_auctiondat_PM_8655;
			if (hour > 12)
				hour -= 12;
		}
		else
		{
			ampm = " " + JS_auctiondat_AM_8656;
			if (hour == 0)
				hour = 12;
		}	
	} 

	out = hour + ":" + (min < 10 ? "0" : "") + min;
	if (doSeconds)
		out += ":" + (sec < 10 ? "0" : "") + sec;
	out += ampm;
	if (doTZName)
		out += " " + getTZName();

	return out;
}

function AuctionData_getTimeRange(state)
{
	if (this.startTime == this.endTime)
		return JS_auctiondat_TBD_8623;
	if (state == 2)
		return this.state == 3 ? JS_auctiondat_NotSold_8624 : (this.state == 4 ? JS_auctiondat_Reserve_8619 : JS_auctiondat_SOLD_8625);
	return formatTime(this.startTime) + ' - ' + formatTime(this.endTime);
}

function AuctionData_makeLine(lineNum, state)
{
	var out = '<tr valign="middle" bgcolor="#';
	var priceClass = 'regular';
	var ironcladStr = '';

	if (lineNum % 2)
		out += 'f2f2f2';
	else
		out += 'e5e5e5';
	
	out += '"><td align="center">' + this.getTimeRange(state);
	out += '</td><td align="center">';

	if (this.rating == "(Pending)" || this.rating == "N/A" || this.url)
		out += '&nbsp;';
	else
	{
		out += '<input onclick="checkBox(' + this.equipId + ')"';
		if (checked[this.equipId])
			out += ' checked';
		out += ' type="checkbox" name="equipId" value="' +
			this.equipId + '">';
	}

	out += '</td><td>' + this.displayId + '</td>';
	if (!this.url) {
		out += '<td><a onMouseOut="hidePreview()" onMouseOver="showPreview('+this.equipId+', event)" href="' + this.getURL() + '" onClick="return showRegistration(\'document.location.href=\\\'' + this.getURL() + '\\\'\', ' + this.equipId + ', false)">' + this.description + '</a></td>';
	}
	else {
		out += '<td><a onMouseOut="hidePreview()" onMouseOver="showPreview('+this.equipId+', event)" href="' + this.getURL() + '" onClick="return showRegistration(\'document.location.href=\\\'' + this.getURL() + '\\\'\', ' + this.equipId + ', false)">' + this.description + '</a></td>';
	}
		
	if(isIPRealm) {
	   if (this.rating == "(Pending)")
	   	ironcladStr = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---';
	   else
	   	ironcladStr = (this.isIronClad ? '<img src="/images/ironclad_assurance_icon.gif" align="absmiddle">'+JS_quoteDetai_Yes_8261 : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+JS_quoteDetai_No_8260);
        }	

	if (this.url)
	{
		if (this.state == 0 && self.hasBidRole)
		{
			out += '<td style="padding-right:8px;"><input type="button" onclick=location.href="/jsp/equip/bidPage.jsp?equipId=' + this.equipId + '&groupId=' + saleGroupId + '" value="' + JS_auctiondat_PlacePr_8743 +'" /></td>';
		}
		else
		{
			out += '<td></td>';
		}
	}
	else
		out += '<td align=right></td>';
	out += '<td>' + ironcladStr + '</td>';
	out += '<td align="right">' + this.longLocation + '</td>';
	if (self.showReserve)
	{
	    // show reserve column, no currency symbol, no conversion;
        // display - if there is no reserve, i.e., reserveType is 0
	    out += '<td align="right"><span id="IP$' + this.equipId + '_reserveprice" class="' +
			    priceClass + '">';
	    if (this.reserveType == 0)
	    {
	        out += '-&nbsp;&nbsp;';
	    }
	    else
	    {
	        out += dollarString(this.reservePrice, this.currency);
	    }
	    out +=  '</span></td>';
    }
	out += '<td align="right">';
	if (loggedIn == this.highBidder && saleGroupMode > 0)
	{
		out += '<img border=0 src="/images/notice.gif" width=14 height=14>';
		priceClass = 'green';
	}

	if (this.state == 3)
		out += JS_auctiondat_NotSold_8624;
	else
		out += '<span id="IP$' + this.equipId + '_price1" class="' +
			priceClass + '">' +
			tbdDollarString(this.price, this.currency) + '</span>';
	out += '</td>';		
	out += '</tr>'
	return out;
}

function AuctionData_makeByTypeLine(lineNum, state)
{
	var out = '<tr valign="middle" bgcolor="#';
	var priceClass = 'regular';
	var ironcladStr = '';

	if (lineNum % 2)
		out += 'f2f2f2';
	else
		out += 'e5e5e5';
	
	out += '"><td width="1%" height="22" align="center">';

	if (this.rating == "(Pending)" || this.rating == "N/A" || this.url)
		out += '&nbsp;';
	else
	{
		out += '<input onclick="checkBox(' + this.equipId + ')"';
		if (checked[this.equipId])
			out += ' checked';
		out += ' type="checkbox" name="equipId" value="' +
			this.equipId + '">';
	}
		
	if(isIPRealm) {
	   if (this.rating == "(Pending)")
	   	ironcladStr = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---';
	   else
	   	ironcladStr = (this.isIronClad ? '<img src="/images/ironclad_assurance_icon.gif" align="absmiddle">'+JS_quoteDetai_Yes_8261 : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+JS_quoteDetai_No_8260);
        }

	if (!this.url) {
		out += '</td><td><a onMouseOut="hidePreview()" onMouseOver="showPreview('+this.equipId+', event)" href="' + this.getURL() + '" onClick="return showRegistration(\'document.location.href=\\\'' + this.getURL() + '\\\'\', ' + this.equipId + ', false)">' + this.description + '</a></td>';
	}
	else {
		out += '</td><td><a onMouseOut="hidePreview()" onMouseOver="showPreview('+this.equipId+', event)" href="' + this.getURL() + '" onClick="return showRegistration(\'document.location.href=\\\'' + this.getURL() + '\\\'\', ' + this.equipId + ', false)">' + this.description + '</a></td>';
	}
	if (this.url)
	{
		if (this.state == 0 && self.hasBidRole)
		{
			out += '<td style="padding-right:8px;"><input type="button" onclick=location.href="/jsp/equip/bidPage.jsp?equipId=' + this.equipId + '&groupId=' + saleGroupId + '" value="' +JS_auctiondat_PlacePr_8743 + '"/></td>';
		}
		else
		{
			out += '<td></td>';
		}
	}
	else
		out += '<td align=right></td>';
	out += '<td>' + ironcladStr + '</td>';
	out += '<td align="right">' + this.longLocation + '</td>';

	if (self.showReserve)
	{
	    // show reserve column, no currency symbol, no conversion;
        // display - if there is no reserve, i.e., reserveType is 0
	    out += '<td align="right"><span id="IP$' + this.equipId + '_reserveprice" class="' +
			    priceClass + '">';
	    if (this.reserveType == 0)
	    {
	        out += '-&nbsp;&nbsp;';
		}
	    else
	    {
	        out += dollarString(this.reservePrice, this.currency);
	    }
	    out +=  '</span></td>';
    }
	out += '<td align="right">';
	if (loggedIn == this.highBidder && saleGroupMode > 0)
	{
		out += '<img border=0 src="/images/notice.gif" width=14 height=14>';
		priceClass = 'green';
	}

	if (this.state == 3)
		out += JS_auctiondat_NotSold_8624;
	else
		out += '<span id="IP$' + this.equipId + '_price" class="' +
			priceClass + '">' +
			tbdDollarString(this.price, this.currency) + '</span>';
	out += '</td>';
	out += '<td align="right">' + this.displayId + '</td><td align="center">';
	out += this.getTimeRange(state) + '</td></tr>';

	return out;
}

function AuctionData_nextPrice()
{
	if (this.bidCount == 0)
		return this.price;
	return this.price + this.increment;
}


function AuctionData(equipId, description, startTime, mins, price, increment,
			pictureUrl, location, longLocation, rating, category, state, bidCount,
			highBidder, extended, needsTransport, width, height,
			isIronClad, currency, catSortOrder, displayId, url,
			reserveType, reservePrice, strikePrice)
{
	if (rating == JS_auctiondat_NA_8626 && state == 0)
		rating = JS_auctiondat_Pending_8627;

	this.equipId = equipId;
	this.description = description;
	this.startTime = startTime * 60000;
	this.endTime = this.startTime + mins * 60000;
	this.price = price;
	this.increment = increment;
	this.pictureUrl = pictureUrl;
	this.location = location;
	this.longLocation = longLocation;
	this.rating = rating;
	this.state = state;
	this.bidCount = bidCount;
	this.highBidder = highBidder;
	this.extFlags = extended;
	this.category = category;
	this.needsTransport = needsTransport;
	this.width = width;
	this.height = height;
	this.isIronClad = isIronClad;
	this.currency = currency;
	this.catSortOrder = catSortOrder;
	this.displayId = displayId;
	this.url = url;
	this.reserveType = reserveType;
	this.reservePrice = reservePrice;
	this.strikePrice = strikePrice;
	this.features = null; 
	this.serial = null;
	this.usage = null;
	
	this.column = -1;
	this.sibling = -1;

	if (this.state == 0)
		upcomingItemCount++;
}


// Assign methods to prototype object; will be inherited by instances.
new AuctionData();		// for JS 1.1 compatibility
AuctionData.prototype.makeCube = AuctionData_makeCube;
AuctionData.prototype.makeReserveCube = AuctionData_makeReserveCube;
AuctionData.prototype.makeLine = AuctionData_makeLine;
AuctionData.prototype.makeByTypeLine = AuctionData_makeByTypeLine;
AuctionData.prototype.timeLeft = AuctionData_timeLeft;
AuctionData.prototype.nextPrice = AuctionData_nextPrice;
AuctionData.prototype.toTableRow = AuctionData_toTableRow;
AuctionData.prototype.getTimeRange = AuctionData_getTimeRange;
AuctionData.prototype.getURL = AuctionData_getURL;


function makeTray(items)
{
	var out;

	out = '<form name="trayForm" method="POST" action="/jsp/equip/confirmBid.jsp?h=' + crumb + '">';
	out += '<input type="hidden" name="equipId" value="">';
	out += '<input type="hidden" name="autobid" value="">';
	out += '<input type="hidden" name="oneClickBid" value="">';
	out += '<table width="100%" border="0" cellspacing="2" cellpadding="0"><tbody>' + "\n";
	var column = 0;
	var gotOne = 0;
	var lastStartTime = 0;
	var lastLeft = -1;

	equips_on_page = new Array();
	loggedIn = getCookie("loggedin");

	items.sort(function(a,b) {
		if (a.startTime < b.startTime)
			return -1;
		if (a.startTime > b.startTime)
			return 1;
		if (a.equipId < b.equipId)
			return -1;
		if (a.equipId > b.equipId)
			return 1;
		return 0;
		});

	for (var i = 0; i < items.length; i++)
	{
		var item = items[i];
		if (item.state == 1)
		{
			if (lastStartTime != item.startTime && column == 1)
			{
				out += '<td></td></tr>';
				column = 0;
				lastLeft = -1;
			}

			if (lastStartTime != item.startTime)
			{
				out += '<tr><td colspan="2" align="center"><font color="#606060">'+JS_ir_Openeda_8695+' ' + formatTime(item.startTime) + ':</font></td></tr>';
			}

			lastStartTime = item.startTime;

			if (item.column == 0 && column == 1)
			{
				out += '<td></td></tr>';
				column = 0;
			}
			else if (item.column == 1 && column == 1 &&
				lastLeft != -1 && item.sibling != -1 &&
				lastLeft != item.sibling)
			{
				out += '<td></td></tr><tr><td width="50%"></td>';
			}

			if (column == 0)
				out += '<tr valign="top"><td width="50%" align="right">';
			else
				out += '<td width="50%">';

			if (item.column == 1 && column == 0)
			{
				out += '</td><td>';
				column = 1;
			}

			item.column = column;
			out += item.makeCube();
			out += "\n</td>";

			if (column == 1)
			{
				out += '</tr>';
				item.sibling = lastLeft;
				lastLeft = -1;
			}
			else
				lastLeft = item.equipId;

			column = (column + 1) % 2;
			gotOne = 1;

			equips_on_page[equips_on_page.length] = item.equipId;
		}
	}

	if (gotOne)
	{
		if (column > 0)
			out += '<td colspan="' + (2 - column) + '">&nbsp;</td></tr>';
		out += '</tbody></table>';
		out += '</form>';
		return out;
	}

	return "";
}

function previewHeader(category, byType, state)
{
	var out = "";
	var timeCell = '<td width="20%" align="center"><b>';

	if (state == 2)
		timeCell += JS_auctiondat_Auction_8629+'</b></td>';
	else
	{
		timeCell += JS_auctiondat_Auction_8628+' </b><br><font size="1"><nobr>' +
			'(<a href="/jsp/equip/timezone.jsp?h=' + crumb +
			'" title="' + JS_auction_dy_Wrongti_5306 + '">' +
			getTZName() + '</a>)</nobr></font></td>';
	}
	
	var headerStr = '<td width="1%">&nbsp;</td>';
	
	if(isIPRealm) 
	   headerStr = '<td width="11%"><B>'+JS_auctiondat_IronCla_6604+'</B></td>';
	

	if (byType != 0)
	{
		out += '<TR valign="middle" BGCOLOR="#CCCCCC">';
		if (self.showReserve)
		{
		    // make room for reserve price column
		    out += '<TD width="28%" COLSPAN="2"><FONT SIZE="3"><B>&nbsp;' + category + '</B></FONT></TD>';
		}
		else
		{
		out += '<TD width="36%" COLSPAN="2"><FONT SIZE="3"><B>&nbsp;' + category + '</B></FONT></TD>';
	    }
		out += '<td width="1%">&nbsp;</td>';
		out +=  headerStr;
		out += '<TD width="7%" align="right"><B>'+JS_search_equ_Loc_6084+'&nbsp;&nbsp;</B></TD>';
		if (self.showReserve)
		{
		     // display reserve column
		     out += '<TD  align="right" width="10%">&nbsp;<B>';
			 out += JS_auctiondat_ReserveWord_8619;
		     out += '</B></TD>';
		}
		out += '<TD width="15%" align="right"><B>';
		if (state == 2)
			out += JS_auctiondat_Winning_8630;
		else
			out += JS_auctiondat_OpensAt_8631;
		out += '</B></TD>';
		out += '<TD width="8%" align="right"><B>'+JS_item_item_2286+'</B></TD>';
		out += timeCell;
		out += '</tr>';
	}
	else
	{
		out += '<tr valign=top BGCOLOR="#CCCCCC">';
		out += timeCell;
		out += '<td width="1%" align="center">&nbsp;</td>';
		out += '<td width="8%"><b>'+JS_item_item_2286+'</b></td>';
		if (self.showReserve)
		{
			// make room for reserve price
			out += '<td width="28%"><b>'+JS_panel_invo_Descrip_5887+'</b></td>';
	    }
	    else
	    {
		out += '<td width="34%"><b>'+JS_panel_invo_Descrip_5887+'</b></td>';
		}
		out += '<td width="0%">&nbsp;</td>';
		out += headerStr;
		out += '<td width="7%" align="right"><B>'+JS_search_equ_Loc_6084+'&nbsp;&nbsp;</B></td>';
		if (self.showReserve)
		{
		     // display reserve column
		     out += '<TD  align="right" width="10%">&nbsp;<B>';
			 out += JS_auctiondat_ReserveWord_8619;
		     out += '</B></TD>';
		}
		
		out += '<td width="13%" align="right"><b>';
		if (state == 2)
			out += JS_auctiondat_Winning_8630;
		else
			out += JS_auctiondat_OpensAt_8631;

		out += '</b></td>';
		out += '</tr>';
	}

	return out;
}

function sortOrderLink(state, byType, minutes)
{
	var when;
	
	if (state == 2 && byType == 0)
	{
	    if (self.showNonSold) {
		     when = JS_auctiondat_SoldNotIte_8632;
		}
		else {
		when = JS_auctiondat_SoldIte_8632;
		}
    }
	else if (minutes == 30)
		when = JS_auctiondat_AllItem_8633;
	else
		when = "";

	eval(JSe_auctiondat_View0by_8638);

	return '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
		'<a href="javascript:void(0);" onclick="setByType(' +
		(byType != 0 ? '0)"><b>'+JS_auctiondat_ViewbyT_8634+'</b></a></td>' :
		          '1)"><b>'+JS_auctiondat_View0by_8638+'</b></a>');
}

function makeLines(items, minutes, state, minItems, byType)
{
	var out = '<a name="upcomingAnchor"></a><table border="0" cellpadding="0" cellspacing="0" width="95%" align="center">';
	var lineNum = 1;
	var ratedItems = 0;
	var hiddenItems = 0;
	var hasNextThirty = 0;
	var hasSold = 0;
	var hasToday = 0;
	var moreThanThirty = 0;
	var compareLink = "";
	var showLaterLink = "";
	var thirty = new Date().valueOf() + (30 * 60 * 1000);
	var eightHours = thirty + (15 * 30 * 60 * 1000);
	var i;

	items.sort(function(a,b) {
		if (byType != 0)
		{
			if (a.catSortOrder < b.catSortOrder)
				return -1;
			if (a.catSortOrder > b.catSortOrder)
				return 1;

			var ad = a.description, bd = b.description;
			if (a.category < b.category)
				return -1;
			if (a.category > b.category)
				return 1;
			if (ad.match(/\d{4} /)) {
				ad = ad.substring(5)
                ad = ad.replace(/\(.*verified\) /,"");
            }
			if (bd.match(/\d{4} /)) {
                bd = bd.substring(5);
                bd = bd.replace(/\(.*verified\) /,"");
            }
			if (ad < bd)
				return -1;
			if (ad > bd)
				return 1;
			if (a.description < b.description)
				return 1;
			if (a.description > b.description)
				return -1;
		}

		if (state == 2)
		{
			if (a.endTime > b.endTime)
				return -1;
			if (a.endTime < b.endTime)
				return 1;
		}
		else
		{
			if (a.startTime < b.startTime)
				return -1;
			if (a.startTime > b.startTime)
				return 1;
		}

		if (a.equipId < b.equipId)
			return -1;
		if (a.equipId > b.equipId)
			return 1;
		return 0;
		});

	for (var i = 0; i < items.length; i++)
	{
		if (items[i].state == 0 && items[i].startTime <= thirty)
			hasNextThirty = 1;
		if (items[i].state == 0 && items[i].startTime <= eightHours)
			hasToday = 1;
		if (items[i].state == 2)
			hasSold = 1;
	}

	if (! hasNextThirty)
		minutes = 1000000;

    if (self.showReserve)
    {
	     out += '<tr bgcolor="#ffffcc"><td colspan="9">';
	}
	else {
	out += '<tr bgcolor="#ffffcc"><td colspan="8">';
	}
	out += '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
	out += '<td align="left"><b>';

	if (state == 0 && upcomingItemCount > 0) {
		eval(JSe_auctiondat_ComingU_8639);
		if (minutes < 1000000)
			out += JS_auctiondat_ComingU_8639;
		else if (hasToday)
			out += JS_auctiondat_ComingU_8635;
		else
			out += saleGroupTitle;

		out += '-- ' + JS_auctiondat_Priorit_6737 + '</b>' +
			sortOrderLink(state, byType, minutes) + '</td>';
		out += '<td align="right">';
		if (hasSold) {
		    if (self.showNonSold) {
		        out += '<a href="javascript:void(0);" onclick="setPreviewStyle(2)"><b>'+JS_auctiondat_ViewSolNot_8745+'</b></a>';
		    } else {
			out += '<a href="javascript:void(0);" onclick="setPreviewStyle(2)"><b>'+JS_auctiondat_ViewSol_8745+'</b></a>';
		}
		}
		else {
			out += formatSGTime();
		}
		out += '</td>';
	}
	else {
	    if (self.showNonSold) {
			out += JS_auctiondat_JustSolNot_8636+'</b>' +
				sortOrderLink(state, byType, minutes) + '</td>';
		} else {
		out += JS_auctiondat_JustSol_8636+'</b>' +
			sortOrderLink(state, byType, minutes) + '</td>';
		}
		if (upcomingItemCount > 0)
			out += '<td align="right"><a href="javascript:void(0);" onclick="setPreviewStyle(0)"><b>'+JS_auctiondat_ViewUpc_8744+'</b></a></td>';
	}

	out += "</tr></table></td></tr>\n";

	if (byType == 0)
		out += previewHeader(null, byType, state) + "\n";

	var lastCategory = "";

	for (var i = 0; i < items.length; i++)
	{
	    <!-- status: 0 preview; 1 auction; 2 sold; 3 not sold -->
		var item = items[i];
		
		if (state != null && item.state != state &&
		    ! (state == 2 && (item.state == 3 || item.state == 4) && self.showNonSold))
		{
			continue;
		}
		if (! minItems || lineNum > minItems)
			if (item.startTime > sTime + (minutes * 60000)) {
				hiddenItems++;
				continue;
			}
		if (item.startTime > sTime + (30 * 60000)) {
			moreThanThirty++;
		}
		
		if (lastCurrency != item.currency)
		{
			lastCurrency = item.currency;
			currencyCount++;
		}

		if (byType != 0 && lastCategory != item.category)
		{
			if (lastCategory != "")
				out += '<TR valign="top"><TD COLSPAN="8">&nbsp;</TD></TR>';
			lastCategory = item.category;
			out += previewHeader(lastCategory, 1, state);
			lineNum = 0;
		}

		if (byType != 0)
			out += item.makeByTypeLine(lineNum++, state) + "\n";
		else
			out += item.makeLine(lineNum++, state) + "\n";

		if (item.rating != 'PENDING' && item.rating != 'N/A' && ! item.url)
			ratedItems++;
	}

	if (ratedItems > 1)
		compareLink = '<div><img src="/n_images/LeftUpArrow.gif" style="float: left;padding: 0px 8px 0px 4px;"/><a href="#" onclick="return showRegistration(\'compareReports();\', null, false);" class="buttonClass"><span><nobr>' + JS_auctiondat_Compare_8657 +'</nobr></span></a><div class="clear" style="font-weight:bold;">' + JS_searchresults_SeeSideB_7363 + '</div></div>';
	if (hiddenItems > 0 && state == 0 && saleGroupMode == 1)
		showLaterLink = '<a href="javascript:void(0);" onclick="setPreviewStyle(1)"><b>'+JS_auctiondat_LaterTo_8746+'</b></a>';
	else if (moreThanThirty > 0 && state == 0 && saleGroupMode == 1)
		showLaterLink = '<a href="javascript:void(0);" onclick="setPreviewStyle(0)"><b>'+JS_auctiondat_ComingU_8747+'</b></a>';
	else if (state == 2 && upcomingItemCount > 0)
		showLaterLink = '<a href="javascript:void(0);" onclick="setPreviewStyle(0)"><b>'+JS_auctiondat_ViewUpc_8744+'</b></a>';

	if (byType != 0)
	{
		out += '<tr><td colspan="2" valign="top">' + compareLink;
		out += '</td><td colspan=4 align="left" valign="top">&nbsp;';
		if (ratedItems > 0 && isIPRealm)
			out += ironcladIndicator;
		out += '</td><td colspan=2 align="center" valign="top">' + showLaterLink;
		out += '</td></tr>';
	}
	else
	{
		out += '<tr><td align="center" valign="top">' + showLaterLink;
		out += '</td><td colspan=3 valign="top">' + compareLink;
		out += '</td><td colspan=4 align="left" valign="top">&nbsp;';
		if (ratedItems > 0 && isIPRealm)
			out += ironcladIndicator;
		out += '</td></tr>';
	}
	
	if (saleGroupMode == 0)
		out += '<tr><td colspan="8" align="center"><span id="bottomPreviewMessage">' + previewMessage() + '</span></td></tr>';

	eval(JSe_auctiondat_NoteBid_8640);
	out += '<tr><td colspan="8" align="center"><table width="85%" border="0"><tr><td><br><br>'+JS_auctiondat_NoteBid_8640;

	if (fmtDTstr.length > 1) {
		out += '<br>' + JS_future_auc_timezone_footnote_2862 + '.';
	}
	
	if (atleastOneConverted == 1) {
		out += ' <i>' + JS_currency_conversion_footnote_2863 + '</i>';
	}

	out += '</td></tr></table></td></tr>';

	return out + '</table><a name="end"></a>';
}

function setEquipsOnPage(eop)
{
	equips_on_page = eop;
	objEquipCount = eop.length;
}

function populatePreviewMessage()
{
	var targetDoc = getTargetDoc();
	var txt = previewMessage();
	var p;

	if ((p = targetDoc.getElementById("previewMessage")) != null)
		p.innerHTML = txt;
	if ((p = targetDoc.getElementById("bottomPreviewMessage")) != null)
		p.innerHTML = txt;

	if (saleGroupMode > 0 &&
	    (p = targetDoc.getElementById("ownerMessage")) != null)
		p.innerHTML = "";
}

function previewMessage()
{
	// Preview message is empty for non-preview public groups
	if (saleGroupScope != 'private' && saleGroupMode > 0)
		return "";

	var txt = '<table width="752" border="0" cellspacing="3" align="center">';
	if (saleGroupDescr)
	{
		txt += '<tr><td align="center"><br>' +
			saleGroupDescr + '</td></tr>';
	}

	txt += '<tr><td align="center">';
	if (consignNotes)
	{
		txt += consignNotes;
	}
	txt += '</td></tr></table>';

	return txt;
}

function populateStatusMessage()
{
	var targetDoc = getTargetDoc();
	var m = targetDoc.getElementById("status");
	var bar = targetDoc.getElementById("bar1");
	var txt = "";
	var bg = "aucPublicBar";

	if (saleGroupMode == 1)
	{
		if (saleGroupScope == 'public' || saleGroupScope == 'practice')
		{
			txt += '<IMG SRC="/images/icon_people.gif" ' +
				'WIDTH="18" HEIGHT="18" BORDER="0" ' +
				'ALIGN="absmiddle" ALT=""> ' +
				JS_auctiondat_TodaysV_8659 +
				'<b ID="UserCount">' +
				userCount +
				'</b>';
		}
	}
	else if (saleGroupMode == 0)
	{
		txt += '<span class=b>'+JS_auctiondat_Auction_8643 +
			'<b id="IP$AuctionOpens">'+JS_auctiondat_Initial_8644 +
			'<a href="/jsp/equip/auction.jsp?irx=0&groupId=' +
			saleGroupId + '" title=JS_auctiondat_Clickif_8645>'+JS_auctiondat_Takingt_8646+'</a></b></span>';
	}

	if (m != null)
		m.innerHTML = txt;

	if (bar != null)
	{
		if (saleGroupScope == 'public')
			bar.className = 'aucPublicBar';
		else
			bar.className = 'aucPrivateBar';
	}

	if ((m = targetDoc.getElementById("tzlink")))
	{
		m.href = "/jsp/equip/timezone.jsp?h=" + crumb;
	}
}

function previewCornerLinks()
{
	var out = '';

	out += '<a href="javascript:var w = window.open(' + "'/pop/how_prioritybid_works_nd.jsp','helpWindow','width=525,height=450,scrollbars,resizable');" + '">'+JS_auctiondat_HowPrio_8748+'</a>';
	out += '<br><img SRC="/images/space.gif" WIDTH="1" HEIGHT="8" BORDER="0">';

	return out;
}

function loginForm()
{

	var loggedIn = getCookie("loggedin");
	var loginName = getCookie("login");
	var irEnabled = getCookie("irx");
	var roles = getCookie("roles");
	var out = "";
	var hasForm = 0;
	var i;

	if (saleGroupMode == 0)
		return previewCornerLinks();

	if (loginName == null)
		loginName = "";
	if (roles == null)
		roles = "";
	
	if (loggedIn && loginName != "")
	{
		var wins = 0;

		if (! isPractice)
		{
			for (i in indexList)
			{
				if ((indexList[i].state == 2 ||
				     indexList[i].extFlags == 2) &&
				    indexList[i].highBidder == loggedIn)
				{
					wins++;
				}
			}
		}
		var rbpCookie = getCookie("RBP");
		var rbp = false;
		
		if ( rbpCookie != null && rbpCookie == 'Y' )
			rbp = true;
			
		out += '<table border="0" cellpadding="0" cellspacing="1">';
		if (roles.indexOf('b') > -1 || roles.indexOf('a') > -1)
		{
//			out += "<tr><td>&nbsp;</td></tr>";
//			out += "<tr><td>"+JS_auctiondat_Yourelo_8647+"&nbsp;<nobr><b>"+loginName+"</b></nobr>&nbsp;&nbsp;&nbsp;&nbsp;<a href=/jsp/logout_nd.jsp><b>"+JS_auctiondat_Logout_8648+"</b></a><br></td></tr>";

			if (wins > 0)
			{
			    eval(JSe_auctiondat_Congrat_8730);
			    eval(JSe_auctiondat_Congrat_8731);
				if(wins == 1)
					out += '<tr bgcolor="#FFFFCC"><td><b>'+JS_auctiondat_Congrat_8730+'</b></td></tr>';
				if (wins > 1)
					out += '<tr bgcolor="#FFFFCC"><td><b>'+JS_auctiondat_Congrat_8731+'</b></td></tr>';
			}
		}
		else if (roles.indexOf('s') > -1)
		{
//			out += "<tr><td>"+JS_auctiondat_Yourelo_8647+"&nbsp;<nobr><b>"+loginName+"</b></nobr>&nbsp;&nbsp;&nbsp;&nbsp;<a href=/jsp/logout_nd.jsp><b>"+JS_auctiondat_Logout_8648+"</b></a><br></td></tr>";
			if ( !rbp )
				out += "<tr bgcolor=#FFFFCC><td><b>"+JS_auctiondat_Reminde_8752+"</b>&nbsp;"+JS_auctiondat_Tobidyo_8751+"</a>&nbsp;</td></tr>";
		}
		else
		{
//			out += "<tr><td>"+JS_auctiondat_Yourelo_8647+"&nbsp;<nobr><b>"+loginName+"</b></nobr>&nbsp;&nbsp;&nbsp;&nbsp;<a href=/jsp/logout_nd.jsp><b>"+JS_auctiondat_Logout_8648+"</b></a><br></td></tr>";
			if ( !rbp )
				out += '<tr bgcolor=#FFFFCC><td>'+ JS_auctiondat_Tobidyo_8751 + '&nbsp;</td></tr>';
		}

		out += '</table>';
	} else {
//		out += '<form method=post action="' + JS_auctiondat_securePrefix +'/jsp/acct/login.jsp?h=' + crumb + '">';
//		out += '<table border="0" cellpadding="0" cellspacing="1">' + "\n";
		if(irEnabled==1)
		{
			if(loginName)
			{
//				out += '<tr bgcolor="#FFFFCC"><td align=left colspan=4><img src=/images/notice.gif border=0>&nbsp;&nbsp;'+JS_auctiondat_Loginto_6280+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/jsp/acct/login.jsp" target=new>'+JS_auctiondat_LoginHe_6281+'</A></td></tr>';
			} else {
//				out += '<tr bgcolor="#FFFFCC"><td align=left colspan=4><img src=/images/notice.gif border=0>&nbsp;&nbsp;'+JS_auctiondat_NewUser_8754+'</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/jsp/acct/login.jsp" target=new>'+JS_auctiondat_LoginHe_8753+'</A></td></TR>';
			}
		} else {
			if(loginName)
			{
//				out += '<tr bgcolor="#FFFFCC"><td align=left colspan=4><img src=/images/notice.gif border=0>&nbsp;&nbsp;<b>'+JS_searchuser_Registe_1094+'</b>:&nbsp;'+JS_auctiondat_Loginbe_6285+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/jsp/acct/login.jsp" target=new>'+JS_auctiondat_LoginHe_6281+'</A></td></TR>';
			} else {
//				out += '<tr bgcolor="#FFFFCC"><td align=left colspan=4><img src=/images/notice.gif border=0>&nbsp;&nbsp;<b>'+JS_auctiondat_NewUser_8754+'</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/jsp/acct/login.jsp" target=new>'+JS_auctiondat_LoginHe_6281+'</A></td></TR>';
			}
		}

//		out += "<tr><td>"+JS_confirm_sh_LoginID_9913+"&nbsp;<input name='!login' style='width:90px;padding-left:2px' size=10 maxlength=30 id='IP$LoginField' value='"+loginName+"'></td>";
//		out += "<td>&nbsp;</td>";
//		out += "<td>"+JS_auctiondat_Passwor_6282+"&nbsp;<input type=password name='!password' style='width:90px;padding-left:2px' size=10 maxlength=16></td>";
//		out += '<td><span class="buttonClass"><INPUT TYPE="submit" BORDER=0 title="' +JS_auctiondat_Enteryo_8660 +'" value="'+JS_button_btn_login2_nd+'"></span></td></tr>';				
		if (realmId == 1 || realmId == 3) {
//			out += '<tr><td colspan=4 align="center">'+JS_auctiondat_Termsan_6283+'</a>. '+JS_auctiondat_Lastrev_6284+'</td></tr>';                            
		}
		else if (realmId == 2) {
//			out += '<tr><td colspan=4 align="center">'+JS_auctiondat_aus_Termsan_6283+'</a>. '+JS_auctiondat_aus_Lastrev_6284+'</td></tr>';                            
		}


//      out += "</table>";
//      out += "</form>";
	}

	return out;
}

function dumpState() {
	var i;
	var proto = itemList[0];
	var table = '<table border="1"><tr><th>ID</th>';
	var props = new Array();
	var pieces = new Array();

	props[0] = 'equipId';

	for (i in proto) {
		if (i != 'equipId' && typeof(proto[i]) != 'function') {
			props[props.length] = i;
			table += '<th>' + i + '</th>';
		}
	}

	table += '</tr>';

	for (i in indexList) {
		pieces[pieces.length] = i;
	}
	pieces.sort();

	for (i in pieces) {
		table += indexList[pieces[i]].toTableRow(props);
	}

	table += '</table>';
	debug('<br>' + table);
}

function checkStale() {
	var i;

	for (i = 0; i < itemList.length; i++) {
		if (itemList[i].state == 0 &&
		    itemList[i].startTime < sTime &&
		    itemList[i].endTime > sTime) {
			debug('Item ' + itemList[i].equipId + ' open is late');
			MarkForRefresh(0, "noOpen," + itemList[i].equipId);
		}

		if (itemList[i].state == 1 &&
		    itemList[i].extFlags < 2 &&
		    itemList[i].endTime + 110000 < sTime) {
			debug('Item ' + itemList[i].equipId + ' close is late');
			MarkForRefresh(0, "noClose," + itemList[i].equipId);
		}
	}
}

function shuffleTimeslot(eqId) {
	var when;
	var i;

	if (indexList[eqId]) {
		when = indexList[eqId].startTime;
        for (i = 0; i < itemList.length; i++) {
			if (itemList[i].startTime == when) {
				itemList[i].column = -1;
				itemList[i].sibling = -1;
			}
		}
	}
}
