    //切换控件的可视状态
    function setVisibleChange(sControlName) {
        tblList = document.getElementById(sControlName);
        if ('' == tblList.style.display) {
            tblList.style.display = 'none';
        } else {
            tblList.style.display = '';
        }
    }

    //切换check的选中状态（当是多个控件时，如果有一个当前为选中状态，则将所有状态置为‘非选中’）
    function setCheckedChange(sCheckName) {
        var oCheck;

        oCheck = document.all[sCheckName];
        if (oCheck == '[object]') {
            if(!oCheck.length){
                //单个控件时直接反转其选中状态即可
                oCheck.checked = !oCheck.checked;
                return;
            }
            else{   
                //多控件时，如果有一个当前为选中状态，则将所有状态置为‘非选中’
                for (i=0; i<oCheck.length; i++) {
                    //当有一个控件为选中时，则将所有CHECKBOX设为非选中状态
                    if (oCheck[i].checked) {
                        clearAllChecked(sCheckName);
                        return;
                    }
                }
                //多控件时，所有checkbox均为非选中时，设置为选中
                selectAllChecked(sCheckName);
                return;
            }
        }
    }

    //取消checkbox的选中状态
    function clearAllChecked(sCheckName){
        var oCheck;

        oCheck = document.all[sCheckName];
        if (oCheck != '[object]') {
            return;
        }
        if(!oCheck.length){
            oCheck.checked = false;
        }
        else{    
            for (i=0; i<oCheck.length; i++) {
                oCheck[i].checked = false;
            }
        }
    }

    //设置checkbox为选中状态
    function selectAllChecked(sCheckName){
        var oCheck;

        oCheck = document.all[sCheckName];
        if (oCheck != '[object]') {
            return;
        }
        if(!oCheck.length){
            oCheck.checked = true;
        }
        else{    
            for (i=0; i<oCheck.length; i++) {
                oCheck[i].checked = true;
            }
        }
    }

    //取Checkbox控件的值,多个同名控件以','分割
    function getValuesWithComma(sControlName) {
        var oControl;
        var sRtn;
        
        sRtn = "";
        oControl = document.all[sControlName];
        if (oControl == '[object]') {
            if(!oControl.length){
                //单个控件时
                if (oControl.checked) {
                    sRtn = oControl.value;
                }
            }
            else{
                //多个同名控件时
                for (i=0; i<oControl.length; i++) {
                    //当有控件选中时，取出该控件的值
                    if (oControl[i].checked) {
                        sRtn += oControl[i].value + ',';
                    }
                }
                sRtn = sRtn.substr(0, sRtn.length - 1);
            }
        }
        return sRtn;
    }
    
    //定时滚动使用的句柄
    var iHandleInterval;

    /*
    功能：    设置自动滚动
    参数：    sType:滚动类型（upstart向上滚动;downstart向下滚动;leftstart:向左滚动;rightstart向右滚动;）；
            sDivName:Div名称；
            nRecordSpace:记录间隔；
            nInterval:定时滚动的间隔执行时间（缺省为80毫秒）；
            nScrollStep:每次滚动距离（缺省为1px）；
    备注：   左右自动滚动需要设置第一个HTML对象的排列方式为左对齐，比如左右滚动的TABLE需要设置align=left
    返回值： 无
    */
    function setAutoScroll(sType, sDivName, nRecordSpace, nInterval, nScrollStep) {
        sScrollType = sType;
        var divList = document.getElementById(sDivName);

        if(null == divList || 'undefined' == typeof(divList)){
            return;
        }
        if (('undefined' == typeof(divList))) {
            return;
        }
        if (('undefined' == typeof(nInterval))) {
            nInterval = 80
        }
        if (('undefined' == typeof(nScrollStep))) {
            nScrollStep = 1
        }
        
        //设置鼠标移入DIV和移出DIV时触发的事件
        divList.onmouseover=function() {clearInterval(iHandleInterval);} 
        divList.onmouseout=function() {iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ", true, " + nRecordSpace + ")", nInterval);} 

        //自动滚动需要增加后续的滚动内容
        divList.innerHTML = divList.innerHTML + divList.innerHTML;
         
        //向右和向下滚动需要设置滚动的初始位置
        switch (sType) {
            case "leftstart":    
                break;
            case "upstart":    
                break;
            case "rightstart":
                divList.scrollLeft = nRecordSpace;
                break;
            case "downstart":
                divList.scrollTop = nRecordSpace;
                break;
            default:
                clearInterval(iHandleInterval);
                return;
                break;
        }
        iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ", true, " + nRecordSpace + ")", nInterval);
    }

    /*
    功能：    设置滚动开始或结束
    参数：    sType:滚动类型（upstart:向上滚动开始;upend:向上滚动结束;downstart:向下滚动开始;downend:向下滚动结束）；
            sDivName:Div名称；
            nInterval:定时滚动的间隔执行实际（缺省为30毫秒）；
            nScrollStep:每次滚动距离（缺省为1）；
    返回值： 无
    */
    function setScroll(sType, sDivName, nInterval, nScrollStep) {
        sScrollType = sType;
        var divList = document.getElementById(sDivName);
        if (('undefined' == typeof(divList))) {
            return;
        }
        if (('undefined' == typeof(nInterval))) {
            nInterval = 30
        }
        if (('undefined' == typeof(nScrollStep))) {
            nScrollStep = 1
        }
        switch (sType) {
            case "leftstart":    
                iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
                break;
            case "upstart":    
                iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
                break;
            case "upend":
                clearInterval(iHandleInterval);
                break;
            case "rightstart":
                iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
                break;
            case "downstart":
                iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
                break;
            case "downend":
                clearInterval(iHandleInterval);
                break;
            case "end":
                clearInterval(iHandleInterval);
                break;
            default:
                clearInterval(iHandleInterval);
                break;
        }
    }

    //滚动开始或结束（定时器）
    function scrollTimer(sDivName, nScrollStep, bAuto, nRecordSpace) {
        if (('undefined' == typeof(bAuto))) {
            bAuto = false;
        }
        var divList = document.getElementById(sDivName);
        if(null!=divList){
            if (!('undefined' == typeof(divList))) {
                switch (sScrollType) {
                    case "leftstart":
                        //向左滚动
                        if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollLeft >= nRecordSpace) {
                                divList.scrollLeft = 0;
                            } else {
                                divList.scrollLeft = divList.scrollLeft + nScrollStep;
                            }
                        } else {
                            divList.scrollLeft = divList.scrollLeft - nScrollStep;
                        }
                        break;
                    case "upstart":
                        //向上滚动
                        if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollTop >= nRecordSpace) {
                                divList.scrollTop = 0;
                            } else {
                                divList.scrollTop = divList.scrollTop + nScrollStep;
                            }
                        } else {
                            divList.scrollTop = divList.scrollTop - nScrollStep;
                        }
                        break;
                    case "upend":
                        break;
                    case "rightstart":
                        //向右滚动
                        if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollLeft <= 0) {
                                divList.scrollLeft = nRecordSpace;
                            } else {
                                divList.scrollLeft = divList.scrollLeft - nScrollStep;
                            }
                        } else {
                            divList.scrollLeft = parseInt(divList.scrollLeft) + nScrollStep;
                        }
                        break;
                    case "downstart":
                        //向下滚动
                        if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollTop <= 0) {
                                divList.scrollTop = nRecordSpace;
                            } else {
                                divList.scrollTop = divList.scrollTop - nScrollStep;
                            }
                        } else {
                            divList.scrollTop = parseInt(divList.scrollTop) + nScrollStep;
                        }
                        break;
                    case "downend":
                        break;
                    case "end":
                        break;
                    default:
                        break;
                }
            }
        }
    }


    function AllTrim(str) {
        if(str == null || str == "") {
            return "";
        }
         
        lIdx = 0;
        rIdx = str.length;
        if (AllTrim.arguments.length == 2) {
            act = AllTrim.arguments[1].toLowerCase();
        } else {
            act = "all";
        }
        for(var i=0; i<str.length; i++){
            thelStr = str.substring(lIdx, lIdx + 1);
            therStr = str.substring(rIdx, rIdx - 1);
            if ((act=="all" || act=="left") && thelStr==" "){
                lIdx++;
            }
            if ((act=="all" || act=="right") && therStr==" "){
                rIdx--;
            }
        }
        str = str.slice(lIdx,rIdx);
        return str;
    }

    //字符串超长，截断后尾部加省略号
    /*
    功能：    字符串超长，截断后尾部加省略号
    参数：    sStr: 要处理的字符串；
            nLen: 截取的长度；
            sTail: 截取后在返回字符串后面加省略号
    返回值： 截取的字符串
    */
    function cutString(sStr, nLen, sTail){
        var value;
        var sChar;
        
        //未指定参数，则设置其缺省值
        if (('undefined' == typeof(nLen)) ) {
            nLen = 0;
        }
        if (('undefined' == typeof(sTail)) ) {
            sTail = " ...";
        }
        
        sRtn = "";
        n = 0;
        for(var i=0;i<sStr.length;i++) {
            sChar = sStr.charAt(i);
            value = String(escape(String(sChar))) ; 
            if(value.length>3) {
                //一个汉字做为两个字符长度处理
                n += 2 ; 
            } else { 
                n += 1 ; 
            }
            sRtn += sChar;
            if ((n + sTail.length >= nLen) && (i != sStr.length-1)) {
                //字符串的长度超过了给定长度
                return sRtn + sTail;
            }
        } 
        return sRtn;
    }
    
    //取字符串长度
    function getStrLen(sStr) { 
        var nLen = 0; 

        for(var i=0;i<sStr.length;i++) {
            var value = String(escape(String(sStr.charAt(i)))) ; 
            if(value.length>3) {
                nLen += 2 ; 
            } else { 
                nLen += 1 ; 
            } 
        } 
        return nLen ; 
    }

    function ShowTitle(objCut, strName){
        var objTitle = document.getElementById(strName);
        if ((objCut.offsetWidth-15)<objTitle.offsetWidth){
            objCut.title = objTitle.innerText;
        }else{
            objCut.title = '';
        }
    }

    /*功能，多选项设置全选，不选，反选功能
      参数:obj,strAct
      strAct:
        select:全选
        clear:全 不选
        reverse:反选
     返回值：用,分割的obj对应值的字符串
      使用例子：
        ResetCheckBox(document.delSoho.id,'select')
    */

    function ResetCheckBox(obj, strAct){
        var values = '';
        if(obj.length > 0) {  //checkbox is array
            //set status one by one
            var eval_str = '';
            switch (strAct){
                case 'select':
                    eval_str = ' if(obj[i].disabled==false){ obj[i].checked = true; } ';
                    break;
                case 'clear':
                    eval_str = ' if(obj[i].disabled==false){ obj[i].checked = false; } ';
                    break;
                case 'reverse':
                    eval_str = ' if(obj[i].disabled==false){ if(obj[i].checked==true){ obj[i].checked = false; }else{ obj[i].checked = true;} } ';
                    break;
            }
            if (eval_str!=''){ eval('for(var i=0; i<obj.length; i++){'+eval_str+'}'); }
            //get values
            var array_id =new Array();
            var j = 0;
            for(var i=0; i<obj.length; i++) {
                if(obj[i].checked) {
                    array_id[j] = obj[i].value;
                    j++;
                }
            }
            values = array_id.join(',');
        }else if(obj.disabled==false) {  //checkbox is a single element
            switch (strAct){
                case 'select':
                    obj.checked = true;
                    break;
                case 'clear':
                    obj.checked = false;
                    break;
                case 'reverse':
                    if(obj.checked==true){ obj.checked = false; }else{ obj.checked = true; }
                    break;
            }
            if (obj.checked==true){
                values = obj.value;
            }else{
                values = '';
            }
        }
        return values;
    }
    /*
    功能: 获取ID的值，并且用各个ID用相应的字符隔开
    参数：ID对象
    */
    function getIdValueStr(obj){
        var values = '';
        if(obj.length>0){
            var array_id =new Array();
            var j = 0;
            for(var i=0; i<obj.length; i++) {
                if(obj[i].checked) {
                    array_id[j] = obj[i].value;
                    j++;
                }
            }
            values = array_id.join(',');
        }else if(obj.disabled==false) {  //checkbox is a single element
            if (obj.checked==true){
                values = obj.value;
            }else{
                values = '';
            }
        }
        return values;
    }

