﻿
var currentSingleShow = '';
var currentMultiShow = '';


//刷新拍卖信息(开始时间，结束时间，中标人，中标价格）,1秒刷新一次
function refreshBids() {
    var i;
    var t, s;
    var bid;
    var supName, supUrl, supLogo;
    
    var allInputs = $(":input");
    for (i = 0; i < allInputs.length; i++) {
        if (allInputs[i].name == "bidids") {
            bid = allInputs[i].value;
            if ($("#overed_"+bid).val() == "0") {
                t = calInterval($("#stoptime_"+bid).val());
                s = calInterval($("#startDate_"+bid).val()); //距离开始的秒数
                if (s > 0) {
                    $('#time_type_' + bid).html('距开拍时间：');
                    $('#BtnSingle_' + bid).attr('src', '/images/GmCjHe.gif');
                    $('#BtnMulti_' + bid).attr('src', '/images/GmCjHe.gif');
                    showtimeinfo(bid, s, false);
                } else {
                    if (t > 0) {
                        $('#time_type_' + bid).html('剩余时间：');
                        $('#BtnSingle_' + bid).attr('src', '/images/GmCj.gif');
                        $('#BtnMulti_' + bid).attr('src', '/images/GmCj.gif');
                        showtimeinfo(bid, t, false);

                    } else {//结束
                        showtimeinfo(bid, -1,true);
                        $("#overed_" + bid).attr("value", "1");
                        //showTimeover(bid);
                        setTimeout("showTimeover(" + bid + ")", 2000);//两秒后再显示计算结果
                    }
                }
            } else {
                //alert(gOvered[i]);
            }
        }
    }
}
//倒计时竞拍
function countDownBid(bid){	
	if ($("#overed_"+bid).val() == "0") {
		t = calInterval($("#stoptime_"+bid).val());
		s = calInterval($("#startDate_"+bid).val()); //距离开始的秒数
		if (s > 0) {
			$('#time_type_' + bid).html('距开拍时间：');
			$('#BtnSingle_' + bid).attr('src', '/images/GmCjHe.gif');
			$('#BtnMulti_' + bid).attr('src', '/images/GmCjHe.gif');
			showtimeinfo(bid, s, false);
		} else {
			if (t > 0) {
				$('#time_type_' + bid).html('剩余时间：');
				$('#BtnSingle_' + bid).attr('src', '/images/GmCj.gif');
				$('#BtnMulti_' + bid).attr('src', '/images/GmCj.gif');
				showtimeinfo(bid, t, false);
			} else {//结束
				showtimeinfo(bid, -1,true);
				$("#overed_" + bid).attr("value", "1");
				//showTimeover(bid);
				setTimeout("showTimeover(" + bid + ")", 2000);//两秒后再显示计算结果
			}
		}
	} else {
		//alert(gOvered[i]);
	}	
}
//刷新抢购信息(开始时间，结束时间，中标人，中标价格）,1秒刷新一次
function refreshBuy() {
    var i;
    var t, s;
    var bid;

    var allInputs = $(":input");
    for (i = 0; i < allInputs.length; i++) {
        if (allInputs[i].name == "bidids") {
            bid = allInputs[i].value;
            if ($("#overed_" + bid).val() == "0") {
                t = calInterval($("#stoptime_" + bid).val());
                s = calInterval($("#startDate_" + bid).val()); //距离开始的秒数
                if (s > 0) {
                    $('#time_type_' + bid).html('距开抢还剩：');
                    $('#btnqgou_' + bid).attr('src', '/images/qgou2.gif');
                    showtimeinfo2(bid, s, false,false);
                } else {
                    if (t > 0) {
                        $('#time_type_' + bid).html('剩余时间：');
                        $('#btnqgou_' + bid).attr('src', '/images/qgou.gif');
                        showtimeinfo2(bid, t, false,true);
                    } else {//结束
                        showtimeinfo2(bid, -1, true,false);
                        $("#overed_" + bid).attr("value", "1");
                        //showTimeover(bid);
                        $('#btnqgou_' + bid).attr('src', '/images/qgou2.gif');
                        //setTimeout("showTimeover(" + bid + ")", 2000); //两秒后再显示计算结果
                    }
                }
            } else {
                //alert(gOvered[i]);
            }
        }
    }
}
//获取时差
function timeDif() {
    return gServerTime.getTime() - gClientTime.getTime();
}
function calInterval(overtime) {
    //var d = new Date();
    //alert(overtime);
    var arr = overtime.split(" ");
    var arr1 = arr[0].split("-");
    var arr2 = arr[1].split(":");

    var d2 = new Date(arr1[0], arr1[1] - 1, arr1[2], arr2[0], arr2[1], arr2[2]);

    //alert(d2);
    var d = new Date();
    //加上与服务器的时差 
    var sjc = (d2.getTime() - d.getTime() - timeDif()) / 1000; 
    return parseInt(sjc, 10);
}
//获取当前页面中显示的竞拍ID,以逗号分隔
function allBids() {
    var i;
    var bids = "";
    var allInputs = $(":input");
    for (i = 0; i < allInputs.length; i++) {
        if (allInputs[i].name == "bidids") {
            if (bids != "") bids = bids + ",";
            bids =bids+ allInputs[i].value;             
        }
    }
    return bids;
}
function showTimeover(bid) {       
    $.ajax({
        type: "get",
        url: "/refeshProductOver.aspx?rnd=" + Math.random() + "&productid=" + bid,
        beforeSend: function(XMLHttpRequest) {
            //ShowLoading();
        },
        success: function(data, textStatus) {
            if (data == "") {                          
                setTimeout("showTimeover(" + bid + ")", 3000); //3秒后再次执行
            }
            else {
                var dataarr = data.split("|");
                var str = "<span style='color:#03689B;font-weight: bold;font-size:16px;'>竞拍结束！</span>";
                if (dataarr[1] != "" && dataarr[1] != "undefined") {
                    refleshProductStatus(bid);
                    str = "<span style='color:#03689B;font-weight: bold;font-size:14px;'>竞拍结束！<br>恭喜" + dataarr[1] + "获胜！</span>";
                    $("#nicknamediv_" + bid).html("<img src='/images/face.gif' alt='' border='' /> " + dataarr[1]);
                }
                $("#timerdiv_" + bid).html(str);
				clearInterval('timer_'+bid);
            }
        },
        complete: function(XMLHttpRequest, textStatus) {
            //HideLoading();
        },
        error: function() {
            //请求出错处理
        }
    });
}
//显示当前的中标人
function showTargetUsers() {
    $.ajax({
        type: "get",
        url: "/GetTargetUsers.aspx?rnd=" + Math.random() + "&id=" + allBids(),
        beforeSend: function(XMLHttpRequest) {
            //ShowLoading();
        },
        success: function(data, textStatus) {
            if (data == "") {
                //setTimeout("showTimeover(" + bid + ")", 3000); //3秒后再次执行
            }
            else {
                var dataarr = data.split(",");
                var i;
                var sHtml;
                var bid;
                for (i = 0; i < dataarr.length; i += 2) {
                    bid = dataarr[i];
                    sHtml = "<img src='/images/face.gif' alt='当前预中标人' border='0' /> " + dataarr[i + 1];                    
                    if ($("#nicknamediv_" + dataarr[i]).html()!=null&&$("#nicknamediv_" + dataarr[i]).html().indexOf(" "+dataarr[i+1])==-1) {
                        //alert($("#nicknamediv_" + dataarr[i]).html());
                        //已变更,闪烁显示
                        $("#nicknamediv_" + bid).html(sHtml);
                        blink("nicknamediv_" + bid, 1);
                    }
                }
            }
        },
        complete: function(XMLHttpRequest, textStatus) {
            //HideLoading();
        },
        error: function() {
            //请求出错处理
        }
    });
}

