function trim(str){
	return String(str).replace(/(^\s*)|(\s*$)/g, "");
}

function ltrim(str){  

 	return String(str).replace(/(^\s*)/g,"");
}

function rtrim(str){

 	return String(str).replace(/(\s*$)/g,"");
}

function UrlEncode(str)    
{    
    return transform(str);    
}    
   
function transform(s)    
{    
    var hex=''   
    var i,j,t    
   
    j=0    
    for (i=0; i<s.length; i++)    
    {    
        t = hexfromdec( s.charCodeAt(i) );    
        if (t=='25')    
        {    
            t='';    
        }    
        hex += '%' + t;    
    }    
    return hex;    
}    
   
function hexfromdec(num) {    
        if (num > 65535) { return ("err!") }    
        first = Math.round(num/4096 - .5);    
        temp1 = num - first * 4096;    
        second = Math.round(temp1/256 -.5);    
        temp2 = temp1 - second * 256;    
        third = Math.round(temp2/16 - .5);    
        fourth = temp2 - third * 16;    
        return (""+getletter(third)+getletter(fourth));    
}    
   
function getletter(num) {    
        if (num < 10) {    
                return num;    
        }    
        else {    
            if (num == 10) { return "A" }    
            if (num == 11) { return "B" }    
            if (num == 12) { return "C" }    
            if (num == 13) { return "D" }    
            if (num == 14) { return "E" }    
            if (num == 15) { return "F" }    
        }    
}   

function replaceStr(str){ 
    str = str.replace(/\&/g, "||");
    return str; 
}

function getLen(str) {
   var totallength=0;   
   for (var i=0;i<str.length;i++)
   {
    var intCode=str.charCodeAt(i);    
    if (intCode>=0&&intCode<=128) {
     totallength=totallength+1; //非中文单个字符长度加 1
    }
    else {
     totallength=totallength+2; //中文字符长度则加 2
    }
   } //end for  
 return totallength;
}