//以下函数从原有系统中的utils.js中拷贝而来-------------------------------------------------------
    //检查输入的数据类型
    
    function checkPositiveInteger(pint1)
    {
        pint1 += ""
        return checkInteger(pint1) && pint1.indexOf('-')==-1
    }

    function checkInteger(int1) 
    {
        int1 += ""
        return checkFloat(int1+"") && Math.floor(int1)==int1 && int1.indexOf(".")==-1
    }

    // These function will check number format, 
    // note it will exclude numbers in special format ,
    // for example: 4.5E6
    function checkFloat(float1) 
    {
        regExp1  = /[^-?\d\.]/
        regExp2 = /^-?\.\d*$/
        regExp3 = /^-?\d*\.$/
        if(isNaN(float1) ||
            regExp1.exec(float1) ||
            regExp2.exec(float1) ||
            regExp3.exec(float1))
            return false
        return true
        
    }
//----------------------------------------------------------------------------------------------



var boolAutoCloseImageWindow = false;

function getImageObject(url){
    var objimg = new Image();
    objimg.src = url;
    return objimg;
}

function doPopupImage(imageURL,imageTitle,strWindowProperties){
    if (strWindowProperties!=''){
        imgWin = window.open('about:blank', '', strWindowProperties);
    }
    var strAutoClose = '';
    with (imgWin.document){
        writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
        writeln('<sc'+'ript>');
        writeln('var isNN,isIE;');
        writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');
        writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){');
        writeln('var w,h;');
        writeln('w=document.PopImage.width;');
        writeln('h=document.PopImage.height;');
        writeln('if (isIE){');
        writeln('    if(w>(screen.width-25)){ w=screen.width-25; }');
        writeln('    if(h>(screen.height-75)){ h=screen.height-75; }');
        writeln('    window.resizeTo(100,100);');
        writeln('    width=100-(document.body.clientWidth-w);');
        writeln('    height=100-(document.body.clientHeight-h);');
        writeln('    window.resizeTo(width,height);');
        writeln('}');
        writeln('if (isNN){');       
        writeln('    if(w>(screen.width-6)){');
        writeln('        if (h>(screen.height-56)){');
        writeln('            w=screen.width-6;');
        writeln('            h=screen.height-56;');
        writeln('        }else {');
        writeln('            h=h+15;');
        writeln('            w=screen.width-6;');
        writeln('        }');
        writeln('    }else {');
        writeln('        if (h>(screen.height-56)){');
        writeln('            h=screen.height-56;');
        writeln('            w=w+15;');
        writeln('        }');
        writeln('    }');
        writeln('    window.innerWidth=w;');
        writeln('    window.innerHeight=h;');
        writeln('}');
        writeln('}');
        writeln('function doTitle(){document.title="'+imageTitle+'";}');
        writeln('</sc'+'ript>');
        if (boolAutoCloseImageWindow){ strAutoClose = ' onblur="self.close()"'; }
        writeln('</head><body bgcolor="#000000" onload="reSizeToImage();doTitle();self.focus()"'+strAutoClose+'>');
        writeln('<sc'+'ript> ');
        writeln('    function Click(){ ');
        writeln('    alert("欢迎访问 www.topsjs.com ");'); 
        writeln('    window.event.returnValue=false;'); 
        writeln('    } ');
        writeln('    document.oncontextmenu=Click; ');
        writeln('    </sc'+'ript>');
        writeln('<img id="PopImage" name="PopImage" src='+imageURL+' style="display:block"></body></html>');
        close();  
    }
}

