﻿/*
  通用脚本。*/
var mfAppPath = "";
String.prototype.trim = function() {
	return this.replace(/(^\s+)|\s+$/g,"");
}

function getCurrentStyle(oElement, sProperty) {
  if (oElement.currentStyle) {
    return oElement.currentStyle[sProperty];
  }
  else if (window.getComputedStyle) {
    sProperty = sProperty.replace(/([A-Z])/g, "-$1").toLowerCase();
    return window.getComputedStyle(oElement, null).getPropertyValue(sProperty);
  }
  else {
    return null;
  }
}

function getEl(id) {
	return document.getElementById(id);
}
// 得到字符串的真实长度（双字节换算为两个单字节）  叶太东   2008-07-04/ 
function getStrActualLen(sChars) { 
    return sChars.replace(/[^\x00-\xff]/g,"xx").length;  
}  
//截取中英混合字符的长度  ***************************叶太东   2008-07-04/ 
function subString(str, len) {     
    if(!str || !len) 
    { return ''; }     
     var a = 0;      //循环计数    
     var i = 0;      //临时字串     
     var temp = '';      
     for (i=0;i<str.length;i++){         
          if (str.charCodeAt(i)>255){             //按照预期计数增加2          
             a+=2;         
          }       
          else{         
             a++;         
          }        
          //如果增加计数后长度大于限定长度，就直接返回临时字符串   
          if(a > len) { 
            return temp;
          }         
          //将当前内容加到临时字符串       
          temp += str.charAt(i);     
     }     
     //如果全部是单字节字符，就直接返回源字符串    
     return str; 
} 