function replacefun(intputstr,replacestr,replacenew)
{
    var oldintputstr=intputstr
    while(oldintputstr.indexOf(replacestr)!=-1)
    {
        oldintputstr=oldintputstr.replace(replacestr,replacenew);
    }
    return oldintputstr;

}

function  Round(v,e)  
{  
		var   t=1;  
		for(;e>0;t*=10,e--);  
		for(;e<0;t/=10,e++);  
		return   Math.round(v*t)/t;  
}


function showSingle(id,showsinglediv) {
        refleshProductStatus(id);//更新当前状态
        
        if(currentSingleShow != '' && currentSingleShow != id) {
			alert("请先关闭您的本拍品或其它拍品的单次出价再尝试。");
			return ;
		}
		if(currentMultiShow != '') {
			alert("请先关闭您的本拍品或其它拍品区间出价再尝试。");
			return ;
		}

		if($("#singlebid_"+id).val()=="") {
			alert("请先填写您的出价");
			return ;
		}
        if(showInterval($("#startDate_"+id+"").val())>0)
        {
            alert("开拍时间："+$("#startDate_"+id+"").val());
            return;
        }
		var price =$("#singlebid_"+id).val();

		if(Number(price)==0) {
			alert("出价不能为0");
			$("#singlebid_"+id).val("");
			return ;
		}
			
       var dddd=0
		//遍历查询出价的次数
		for( i = 1 ; i <= 5 ; i++ ) {
			if( document.getElementById("singletab_"+id+"_"+i).className == "bid_tab_active" ) {
				dddd = dddd  + 1 ;
			}
		}
         
         //alert(document.getElementById("top_count_"+id).innerHTML-dddd);
		if(dddd==5)
		{		
		    alert("已达到5个出价，请确认出价后再重试！");
		    return;
		}

		var point = $("#point_" + id).val();		
	var currentcount = 0 ;
	var totalPoint = 0 ;
	var currentprice=$("#singlebid_"+id).val();
	var havethisprice=false; 
	if(currentSingleShow == id) {
		var i = 0 ; 
		//验证价格是否重复
		for( i = 1 ; i <= 5 ; i++ ) {
		    if(currentprice==$("#bidprice_"+id+"_"+i).val())
		        havethisprice=true;			
		}
		
		if(havethisprice)
		{
		    alert(currentprice+"价位您已经出过，为了您的利益，系统将自动为您排除！");
		    return ;
		}
		
		//遍历是否有空部分，进行写入
		for( i = 1 ; i <= 5 ; i++ ) {
			if( document.getElementById("singletab_"+id+"_"+i).className == "bid_tab_active" ) {
				continue ;
			}
			else {
				activeSingleTab(id,i);
				break ;
			}
		}
		//遍历查询出价的次数
		for( i = 1 ; i <= 5 ; i++ ) {
			if( document.getElementById("singletab_"+id+"_"+i).className == "bid_tab_active" ) {
				currentcount = currentcount  + 1 ;
			}
		}
		
		totalPoint = Number(point) * currentcount ;
//		$("#bid_required_point_"+id).html("<span style='font-size:12px;color:#000000;'>当前出价需要点宝：<span style='font-weight: bold;'>"+totalPoint+"</span></span");
        var topcount=parseInt($("#top_hidden_number"+id).html())-1;
        
        if(topcount<=0)
        {  
             
             document.getElementById("top_count_"+id).innerHTML="0";
             document.getElementById("top_count_"+id).title="您还剩0个出价";
        }
        else
        {
            $("#top_count_"+id).html(topcount);
           
            $("#top_count_"+id).attr("title","您还剩"+topcount+"个出价");
            
        }
        if(topcount==0)
        {
         document.getElementById("top_hidden_number"+id).innerHTML="0";
        }
        else
        {
            $("#top_hidden_number"+id).html(topcount);
        }
        /*************总价*************/
        var toptotalcount=parseInt($("#top_hidden_total"+id).val())-1;
        if(toptotalcount<=0)
        {  
             
             document.getElementById("top_total"+id).innerHTML="0";
             document.getElementById("top_total"+id).title="该商品还剩0个出价";
        }
        else
        {
            $("#top_total"+id).html(toptotalcount);
           
            $("#top_total"+id).attr("title","该商品还剩"+toptotalcount+"个出价");
            
        }
        if(toptotalcount==0)
        {
         document.getElementById("top_hidden_total"+id).value="0";
        }
        else
        {
            $("#top_hidden_total"+id).val(toptotalcount);
        }
        $("#totalPoint").html(""+totalPoint);
	    $("#singletab_"+id+"_confirm").attr("title","当前出价需要支付点宝："+totalPoint);//增加样式
		return ;
	}

	
	currentcount = 1 ;
	totalPoint = Number(point) * currentcount;
//    $("#bid_required_point_"+id).html("<span style='font-size:12px;color:#000000;'>当前出价需要点宝：<span style='font-weight: bold;'>"+totalPoint +"</span></span>");

    var topcount=parseInt($("#top_hidden_number"+id).html())-currentcount;
       
        if(topcount<=0)
        {  
             
             document.getElementById("top_count_"+id).innerHTML="0";
             document.getElementById("top_count_"+id).title="您还剩0个出价";
        }
        else
        {
            $("#top_count_"+id).html(topcount);
            $("#top_count_"+id).attr("title","您还剩"+topcount+"个出价");
            
        }
        if(topcount==0)
        {
         document.getElementById("top_hidden_number"+id).innerHTML="0";
        }
        else
        {
            $("#top_hidden_number"+id).html(topcount);
        }
        /*************总价*************/
        var toptotalcount=parseInt($("#top_hidden_total"+id).html())-currentcount;
        if(toptotalcount<=0)
        {  
             
             document.getElementById("top_total"+id).innerHTML="0";
             document.getElementById("top_total"+id).title="该商品还剩0个出价";
        }
        else
        {
            $("#top_total"+id).html(toptotalcount);
           
            $("#top_total"+id).attr("title","该商品还剩"+toptotalcount+"个出价");
            
        }
       
        
        if(toptotalcount==0)
        {
         document.getElementById("top_hidden_total"+id).value="0";
        }
        else
        {
           $("#top_hidden_total"+id).html(toptotalcount); 
        }
    $("#totalPoint").html(""+totalPoint);
    document.getElementById("singletab_" + id).className = "bid_tab_single_show";
    //$("#singletab_" + id).show();
	currentSingleShow = id ;
	activeSingleTab(id,1);
	$("#singletab_"+id+"_confirm").attr("style","cursor:hand");//增加样式
	$("#singletab_"+id+"_confirm").attr("title","当前出价需要支付点宝："+totalPoint);//增加样式
    
}