function PopupImage(imageURL,imageTitle,strWindowProperties){
    if (strWindowProperties!=''){
        imgWin = window.open('about:blank', '', strWindowProperties);
    }
    var strAutoClose = '';
    with (imgWin.document){
        writeln('<html><head><title>'+imageTitle+'</title><style>body{margin:0px;}</style>');
        writeln('</head><body bgcolor="#000000" self.focus()"'+strAutoClose+'>');
        writeln('<sc'+'ript> ');
        writeln('    function Click(){ ');
        writeln('    alert("欢迎访问 www.topsjs.com ");'); 
        writeln('    window.event.returnValue=false;'); 
        writeln('    } ');
        writeln('    document.oncontextmenu=Click; ');
        writeln('    </sc'+'ript>');
        writeln('<img id="PopImage" name="PopImage" src='+imageURL+' style="display:block"></body></html>');
        close();  
    }
}


function popImage(strUrl,imgTitle){
    var isNN,isIE;
    if (parseInt(navigator.appVersion.charAt(0))>=4){
       isNN=(navigator.appName=="Netscape")?1:0;
       isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
    }
    if(strUrl.length==0){ return; }
    var strWindowProperties = '';
    var strScrollBars = ',scrollbars=no';
    var oimg = getImageObject(strUrl);
    if (oimg.width > (screen.width-6) || oimg.height>(screen.height-56)){
        strScrollBars = ',scrollbars=yes';
    }
    if (isNN){ strWindowProperties = 'width='+(screen.width-6)+',height='+(screen.height-56)+',left=0,top=0'+strScrollBars; }
    if (isIE){ strWindowProperties = 'width=1,height=1,left=0,top=0'+strScrollBars; }
    doPopupImage(strUrl, '国际服装设计网 -- 图片浏览 -- '+imgTitle, strWindowProperties);
}

