//计算字结数
function strLenB(strString){
	var intLenB
	if (!strString.length)
		return 0
	intLenB = 0
	for(i=0;i<strString.length;i++){
		if (strString.charCodeAt(i) < 128)
			intLenB = intLenB + 1
		else
			intLenB = intLenB + 2
	}
	return intLenB
}

//全选多选框
function SelectAll(frm){
	for (var i=0; i< frm.elements.length; i++)
	{
		var e = frm.elements[i];
		if (e.name != 'selectall')
			e.checked = frm.selectall.checked; 
	}
}


//清除字符串两端空白
function Trim(str){
	var regexp = /^\s*/g;
	var blank="";
	strReturn = str.replace(regexp,blank); //LTrim
	regexp = /\s*$/g;
	strReturn = strReturn.replace(regexp,blank); //RTrim
	return strReturn;
}
//清除左端空格
function LTrim(str){
	var regexp = /^\s*/g;
	var blank="";
	strReturn = str.replace(regexp,blank); //LTrim
	return strReturn;
}
//清除右端空格
function RTrim(str){
	regexp = /\s*$/g;
	var blank="";
	strReturn = str.replace(regexp,blank); //LTrim
	return strReturn;
}

//验证email
function isEmail(strEmail){
	regexp = /^\S+@\S+\.\S+$/
	return (regexp.test(strEmail))
}



//检查润年
function isleapyear(thisyear){
 	return(((thisyear%4==0) && (thisyear%100!=0)) || (thisyear%400==0))
}

//判断是否为Float类型
function isFloat(strNum)
{
	return !isNaN(strNum)	
}
//验证是否为整数
function isInt(strNumber)
{
	var regexp = /^[-]*[1-9]{1}\d*$/ ;
	var regexp1 = /^[0]{1}$/ ;
	return ( regexp.test(strNumber) || regexp1.test(strNumber) ) ; 
}

//换图程序
function menuOver(strId){
	var fullFileName = document.images[strId].src ;
	var extendName = fullFileName.substr(fullFileName.lastIndexOf(".")) ;
	document.images[strId].src = SITEROOT + "i/" + strId + "o" + extendName ;
}
function menuOut(strId){

	var fullFileName = document.images[strId].src ;
	var extendName = fullFileName.substr(fullFileName.lastIndexOf(".")) ;
	document.images[strId].src = SITEROOT + "i/" + strId + extendName ; 
}

function isChecked(chkBox)
{
	if( !isNaN (chkBox.length) )
	{
		for( i = 0 ; i < chkBox.length ; ++ i)
		{
			if (chkBox[i].checked)
				return true ;
		}
		return false ;
	}
	else
	{
		if (chkBox.checked)
			return true ;
		else
			return false ;
	}
}
function FormatNumToStr( iNum , iLength)
{
	var strReturn = iNum.toString();
	for( var i = strReturn.length ; i < iLength ; ++ i)
	{
		strReturn = "0" + strReturn ;
	}
	return (strReturn) ;
}

function OpenFileWin(strUrl)
{
	var FileWin = window.open(strUrl,"FileWin","height=400,width=600,top=50,left=20,status=no,scrollbars=yes,toolbar=no,location=no,statusbar=yes,resizeable=no") ;
	FileWin.focus() ;
}

function OpenAttachWin(strUrl)
{
	var imageWin = window.open(strUrl,"attachWin","height=400,width=350,top=50,left=20,status=no,scrollbars=yes,toolbar=no,location=no,statusbar=yes,resizeable=no") ;
	imageWin.focus() ;
}

function SetFile(strValue,strName)
{
	with(document.frmName)
	{
		for( var i = 0 ; i< elements.length ; ++ i)
		{
			if( elements[i].name == strName  )
			{
				elements[i].value = strValue ;
			}	
		}
	}
}
/*
动态数组 
Create by xufei 2004-5-5
*/
function CList( iSize )
{
	if ( iSize > 0 )
		this.List = new Array( iSize ) ;
	else
		this.List = new Array( 10 ) ;
	this.Length = 0 ;
}

CList.prototype.Find = function( oValue ) 
{
	for ( var i = 0 ; i < this.Length ; ++ i)
	{
		if(oValue == this.List[i])
			return i ;
	}
	return -1 ;
}
CList.prototype.Add = function( oValue ) 
{
	this.List[this.Length] = oValue ;
	++ this.Length ;
}
CList.prototype.Remove = function( oValue ) 
{
	for ( var i = 0 ; i < this.Length ; ++ i)
	{
		if(oValue == this.List[i])
		{
			for( j = i ; j < this.Length - 1 ; ++ j )
			{
				this.List[j] = this.List[j+1] ;
			}
			-- this.Length ;
			return true ;
		}
	}	
	return false ;
}
CList.prototype.Clear = function( oValue ) 
{
	for ( var i = 0 ; i < this.Length ; ++ i)
	{
		this.List[i] = undefined ;
	}
	this.Length = 0 ;
}
/*
动态数组 结束 

*/

function PreLoad(arrImage , strBaseFolder)
{
	var d = document
	d.PreImage = new Array() ; 
	for( var i = 0 ; i < arrImage.length ; ++ i)
	{
		d.PreImage[i] = new Image() ;
		d.PreImage[i].src = strBaseFolder + arrImage[i]
	}
}





















