<!-- IF B_COUNTDOWN -->
<script type="text/javascript">
$(document).ready(function() {
	var currenttime = '{ENDS_IN}';
	function padlength(what)
	{
		return (what.toString().length == 1)? '0' + what : what;
	}
	function displaytime()
	{
		currenttime -= 1;
		if (currenttime > 0)
		{
			var hours = Math.floor(currenttime / 3600);
			var mins = Math.floor((currenttime - (hours * 3600)) / 60);
			var secs = Math.floor(currenttime - (hours * 3600) - (mins * 60));
			var timestring = padlength(hours) + ':' + padlength(mins) + ':' + padlength(secs);
			$("#ending_counter").html(timestring);
			setTimeout(displaytime, 1000);
		}
		else
		{
			$("#ending_counter").html('<div class="error-box">{L_911}</div>');
		}
	}
	setTimeout(displaytime, 1000);


	var interestEndsIn = '{WINNING_BID_ENDS_IN}';
	function displayInterestEndTime()
	{
		interestEndsIn -= 1;
		
		if (interestEndsIn > 0)
		{
			var days = Math.floor(interestEndsIn / (3600 * 24));
			var hours = Math.floor((interestEndsIn - (days * 3600 * 24)) / 3600);
			var mins = Math.floor((interestEndsIn - (days * 3600 * 24) - (hours * 3600)) / 60);
			var secs = Math.floor(interestEndsIn - (days * 3600 * 24) - (hours * 3600) - (mins * 60));
			var timestring = padlength(days) + ' days ' + padlength(hours) + ':' + padlength(mins) + ':' + padlength(secs);

			$("#winner_countdown").html(timestring);
			setTimeout(displayInterestEndTime, 1000);
		}
		else
		{
			var winningBidStart = '{WINNING_BID_START}';
			var winningBidInterestPeriod = '{WINNING_BID_INTEREST_PERIOD}';
			var repaymentDate = new Date(winningBidStart);

			repaymentDate.setTime( repaymentDate.getTime() + winningBidInterestPeriod * 86400000 );
			
			var output = repaymentDate.toLocaleDateString('en-GB', {
				day : 'numeric',
				month : 'short',
				year : 'numeric'
			});

			var repaymentDate = '{WINNING_BID_END}';
			
			//var utcSeconds = '{WINNING_BID_END}';
			//console.log(utcSeconds);
			//var d = new Date(0); // The 0 there is the key, which sets the date to the epoch
			//d.setUTCSeconds(utcSeconds);

			$("#winner_countdown").parent().html('<div class="error-box">Repayment completed on ' + repaymentDate + '</div>');
		}
	}
	setTimeout(displayInterestEndTime, 1000);

});
</script>
<!-- ENDIF -->
<div class="row">
	<div class="col-md-12">
		<ul class="breadcrumb"><b>{L_041}:</b> {TOPCATSPATH}</ul>
		<div class="panel panel-default sm-padding" style="text-align: right;">
			{VIEW_HISTORY1}
			<a href="{SITEURL}friend.php?id={ID}">{L_106}</a> |
<!-- IF B_CANCONTACTSELLER -->
			<a href="{SITEURL}send_email.php?auction_id={ID}">{L_922}</a> |
<!-- ENDIF -->
<!-- IF B_LOGGED_IN -->
			<a href="{SITEURL}item_watch.php?{WATCH_VAR}={ID}">{WATCH_STRING}</a>
<!-- ELSE -->
			<a href="{SITEURL}user_login.php?">{L_5202}</a>
<!-- ENDIF -->
		</div>
		<div class="row grid-padding">
			<div class="col-md-5 col-sm-5 grid-padding">
				<div class="item-title visible-xs text-capitalize">{TITLE}</div>
