var iOne_day = 60*60*24;
if(typeof(iParse_limit) == 'undefined') {var iParse_limit = 5;}
if(typeof(bAuction_in_progress) == 'undefined') {var bAuction_in_progress = false;}
if(typeof(bAuction_frozen) == 'undefined') {var bAuction_frozen = true;}
if(typeof(iTime_left) == 'undefined') {var iTime_left = 0;}
if(typeof(fMin_bid) == 'undefined') {var fMin_bid = 99999999999999999999;}
if(typeof(sPage_buyout_no_discl) == 'undefined') {var sPage_buyout_no_discl = window.location;}

function beginrefresh() {
	if (!document.images) {
		return
	}
	if (iParse_limit==1) {
		window.location.reload(false);
	}
	else {
		iParse_limit-=1;
		setTimeout("beginrefresh()",1000);
	}
}

function updatePageRef(fBuyout_price, bDiscl_ok, sPage_buyout_no_discl) {
	var oBidbox = document.getElementById("tbBidBox");
	var oBid = oBidbox.value.replace(",",".");
	var fBid = parseFloat(oBid);
	var oHf_page = document.getElementById("auction_page");
	var oHf_bidtype = document.getElementById("auction_bid_type");

	if (fBuyout_price > 0) {
		if (fBid >= fBuyout_price) {
			//direct_buy
			oHf_bidtype.value = 'direct_buy';
			if (!bDiscl_ok) {
				oHf_page.value = sPage_buyout_no_discl;
			}
		}
	}
}

function bidClick(){
	var oBidbox = document.getElementById("tbBidBox");
	var oBtn_bid = document.getElementById("btnBid");

	oBtn_bid.focus();
	bidChange();
}


function bidChange() {
	var oBidbox = document.getElementById("tbBidBox");
	var oBtn_bid = document.getElementById("btnBid");
	var oDiv_bid = document.getElementById("divBid");
	var oSetbox = document.getElementById("setBidBox");

	var oBid = oBidbox.value.replace(",",".");

	var fBid = parseFloat(oBid);

	if (fBid.toString() == 'NaN' || fBid == 0 || !bAuction_in_progress) {
		oBtn_bid.disabled = true;
		oBtn_bid.style.color = "#808080";
		oBtn_bid.style.cursor = 'default';
	}
	else if (fBid < fMin_bid) {
		oBtn_bid.disabled = true;
		oBtn_bid.style.cursor = 'default';
		oBtn_bid.style.color = "#808080";
	}
	else {
		oBtn_bid.disabled = false;
		oBtn_bid.style.cursor = 'pointer';
		oBtn_bid.style.color = "#000000";
		oSetbox.value = fBid;
	}
}

function noBid() {
	//nothing
}

function UpdateTimeLeft(sLbl_days, sLbl_day) {
	var oSpan_time_left = document.getElementById("span_auction_remaining_time");
	var iDays = 0;
	var iSeconds = iTime_left % 60;
	var iMinutes = Math.floor((iTime_left % (60*60))/60);
	var iDays = Math.floor(iTime_left / (60*60*24));
	var iHours = Math.floor(((iTime_left)/(60*60))-iDays*24);

	if (iHours < 10) iHours = '0' + iHours;
	if (iMinutes < 10) iMinutes = '0' + iMinutes;
	if (iSeconds < 10) iSeconds = '0' + iSeconds;



	if ((!bAuction_in_progress) || (iTime_left < 1)) {
		//		oSpan_time_left.innerHTML = '---';
		// disable bid button
		bAuction_in_progress = false;
		bidChange();
	}

	if (iDays > 1) {
		oSpan_time_left.innerHTML =  iDays + ' ' + sLbl_days + ' ' + iHours + ':' + iMinutes  + ':' + iSeconds;
	}
	else if (iDays == 1) {
		oSpan_time_left.innerHTML =  iDays + ' ' + sLbl_day + ' ' + iHours + ':' + iMinutes  + ':' + iSeconds;
	}
	else {
		oSpan_time_left.innerHTML =  iHours + ':' + iMinutes  + ':' + iSeconds;
	}
	iTime_left = Math.max(0, iTime_left - 1);
	//timerID = setTimeout("UpdateTimeLeft()", 1000);
	setTimeout("UpdateTimeLeft('" + sLbl_days + "','" + sLbl_day + "')", 1000);
}

function cancel_bid(bid_id, form_id, question) {
	if (confirm(question)) {
		var oForm = document.getElementById(form_id);
		var oHidden = document.getElementById('bid_val_input');
		oHidden.value = bid_id;
		oForm.submit();
	}
}

function popZoom(sLink) {
	zoomwindow = window.open (sLink, "zoomwindow",	"location=0,status=0,scrollbars=0,width=510,height=530");
	zoomwindow.moveTo(0,0);
	zoomwindow.focus();
}

//function popVideoZoom(template,url,file,variables,wdth,hght)
function popVideoZoom(sTemplate) {
	auctionwindow = window.open (sTemplate, "auctionwindow",	"location=0,status=0,scrollbars=0,width=500,height=370");
	auctionwindow.moveTo(0,0);
	auctionwindow.focus();
}



function popPlacedZoom(sFile) {
	placedwindow = window.open (sFile, "placedwindow",	"location=0,status=0,scrollbars=0,width=856,height=350");
	placedwindow.moveTo(0,0);
	placedwindow.focus();
}