//弹出的窗口中显示的图片有白色边框（浏览器默认的边框）
function popImage2(sUrl){
    var nMaxWidth = screen.width - 6;
    var nMaxHeight = screen.height - 56;
    var objTmpImage = getImageObject(sUrl);
    var nWidth = objTmpImage.width + 20;
    var nHeight = objTmpImage.height + 30;
    var strScrollBars = ',scrollbars=no';
    if(nWidth > nMaxWidth){
        nWidth = nMaxWidth;
        strScrollBars = ',scrollbars=yes';
    }
    if(nHeight > nMaxHeight){
        nHeight = nMaxHeight;
        strScrollBars = ',scrollbars=yes';
    }

    var strWindowProperties = 'width='+nWidth+',height='+nHeight+',left=0,top=0'+strScrollBars;
    imgWin = window.open(sUrl, '', strWindowProperties);
    imgWin.focus();
}
/*
功能：    按图片的原始比例缩小图片的显示尺寸
参数：    第一个：图片对象
        第二个：图片宽度
        第三个：图片高度
返回值： 无
*/
function resizeImg(){
    var aArg = resizeImg.arguments;  
    var nArg = aArg.length;
    if (nArg == 0){ return; }
    
    var objImage = aArg[0];
    var objTmpImage = getImageObject(objImage.src);
    var nOldWidth = objTmpImage.width;
    var nOldHeight = objTmpImage.height;
    if(nOldWidth == 0 || nOldHeight == 0){ return; }

    if(nArg > 1){
        nNewWidth = parseInt(aArg[1]);
    }else{
        nNewWidth = objImage.width;
    }
    if(nArg > 2){
        nNewHeight = parseInt(aArg[2]);
    }else{
        nNewHeight = objImage.height;
    }
    var nTmpWidth = nOldWidth * nNewHeight / nOldHeight;
    var nTmpHeight = nOldHeight * nNewWidth / nOldWidth;

    if(nNewWidth == 0){
        nNewWidth = nTmpWidth;
    }
    if(nNewHeight == 0){
        nNewHeight = nTmpHeight;
    }
    if(nOldWidth > nNewWidth){
        if(nOldHeight > nNewHeight){
            if ((nOldWidth / nOldHeight) > (nNewWidth / nNewHeight)){
                nNewHeight = nTmpHeight;
            }else{
                nNewWidth = nTmpWidth;
            }
        }else{
            nNewHeight = nTmpHeight;
        }
    }else{
        if(nOldHeight > nNewHeight){
            nNewWidth = nTmpWidth;
        }else{
            if(nArg >3){
                var enlarge = aArg[3];
            }else{
                var enlarge = false;
            }
            if(enlarge){
                if((nOldWidth / nOldHeight) > (nNewWidth / nNewHeight)){
                    nNewHeight = nTmpHeight;
                }else{
                    nNewWidth = nTmpWidth;
                }
            }else{
                nNewWidth = nOldWidth;
                nNewHeight = nOldHeight;
            }
        }
    }
    objImage.width = Math.round(nNewWidth);
    objImage.height = Math.round(nNewHeight);
}

