/*
	图文并存显示拍品信息
	Dwen	2011-08-04
	auctionType:拍品类别
	auctionName:拍品级别名称
	return 返回级别等级
*/
function loadAuctionGradePic(auctionType,characterName){
	if(auctionType=='1'){//邮票类
		if(characterName=="全品"){
			return 5;
		}
		if(characterName=="上品"){
			return 4;
		}
		if(characterName=="中上品"){
			return 3;
		}
		if(characterName=="中品"){
			return 2;
		}
		if(characterName=="差品"){
			return 1;
		}
		if(characterName=="修补品"||characterName=="修補品"){
			return 0;
		}
		if(characterName=="无"||characterName=="無"){
			return 0;
		}
	}
	if(auctionType=='2'){//金银币类
		if(characterName=="完全未使用品"){
			return 6;
		}
		if(characterName=="未使用品"){
			return 5;
		}
		if(characterName=="近未使用"){
			return 4;
		}
		if(characterName=="极美品"||characterName=="極美品"){
			return 3;
		}
		if(characterName=="美品"){
			return 2;
		}
		if(characterName=="通货品"||characterName=="通貨品"){
			return 1;
		}
		if(characterName=="无"||characterName=="無"){
			return 0;
		}
	}
	if(auctionType=='3'){//纸钞类
		if(characterName=="绝品"||characterName=="絕品"){
			return 10;
		}
		if(characterName=="十品"){
			return 9;
		}
		if(characterName=="九五品"){
			return 8;
		}
		if(characterName=="九品"){
			return 7;
		}
		if(characterName=="八五品"){
			return 6;
		}
		if(characterName=="八品"){
			return 5;
		}
		if(characterName=="七品"){
			return 4;
		}
		if(characterName=="六品"){
			return 3;
		}
		if(characterName=="五品"){
			return 2;
		}
		if(characterName=="普品"){
			return 1;
		}
		if(characterName=="无"||characterName=="無"){
			return 0;
		}
	}
} 

/*
	不同拍品类型的级数
	Dwen	2010-9-8
*/
function getGrade(auctionType){
	if(auctionType=='1'){//邮票类
		return 5;//5级
	}
	if(auctionType=='2'){//金银币类
		return 6;//6级
	}
	if(auctionType=='3'){//纸钞类
		return 10;//10级
	}
}

/*
	显示拍品图片等级
	Dwen	2010-9-8
*/
function showGradePic(auctionType,characterName){
			var num=loadAuctionGradePic(auctionType,characterName);//当前拍品是多少等级
			var gradeNum=getGrade(auctionType);//拍品级数
			var img="";//图片
			for(i=1;i<=gradeNum;i++){
				if(num!=0){
				if(i<=num){
					//img=img.concat("<img alt='' src='/images/buyico.gif'/>");
					img=img.concat("<img alt='' src='/images/buyicon_1.jpg'/>");
				}else{
					//img=img.concat("<img alt='' src='/images/buyico02.gif'/>");
					img=img.concat("<img alt='' src='/images/buyicon_2.jpg'/>");
				}
				}
			}
			document.getElementById("div_grade").innerHTML=img;
}


