
/**
* 计算字符串的长度，一个汉字两个字符
*/
String.prototype.realLength = function()
{   
//  return this.replace(/[^\\x00-\\xff]/g,"**").length;
    var i;
    var num=0;
    for(i=0;i<this.length;i++){
        num++;
        if(this.charCodeAt(i)>255)num++;
    }
    return num;
}         
              
String.prototype.Chop = function(num){
        if(!num || num<0) num = 10;
    var s = this;
    while(s.realLength()>num){
        s=s.substring(0,s.length-1);
    }         
    return s;
} 
//弹出页面
function popup(weburl,w,h){
		window.open(weburl,w,"toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=no,scrollbars=no,width="+w+",height="+h+",left=100,top=10");
}

//弹出页面can be resized
function popup1(weburl,w,h){
        window.open(weburl,"mybox","toolbar=yes,location=yes,directories=yes,menubar=yes,resizable=yes,status=yes,scrollbars=no,width="+w+",height="+h+",left=100,top=10")
}

//去掉字串左边的空格 
function lTrim(str) { 
        if (str.charAt(0) == " ") { 
                //如果字串左边第一个字符为空格
                str = str.slice(1);//将空格从字串中去掉 
                //这一句也可改成 str = str.substring(1, str.length); 
                str = lTrim(str); //递归调用 
        } 
        return str; 
}

//去掉字串右边的空格 
function rTrim(str) { 
        var iLength; 

        iLength = str.length; 
        if (str.charAt(iLength - 1) == " ") { 
                //如果字串右边第一个字符为空格 
                str = str.slice(0, iLength - 1);//将空格从字串中去掉 
                //这一句也可改成 str = str.substring(0, iLength - 1); 
                str = rTrim(str); //递归调用 
        } 
        return str; 
} 

//去掉字串两边的空格 
function trim(str) { 
        return lTrim(rTrim(str)); 
} 


function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}