//alt 显示图片的文件大小和原始尺寸信息
function getImgInfo(strURL){
    var objTmpImage = getImageObject(strURL);
    var nOldWidth = objTmpImage.width;
    var nOldHeight = objTmpImage.height;
    var nOldSize = objTmpImage.fileSize;
    if(nOldSize>0){
        var sImgBytes = FormatNumber(Math.ceil(nOldSize), 0, 0, 0, -1) + ' 字节';
    }else {
        var sImgBytes = '（未知）';
    }
    var sRtn = '文件大小：' + sImgBytes + '\n实际尺寸：' + nOldWidth + '×' + nOldHeight + ' 像素';
    return sRtn;
}

//    
//    参数 : emails  ,可以使 email 串 ,或者是 text 控件
//           nLimitEmailNum 限制 email 数量 -1,缺省 代表 不限制
//                
function checkEmail(emails,nLimitEmailNum){
    var sEmails = "";
    var sEmail = "";
    var nCount = 0;
    var array_id =new Array();
    
    //    判断 emails 参数是否合法
    if ('undefined' == typeof(emails)) {
        alert("email 检测函数的参数没有定义!");
        return -1;
    }
    //  判断 nLimitEmailNum 值
    //    没定义或者小于0 则 nLimitEmailNum = -1;
    //    其他不变
    if ('undefined' == typeof(nLimitEmailNum)) {
        nLimitEmailNum = -1;
    }

    //判断 emails 是对象还是字符串
    if("string"==typeof(emails)){
        sEmails = emails;
    }else if("object"==typeof(emails)){
        sEmails = emails.value;
    }
    
    aEmails = sEmails.split(",");
    nCount = aEmails.length;
    if(-1 != nLimitEmailNum && nCount > nLimitEmailNum){
        alert("你设置的 email 数量超过了 " + nLimitEmailNum + " 个!");
        return -1;
    }
    for(var i =0 ; i < nCount ; i++){
        sEmail = aEmails[i];
        if(!isEmail(sEmail)){
            var sMsg = "";
            if(""==sEmail){
                sMsg = "严格的要求使用1个 ',' 分隔 Email!";
                sMsg = sMsg + "\n";
                sMsg = sMsg + "前后没有 Email 请不要使用 ',' ";
            }else{
                sMsg = "< " + sEmail + " > ";
                sMsg = sMsg + "\n";
                sMsg = sMsg + "不是合法的 Emial 格式!";
            }
            alert(sMsg);
            return -1;
        }
    }
    return nCount;
}