function showMulti(id) {
        refleshProductStatus(id);//更新当前状态
        
	if(currentSingleShow != '') {
		alert("请先关闭您的本拍品或其它拍品的单次出价再尝试。");
		return ;
	}
	if(currentMultiShow != '') {
		alert("请先关闭您的本拍品或其它拍品区间出价再尝试。");
		return ;
	}
	if( document.getElementById("multibid_"+id+"_1").value=='') {
		alert("请先填写您的区间出价");
		return ;
	}

	if( document.getElementById("multibid_"+id+"_2").value=='') {
		alert("请先填写您的区间出价");
		return ;
	}

    if(showInterval($("#startDate_"+id+"").val())>0)
	{
	    alert("开拍时间："+$("#startDate_"+id+"").val());
	    return;
	}
	var price1 = document.getElementById("multibid_"+id+"_1").value ;
	var price2 = document.getElementById("multibid_"+id+"_2").value ;

	var price = document.getElementById("singlebid_"+id).value;
    
	if(Number(price1)==0) {
		alert("出价不能为0");
		document.getElementById("multibid_"+id+"_1").value = "" ;
		return ;
	}

	if(Number(price2)==0) {
		alert("出价不能为0");
		document.getElementById("multibid_"+id+"_2").value = "" ;
		return ;
	}
	
	var point = document.getElementById("point_"+id).value;

	var tempPrice = "" ;
	if( Number(price2) < Number(price1)) {
		tempPrice = price2 ;
		price2 = price1 ;
		price1 = tempPrice ;
	}

	document.getElementById("multibid_"+id+"_1").value = '' ;
	document.getElementById("multibid_"+id+"_2").value = '' ;

	var multititle = "<span style='color:#000000;'>出价区间：￥<span style='font-weight: bold;font-size:14px;'>"+ Round(Number(price1)*0.01,2) +"</span>";
	multititle += " ～ <span style='font-weight: bold;font-size:14px;'>"+ Round(Number(price2)*0.01,2) +"</span></span>";
	var totalCount = Number(price2) - Number(price1) + 1;
	
	if(totalCount>100)
	{
		alert('区间出价次数最多只能100个。');
		return false;
	}
	var topcount=parseInt($("#top_hidden_number"+id).html())-totalCount;

	if(topcount<=0)
    {  
         
         document.getElementById("top_count_"+id).innerHTML="0";
         document.getElementById("top_count_"+id).title="您还剩0个出价";
    }
    else
    {
        $("#top_count_"+id).html(topcount);
        $("#top_count_"+id).attr("title","您还剩"+topcount+"个出价");
        
    }
    if(topcount==0)
    {
     document.getElementById("top_hidden_number"+id).innerHTML="0";
    }
    else
    {
        $("#top_hidden_number"+id).html(topcount);
    }
    /*************总价*************/
        var toptotalcount=parseInt($("#top_hidden_total"+id).html())-totalCount;
        if(toptotalcount<=0)
        {  
             
             document.getElementById("top_total"+id).innerHTML="0";
             document.getElementById("top_total"+id).title="该商品还剩0个出价";
        }
        else
        {
            $("#top_total"+id).html(toptotalcount);
           
            $("#top_total"+id).attr("title","该商品还剩"+toptotalcount+"个出价");
            
        }
       
        
        if(toptotalcount==0)
        {
         document.getElementById("top_hidden_total"+id).value="0";
        }
        else
        {
           $("#top_hidden_total"+id).html(toptotalcount); 
        }
	var totalPoint = Number(point) * Number(totalCount) ;
	multititle += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:#000;'>出价个数：<span style='font-weight: bold;font-size:14px;' id='totalCount_"+id+"'>" + totalCount+"</span>" ;
	multititle += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;需要点宝：<span style='font-weight: bold;font-size:14px;'>" + totalPoint +"</span></span>";

//	document.getElementById("bid_required_point_"+id).innerHTML = "<span style='font-size:12px;color:#000000;'>当前出价需要点宝：<span style='font-weight: bold;'>"+totalPoint +"</span></span>";
	if(document.getElementById("totalPoint")!=null) {
		document.getElementById("totalPoint").innerHTML = "" + totalPoint ;
	}
	
	document.getElementById("multitab_price_title_"+id).innerHTML = multititle ;
	document.getElementById('multiprice_'+id+'_list').value = "" + Number(price1) + "-" + Number(price2) ;
	document.getElementById("multitab_"+id).className = "bid_tab_multi_show" ;
	currentMultiShow = id ;
	$("#multitab_"+id+"_confirm").attr("style","cursor:hand");//增加样式
	$("#multitab_"+id+"_confirm").attr("title","当前出价需要支付点宝："+totalPoint);//增加样式
}

