function jsTrim(value){
  return value.replace(/(^\s*)|(\s*$)/g,"");
}

function isNULL( chars ) {
	if (chars == null)
		return true;
	if (jsTrim(chars).length==0)
		return true;
	return false;
}

function isValidDecimal( chars ) {
	chars += '';
	var re=/^[\d\.]+$/;
	if (chars.match(re) == null)
		return false;
	else
		return true;
}

function isNumber( chars ) {
	chars += '';
	var re=/^\d+$/;
	if (chars.match(re) == null)
		return false;
	else
		return true;
}

function tkDrawImage(ImgD,FitWidth,FitHeight){
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		if(image.width/image.height>= FitWidth/FitHeight){
			if(image.width>FitWidth){
				ImgD.width=FitWidth;
				ImgD.height=(image.height*FitWidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		} else{
			if(image.height>FitHeight){
				ImgD.height=FitHeight;
				ImgD.width=(image.width*FitHeight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
	}
} 

function showWW(turl,tname)
{
	//document.write('<a href="'+turl+'" target="_blank"><img src="http://amos1.taobao.com/online.ww?v=2&uid='+encodeURIComponent(tname)+'&s=1" border="0" width="77" align="absmiddle" alt="点击与'+tname+'淘宝旺旺即时对话" /></a>');
}
function tj(w,u){try{var s='http://www.hi5360.com/s1/g/?w='+w;if(u)s+='&u='+u;(new Image).src=s;}catch(e1){}}

function bytes(str)
{
    if(typeof(str)!='string'){
		str = str.value;
	}
	var len = 0;
	for(var i = 0; i < str.length; i++){
		if(str.charCodeAt(i) > 127){
			len++;
		}
		len++;
	}
	return len;
}