function isEmail(regexpValue){
    if ('undefined' == typeof(regexpValue)) {
        return false;
    }
    var email_regexp=/^[^\s].*@(\w*\-*\w*)+\.\w+/;
    var get_data = regexpValue;
    var result=get_data.match(email_regexp);
    if(result!=null){
        if(!get_data.match(/.*@.*@.*/))
            return true;
        return false;
    }
    return false;
}

    //从本机导入EMAIL（需要定义非IE浏览器的接口函数：setEmailList(sMail)，其中sMail为选中的MAIL地址）
    //ie浏览器直接返回选中的MAIL地址
    function importMail() { 
        var sUrl = "/php/common/com_import_mail_load.php";
        if (isIE) {
            //IE时用模态框的方式打开
            var sParam = "";
            var sProperty = "dialogWidth:608px; dialogHeight:320px";
            var oRet = window.showModalDialog(sUrl, sParam, sProperty);
            if(null != oRet && "string" == typeof(oRet)) {
                sRtn = oRet;
            } else {
                sRtn = "";
            }
        } else {
            var sWinName = "importMail";
            var sProperty = "toolbar=no,location=no,width=608px,height=320px,scrollbars=no";
            var oWin = window.open(sUrl, sWinName, sProperty);
            if (!oWin.opener ) {
                oWin.opener = window ;
            }
            oWin.focus();
            sRtn = "";
        }
        return sRtn;
    }
    
    //导入一级好友
    //需要在窗口中定义接口函数：setFriendList(sFriend)，其中sFriend为选中的好友名称）
    function importFriend() { 
        var sUrl = "/php/common/com_import_friend.php";
        /*if (isIE) {
            var sParam = "";
            var sProperty = "dialogWidth:608px; dialogHeight:470px";
            var oRet = window.showModalDialog(sUrl, sParam, sProperty);
            if(null != oRet && "string" == typeof(oRet)) {
                sRtn = oRet;
            } else {
                sRtn = "";
            }
        } else {//*/
            var sWinName = "importFriend";
            var sProperty = "toolbar=no,location=no,width=608px,height=600px,scrollbars=yes";
            var oWin = window.open(sUrl, sWinName, sProperty);
            if (!oWin.opener ) {
                oWin.opener = window ;
            }
            oWin.focus();
            sRtn = "";
        //}
        return sRtn;
    }
    /*
    function resizeImg(sControlName, nWidth, nHeight, bLessThanResize) {
        var nNewWidth
        var nNewHeight

        //高度和宽度均未指定，则不做处理
        if (('undefined' == typeof(nWidth) && 'undefined' == typeof(nHeight))) {
            return;
        }
        
        //判断 sControlName 是对象还是字符串
        if("string"==typeof(sControlName)){
            imgResize = document.getElementById(sControlName);
        }else if("object"==typeof(sControlName)){
            imgResize = sControlName;
        }
        //未取到对象则退出
        if ('undefined' == typeof(imgResize)) {
            return;
        }
        
        //缺省在原图小于指定宽度时不做处理
        if ('undefined' == typeof(bLessThanResize)) {
            bLessThanResize = false;
        }

        //取原始宽度和高度
        nOldWidth = imgResize.width;
        nOldHeight = imgResize.height;
        if (0 == nOldWidth || 0 == nOldHeight) {
            return;
        }
        if(nWidth == "" || nWidth == 0 || nHeight == "" || nHeight == 0){
             nNewWidth = nWidth;
            nNewHeight = nHeight;
            if ('undefined' == typeof(nHeight) || 0 == nHeight) {
                //未指定高度
                if (!bLessThanResize && nOldWidth < nNewWidth) {
                    //如果现有图像宽度小于当前图像宽度，且未指定该种情形下强制转换，则不做处理直接退出
                    return;
                }
                //如果未指定高度，则按给定的宽度和原有尺寸的比例计算新高度的值
                nNewHeight = nOldHeight * (nWidth / nOldWidth);
            } else if ('undefined' == typeof(nWidth) || 0 == nWidth) {
                //未指定宽度
                if (!bLessThanResize && nOldHeight < nNewHeight) {
                    //如果现有图像高度小于当前图像高度，且未指定该种情形下强制转换，则不做处理直接退出
                    return;
                }
                //如果未指定宽度，则按给定的高度和原有尺寸的比例计算新宽度的值
                nNewWidth = nOldWidth * (nHeight / nOldHeight);
            }
        }else{
            nNewWidth = 0;
            nNewHeight = 0;
            //原图宽高 比例
            oldRatio = nOldWidth/nOldHeight;
            //用户指定 宽高比例
            newRatio = nWidth/nHeight;
            
            if(oldRatio < newRatio){
            // 以原图 高度 为基础 进行 压缩
                if(!bLessThanResize && nOldHeight <= nHeight){
                    // 原图高度小于指定高度，且当前 不指定 强行放大
                    nNewHeight = nOldHeight;
                    nNewWidth = nNewHeight * oldRatio;
                }else{
                    nNewHeight = nHeight;
                    nNewWidth = nNewHeight * oldRatio;
                }
            }else{
            // 以原图 宽度 为基础 进行 压缩
                if(!bLessThanResize && nOldWidth <= nWidth){
                    // 原图高度小于指定宽度，且当前 不指定 强行放大
                    nNewWidth = nOldWidth;
                    nNewHeight = nNewWidth / oldRatio;
                }else{
                    nNewWidth = nWidth;
                    nNewHeight = nNewWidth / oldRatio;
                }
            }
        }
        imgResize.width = nNewWidth;
        imgResize.height = nNewHeight;
    }
*/