function activeSingleTab(id , index) {
	document.getElementById("singletab_"+id+"_"+index).className = "bid_tab_active" ;
	var price = document.getElementById("singlebid_"+id).value;
	
	document.getElementById("singlebid_"+id).value = "";
	//alert($("#spanprice_"+id+"_"+index).html())
	$("#spanprice_"+id+"_"+index).show();
   try   {   
      (1).toFixed(1);   
    }   
   catch(e)   {   
      Number.prototype.toFixed   =   function(dot)   {   
          with(Math){   
              var   m=pow(10,Number(dot))   
              var   s   =   (round(this*m)/m).toString();   
          }   
          if(s.indexOf('.')   <   0)   
                s   +=   ".";   
        s   +=   "00000000000000000000000000";   
          return   s.substr(0,s.indexOf('.')+dot+1);   
      }   
    } 
	document.getElementById("spanprice_"+id+"_"+index).innerHTML = "&nbsp;&nbsp;<span style='color:#000;'>￥<span style='font-weight: bold;font-size:14px;color:#000;'>"+ (Round(Number(price)*0.01,2)).toFixed("2")+"</span></span><br />&nbsp;&nbsp;<span style='color:#999'>第&nbsp;" + index + "&nbsp;个出价</span>" ;
	document.getElementById("bidprice_"+id+"_"+index).value = price ;
	
}

