<?php
	error_reporting(0);
	include("config/connect.php");
	include("functions.php");

	$aucid = $_REQUEST["aid"];
	$prid = $_REQUEST["pid"];
	$uid = $_SESSION["userid"];
	if($aucid=="")
	{
		header("location: index.php");
	}
	$now=time();
	$qrysel = "select *,p.".$lng_prefix."name as name,".$lng_prefix."short_desc as short_desc,".$lng_prefix."long_desc as long_desc,adt.auc_due_time from products p left join auction a on p.productID=a.productID  left join auc_due_table adt on a.auctionID=adt.auction_id left join registration r on a.buy_user=r.id left join shipping s on a.shipping_id=s.id  left join auction_management am on am.auc_manage=a.time_duration where a.auctionID='$aucid' and a.auc_start_time <".$now."";
	$ressel = mysql_query($qrysel);
	$total = mysql_num_rows($ressel);
	if($total<1){
	 header("location: index.php");
	}
	$obj = mysql_fetch_object($ressel);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>拍客网</title>
<link href="style/css/index.css" rel="stylesheet" type="text/css" />

<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript" src="function.js"></script>
<script language="javascript" src="basic.js"></script>
<script language="javascript" src="jquery.js"></script>
<script language="javascript" src="effect.js"></script>
<script language="javascript" src="default.js"></script>
<script language="javascript" src="jqModal.js"></script>

<script language="javascript" type="text/javascript">
	function hideDisplayBids(id)
	{
		if(id==1)
		{
			document.getElementById('producthistory1_hidden').style.display='none';
			document.getElementById('producthistory1').style.display='block';
		}
		if(id==2)
		{
			document.getElementById('producthistory1_hidden').style.display='block';
			document.getElementById('producthistory1').style.display='none';
		}
	}

	