/* the following function copied from:
   http://www.4guysfromrolla.com/webtech/code/FormatNumber.shtml
*/
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
    IN:
        NUM - the number to format
        decimalNum - the number of decimal places to format the number to
        bolLeadingZero - true / false - display a leading zero for
                                        numbers between -1 and 1
        bolParens - true / false - use parenthesis around negative numbers
        bolCommas - put commas as number separators.
 
    RETVAL:
        The formatted number!
 **********************************************************************/
{ 
        if (isNaN(parseInt(num))) return 'NaN';

    var tmpNum = num;
    var iSign = num < 0 ? -1 : 1;        // Get sign of number
    
    // Adjust number so only the specified number of numbers after
    // the decimal point are shown.
    tmpNum *= Math.pow(10,decimalNum);
    tmpNum = Math.round(Math.abs(tmpNum))
    tmpNum /= Math.pow(10,decimalNum);
    tmpNum *= iSign;                    // Readjust for sign
    
    
    // Create a string object to do our formatting on
    var tmpNumStr = new String(tmpNum);

    // See if we need to strip out the leading zero or not.
    if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
        if (num > 0)
            tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
        else
            tmpNumStr = '-' + tmpNumStr.substring(2,tmpNumStr.length);
        
    // See if we need to put in the commas
    if (bolCommas && (num >= 1000 || num <= -1000)) {
        var iStart = tmpNumStr.indexOf('.');
        if (iStart < 0)
            iStart = tmpNumStr.length;

        iStart -= 3;
        while (iStart >= 1) {
            tmpNumStr = tmpNumStr.substring(0,iStart) + ',' + tmpNumStr.substring(iStart,tmpNumStr.length)
            iStart -= 3;
        }        
    }

    // See if we need to use parenthesis
    if (bolParens && num < 0)
        tmpNumStr = '(' + tmpNumStr.substring(1,tmpNumStr.length) + ')';

    return tmpNumStr;        // Return our formatted string!
}

