//搜索
function SearchSite()
{
  var searchtype=document.getElementsByName("searchtype");
  var Keyword=document.getElementById("Keyword").value;
  if (Keyword!='' && Keyword!='关键字')
  {
	 if (searchtype[1].checked)
	 {
		this.location="sell.html?key="+escape(Keyword);
	 }
	 else
	 {
		this.location="http://www.hengzhe.com/provide/g.html?q="+escape(Keyword);  
	 }
	 return true;
  }
  else
  {
	  alert('请输入关键字!');
	  document.getElementById("Keyword").focus();
	  return false;
  }
}

//设置客服号码---------------------------------------------
function setQQ()
{
	var topx=document.documentElement.scrollTop-window.screenTop+510;  //获取滚动条高度
	window.document.getElementById("Online").style.top=topx; //层的高度定位

}


//添加到收藏夹代码---------------------------------------------
function bookmarkit()
{
	var url=parent.document.location;
    window.external.addFavorite(url,parent.document.title);
}
			
//设为首页---------------------------------------------
function SetSite(ds)
{
	var url=parent.document.location;
    ds.setHomePage(url);
}

function checklen(obj){
	var lenE = obj.value.length;
	var lenC = 0;
	var CJK = obj.value.match(/[\u4E00-\u9FA5\uF900-\uFA2D]/g);
	if (CJK != null) lenC += CJK.length;
	tno.innerText = 200 - lenC - lenE ;
	if (tno.innerText < 0) {
	var tmp = 0
	var cut = obj.value.substring(0, obj.maxlength);
	for (var i=0; i<cut.length; i++){
	tmp += /[\u4E00-\u9FA5\uF900-\uFA2D]/.test(cut.charAt(i)) ? 2 : 1;
	if (tmp > obj.maxlength) break;
	}
	obj.value = cut.substring(0, i);
	}
}


//字符串截取函数
function getsubstr(s,l)
{
   if (s.length>l)
   {
	  s=s.substring(0,l)+'..';
   }
   return s;
}

//格式化日期
Date.prototype.toText2=function(){ 
var m; 
var d; 
if(this.getMonth()<9){ 
m="0"+(this.getMonth()+1); 
}else{ 
m=this.getMonth()+1; 
} 
if(this.getDate()<10){ 
d="0"+this.getDate(); 
}else{ 
d=this.getDate(); 
} 
//return this.getYear()+"-"+m+"-"+d; 
return m+"-"+d; 
} 

//格式化日期
Date.prototype.toText=function(){ 
var m; 
var d; 
if(this.getMonth()<9){ 
m="0"+(this.getMonth()+1); 
}else{ 
m=this.getMonth()+1; 
} 
if(this.getDate()<10){ 
d="0"+this.getDate(); 
}else{ 
d=this.getDate(); 
} 
return this.getYear()+"-"+m+"-"+d; 
//return m+"-"+d; 
} 

//JS按比例缩放图片
function SetSize(img, width, height) 
{ 

      		var vWidth=img.width;
      		var vHeight=img.height;
      		if(vWidth>vHeight){
      			img.width=100;
      			img.height=vHeight/vWidth*100;
      			img.style.marginTop=(100-img.height)/2;
      		}else if(vWidth<vHeight){
      			img.height=100;
      			img.width=vWidth/vHeight*100;
      			img.style.marginTop=0;
      		}else{
      			img.width=100;
      			img.height=100;
      			img.style.marginTop=0;
      		}
} 