function deactiveSingleTab(id,index) {
	$("#singletab_"+id+"_"+index).removeClass("bid_tab_active").addClass("bid_tab_grey") ;
	//$("#spanprice_"+id+"_"+index).hide();
	$("#spanprice_"+id+"_"+index).html("&nbsp;&nbsp;<span style='font-size:12px;color:#999;'>￥0.00</span><br />&nbsp;&nbsp;<span style='color:#999'>第&nbsp;" + index + "&nbsp;个出价</span>");
	$("#bidprice_"+id+"_"+index).val("");
	var flag = false ;
	var point = $("#point_"+id).val();
	var currentcount = 0 ;
	var totalPoint = 0 ;

	for( i = 1 ; i <= 5 ; i++ ) {
		if( document.getElementById("singletab_"+id+"_"+i).className == "bid_tab_active" ) {
			flag = true ;
			currentcount = currentcount + 1;
		}
	}
	if(flag)
	{
	    totalPoint = Number(point) * currentcount ;
//	    $("#bid_required_point_"+id).html("<span style='font-size:12px;color:#000000;'>当前出价需要点宝：<span style='font-weight: bold;'>"+totalPoint+"</span></span>");
        $("#totalPoint").html(totalPoint);
	    $("#singletab_"+id+"_confirm").attr("title","当前出价需要支付点宝："+totalPoint);//增加样式
	   
    }
	else
	{
		closeSingle(id);
		
    }
    var topcount=parseInt($("#top_hidden_number"+id).html())+1
    if(topcount<=0)
    {  
         
       
         document.getElementById("top_count_"+id).innerHTML="0";
         document.getElementById("top_count_"+id).title="您还剩0个出价";
    }
    else
    {
        $("#top_count_"+id).html(topcount);
        $("#top_count_"+id).attr("title","您还剩"+topcount+"个出价");
        
    }
    if(topcount==0)
    {
     document.getElementById("top_hidden_number"+id).innerHTML="0";
    }
    else
    {
        $("#top_hidden_number"+id).html(topcount);
    }
    var toptotalcount=parseInt($("#top_hidden_total"+id).html())+1;
        if(toptotalcount<=0)
        {  
             
             document.getElementById("top_total"+id).innerHTML="0";
             document.getElementById("top_total"+id).title="该商品还剩0个出价";
        }
        else
        {
            $("#top_total"+id).html(toptotalcount);
           
            $("#top_total"+id).attr("title","该商品还剩"+toptotalcount+"个出价");
            
        }
       
        
        if(toptotalcount==0)
        {
         document.getElementById("top_hidden_total"+id).value="0";
        }
        else
        {
           $("#top_hidden_total"+id).html(toptotalcount); 
        }
	return ;
}

function closeSingle(id) {
    
//	$("#bid_required_point_"+id).html("") ;
	$("#totalPoint").html("0") ;
	currentSingleShow = '' ;
	//$("#singletab_"+id).hide();
	document.getElementById("singletab_" + id).className = "bid_tab_single";

}


function closeMulti(id) {
	currentMultiShow = '' ;
	var topcount=parseInt($("#top_hidden_number"+id).html())+parseInt($("#totalCount_"+id).html());
	if(topcount<=0)
    { 
         document.getElementById("top_count_"+id).innerHTML="0";
         document.getElementById("top_count_"+id).title="您还剩0个出价";
    }
    else
    {
        $("#top_count_"+id).html(topcount);
        $("#top_count_"+id).attr("title","您还剩"+topcount+"个出价");
        
    }
    if(topcount==0)
    {
     document.getElementById("top_hidden_number"+id).innerHTML="0";
    }
    else
    {
        $("#top_hidden_number"+id).html(topcount);
    }
	var toptotalcount=parseInt($("#top_hidden_total"+id).html())+parseInt($("#totalCount_"+id).html());
        if(toptotalcount<=0)
        {  
             
             document.getElementById("top_total"+id).innerHTML="0";
             document.getElementById("top_total"+id).title="该商品还剩0个出价";
        }
        else
        {
            $("#top_total"+id).html(toptotalcount);
           
            $("#top_total"+id).attr("title","该商品还剩"+toptotalcount+"个出价");
            
        }
       
        
        if(toptotalcount==0)
        {
         document.getElementById("top_hidden_total"+id).value="0";
        }
        else
        {
           $("#top_hidden_total"+id).html(toptotalcount); 
        }
	document.getElementById('multiprice_'+id+'_list').value = ""  ;
//	document.getElementById("bid_required_point_"+id).innerHTML = "" ;
	if(document.getElementById("totalPoint")!=null) {
		document.getElementById("totalPoint").innerHTML = "0" ;
	}
	document.getElementById("multitab_"+id).className = "bid_tab_multi" ;			
}

function deactiveAllSingleTab(id) {
	var index = 0 ;
	for( index = 1 ; index <= 5 ; index++) {
		document.getElementById("singletab_"+id+"_"+index).className = "bid_tab_grey" ;
		document.getElementById("spanprice_"+id+"_"+index).innerHTML = "" ;
		document.getElementById("bidprice_"+id+"_"+index).value = "" ;
	}
	closeSingle(id);
	return ;
}

