/*截取字符串*/
function subString(str, len, hasDot)
{
    var newLength = 0;
    var newStr = "";
    var chineseRegex = /[^\x00-\xff]/g;
    var singleChar = "";
    var strLength = str.replace(chineseRegex,"**").length;
    for(var i = 0;i < strLength;i++)
    {
        singleChar = str.charAt(i).toString();
        if(singleChar.match(chineseRegex) != null)
        {
            newLength += 2;
        }    
        else
        {
            newLength++;
        }
        if(newLength > len)
        {
            break;
        }
        newStr += singleChar;
    }
      
    if(hasDot && strLength > len)
    {
        newStr += "...";
    }
    return newStr;
} 
function NoHTML(str) {
	str = str.replace(/<[^>]+>/g,"");//去掉所有的html标记
	str = str.replace(/<\/?[^>]*>/g,''); //去除HTML tag
	str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
	//str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
	str=str.replace(/&nbsp;/ig,'');//去掉&nbsp;
	return str;
}
/*获取图片路径*/
function GetImgUrl(_imgUrl){	
	var	str = _imgUrl;
	var arr= new Array();
	arr = str.toString().split(";");
	var  image=arr[0];
	var s3 = image.substr(0, 2);
	if(s3=="P0"){
		var httphead = "/protect/";
		var s1 = image.substr(0, 8);
		var s2 = image.substr(0,10);
		httphead+=s1+"/"+s2+"/"+image;
		_imgUrl=httphead;
	}else if(s3 == "W0"){
		var httphead = "/webpic/";
		var s1 = image.substr(0, 8);
		var s2 = image.substr(0,10);
		httphead+=s1+"/"+s2+"/"+image;
		_imgUrl = httphead;
	}else {
	 _imgUrl = _imgUrl;
	}
	return _imgUrl;
}		
//取图片进行地址转换，主要为了兼容历史数据
function formatImgUrl(_imgUrl){
	formatImgUrl(_imgUrl,"347","249");
}
function formatImgUrl(_imgUrl,_width,_height,_imgTitle){	
	if(_width==null || _width==""){ _width=347};
	if(_height==null || _height==""){ _height=249};
	var	str = _imgUrl;
	var arr= new Array();
	arr = str.toString().split(";");
	var  image=arr[0];
	var s3 = image.substr(0, 2);
	if(s3=="P0"){
		var httphead = "/protect/";
		var s1 = image.substr(0, 8);
		var s2 = image.substr(0,10);
		httphead+=s1+"/"+s2+"/"+image;
		document.write('<img src="'+httphead+'" height="'+_height+'" width="'+_width+'" alt="'+_imgTitle+'" />');
	}else if(s3 == "W0"){
		var httphead = "/webpic/";
		var s1 = image.substr(0, 8);
		var s2 = image.substr(0,10);
		httphead+=s1+"/"+s2+"/"+image;
		document.write('<img src="'+httphead+'" height="'+_height+'" width="'+_width+'" alt="'+_imgTitle+'" />');
	}else {
		document.write('<img src="'+_imgUrl+'" height="'+_height+'" width="'+_width+'" alt="'+_imgTitle+'" />');
	}	
}