<!-- IF B_HASIMAGE -->
				<div class="main-gallery panel panel-default">
					<div class="panel-heading"><span class="label label-default">{L_113}: {ID}</span></div>
					<div class="panel-body">
						<div class="col-md-12">
							<img class="img-rounded img-responsive center-block" src="{SITEURL}getthumb.php?w=430&fromfile={PIC_URL}" border="0" align="center" width="430px">
						</div
>	<!-- IF B_HASGALELRY -->
						<div>
							<a name="gallery"></a>
							<div id="gallery">
		<!-- BEGIN gallery -->
								<div class="col-md-4 col-xs-4 col-sm-4">
									<a href="{SITEURL}{UPLOADEDPATH}{ID}/{gallery.V}" title="" data-lightbox="gallery">
									<img class="img-rounded img-responsive" src="{SITEURL}getthumb.php?w={THUMBWIDTH}&fromfile={UPLOADEDPATH}{ID}/{gallery.V}" border="0"></a>
								</div>
		<!-- END gallery -->
							</div>
						</div>
					</div>
					<div class="panel-footer">{L_611} <font color="#ff3300"><b>{AUCTION_VIEWS}</b></font> {L_612}</div>
				</div>
	<!-- ENDIF -->
<!-- ELSE -->
				<div class="panel panel-default">
					<div class="panel-heading"><span class="label label-default">{L_113}: {ID}</span></div>
					<div class="panel-body">
						<img class="thumbnail img-responsive center-block" src="{SITEURL}/themes/{THEME}/img/no-picture-gallery.png" alt="no picture" width="430px" />
					</div>
					<div class="panel-footer">{L_611} <font color="#ff3300"><b>{AUCTION_VIEWS}</b></font> {L_612}</div>
				</div>
<!-- ENDIF -->
			</div>
			<div class="col-md-7 col-sm-7">
				<div class="item-title hidden-xs text-capitalize">{TITLE}</div>
<!-- IF B_CANEDIT -->
				<a class="btn btn-primary btn-xs" href="{SITEURL}edit_active_auction.php?id={ID}">{L_30_0069}</a>
<!-- ENDIF -->
				<div class="panel panel-default">
					<table class="table table-bordered table-condensed table-striped">
						<!-- auction type -->
						<tr>
							<td width="30%" align="left">{L_261}: </td>
							<td align="left">{AUCTION_TYPE}</td>
						</tr>
						<!-- higher bidder -->
<!-- IF B_HASBUYER and B_NOTBNONLY -->
						<tr>
							<td width='30%' style="leftpan" valign="top">{L_117}: </td>
							<td>
	<!-- BEGIN high_bidders -->
		<!-- IF B_BIDDERPRIV -->
								<b>{high_bidders.BUYER_NAME}</b>
		<!-- ELSE -->
								<a href="{SITEURL}profile.php?user_id={high_bidders.BUYER_ID}&amp;auction_id={ID}"><b>{high_bidders.BUYER_NAME}</b></a>
								<b>(<a href="{SITEURL}feedback.php?id={high_bidders.BUYER_ID}&amp;faction=show">{high_bidders.BUYER_FB}</a>)</b>
		<!-- ENDIF -->
								{high_bidders.BUYER_FB_ICON}
	<!-- END high_bidders -->
							</td>
						</tr>
<!-- ENDIF -->
<!-- IF QTY gt 1 -->
						<tr>
							<td width="30%" align="left">{L_901}: </td>
							<td align="left">{QTY}</td>
						</tr>
<!-- ENDIF -->
						<tr>
							<td width="30%" align="left">{L_923}: </td>
							<td align="left">{COUNTRY}</td>
						</tr>
						<tr>
							<td width="30%" align="left">{L_118}: </td>
							<td align="left" valign="top">
<!-- IF B_COUNTDOWN -->
								<span id="ending_counter">{ENDS}</span>
<!-- ELSE -->
								{ENDS}<!-- IF B_SHOWENDTIME --><br><span class="text-muted"><small>({ENDTIME})</small></span><!-- ENDIF -->
