//日期自动转换函数

function showlefttime(auctionDate)
{
   
    var _day = '天';
    var _hour = '小时';
    var _minute = '分钟'; 
    var ts=auctionDate;
    var dateLeft = 0;
    var hourLeft = 0;
    var minuteLeft = 0; 
    var Temp='';  
    if(ts < 0)
    {
        Temp="成交结束";   
    } 
    else 
    {       
       dateLeft =parseInt(ts/86400);//剩余多少天
       if( dateLeft > 0 )
           Temp = dateLeft + _day ;
       else
      {
          hourLeft = parseInt(ts/3600);        
          if( hourLeft > 0 )
              Temp = hourLeft + _hour ;
          else
          {
              minuteLeft = parseInt(ts/60);     
              if( minuteLeft > 0 )
                 Temp = minuteLeft + _minute ;
              else 
                 Temp = "成交结束";
          }
       }
    }  
	document.write(Temp);   
}
//图片自适应大小函数
var imageObject;
function ResizeImage(obj, MaxW, MaxH)
{  
    if (obj != null) imageObject = obj;
    var state=imageObject.readyState;
    if(state==undefined)
        state=imageObject.complete;
   
	if(state!='complete' && state==false) {
        setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",50);
		return;
    }
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH;
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0) {
        imageObject.width=dW;
		imageObject.height=dH;
	}
}
function checkSelect(ctlname)
{
  var checkIdObj = eval("infoform.infodelid");
  var flag = false;
    //判断对象是否为空
    if (!checkIdObj.length)
    {
      if(infoform.infodelid.checked)
      {
        infoform.submit();
      }
      else
      {
        alert("请选择要删除的条目！");
        return false;
      }
    }
    else
    {//如果check列表对象多于一个
      for (i=0; i<checkIdObj.length; i++)
      {
         if(checkIdObj[i].checked)
         {
          flag=true;
         }
       }
      if(flag)
      {
          infoform.submit();
      }
      else
      {
         alert("请选择要删除的条目！");
         return false;
      }
    }
}


//**********************
//功能---全选复选框
//使用---AdminUser
//**********************
function SelectAllCheckboxes(spanChk){
　var oItem = spanChk.children;
　var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
　xState=theBox.checked;
　elm=theBox.form.elements;
　for(i=0;i<elm.length;i++)
　if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
　{
　　if(elm[i].checked!=xState)
　　elm[i].click();
　}
}
function showHelp(id)
{ 
  var obj=document.getElementById(id);
  obj.style.display="";
  obj.style.left=event.x;
  obj.style.top=event.y;
  
  
}
function hidenHelp(id)
{
  var obj=document.getElementById(id);
  obj.style.display="none";
}

 function doCompare() {
    var form=document.forms['aspnetForm']
    var old_target=form.target;
    var old_action=form.action;
    var es = form.elements;			
    var n = 0;
    for (var i = 0; i < es.length; ++i) {
        var e = es[i];
        if (e.name == 'cb_id' && e.checked) { ++n; }
    }
    if (n > 0) {   
    form.action="../Auction/AuctionCompare.aspx";
    form.target="_blank";
    form.submit();  
    form.action=old_action;
    form.target=old_target;
   
  }
    else { 
      alert('请先选择您要比较的商品。');
      return false;
  }
}

 function doDelete() {
    var form=document.forms['aspnetForm']
    var es = form.elements;			
    var n = 0;
    for (var i = 0; i < es.length; ++i) {
        var e = es[i];
        if (e.name == 'cb_id' && e.checked) {
           e.value=e.id;
           ++n; 
        }
    }
    if (n > 0) {
    //form.submit();  
  }
    else { 
      alert('请先选择商品。'); 
      return false;
    }
}
 var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0 
 
function dyniframesize(iframename) {
  var pTar = null;
  if (document.getElementById){
    pTar = document.getElementById(iframename);
  }
  else{
    eval('pTar = ' + iframename + ';');
  }
  if (pTar && !window.opera){
    //begin resizing iframe
    pTar.style.display="block"
    
    if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
      //ns6 syntax
      pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; 
    }
    else if (pTar.Document && pTar.Document.body.scrollHeight){
      //ie5+ syntax
      pTar.height = pTar.Document.body.scrollHeight;
    }
  }
}
//检测输入字数是否有超出限制
function CheckInputCharNums(obj,limitNums)
{
   if(obj.value.length>limitNums)
   {
     alert('输入字数超出'+limitNums+"字限制!");
     return false;
   }
}