function confirmAllSingle(id) {
    var point = document.getElementById("point_"+id).value;
	var i = 1 ;
	var price = "" ;
	var pricelist = "" ;
	for( i = 1 ; i <= 5 ; i++ ) {		
		price = document.getElementById("bidprice_"+id+"_"+i).value ;
		
		if( price == "" )
			continue ;
		if(pricelist != "")
			pricelist = pricelist + "," ;
		pricelist = pricelist + price ;
	}
	
	if(currentSingleShow != '')
		deactiveAllSingleTab(id);

	var spaceid = document.getElementById("spaceid_"+id).value ;
	var bidruleid = document.getElementById("bidruleid_"+id).value ;
	if (spaceid == "3") {
	    openWindow('/InputVerifyCode.aspx?key='+id+'&rd='+escape('/UserBid.aspx?bidid=' + id + '&space=' + spaceid + '&bidrule=' + bidruleid + '&price=' + pricelist + '&point=' + point), 320, 200, "竞拍出价");
	    return;
	}
	openWindow('/UserBid.aspx?bidid='+id+'&space='+spaceid+'&bidrule='+bidruleid+'&price='+pricelist+'&point='+point, 320, 200, "竞拍出价");
}

function confirmAllMulti(id) {
    var point = document.getElementById("point_"+id).value;
	var pricelist = document.getElementById('multiprice_'+id+'_list').value ;

	if(currentMultiShow != '')
		closeMulti(id);

	var spaceid = document.getElementById("spaceid_"+id).value ;
	var bidruleid = document.getElementById("bidruleid_"+id).value ;
	openWindow('/UserBid.aspx?bidid='+id+'&space='+spaceid+'&bidrule='+bidruleid+'&price='+pricelist+'&point='+point, 320, 200, "竞拍出价");
	
}

function refleshProductStatus(id)
{	
//    alert($("#point_"+id).val());//单次出价价格
//    alert($("#jiajiadiv_"+id).html());//目前需要出价的加价值
//    alert($("#nicknamediv_"+id).html());
    $.ajax({
		type: "get",
		url: "/reflashPrice.aspx?rnd="+Math.random()+"&productid="+id,
		beforeSend: function(XMLHttpRequest){   
			//ShowLoading();
		},
		success: function(data, textStatus){ 	
            var dataarr=data.split("|");
            $("#point_"+id).val(dataarr[1]);
            $("#jiajiadiv_"+id).html(dataarr[0]);
            $("#nicknamediv_"+id).html(dataarr[2]);
			//alert(data);
		    },
		    complete: function(XMLHttpRequest, textStatus){
			    //HideLoading();
		    },
		    error: function(){
			    //请求出错处理
		    }
    });
    
}
function producttimeover(id)
{
    $.ajax({
		type: "get",
		url: "/refeshProductOver.aspx?rnd="+Math.random()+"&productid="+id,
		beforeSend: function(XMLHttpRequest){   
			//ShowLoading();
		},
		success: function(data, textStatus){ 
		 if(data=="")
		 {
		    setTimeout("producttimeover("+id+")",2000);
		 }
		 else
		 {
              var dataarr=data.split("|");
                var str="<span style='color:#03689B;font-weight: bold;font-size:16px;'>竞拍结束！</span>";
                if (dataarr[1]!="" && dataarr[1]!="undefined")
                {
                   refleshProductStatus(id);
                   str="<span style='color:#03689B;font-weight: bold;font-size:14px;'>竞拍结束！<br>恭喜"+dataarr[1]+"获胜！</span>";
                   $("#nicknamediv_"+id).html("<img src='/images/face.gif' alt='' border='' /> "+dataarr[1]);
                }
                $("#timerdiv_"+id).html(str);
            }

		    },
		    complete: function(XMLHttpRequest, textStatus){
			    //HideLoading();
		    },
		    error: function(){
			    //请求出错处理
		    }
    });
}
function showtimeinfo(productid,productstoptime,tp)
{   
    if(productstoptime>=0)
    {
        days = Math.floor(productstoptime/60/60/24);
        hours = Math.floor(productstoptime/60/60)%24;
        minutes = Math.floor(productstoptime/60)%60;
        seconds = Math.floor(productstoptime%60);
        if(days<10){ days="0"+days;}
        if(hours<10){ hours="0"+hours;}
        if(minutes<10){ minutes="0"+minutes;}
        if(seconds<10){ seconds="0"+seconds;}
        days="<span style='font-family: Verdana;font-weight: bold;font-size:16px;'>"+days+"</span>";
        hours="<span style='font-family: Verdana;font-weight: bold;font-size:18px;'>"+hours+"</span>";
        minutes="<span style='font-family: Verdana;font-weight: bold;font-size:20px;'>"+minutes+"</span>";
        seconds="<span style='font-family: Verdana;font-weight: bold;font-size:22px;'>"+seconds+"</span>";
        msg = days+"d &nbsp;"+hours+"h &nbsp;"+minutes+"m &nbsp;"+seconds+"s";
    }
    else if(tp)
    {
         msg = "<span style='color:#03689B;font-weight: bold;font-size:16px;'>正在计算中....</span>"; 
         $("#singletab_"+productid+"_confirm").removeAttr("onclick");
         $("#singletab_" + productid + "_confirm").click(function() { alert("竞拍已经结束！") });
         $("#multitab_" + productid + "_confirm").removeAttr("onclick");
         $("#multitab_" + productid + "_confirm").click(function() { alert("竞拍已经结束！") });    
    }
    
    //document.all["timerdiv_"+productid].innerHTML=msg;
    $("#timerdiv_"+productid).html(msg);
}
function showtimeinfo2(productid, productstoptime, tp, started) {
    if (productstoptime >= 0) {
        days = Math.floor(productstoptime / 60 / 60 / 24);
        hours = Math.floor(productstoptime / 60 / 60) % 24;
        minutes = Math.floor(productstoptime / 60) % 60;
        seconds = Math.floor(productstoptime % 60);
        if (days < 10) { days = "0" + days; }
        if (hours < 10) { hours = "0" + hours; }
        if (minutes < 10) { minutes = "0" + minutes; }
        if (seconds < 10) { seconds = "0" + seconds; }
        days = "<span style='font-family: Verdana;font-weight: bold;font-size:16px;'>" + days + "</span>";
        hours = "<span style='font-family: Verdana;font-weight: bold;font-size:18px;'>" + hours + "</span>";
        minutes = "<span style='font-family: Verdana;font-weight: bold;font-size:20px;'>" + minutes + "</span>";
        seconds = "<span style='font-family: Verdana;font-weight: bold;font-size:22px;'>" + seconds + "</span>";
        msg = days + "d &nbsp;" + hours + "h &nbsp;" + minutes + "m &nbsp;" + seconds + "s";
        if (started) {
            //$("#btnqgou_" + productid).attr("onclick", "document.location='UserBuying.aspx?id=" + productid + "'");
            $("#btnqgou_" + productid).unbind("click");
            $("#btnqgou_" + productid).click(function() { document.location = "UserBuying.aspx?id=" + productid; }); 
        } else {
            //$("#btnqgou_" + productid).attr("onclick", "alert('开抢时间: " + $("#startDate_" + productid).val() + "')");
            //$("#btnqgou_" + productid).removeAttr("onclick");
            $("#btnqgou_" + productid).unbind("click");
            $("#btnqgou_" + productid).click(function() { alert("开抢时间: " + $("#startDate_" + productid).val()) });          
        }
    }
    else if (tp) {
        msg = "<span style='color:#03689B;font-weight: bold;font-size:16px;'>抢购已结束</span>";

        //$("#btnqgou_" + productid).removeAttr("onclick");
        $("#btnqgou_" + productid).unbind("click");
        $("#btnqgou_" + productid).click(function() { alert("抢购已经结束！") });
    }

    //document.all["timerdiv_"+productid].innerHTML=msg;
    $("#timerdiv_" + productid).html(msg);
}
//闪烁文字
function blink(objId,iTime){
   var obj = document.getElementById(objId);
   var colors=new Array();
   colors[0]="#FF0000";
   colors[1]="#00FF00";
   colors[2]="#0000FF";
   colors[3]="#FF6600";
   colors[4]="#9933CC";
   colors[5]="#996600";
   colors[6]="#330066";
   colors[7]="#669933";
   
   var i = parseInt((colors.length-0+1) * Math.random() + 1)
   obj.style.color = colors[i];
   iTime++;
   if(iTime<20)
       setTimeout("blink('" + objId + "'," + iTime + ")", 50);
    else
        obj.style.color = "";
}

