﻿function selectItem(o,state)
{
	if(o!=null&&o.type=="checkbox"&&o.disabled==false)
	{
		o.checked=state;
	}
}
function selectAllItem(my,group)
{
	if(my!=null&&my.type=="checkbox"&&my.disabled==false)
	{
		for(i=0;i<document.all.length;i++)
		{
			var o=document.all(i);
			if(o.type=="checkbox"&&o.id!=null&&o.id.search(group)>0)
			{
				selectItem(o,my.checked);
			}
		}
	}
}

//数字验证onkeyup="charCheck(this.value,this.id,1)" onKeypress="if (event.keyCode < 46 || event.keyCode > 57) event.returnValue = false;" 
function intCheck(_value,_id,isnull)
{
	if ( isnull == 1 )
	{
		if( _value == "" || _value == null )
		{
		   alert("该项必填项,空值用0表示。");
		   document.getElementById(_id).focus();
		   return false;
		}
	}
	
	if (isNaN(_value))
	{
		alert('只能输入数字！');
		//document.getElementById(_id).innerText = '';
		document.getElementById(_id).focus();
		return false;
	}
	return true;
	
}

//数字验证onkeyup="charCheck(this.value,2,this.id)" onKeypress="if (event.keyCode < 46 || event.keyCode > 57) event.returnValue = false;" 
function charCheck(_value,_length,_id)
{
	if (_value.length == 0)
	{
		return true;
	}
	
	if (isNaN(_value))
	{
		alert('只能输入数字！');
		//document.getElementById(_id).innerText = '';
		document.getElementById(_id).focus();
		return false;
	}
	var arrayValue = _value.split('.');
	if (arrayValue.length>1)
	{
	    var val = arrayValue[1];
	    //alert(v);
	    //alert(v.length);
	    
		if (val.length > _length)
		{
		    if( _length == 0 )
		       {alert('只能输入整数');}
		    else
			   {alert('只能输入' + _length + '位小数');}
			document.getElementById(_id).focus();
		    return false;
		}
	}
	return true;
}

function findRowObject(row,objectid)
{
	if(row!=null)
	{
		for(var i=0;i<row.all.length;i++)
		{
			var o=row.all(i);
			if(o!=null&o.id!=null&&o.id!=""&&o.id.search(objectid)>0)
			{
				return o;
			}
		}
	}
	return null;
}

 function   Chinese(num){   
  var   arr1=new   Array("仟","佰","拾","亿","仟","佰","拾","万","仟","佰","拾","元","点","角","分");
  var   arr3=new   Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖");
  var   point=num.indexOf(".");
  if(point<0)point=num.length;
  var   len=arr1.length-point-3   
  var   strRet="",lastChar="";   
  for(i=0;i<num.length;i++){   
  if(i!=point){   
  val=arr1[i+len]   
  if(num.charAt(i)!="0")   
  strRet+=arr3[num.charAt(i)]+val;   
  else{   
  lastChar=strRet.substr(strRet.length-1)   
  if(val=="亿"||val=="万"||val=="元"||val=="分"){   
  if(lastChar=="零")strRet=strRet.substr(0,strRet.length-1);   
  lastChar=strRet.substr(strRet.length-1)   
  if(!((val=="万"&&lastChar=="亿")||(val=="分"&&lastChar=="角")))strRet+=val   
  }else{   
  if(lastChar!="零")strRet+="零";   
  }   
  }   
  }   
  }   
  return   strRet   
  }   

