 //utf-8
//获取radio的值value
function GetRadioValue(RadioName){
    var obj;   
    obj=document.getElementsByName(RadioName);
    if(obj!=null){
        var i;
        for(i=0;i<obj.length;i++){
            if(obj[i].checked){
                return obj[i].value;           
            }
        }
    }
    return null;
}

//获取对象
function $(name){
  return document.getElementById(name);
}

//获取字符串长度
function calcLen(s){
var len=0; 
for(var i=0;i<s.length;i++){
  if(s.charCodeAt(i)>=10000)len=len+2
  else len=len+1; 
}
return len;
}

//根据参数获取对应字符
function get_value(code){
   oCodes=new codes();//获取参数集
   oResults=new results();//获取结果集
     for(i in oCodes){
       if (oCodes[i]==code){
         return oResults[i];
       }
   }
   alert("未找到批配字符");
   return "";
}
/**
function codes()
 {
    return new Array("test");
 }
function results()
  {
      return new Array("arson");
  }
  **/

//获取字符串长度
function getStrLen(str)
{
var nPos;
var nLen;

	if(str==null) return 0;

	nPos = 0;
    	nLen = 0;
	while (nPos < str.length)
	{	
		if(str.charCodeAt(nPos) > 127)
		{
			nLen = nLen + 2;
		}
		else
	    	{
			nLen = nLen +1;
		}
		nPos++;
	}		
	return nLen;
}

/**字符串匹配数组
 **str要匹配字符串
 **strArray被匹配的字符串数组 用;号格开
 **contrast type 对比方式 ==相等!=不等
 **type 匹配方式&&和||或
 **/
 function str_check_array(str,strArray,contrast,type){
    var strList=strArray.split(";");
    if(contrast=="=="){
      if(type=="&&"){
        for(var x=0;x<strList.length;x++){
           if(str!=strList[x]){
              return false;
           }
         }
         return true;
      }else if(type=="||"){
        for(var x=0;x<strList.length;x++){
           if(str==strList[x]){
              return true;
           }
         }
         return false;
      }
     }else if(contrast=="!="){
      if(type=="&&"){
        for(var x=0;x<strList.length;x++){
           if(str==strList[x]){
              return false;
           }
         }
         return true;
      }else if(type=="||"){
        for(var x=0;x<strList.length;x++){
           if(str!=strList[x]){
              return true;
           }
         }
         return false;
      }
    }
 }