function AuctionDetail(auction) 
{
	//循环时间
	this.loopTimer = null;
	this.limitWidth = 50;
	this.mainStep = 0;
	this.timerSpeed = 1;	
	this.scrollStep = 4;//一次滚动4张图片	
	this.showWidth = 200;
	this.step = 0;
	this.stepright = 0;
	
	//this.limitWidth = this.limitWidth / this.scrollStep;  
	// 所有图片加起来的长度
	this.mainWidth = this.limitWidth * parseInt(auction.picnum); 
	
	this.nextPrice=parseFloat(auction.nextPrice);
	this.maxPrice=parseFloat(auction.maxPrice);
	this.buycharge=parseFloat(auction.acBuycharge);
	this.userid=parseInt(auction.userId);
	this.isauction=parseInt(auction.isauction);
	this.acNewId = parseInt(auction.acNewId);
	this.auctionName = auction.auctionName;
	this.description = auction.description;
}
AuctionDetail.prototype.getAddRange=function(num) {
	var rangeNum = 0;
	if (num >= 0 && num <= 50) {
	rangNum = 1;} 
	else {
	if (num > 50 && num <= 100){
			rangNum = 2;
		} else {
			if (num > 100 && num <= 500) {
				rangNum = 5;
			} else {
				if (num > 500 && num <= 1000) {
					rangNum = 10;
				} else {
					if (num > 1000 && num <= 2000) {
						rangNum = 20;
					} else {
						if (num > 2000 && num <= 5000) {
							rangNum = 50;
						} else {
							if (num > 5000 && num <= 10000) {
								rangNum = 100;
							} else {
								if (num > 10000 && num <= 20000) {
									rangNum = 200;
								} else {
									if (num > 20000 && num <= 50000) {
										rangNum = 500;
									} else {
										if (num > 50000 && num <= 200000) {
											rangNum = 1000;
										} else {
											if (num > 200000) {
												rangNum = 2000;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return rangNum;
};
AuctionDetail.prototype.isBidRange=function(bidprice, addRange) {
	if (bidprice % addRange == 0) {
		return true;
	} else {
		return false;
	}
};
//对竞拍存储过程及修改代理价存储过程返回状态进行相关提示	Dwen 2010-9-3
AuctionDetail.prototype.bidresult=function(bidresult){
	if('0'==bidresult){
		alert(m_auction_detail_ask_givePrice_success);
		return;
	}else if('1'==bidresult){
		alert(m_auction_detail_ask_user_notExist);
		return;
	}else if('2'==bidresult){
		alert(m_auction_detail_ask_user_lock);
		return;
	}else if('3'==bidresult){
		alert(m_auction_detail_ask_user_quotaNotEnough);
		return;
	}else if('4'==bidresult){
		alert(m_auction_detail_ask_auction_end);
		return;
	}else if('5'==bidresult){
		alert(m_auction_detail_ask_addPrice_error);
		return;
	}else if('6'==bidresult){
		alert(m_auction_detail_ask_givePrice_had);
		return;
	}else if('7'==bidresult){
		alert(m_auction_detail_ask_systemLock_error);
		return;
	}else if('8'==bidresult){
		alert(m_auction_detail_ask_unknowError);
		return;
	}
};
AuctionDetail.prototype.bidsubmit=function()
{
  if(0==this.userid || ""==this.userid)
  {
	  window.location = "/customer/login.jsp?reurl="+location.href;
	  return false;
  }
  var authCode=document.getElementById("validateNumber").value;
	
  if(authCode.length !=1 || !authCode.match(/\d{1}/))
  {
		alert(m_auction_detail_ask_validateNumber_error);
		document.getElementById("validateNumber").focus();
		return false;
  }
  if(!this.checkUserBid())
  {
	return false;
  }
	return true;
};
AuctionDetail.prototype.checkUserBid=function()
{
   	var userbid=0.00;
 	if(document.getElementById("bid")!=null){
	  userbid=document.getElementById("bid").value;
	  if (!userbid.match(/\d+(\.\d{2})?/))
	
	  {
	  	document.getElementById("bid").focus();
		alert(m_auction_detail_ask_number_error);
		return false;
	  }
	  if(userbid <=0 || userbid<this.nextPrice)
	  {
	  	document.getElementById("bid").focus();

		alert(m_auction_detail_ask_addPrice_error);
	
		return false;
	  }
		
	}
	else if(document.getElementById("proxy")!=null)
	{ 
	  userbid=document.getElementById("proxy").value;
	  
	  if (!userbid.match(/\d+(\.\d{2})?/))
	
	  {
	  	document.getElementById("proxy").focus();
		alert(m_auction_detail_ask_number_error);
	
		return false;
	  }
	  if(userbid <=0 ){
	  	document.getElementById("proxy").focus();
		alert(m_auction_detail_ask_proxyPrice_error);
	
		return false;
	  }
	}
    
	
	
	return true;
};
AuctionDetail.prototype.caculateBidCharge=function()
{
	var userBid = 0.0;
	var bidcharge = 0.0;
	var bidprice = 0.0;
	if(document.getElementById("bid")!=null)
	{         
	          var tmp1=document.getElementById("bid").value;
	          //alert(":"+tmp1+":");
	          if(null == tmp1 || tmp1==""){
	             tmp1=0.00;
	             }
		userbid=parseFloat(tmp1);
		bidcharge=(this.buycharge/100*userbid).toFixed(2);
		bidprice=((1+this.buycharge/100)*userbid).toFixed(2);
		//alert(document.getElementById("bid").value);
		//if(bidcharge == NaN){
		// bidcharge=0.00;
		//}
		document.getElementById('p_bidcharge').innerHTML=bidcharge;
		document.getElementById('p_bidprice').innerHTML=bidprice;
	}
};
AuctionDetail.prototype.sendAsk=function(){
	if(""==this.userid || 0==this.userid){
	  window.location = "/customer/login.jsp?reurl="+location.href;
	  return false;
	  }
	var asktype=document.getElementById("askType").value;
	
	var askContent=document.getElementById("askContent").value;
	if(askContent.match(/^\s*$/)){
	    alert(m_auction_detail_ask_content_null);
	    return;
	}
	if(askContent.length>500 || askContent.length<10){
		alert(m_auction_detail_ask_content_moreOrLess);
		document.getElementById("askContent").focus();
		return;
	}
	if(document.getElementById("save1").checked==false){
	  issave=0;
	}
	if(document.getElementById("save1").checked==true){
	  issave=1;
	}
	//alert(":"+issave);
	var authCode=document.getElementById("authCode1").value;
	
	if(authCode.length !=4 || !authCode.match(/\d{4}/)){
		alert(m_auction_detail_ask_validateNumber_error);
		return;
	}
	
	document.getElementById("showajax1").innerHTML="<img src='/images/ajax-loader.gif' border='0'/>";
	
	AuctionHelper.sendAsk(this.acNewId,asktype,askContent,issave,authCode,this.sendAskCall);
};

AuctionDetail.prototype.sendAskCall=function(msg){
	//alert(msg);
	document.getElementById("showajax1").innerHTML="";
	if("1"==msg){
		alert(m_auction_detail_ask_leaveMessage_success);
		document.getElementById("askContent").disabled=true;
		document.getElementById("SubmitAsk").disabled=true;
		document.getElementById("authCode1").disabled=true;
		return;
	}else if("2"==msg){
		alert(m_auction_detail_ask_validateNumber_wrong);
	}else if("3"==msg){
	    alert(m_auction_detail_ask_user_notLogin);
	}else{
		alert(m_auction_detail_ask_unknowError);
	}
};

AuctionDetail.prototype.sendRecommend=function()
{
	var email1=document.getElementById("address").value;
	if(!email1.match(/\w+([-+._]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/))
	{
		alert(m_auction_detail_ask_email_error);
		return;
	}
    	var authCode=document.getElementById("authCode2").value;
	if(authCode.length !=4 || !authCode.match(/\d{4}/)){
		alert(m_auction_detail_ask_validateNumber_error);
		return;
	}
	if(""==this.userid){
	  window.location = "/customer/login.jsp?reurl="+location.href;
	  return false;
	  }
	var message=document.getElementById("message").value;
	
	document.getElementById("showajax").innerHTML="<img src='/images/ajax-loader.gif' border='0'/>";
	AuctionHelper.sendRecommend(authCode,email1,message,this.acNewId,this.description,this.acNewId,this.reSendRecommend);
};

AuctionDetail.prototype.reSendRecommend=function(msg)
{
	document.getElementById("showajax").innerHTML="";
	  if("1"==msg){
	     alert(m_auction_detail_ask_commend_success);
	     document.getElementById("Submit2").disabled="disabled";
	     document.getElementById("authCode2").disabled=true;
	     document.getElementById("address").disabled=true;
	     document.getElementById("message").disabled=true;
	     return;
	  }else if("2"==msg){
	  	alert(m_auction_detail_ask_validateNumber_error);
	  	return;
	  }else if("3"==msg){
	  	alert(m_auction_detail_ask_user_notLogin);
	  	return;
	  }else{
			alert(m_auction_detail_ask_unknowError);
			return;
		}
};

AuctionDetail.prototype.startMove=function(dir) 
{
	if(dir == "left")
	{
		this.mainStep = this.mainStep - 1;
		this.stepright = this.stepright+this.scrollStep;
		if(this.mainStep > 0)
		{
			if ((this.mainStep % this.limitWidth) == 0) 
			{
				document.getElementById("imgshowDiv").style.left = this.stepright+"px";
				clearInterval(this.loopTimer);
			}
			else
			{
				document.getElementById("imgshowDiv").style.left = this.stepright+"px";
				
			}
			if (document.getElementById("btnRight").disabled) 
			{
				document.getElementById("btnRight").disabled = false;
				document.getElementById("btnRight").className = "inputPronLeftAn2";
			}
		}
		else
		{
			this.step = 0;
			clearInterval(this.loopTimer);
			document.getElementById("btnLeft").disabled = true;
			document.getElementById("btnLeft").className = "inputPronLeftAn1_1";
			document.getElementById("imgshowDiv").style.pixelLeft = 0;
		}
	}
	if(dir=="right")
	{
		this.mainStep = this.mainStep + 1;
		this.step = this.step+this.scrollStep;
		if (this.mainStep < ((this.mainWidth - this.showWidth) / this.scrollStep)) 
		{
			if ((this.mainStep % this.limitWidth) == 0) 
			{
				document.getElementById("imgshowDiv").style.left = -this.step + "px";
				this.stepright = this.stepright-this.scrollStep; 
				clearInterval(this.loopTimer);
			}
			else
			{
				document.getElementById("imgshowDiv").style.left= -this.step + "px";
				this.stepright = this.stepright-this.scrollStep;  
			}
			if (document.getElementById("btnLeft").disabled) 
			{
				document.getElementById("btnLeft").disabled = false;
				document.getElementById("btnLeft").className = "inputPronLeftAn1";
			}
		}
		else
		{
			this.step = 0;
			clearInterval(this.loopTimer);
			document.getElementById("btnLeft").disabled = false;
			document.getElementById("btnLeft").className = "inputPronLeftAn1";
			document.getElementById("btnRight").disabled = true;
			document.getElementById("btnRight").className = "inputPronLeftAn2_1";
			document.getElementById("imgshowDiv").style.pixelLeft = 0 - (this.mainStep * this.scrollStep);
			this.stepright = this.stepright-this.scrollStep; 	
		}
	}
};
AuctionDetail.prototype.initpic=function(sDir,instance)
{
    clearInterval(this.loopTimer);
    this.loopTimer = setInterval(instance+".startMove('"+sDir+"')", this.timerSpeed);
};
AuctionDetail.prototype.newValidateNumber=function(digits)
{
	var validatePIC = document.getElementById("validatePIC");
	if(!digits)
		validatePIC.src="/validatecode.jpg?n="+Math.random();
	else
		validatePIC.src="/validatecode.jpg?digits="+digits+"&n="+Math.random();
};

/*
**Author: huangzhenzhong
**Usage : For manipulate price tables
*/
var AuctionPrice={};
updateAuctionPrices=function(auctionId,page,userId)
{
	AuctionPrice.auctionId=auctionId;
	AuctionPrice.userId=userId;
	$("ajaxLoader").style.display="block";
	if(!AuctionPrice.isTraded)
		AuctionHelper.getAuctionPrices(auctionId,page,fillTable);
	else
		AuctionHelper.getTradePrices(auctionId,page,fillTable);
	
};
updateAuctionPrices2=function(status,auctionId,page,userId)
{
	AuctionPrice.auctionId=auctionId;
	AuctionPrice.userId=userId;
	$("ajaxLoader").style.display="block";
	AuctionPrice.setTrade(status);
	if(AuctionPrice.isTraded==2)
		AuctionHelper.getAuctionPrices(auctionId,page,fillTable_Two);
	else
		AuctionHelper.getAuctionPrices(auctionId,page,fillTable);
};
fillTable=function(pageList)
{
	 dwr.util.removeAllRows("priceBody", { filter:function(tr) { return (tr.id != "pattern"); }});
	 var highLightColor="#fbfed1";
	 for(var i=0;i<pageList.list.length;i++)
	 {
	 	price = pageList.list[i];
	 	dwr.util.cloneNode("pattern", { idSuffix: ""+i });
	 	
	 	if(price.isMax==1)
	 	{
			state='<span class="org">'+m_auction_price_win+'</span>';
			if(price.isProxy==1)
				state+=m_auction_price_proxy;
			
		}
		else
			state=m_auction_price_fail;
	 	    dwr.util.setValue("priceBodyUserId" + i, price.userId);
      		dwr.util.setValue("priceBodyPrice" + i, price.bid.toFixed(2));
 	     	dwr.util.setValue("priceBodyDate" + i, formateDate(price.createdAt,"YYYY-MM-DD HH:MI:SS"));
 	     	dwr.util.setValue("priceBodyState" + i, state,{ escapeHtml:false });
 	     	dwr.util.setValue("priceBodyAddress" + i, price.country+"|"+price.province+"|"+price.city);
 	     	dwr.util.setValue("priceBodyIp" + i, price.ip.replace(/\d+\s*\s*$/,"*"));
 	     	if(window.navigator.appName.toLowerCase()=="netscape")
 	     		document.getElementById("pattern" + i).style.display = "table-row";
 	     	else
 	     		document.getElementById("pattern" + i).style.display = "inline";
 	     	if(AuctionPrice.userId==price.userId)
 	     	{
 	     		cells = $("pattern"+i).cells;
 	     		for(var j=0;j<cells.length;j++)
 	     			cells[j].style.backgroundColor=highLightColor;
 	     	}
	 }
	 AuctionPrice.pageList = pageList;
	 $('pricePageList').innerHTML=AuctionPrice.constructPageList();
	 $('pageNum').value = pageList.currentPage;
	 $("ajaxLoader").style.display="none";
};
fillTable_Two=function(pageList)
{
	 dwr.util.removeAllRows("priceBody", { filter:function(tr) { return (tr.id != "pattern"); }});
	 var highLightColor="#fbfed1";
	 for(var i=0;i<pageList.list.length;i++)
	 {
	 	price = pageList.list[i];
	 	dwr.util.cloneNode("pattern", { idSuffix: ""+i });
	 	
	 	if(price.isMax==1)
	 	{
			state='<span class="org">'+m_auction_price_win+'</span>';
			if(price.isProxy==1)
				state+=m_auction_price_proxy;
			
		}
		else
			state=m_auction_price_fail;
	 	    //dwr.util.setValue("priceBodyUserId" + i, price.userId);
	 	if(price.userId.toString().length>5)
	 	    dwr.util.setValue("priceBodyUserId" + i, price.userId.toString().substr(0,4)+"***");
      		dwr.util.setValue("priceBodyPrice" + i, price.bid.toFixed(2));
 	     	dwr.util.setValue("priceBodyDate" + i, formateDate(price.createdAt,"YYYY-MM-DD HH:MI:SS"));
 	     	dwr.util.setValue("priceBodyState" + i, state,{ escapeHtml:false });
 	     	dwr.util.setValue("priceBodyAddress" + i, price.country+"|"+price.province+"|"+"*");
 	     	//dwr.util.setValue("priceBodyIp" + i, price.ip.replace(/\d+\s*\s*$/,"*"));
 	     	var fourthPoint = price.ip.substr(0,price.ip.lastIndexOf("."));
 	     	var thirdPoint = fourthPoint.substr(0,fourthPoint.lastIndexOf("."));
 	     	var ip = thirdPoint+".*.*";
 	     	dwr.util.setValue("priceBodyIp" + i, ip);
 	     	if(window.navigator.appName.toLowerCase()=="netscape")
 	     		document.getElementById("pattern" + i).style.display = "table-row";
 	     	else
 	     		document.getElementById("pattern" + i).style.display = "inline";
 	     	if(AuctionPrice.userId==price.userId)
 	     	{
 	     		cells = $("pattern"+i).cells;
 	     		for(var j=0;j<cells.length;j++)
 	     			cells[j].style.backgroundColor=highLightColor;
 	     	}
	 }
	 AuctionPrice.pageList = pageList;
	 $('pricePageList').innerHTML=AuctionPrice.constructPageList();
	 $('pageNum').value = pageList.currentPage;
	 $("ajaxLoader").style.display="none";
};
AuctionPrice.getURL = function( text,  currentPage, className)
{
	query = "<a href=javascript:updateAuctionPrices2(AuctionPrice.isTraded,'"+AuctionPrice.auctionId+"',"+"'<0>'"+",'"+AuctionPrice.userId+"')><1></a>";
	var str = "";
	if (query != null) {
		str = query.replace("<0>", currentPage + "");
		str = str.replace("<1>", text);
		if(this.pageList.currentPage==currentPage)
		{
			str = str.replace("<a ", "<span class=\"ahov\" ");
			str = str.replace("</a>", "</span>");
		}
		else if(className)
		{
			str = str.replace("<a ", "<a class=\""+className+"\" ");
		}
	}
	return str;
};

AuctionPrice.constructPageList=function()
{
	pageList = this.pageList;
	var privousImg = this.getPriviousImage("/images/leftindeximg-05_2.gif");
	var nextImg = this.getNextImage("/images/leftindeximg-05_1.gif");
	bfHref="";
	if (pageList != null) 
	{
		if (pageList.up) {
			bfHref+=(this.getURL(privousImg+m_auction_price_previous_page, pageList.currentPage - 1,"text"));
		}
		if (pageList.down) {
			bfHref+=(this.getURL(m_auction_price_next_page+nextImg, pageList.currentPage + 1,"text"));
		} 
		
		//has first page
		if (pageList.totalPage > 0) {
				bfHref+=(this.getURL("1",1));
			bfHref+=("&nbsp;");
		}
		
		//has second page
		if(pageList.totalPage > 1) {
			bfHref+=(this.getURL("2",2));
			bfHref+=("&nbsp;");
		}
		
		
		if(pageList.currentPage>1 && pageList.currentPage<pageList.totalPage)
		{
			if(pageList.currentPage>4)
			{
				bfHref+=("....");
				bfHref+=("&nbsp;");
			}
			if(pageList.currentPage>3)
			{
				bfHref+=(this.getURL(pageList.currentPage-1,pageList.currentPage-1));
				bfHref+=("&nbsp;");
			}
			if(pageList.currentPage>2 && pageList.currentPage<pageList.totalPage-1)
			{
				bfHref+=(this.getURL(pageList.currentPage,pageList.currentPage));
				bfHref+=("&nbsp;");
			}
			
			if(pageList.currentPage<pageList.totalPage-2)
			{
				bfHref+=(this.getURL(pageList.currentPage+1,pageList.currentPage+1));
				bfHref+=("&nbsp;");
			}
			if(pageList.currentPage<pageList.totalPage-3)
			{
				bfHref+=("....");
				bfHref+=("&nbsp;");
			}
			
		}
		else if(pageList.totalPage>5)
		{
			bfHref+=("....");
			bfHref+=("&nbsp;");
		}
		
		
		//last two pages
		if(pageList.totalPage > 3) {
			bfHref+=(this.getURL(pageList.totalPage-1,pageList.totalPage-1));
			bfHref+=("&nbsp;");
		}
		if(pageList.totalPage > 2)
		{
			bfHref+=(this.getURL(pageList.totalPage,pageList.totalPage));
			bfHref+=("&nbsp;");
		}

	}	
	return bfHref;		
};

AuctionPrice.getPriviousImage=function(path) 
{
		return "<img src=\"" + path + "\"  style=\"border:none;padding:0 4px 2px 0;\">";
};
AuctionPrice.getNextImage=function(path)
{
		return "<img src=\"" + path + "\"  style=\"border:none;padding:0 0 2px 3px;\">";
};
AuctionPrice.setTrade=function(isTraded)
{
	this.isTraded=isTraded;
};
		
/*Author: Huangzhenzhong:)
**Usage: <script>new RecentView()</script>
*/

function RecentView(auctionId, auctionName, auctionImage)
{
	try
	{
	var size = 5;
	var allcookies = document.cookie;
	var pos = allcookies.indexOf("recentView=");
	var start = pos + 11;
	var end = allcookies.indexOf(";",start);
	if(end==-1) end=allcookies.length; 
	
	var value = allcookies.substring(start, end);  
	value = unescape(value);
	
	var auctionIds = [];
	var auctionNames = [];
	var auctionImages = [];
	if(value)
	{
		var auctions = value.split(/`/);
		for(var i=0;i<auctions.length;i++)
		{
			auction = auctions[i].split(/~/);
			if(auction.length==3 && auction[0]!=auctionId && auctionIds.length<size)
			{
				auctionIds.push(auction[0]);           //1: auction id
				auctionNames.push(auction[1]);	//2: auction name
				auctionImages.push(auction[2]);        //3: auction image
			}
		}
	}
	
	var html = '<div style="width: 830px; line-height:25px;">${tables}</div>';
	var tables = '';
	for(var i=0;i<auctionIds.length;i++)
	{
		tables = tables + '<table cellpadding="0" cellspacing="0" align="left" style="widht:165px;">' +
				'<tr>'+
					'<td style="widht:165px; text-align:left;">'+
						'<table style="width:165px" cellpadding="0" cellspacing="0" align="left">'+
							'<tr>'+
								'<td style="text-align:center;">'+
									'<table cellpadding="0" cellspacing="0" style="height: 90px; border:1px solid #E4D8CD;background-color:#FFFFFF;padding:3px; width:82px;" align="center">'+
										'<tr>'+
											'<td><a href="/detail/auction-'+auctionIds[i]+'-detail.shtml" target="_blank"><img src="'+auctionImages[i]+'" alt="" style="border:none;" /></a></td>'+
										'</tr>'+
									'</table>'+
								'</td>'+
							'</tr>'+
							'<tr>'+
								'<td style="text-align:center;"><a href="/detail/auction-'+auctionIds[i]+'-detail.shtml " target="_blank" title="'+auctionNames[i]+'">'+this.shortName(auctionNames[i],12)+'</a></td>'+
							'</tr>'+
						'</table>'+
					'</td>'+
				'</tr>'+
			    '</table>';
				
	}
	html = html.replace('${tables}',tables);
	document.write(html);
	
	
	if(auctionId&&auctionName&&auctionImage)
	{
		auctionIds.unshift(auctionId);
		auctionNames.unshift(auctionName);
		auctionImages.unshift(auctionImage);
	}
	
	value = "";
	for(var i=0;i<size+1 && i<auctionIds.length;i++)
		value = value + auctionIds[i] +"~"+auctionNames[i]+"~"+auctionImages[i]+"`";
	
	var expires = new Date(new Date().getTime()+ 3600*24*7*1000);
	
	document.cookie = "recentView="+escape(value)+";expires="+expires.toUTCString()+";path=/";
	}
	catch(e){}
};
RecentView.prototype.shortName=function(s,l)
{
	if(s.length>l){
		return s.substr(0,l-1)+'...';
	}
	else{
		return s;
	}
};