function number_format( number, decimals, dec_point, thousands_sep ) {
	var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
	var d = dec_point == undefined ? "." : dec_point;
	var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
	var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

function ChangePlaceBids()
{
	//userpendingbids = document.getElementById('bids_count').innerHTML;
	//placebids = document.getElementById('placebidscount').innerHTML;
	//placeamount = document.getElementById('placebidsamount').innerHTML;
	
	//if(userpendingbids>0)
	//{
	//	document.getElementById('placebidscount').innerHTML = Number(placebids) + 1;
	//	document.getElementById('placebidsamount').innerHTML = 	number_format(Number(placeamount) + <?=$minbiddingprice;?>,2,'.','');
	//	newsavingvalue =  Number(document.getElementById('placebidssaving').innerHTML) - <?=$minbiddingprice;?>;
	//	document.getElementById('placebidssaving').innerHTML = number_format(newsavingvalue,'2','.','');
	//	document.getElementById('placebidssavingdisp').innerHTML = number_format(newsavingvalue,'2','.',',');
	//}
}

</script>
</head>
<body onload="OnloadPage();">
<?
	include("d1.php");
?>
<div id="wrap">
	<div class="detail-row">
		<div class="title"><?=stripslashes($obj->name);?></div>
		<div class="link"><a href="simreg.html"><img src="style/images/detail-link.gif" /></a></div>
		<div class="clear"></div>
	</div>
	
	<div class="detail-row" >
		<div class="detail-col1" title="<?=stripslashes($obj->auctionID);?>" id="auction_<?=stripslashes($obj->auctionID);?>">
			<div class="col1-picture">
				<div class="product-picture"><span id="mainimage1">
									<img src="uploads/products/<?=$obj->picture1;?>" />
									</span>
									<span id="mainimage2" style="display:none;"><? if($obj->picture2!=""){ ?><img src="uploads/products/<?=$obj->picture2;?>"/><? }	?>								</span>
									<span id="mainimage3" style="display: none"><? if($obj->picture3!=""){ ?><img src="uploads/products/<?=$obj->picture3;?>" /><? }	?></span>								
									<span id="mainimage4" style="display: none"><? if($obj->picture4!=""){ ?><img src="uploads/products/<?=$obj->picture4;?>"/><? } ?></span>	</div>
				<div class="thumb-list">
					<ul>
					<? if($obj->picture1!=""){ ?>
									<img src="uploads/products/thumbs/thumb_<?=$obj->picture1;?>" width="75" height="60" onclick="changeimage(1);" id="otherimageprd_1" style="cursor: pointer" />
									<? } else { ?><img id="otherimageprd_1" src="<?=$lng_imagepath;?>no_image.gif"  width="79" height="60" style="cursor: pointer" /><? } ?>						
									
									<? if($obj->picture2!=""){ ?>									
									<img id="otherimageprd_2" src="uploads/products/thumbs/thumb_<?=$obj->picture2;?>" width="75" height="60" onclick="changeimage(2);" style="cursor: pointer" /><? } else { ?><img src="<?=$lng_imagepath;?>no_image.gif" style="cursor: pointer" width="79" height="60"/><? } ?>
									
									<? if($obj->picture3!=""){ ?>									
									<img src="uploads/products/thumbs/thumb_<?=$obj->picture3;?>" width="79" height="60" style="cursor: pointer"  onclick="changeimage(3);" id="otherimageprd_3" />
									<? } else { ?><img src="<?=$lng_imagepath;?>no_image.gif" style="cursor: pointer" width="75" height="60" /><? } ?>									
									
									<? if($obj->picture4!=""){ ?>									
									<img id="otherimageprd_4" src="uploads/products/thumbs/thumb_<?=$obj->picture4;?>" onclick="changeimage(4);" width="75" height="60" style="cursor: pointer" /><? } else { ?><img src="<?=$lng_imagepath;?>no_image.gif" style="cursor: pointer" width="79" height="60"/><? } ?>
					</ul>
				</div>
			</div>

			<?if($obj->auc_status==2){?>
			<div class="col1-info">
			<div class="auction-item" style="display: none" title="<?=$obj->auctionID;?>" id="auction_<?=$obj->auctionID;?>"></div>
			<div class="auction-id" style="display: none"  id="<?=$obj->auctionID	;?>"></div>
				<div class="info-price" id="bid_price_{$info['id']}"> 当前价：<span id="currencysymbol_<?=$obj->auctionID;?>"> </span><span id="price_index_page_<?=$obj->auctionID;?>">--</span>
				</div>

				<div class="info-username" id="bid_username_{$info['id']}">出价人：<span id="product_bidder_<?=$obj->auctionID;?>">---</span></div>

				<div class="info-time" >
				<span  id="counter_index_page_<?=$obj->auctionID;?>">
										<?
										$now=time();
										$newtime=$obj->auc_due_time-$now;
										 echo "<script language=javascript>
											  document.getElementById('counter_index_page_".$obj->auctionID."').innerHTML = calc_counter_from_time('".$newtime."');									 
											  </script>";
										?>
									
										  </span>
										

				</div>
				<div class="info-button"> <? if($uid==""){ ?>
									<img src="style/images/bid-list-button.gif" border="0"  alt="BID" onmouseover="this.src='<?=$lng_imagepath;?>BIG_LOGIN_btn_hover.png'" onmouseout="this.src='<?=$lng_imagepath;?>BIG_BID_btn.png'" onclick="javascript: window.location.href='login.html'" id="image_main_<?=$obj->auctionID;?>"  style="cursor: pointer"/>
							  <? } else { ?>
							<?
							   if(getWonCount()<8)
							   {
							?> 
									<img src="style/images/bid-list-button.gif" border="0" class="bid-button-link" name="getbid.php?prid=<?=$obj->productID;?>&aid=<?=$obj->auctionID;?>&uid=<?=$uid;?>" alt="BID" onmouseover="this.src='style/images/bid-list-button.gif'" onmouseout="this.src='style/images/bid-list-button.gif'" id="image_main_<?=$obj->auctionID;?>"  style="cursor: pointer" onclick="ChangePlaceBids();"/>
						  	<? }else{ ?>
								<img src="style/images/bid-list-button.gif" border="0" name="" alt="BID" onclick="alert('<?=$lng_notice_maxbidnum;?>');" onmouseover="this.src='style/images/bid-list-button.gif'" onmouseout="this.src='style/images/bid-list-button.gif'" id="image_main_<?=$obj->auctionID;?>"  style="cursor: pointer"/>
						  	<?	 } ?>
							  <? } ?>
				</div>
				<? if($uid==""){ ?>
				<div class="info-text">参与竞拍? 请先登录</div>  
				<? } ?>
				<div class="info-spread-price">差价购买：<?=$Currency;?><?=$obj->price;?></div>				
				<div class="info-intro">每次出价需1个拍币，成交价将提高<?=$obj->auc_plus_price;?> 元。在倒计时10秒内，每次出价剩余时间将增长<?=$obj->auc_plus_time ;?>秒</div>
			</div>


<?}
	elseif($obj->auc_status==3)
							{
								$qrybid = "select *,sum(bid_count) as bidcount from bid_account where bid_flag='d' and auction_id=$aucid and user_id=".$obj->buy_user." group by auction_id";
								$resbid = mysql_query($qrybid);
								$total = mysql_num_rows($resbid);
								$objbid = mysql_fetch_object($resbid);
								$totbid = $objbid->bidcount; 
								$totbidprice = $totbid *1;
						
								$price = $obj->price;
								$fprice = $obj->auc_final_price;
								$saving_price = $price-$totbidprice-$fprice;
								$saving_percent = ($saving_price*100)/$price;
								
								if($uid!="" && $aucid!="")
								{
									$auc_state='0';
									$sql = "select state from shops_orders where userid='$uid' and aid='$aucid' ";
									$res2 = mysql_query($sql);
									$total2 = mysql_num_rows($res2);
									if($total2>0){
										$objbid2 = mysql_fetch_object($res2);
										$auc_state = $objbid2->state; 
								  }
									if($auc_state=='0'){
										$qrybid2 = "select *,sum(bid_count) as bidcount from bid_account where bid_flag='d' and auction_id='$aucid' and user_id='$uid' group by auction_id";
										$resbid2 = mysql_query($qrybid2);
										$total2 = mysql_num_rows($resbid2);
										$objbid2 = mysql_fetch_object($resbid2);
										$totbid2 = $objbid2->bidcount; 
										$totbidprice2 = $totbid2 * 1;

										$price2 = $obj->price;
										if($obj->fixedpriceauction=="1") { $fprice2 = $obj->auc_fixed_price;}
										elseif($obj->offauction=="1")  { $fprice2 = "0.00"; }
										else { $fprice2 = $obj->auc_final_price;}
										$saving_price2 = $price2-$totbidprice2;
										$saving_percent2 = ($saving_price2*100)/$price2;
								  }
								}								

						?>
						 <div class="col1-info">
						 <div class="info-price" > 获胜价格：<?=$Currency;?><?=$obj->auc_final_price;?>
				</div>
						 <div class="info-username">获得者：<?=$obj->username;?></div>
							 <div class="info-time" >
							 本次拍卖结束于：<br><?=date('Y-m-d H:i:s',$obj->auc_final_end_date);?>

				 </div>				
							<div class="info-button">			
									
									<?
									if($obj->username!="")
									{
									?>
						<?=$lng_congratulations;?><?=$obj->username;?>!<div style="font-size: 18px; color: green;" align="center"><?=$lng_savings;?> : <?=number_format($saving_percent,2);?> %</div>				
										</div>
										<div class="row" style="padding-top: 5px;">
											<? $tt=time();
											   $oldtime=$obj->auc_final_end_date+60*60*24*7;
											if($tt<$oldtime){											  
											  if($totbid2!="" && $obj->username!=getUserName($uid)){
											?>
												<img src="<?=$lng_imagepath;?>buynow_btn.png" border="0"  alt="您可以市场价减去竞拍费用购买本商品" onclick="javascript: window.location.href='buynow.html?aucid=<?=$aucid;?>'" style="cursor: pointer"/>							<div class="row">
											<div class="left1">你累计付出(<?=$totbid2!=""?$totbid2:"0";?>):￥<?=number_format($totbidprice2,2);?>，获得保价￥<?=$saving_price2;?>购买，折扣<?=$saving_percent2;?>%</div>
										</div>								
												<?
												  }
												}
												?>
										</div>
				 <?
									 }
									 else
									 {
									 ?>
										<div class="info-button">
											<div class="darkblue-text-17-b" align="center"><?=$lng_nobidspalced;?>!</div>				
										</div>
									 <?
									 }
									 ?>
										<div class="row" style="padding-top: 15px;">
										<div class="left1"><strong><?=$lng_savings;?>:</strong></div>
										</div>
										<div class="row" style="padding-top: 10px;">
											<div class="left1"><?=$lng_worthupto;?><?=$Currency;?><?=$obj->price;?></div>
										</div>
										<div class="row">
											<div class="left1">累计付出(<?=$totbid!=""?$totbid:"0";?>):<?=$Currency;?><?=number_format($totbidprice,2);?></div>
										</div>
										<div class="row">
											<div class="left1"><?=$lng_finalprice;?>:<?=$Currency;?><?=$fprice;?></div>
										</div>
										<div class="row">
											<div class="savingline"></div>
										</div>
										<div class="row">
											<div class="left1"><?=$lng_savings;?>:<?=$Currency;?><?=number_format($saving_price,2);?></div>
										</div>
										<div class="row" style="padding-top: 15px;">
											<div style="width: 260px;">"市场参考价" 会受到市场价格波动影响.</div>
										</div>
									
								
									</div>
						<?
							}
						?>	

	

			<div class="clear"></div>
		</div>

		<script type="text/javascript">
			function selectTag1(selfObj)
			{
				if(selfObj.id == "tab-li2"){
				

				document.getElementById("cont1").style.display="none";//隐藏 
					document.getElementById("cont11").style.display="none";//隐藏
　　				document.getElementById("cont2").style.display="block";//显示
				}else{				
					document.getElementById("cont2").style.display="none";//隐藏 
　　			document.getElementById("cont1").style.display="";//显示
				document.getElementById("cont11").style.display="";//显示
				}
			}
			
		</script>
		<div class="detail-col2">
			<div class="tab-list">
				<div class="tab-li" id="tab-li1" onclick="selectTag1(this);">聊天室</div>
				<div class="tab-li" id="tab-li2" onclick="selectTag1(this);">出价记录</div>
			</div>
			<div class="tab-content" id="cont1"  style="display:none">
				<ul id="chat_box">
					<span id="cha_index_page_<?=$obj->auctionID;?>">
<?php
$qryauc = "select * from chat  c left join  auction  a on a.auctionID=c.bid where a.auctionID='$aucid' order by addtime DESC, id DESC limit 0,6";
$resauc = mysql_query($qryauc);
$totalauc = mysql_num_rows($resauc);
while($objauc=mysql_fetch_array($resauc)) {
	$chat_list[] = $objauc;
}
if (isset($chat_list)) {
	krsort($chat_list);
}
foreach($chat_list AS $objauc) {
?>
<li>
	<div class="tab-title"><?=$objauc["id"];?><?=$objauc["username"];?>：<?=$objauc["content"];?></div>
	<div class="time"><?=date('Y-m-d H:i:s',$objauc["addtime"]);?> </div>
</li>
<?php
}
?>
					</span>	
				</ul>
<script type="text/javascript">
var box = document.getElementById('chat_box');
box.scrollTop = box.scrollHeight;
</script>
			</div>

			<div class="chat-form" id='cont11'  style="display:none">
				<div class="chat-title">发表留言</div>
				<div class="chat-input"><input type="text" name="chat" size="40" id="chat"/></div>
				<div class="chat-button">
					<div class="chat-add">
					<? if($uid==""){ ?>
				
					<input class="bttn-s" onClick="window.location.href='login.html'" type="button" value="发送">
					<?}
					else{
					?>

					<input type="submit" name="add" value="发送" onclick="addchat(<?=$obj->auctionID;?>)"/>
					<? } ?>
					</div>
					<div class="chat-reset"><input type="reset" name="clear" value="清空" onclick="removerchat()"/></div>
				</div>
				 </div>


<div class="tab-content" id='cont2' >
				<ul>
				   
				  <span id="bid_account_page_<?=$obj->auctionID;?>">			 
				   
					<?	
	$qryacc = "select * from bid_account b left join registration r on b.user_id=r.id  where b.auction_id='$aucid' order by bidpack_buy_date desc";
	$resacc = mysql_query($qryacc);
	//$totalacc = mysql_num_rows($resacc);
	//echo $qryacc;

				   while($objacc=mysql_fetch_array($resacc))
				   {	

				?>
				<li>
						<div class="tab-title"><?=$objacc["username"];?> 出价<?=$objacc["bidding_price"];?>元 &nbsp;  &nbsp;&nbsp; 
						   <font color='black'><?=$objacc["bidpack_buy_date"];?></font> </div>
					</li>
						
					<?
					}
			
					?>  
				</span>	
				</ul>
			</div>


		</div>
		<div class="clear"></div>
	</div>
	
	<div class="detail-row">
		<div class="banner1"><img src="style/images/detail-banner1.gif" /></div>
		<div class="banner2"><img src="style/images/detail-banner2.gif" /></div>
		<div class="clear"></div>
	</div>
	
	<div class="detail-row">
		<div class="detail-title">商品详细介绍</div>
		<div class="detail-content"><?=stripslashes($obj->long_desc);?>	</div>
	</div>
	
	<div class="detail-row">
		<div class="detail-title">常见问题</div>
		<div class="detail-content">
			<div class="faq-list">
				<ul>
					<li>
						<div class="faq-title">竞拍成功后怎么做？</div>
						<div class="intro">
							首先恭喜您竞拍成功，进入“我的账户中心”您会看到刚刚竞拍成功的商品，在线支付成功后，必得喜客服人员会在两个工作日内与您联系确认订单和发货。						
						</div>
					</li>
					<li style="margin-right:0">
						<div class="faq-title">没有竞拍成功怎么办？</div>
						<div class="intro">
							没关系，您可以在商品竞拍结束后的48小时内使用“差价购买”功能补上差价，即可不浪费您使用过的喜币，购得该商品。注意：虚拟产品不支持差价购买，例如虚拟币，游戏卡
						</div>
					</li>
					<li>
						<div class="faq-title">付款后多长时间可以收到货？</div>
						<div class="intro">
							必得喜是国内最专业的商品竞拍平台，为您提供公开、公平、公正的娱乐竞拍服务。我们的货源是与国内知名商城合作，包括京东、新蛋、卓越、当当和淘宝商城，所有商品均正品行货。一般情况在您支付成功后的第二个工作日内商品发出，经过3－5天到达。						
						</div>
					</li>
					<li style="margin-right:0">
						<div class="faq-title">收到货后晒单如何奖励？</div>
						<div class="intro">
							凡是竞拍成功的实物商品，都可以参与晒单，向其他喜友展示您的成果。晒单需要至少两张商品图片，一段自己的竞拍感言或心得，必得喜管理员会根据您的晒单内容质量给出10－30个不等喜币奖励。图片中若是有您的靓照，奖励翻倍。						
						</div>
					</li>															
				</ul>
			</div>
			<div class="faq-picture"><img src="style/images/faq-picture.gif" /></div>
		</div>
	</div>
	
</div>


							
<?
	include("footer2.php");
?>		
<?
	if($obj->is_close==0)
	{
?>
<span style="display: none;" class="productImageThumb">Details</span>
<span style="display: none;" id="curproductprice"></span>
<?
	}
?>
</div>

</body>
</html>