<!-- ENDIF -->
							</td>
						</tr>
<!-- IF B_NOTBNONLY -->
						<tr>
							<td width="30%" align="left">{L_119}: </td>
							<td align="left">{NUMBIDS} {VIEW_HISTORY2}</td>
						</tr>
	<!-- IF ATYPE eq 2 -->
						<tr>
							<td width="30%" align="left">
								{L_038}:
							</td>
							<td align="left">{MINBID}</td>
						</tr>
	<!-- ENDIF -->
						<tr>
							<td width="30%" align="left">{L_116}: </td>
							<td align="left" valign="middle">{MAXBID}<!-- IF B_HASRESERVE -->&nbsp;<span class="text-muted"><small>{L_514}<small></span><!-- ENDIF --></td>
						</tr>
<!-- ENDIF -->
<!-- IF B_SHIPPING -->

<!-- ENDIF -->
<!-- IF (B_ADDITIONAL_SHIPPING_COST or B_BUY_NOW_ONLY) and B_SHOW_ADDITIONAL_SHIPPING_COST -->

<!-- ENDIF -->
<!-- IF B_BUY_NOW -->
						<tr>
							<td width="30%" align="left">{L_496}:</td>
							<td align="left">
								{BUYNOW2}
							</td>
						</tr>
<!-- ENDIF -->
<!-- IF B_HASENDED -->
						<tr>
							<td colspan="2" align="left"><b>{L_904}</b></td>
						</tr>
	<!-- IF ALLOW_WIN_SELECT eq true -->
						<tr>
							<td colspan="2" align='center'><b>Please Select a winning bid</b></td>
						</tr>
	<!-- ELSE -->
						<tr>
							<td colspan="2" align='center'><b>Winning Bid Details</b></td>
						</tr>
						<tr>
							<td>Amount</td>
							<td>{WINNING_BID_AMOUNT}</td>
						</tr>
						<tr>
							<td>Interest rate</td>
							<td>{WINNING_BID_INTEREST_RATE} %</td>
						</tr>
						<tr>
							<td>Interest period</td>
							<td>{WINNING_BID_INTEREST_PERIOD} days</td>
						</tr>
						<tr>
							<td>Interest Period Start</td>
							<td>{WINNING_BID_START}</td>
						</tr>
						<tr>
							<td>Interest Period End</td>
							<td>{WINNING_BID_END}</td>
						</tr>
						<tr>
							<td colspan="2" align='center'>
								<b>Repayment due in <span id="winner_countdown">{WINNING_BID_ENDS_IN}</span></b>
							</td>
						</tr>
						<tr>
							<td>
								{WINNING_BID_END_DEBUG}
							</td>
						</tr>
	<!-- ENDIF -->
<!-- ENDIF -->
					</table>
				</div>
			</div>
			<div class="col-md-7 col-sm-12">
				<div class="panel panel-default">
					<div class="panel-heading"><b>{L_30_0209}</b></div>
					<div class="panel-body">
						<div>
							<a href='{SITEURL}profile.php?user_id={SELLER_ID}&amp;auction_id={ID}'><b>{SELLER_NICK}</b></a>
							(<a href='{SITEURL}feedback.php?id={SELLER_ID}&amp;faction=show'>{SELLER_TOTALFB}</A>)
							{SELLER_FBICON}
						</div>
						<div>
							<ul class="list-unstyled">
								<li>{L_5509}{SELLER_NUMFB}{L__0151}
								<li><b>{L_5506}{SELLER_FBPOS}</b>
<!-- IF SELLER_FBNEG ne 0 -->
								<li>{SELLER_FBNEG}</li>
<!-- ENDIF -->
								<li>{L_5508}{SELLER_REG}</li>
							</ul>
							<a href="{SITEURL}active_auctions.php?user_id={SELLER_ID}"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true" style="padding-right: 5px;"></span>{L_213}</a>
							<br><br>
						</div>