function showtime(productid,productstoptime)
{   
    if(productstoptime>=0)
    {
    days = Math.floor(productstoptime/60/60/24);
    hours = Math.floor(productstoptime/60/60)%24;
    minutes = Math.floor(productstoptime/60)%60;
    seconds = Math.floor(productstoptime%60);
    if(days<10){ days="0"+days;}
    if(hours<10){ hours="0"+hours;}
    if(minutes<10){ minutes="0"+minutes;}
    if(seconds<10){ seconds="0"+seconds;}
    days="<span style='font-family: Verdana;font-weight: bold;font-size:16px;'>"+days+"</span>";
    hours="<span style='font-family: Verdana;font-weight: bold;font-size:18px;'>"+hours+"</span>";
    minutes="<span style='font-family: Verdana;font-weight: bold;font-size:20px;'>"+minutes+"</span>";
    seconds="<span style='font-family: Verdana;font-weight: bold;font-size:22px;'>"+seconds+"</span>";
    msg = days+"d &nbsp;"+hours+"h &nbsp;"+minutes+"m &nbsp;"+seconds+"s";
    }
    else
    {
     msg = "<span style='color:#03689B;font-weight: bold;font-size:16px;'>正在计算中....</span>"; 
     $("#singletab_"+productid+"_confirm").removeAttr("onclick");
     $("#singletab_"+productid+"_confirm").click(function(){alert("竞拍已经结束！")});  
    }
    
    //document.all["timerdiv_"+productid].innerHTML=msg;
    $("#timerdiv_"+productid).html(msg);
}
function showtimeinfo1(productid,productstoptime)
{
    if(productstoptime>=0)
    {
    days = Math.floor(productstoptime/60/60/24);
    hours = Math.floor(productstoptime/60/60)%24;
    minutes = Math.floor(productstoptime/60)%60;
    seconds = Math.floor(productstoptime%60);
    if(days<10){ days="0"+days;}
    if(hours<10){ hours="0"+hours;}
    if(minutes<10){ minutes="0"+minutes;}
    if(seconds<10){ seconds="0"+seconds;}
    days="<span style='font-family: Verdana;font-weight: bold;font-size:11px;'>"+days+"</span>";
    hours="<span style='font-family: Verdana;font-weight: bold;font-size:12px;'>"+hours+"</span>";
    minutes="<span style='font-family: Verdana;font-weight: bold;font-size:14px;'>"+minutes+"</span>";
    seconds="<span style='font-family: Verdana;font-weight: bold;font-size:16px;'>"+seconds+"</span>";
    msg = days+"d &nbsp;"+hours+"h &nbsp;"+minutes+"m &nbsp;"+seconds+"s";
    }
    else
    {
     msg = "<span style='color:#03689B;font-weight: bold;font-size:12px;'>正在计算中....</span>"; 
	    
    }
    $("#timerdiv_"+productid).html(msg);
}
function showNumberInfo(productid)
{

    $.ajax({
		type: "get",
		url: "/RefeshProductNumber.aspx?rnd="+Math.random()+"&productid="+productid,
		beforeSend: function(XMLHttpRequest){   
			//ShowLoading();
		},
		success: function(data, textStatus){
		    var str= "<span style='font-family: Verdana;font-weight: bold;font-size:20px; float:left; padding-left:55px;'>"+data+"</span>";	
            $("#timerdiv_"+productid).html(str);
            
		    },
		    complete: function(XMLHttpRequest, textStatus){
			    //HideLoading();
		    },
		    error: function(){
			    //请求出错处理
		    }
    });
}

 function producttimeover122(id)
{
    $.ajax({
		type: "get",
		url: "/refeshProductOver.aspx?rnd="+Math.random()+"&productid="+id,
		beforeSend: function(XMLHttpRequest){   
			//ShowLoading();
		},
		success: function(data, textStatus){ 	
		    if(data=="")
	         {
	          timer_target=setInterval("producttimeover1("+id+")",3000);
	         }
	         else
	         {
                var dataarr=data.split("|");
                var str="<span style='color:#03689B;font-weight: bold;font-size:12px;'>竞拍结束！</span>";
                if (dataarr[1]!="")
                {
                   str="<span style='color:#03689B;font-size:11px;'>竞拍结束！<br>恭喜"+dataarr[1]+"获胜！</span>";//以"+dataarr[0]*0.01+"元
                   
                }
                $("#timerdiv_"+id).html(str);
              }
		    },
		    complete: function(XMLHttpRequest, textStatus){
			    //HideLoading();
		    },
		    error: function(){
			    //请求出错处理
		    }
    });
}
function showInterval(overtime){

    return calInterval(overtime);
     //var d = new Date(); 
     var arr=overtime.split(" ");   
     var arr1=arr[0].split("-");   
     var arr2=arr[1].split(":");
 
     var date=new Date(arr1[0],arr1[1]-1,arr1[2],arr2[0],arr2[1],arr2[2]);
     
     var result = getXmlHttpObject();
    result.open("POST", "getDate.aspx?rnd="+Math.random(), false);
    result.send();            
     var datenow=result.responseText
     var dd=datenow.split(",");
     var d = new Date(dd[0],dd[1]-1,dd[2],dd[3],dd[4],dd[5]); 
     var sjc = (date.getTime()-d.getTime())/1000;//Date.parse(overtime.replace('-', "/")
     return parseInt(sjc,10);
 }