//弹出小窗口
function popupSmallWindow(){
    var aArg = popupSmallWindow.arguments;
    var nArg = aArg.length;
    if(nArg == 0){ return false; }

    var sUrl = aArg[0];
    if(nArg > 1){
        nWidth = aArg[1];
        if(nWidth > screen.availWidth){
            nWidth = screen.availWidth;
        }
    }else{
        nWidth = 480;
    }
    if(nArg > 2){
        nHeight = aArg[2];
        if(nHeight > screen.availHeight){
            nHeight = screen.availHeight;
        }
    }else{
        nHeight = 360;
    }

    nLeft = Math.ceil((screen.width - nWidth)/2);
    if(nLeft < 0){ nLeft = 0; }

    nTop = Math.ceil((screen.height - nHeight)/2);
    if(nTop < 0){ nTop = 0; }

    if(top.isIE){
        sProperties = 'dialogTop:'+nTop+'px;';
        sProperties += 'dialogLeft:'+nLeft+'px;';
        sProperties += 'dialogWidth:'+nWidth+'px;';
        sProperties += 'dialogHeight:'+nHeight+'px;';
        sProperties += 'help:no; resizable:no; scroll:yes; status:no';
        window.showModalDialog(sUrl, window, sProperties);
    }else{
        sProperties = 'top='+nTop+',';
        sProperties += 'left='+nLeft+',';
        sProperties += 'width='+nWidth+',';
        sProperties += 'height='+nHeight+',';
        sProperties += 'menubar=no, toolbar=no, resizable=no, scrollbars=yes, status=no';
        objWindow = window.open(sUrl, '', sProperties);
        objWindow.focus();
    }
}

//显示弹出信息
function popupMessage(sMessage){
    /*
    if(top.isIE){
        nWidth = 100;
        nHeight = Math.ceil((getStrLen(sMessage)*12) /nWidth);
        sProperties = 'center:yes; help:no; resizable:no; scroll:no; status:no';
        sProperties += 'dialogWidth:'+nWidth+'px;';
        sProperties += 'dialogHeight:'+nHeight+'px;';
        window.showModelessDialog('/common/inModalDialog.html', sMessage, sProperties);
        window.alert(sMessage);
    }else{
        window.alert(sMessage);
    }
    */
    window.alert(sMessage);
}

function copyText(obj){
  var isIE;
  if(parseInt(navigator.appVersion.charAt(0))>=4){
     isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
  }
    
  if(!isIE){ return; }
  clipboardData.setData('text', obj.value);
  alert("地址已经复制成功，您可以在聊天工具上转发给朋友了！!");
}

function inArray(rnID, raArray) {
    for(var i=0; i<raArray.length; i++) {
        if(rnID==raArray[i]) {
            return true;
        }
    }
    return false;
}

//屏蔽掉href
function disableAnchor(o){
    var href = o.getAttribute("href");
    if(href && href != "" && href != null){
        o.setAttribute('href_bak', href);
    }
    o.removeAttribute('href');
}