<!-- IF B_HASENDED eq false and B_CAN_BUY -->
						<div class="well well-sm">
							<div class="row">
	<!-- IF B_NOTBNONLY -->
								<form name="bid" action="{SITEURL}bid.php" method="post">
									<div class="form-group">
										<div class="col-md-3 col-md-offset-2">
		<!-- IF QTY gt 1 -->
											<input type="text" class="form-control" name="qty" placeholder="{L_284}"> {QTY} {L_5408}
		<!-- ENDIF -->
											<p><input type="text" class="form-control" name="bid" placeholder="{L_121}"></p>

											<p><input type="text" class="form-control" name="interest_rate" placeholder="{L_5510}"></p>

											<p>
												<select class='interest_period' name="interest_period">
													<option value="30">30 Days</option>
													<option value="60">60 Days</option>
													<option value="90" selected="selected">90 Days</option>
													<option value="120">120 Days</option>
													<option value="150">150 Days</option>
													<option value="180">180 Days</option>
													<option value="210">210 Days</option>
													<option value="240">240 Days</option>
													<option value="270">270 Days</option>
													<option value="300">300 Days</option>
													<option value="330">330 Days</option>
													<option value="360">360 Days</option>
												</select>
											</p>
										</div>
									</div>
									<div class="col-md-5">
		<!-- IF ATYPE eq 1 -->
										<div class="md-padding">Loan Amount</div><br><span class="interest-rate">%</span>
										<br><br>
										<span class="loan-period">Loan Period</span>
		<!-- ENDIF -->					
									</div>
									<div class="col-md-8 col-md-offset-2">
										<input type="hidden" name="seller_id" value="{SELLER_ID}">
										<input type="hidden" name="title" value="{TITLE}" >
										<input type="hidden" name="category" value="{CAT_ID}" >
										<input type="hidden" name="id" value="{ID}">
										<input type="hidden" name="csrftoken" value="{_CSRFTOKEN}">
										<input type="submit" name="" value="{L_30_0208}" class="form-control btn btn-primary">
									</div>
								</form>
	<!-- ELSE -->
								<div class="col-md-8 col-md-offset-2">
									{BUYNOW} <a class="btn btn-success btn-block" href="{SITEURL}buy_now.php?id={ID}">{L_496}</a>
								</div>
	<!-- ENDIF -->
							</div>
						</div>
<!-- ENDIF -->
<!-- IF B_CAN_BUY eq false -->
						<div class="row">
							<div class="col-md-8 col-md-offset-2">
								<div class="alert alert-warning" role="alert">
									<span class="pull-left"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>  {L_5002}</span> <span class="pull-right"><a class="btn btn-warning btn-xs" href="{SITEURL}user_login.php?" class="alert-link">{L_221}</a></span>
									<div class="clearfix"></div>
								</div>
							</div>
						</div>
<!-- ENDIF -->
					</div>
				</div>
				<a class="report-item pull-right" href='{SITEURL}item_report.php?id={ID}'>{L_report_this_item}</a>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title"><a name="description"></a>{L_018}</h3>
					</div>
					<div class="panel-body">
						{AUCTION_DESCRIPTION}
					</div>
				</div>
<!-- IF B_HAS_QUESTIONS -->
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title"><a name="questions"></a>{L_552}</h3>
					</div>
					<div class="panel-body">
	<!-- BEGIN questions -->
						<span class="glyphicon glyphicon-comment" aria-hidden="true" style="padding-right: 10px;"></span>
						<div class="well well-sm">
		<!-- BEGIN conv -->
							<p><span class="text-muted"><small>{questions.conv.BY_WHO}:</small></span> {questions.conv.MESSAGE}</p>
		<!-- END conv -->
						</div>
	<!-- END questions -->
					</div>
				</div>
<!-- ENDIF -->
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">{L_724}</h3>
					</div>
					<div class="panel-body">
						<table width="100%" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									<div class="tableContent2">
										<div class="table2">