function loadImage(url) {
    var img = new Image(); //创建一个Image对象，实现图片的预下载
    img.src = url;
}
function joinPK(id, deposit, dbname) {
    if (gUserId == 0) {
        alert("您还没有登陆，请先登陆。");
        return;
    }
    if (confirm("将预付"+deposit+dbname+"点宝，确定要加入此PK吗？")) {
        document.location = "JoinPK.aspx?id="+id;
    }
}
function safeOpenWindow(url) {
    var frm =document.getElementById("frmNewWindow");// document.frmNewWindow;
    frm.action = url;
    frm.submit();
}
function clickSupLogo(bid) {
    var t;

    t = t = calInterval($("#stoptime_" + bid).val());
    //赞助商链接
    if (t > 600) { //600秒即10分钟外转向赞助商链接
        supName = $("#suppliername_" + bid).val();
        supLogo = $("#supplierlogo_" + bid).val();
        supUrl = $("#supplierurl_" + bid).val();
        if (supName == "") {
            safeOpenWindow("/ApplySupplier.aspx");
        } else {
           safeOpenWindow(supUrl);
        }
    } else { //600秒以内         
        //如果有访问过此地址，不再打开新窗口，否则打开新窗口
        supName = $("#suppliername_" + bid).val();
        supLogo = $("#supplierlogo_" + bid).val();
        supUrl = $("#supplierurl_" + bid).val();

        $("#sup_" + bid).html("<div style='width:105px;text-align:left;line-height:20px; padding-top:15px;'><strong><a href='javascript:showStatPics1(" + bid + ");' class='GmLink' title='当前所有出价情况频谱图示分析'>走势分析</a></strong><div id='nicknamediv_" + bid + "'></div></div>");
        showTargetUsers();
    }
}