<!-- IF CITY ne '' or COUNTRY ne '' or ZIP ne '' -->
											<b>{L_014}:</b> <!-- IF CITY ne '' -->{CITY}<!-- ENDIF --> <!-- IF COUNTRY ne '' -->{COUNTRY}<!-- ENDIF --> <!-- IF ZIP ne '' -->({ZIP})<!-- ENDIF --><br>
<!-- ENDIF -->
<!-- IF B_SHIPPING -->
											
<!-- ENDIF -->
<!-- IF SHIPPINGTERMS ne '' -->
											<table border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td valign="top"><b>{L_25_0215}:</b>&nbsp;</td>
													<td valign="top">{SHIPPINGTERMS}</td>
												</tr>
											</table>
<!-- ENDIF -->
											<br>
											<b>{L_026}:</b> {PAYMENTS}<br>
<!-- IF ! B_BUY_NOW_ONLY -->
											<b><!-- IF ATYPE eq 1 -->{L_127}<!-- ELSE -->{L_038}<!-- ENDIF -->:</b> {MINBID}<br>
<!-- ENDIF -->
											<br>
											<b>{L_111}:</b> {STARTTIME}<br>
											<b>{L_112}:</b> {ENDTIME}<br>
											<b>{L_113}:</b> {ID}<br>
											<br>
											<b>{L_041}:</b> {CATSPATH}<br>
											<!-- IF SECCATSPATH ne '' --><b>{L_814}:</b> {SECCATSPATH}<!-- ENDIF -->
										</div>
									</div>
								</td>
							</tr>
						</table>
					</div>
				</div>
<!-- IF B_SHOWHISTORY -->
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title"><a name="history"></a>{L_26_0001}</h3>
					</div>
					<div class="panel-body">
						<table class="table table-bordered table-striped table-condensed">
							<tr>
								<th width="20%" align="center">{L_176}</th>
								<th width="20%" align="center">{L_130}</th>
								<th width="20%" align="center">{L_5510}</th>
								<th width="20%" align="center">{L_5511}</th>

								<th width="20%" align="center">{L_175}</th>
	<!-- IF ATYPE eq 2 -->
								<th width="20%" align="center">{L_284}</th>
	<!-- ENDIF -->
							</tr>
	<!-- BEGIN bidhistory -->
							<tr valign="top" {bidhistory.BGCOLOUR}>
								<td>
		<!-- IF B_BIDDERPRIV -->
									{bidhistory.NAME}
		<!-- ELSE -->
									<a href="{SITEURL}profile.php?user_id={bidhistory.ID}">{bidhistory.NAME}</a>
		<!-- ENDIF -->
		<!-- IF ALLOW_WIN_SELECT -->
									<form class="pull-right" name="bid" action="{SITEURL}item.php?id={ID}&history=view#history" method="post">
										<input type="hidden" name="chosenbidder" value="{bidhistory.BIDID}">
										<input type="submit" class="btn btn-default btn-xs" value="Select Winning Bid">
									</form>
		<!-- ENDIF -->
		<!-- IF bidhistory.BIDID eq WINNING_BID -->
									<div class='btn btn-success btn-xs pull-right selected-bid'>Selected Bid</div>
		<!-- ENDIF -->

								</td>
								<td align="center">
									{bidhistory.BID}
								</td>
								<td align="center">
									{bidhistory.INTRATE} %
								</td>
								<td align="center">
									{bidhistory.INTPERIOD} Days
								</td>
								<td align="center">
									{bidhistory.WHEN}
								</td>
		<!-- IF ATYPE eq 2 -->
								<td align="center">
									{bidhistory.QTY}
								</td>
		<!-- ENDIF -->
							</tr>
	<!-- END bidhistory -->
						</table>
					</div>
				</div>
<!-- ENDIF -->
			</div>
		</div>
	</div>
</div>
