
//' 函数名: trim
//  功能描述  ：去掉空格
//	传入参数  :
//		str   待检字符	
//	返回值 ：去掉空格的字符串
//	作者:  韩龙
//	创建时间:2005-01-19
function trim(str) {
    return str.replace(/(^\s*)|(\s*$)/g, "");
}

// 函数名    ：fontZoom
// 功能描述  ：改变新闻的字体大小
// 传入参数  :
//	'#size  字体大小
//' 返回值 ：no
//' 作者:  韩龙
//' 创建时间:2005-3-18

function fontZoom(size)
{
	document.getElementById('fontzoom').style.fontSize=size+'px'
}

// 函数名    : choiceItem
// 功能描述  ：选择操作记录
//  		  formItem为表单名 menuItem为复选框名 
// 传入参数  : no
//' 返回值 ：  no
//' 作者:  王艳丽
//' 创建时间:2005-9-9
//' 修改时间: 2005-9-16 韩龙
//'修改时间：2005-9-29 龙飞
function choiceItem()
 {       if (document.formItem.menuItem.checked==false)
        {
          document.formItem.menuItem.checked=true;
         
        }else if (document.formItem.menuItem.checked==true)	
        {
          document.formItem.menuItem.checked=false;
        
        }else if (document.formItem.menuItem.length>1 && document.formItem.menuItem[0].checked==true)
        {
          for(var i=0;i<document.formItem.menuItem.length;i++)
		{
			document.formItem.menuItem[i].checked=false;
		}	
        }else if (document.formItem.menuItem.length>1 && document.formItem.menuItem[0].checked==false)
	{
          for(var i=0;i<document.formItem.menuItem.length;i++)
		{
			document.formItem.menuItem[i].checked=true;
		}
        }
}

// 函数名    : topen
// 功能描述  ： 在新窗口中打开页面  		  
// 传入参数  : 
//			 #path 要打开的页面地址
//' 返回值 ：  no
//' 作者:  韩龙
//' 创建时间:2005-9-16

function topen(path)
{
	var newwindow=window.open("" + path + "","","left=150,top=150,width=620,height=450,scrollbars=yes");
}


//' 函数名: isNumber
//  功能描述  ：数字检查
//	传入参数  :
//		c   待检字符	
//		 返回值 ：最大值
//		 作者:  韩龙
//		 创建时间:2005-01-19
function isNumber(c) {
    if ((c>='0') && (c<='9'))
        return true;
    else
    {
        alert("不是数字!");
        return false;
    }
}

//' 函数名: isChar
//  功能描述  ：英文字母检查
//	传入参数  :
//		c   待检字符	
//		 返回值 ：最大值
//		 作者:  韩龙
//		 创建时间:2005-01-19
//
function isChar(c) {
    if (((c>='a') && (c<='z')) || ((c>='A') && (c<='Z')))
        return true;
    else
    {
        alert("不是英文字母!");
        return false;
    }    
}


//
//' 函数名: isCode
//  功能描述  字符检查
//	传入参数  :
//		c   待检字符	
//		 返回值 ：最大值
//		 作者:  韩龙
//		 创建时间:2005-01-19
//
function isCode(c) {
    if (((c>='a') && (c<='z')) || ((c>='A') && (c<='Z')) || ((c>='0') && (c<='9')) || (c=='_'))
        return true;
    else
    {
        alert("不是字符!");
        return false;
    }
}


//
//' 函数名: onlyNumber
//  功能描述  只能输入数字
//	传入参数  :
//		str   待检字符	
//	返回值 ：无
//	作者:  韩龙
//	创建时间:2005-01-19
//
function onlyNumber()
{
	if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) 
		|| (window.event.keyCode == 13) || (window.event.keyCode == 46) 
		|| (window.event.keyCode == 45)))
	{
		window.event.keyCode = 0 ;
	}
} 


//
//' 函数名: isTel
//  功能描述  电话号码检查
//	传入参数  :
//		str   待检字符	
//	返回值 ：无
//	作者:  韩龙
//	创建时间:2005-01-19
//
function isTel(str) {
    var c,i, checkresult,length;
    str=trim(str);
    length = str.length;
    checkresult = true;
    for (i = 0; i < length; i++)
    {
        c=str.substr(i,1);    
        if (((c>='0') && (c<='9')) || (c=='-') || (c=='(') || (c==')') || (c=='*') || (c=='_'))
        { checkresult=true; }
        else
        {
            checkresult=false;
            break;    
        }
    }
    if (!checkresult)
    {
        alert("无效电话号码!");
        return false;
    }    
}

//
//' 函数名: isZipCode
//  功能描述  邮政编码检查
//	传入参数  :
//		zip   待检字符	
//	返回值 ：无
//	作者:  韩龙
//	创建时间:2005-01-19
//
function isZipCode(zip) {
    if (zip!=null)
    {
        zip=trim(zip);
        if(zip.length ==0 || zip.length ==5 || zip.length ==6)
        {
            if(!isnumber(zip))
            {
                alert("邮政编码错误!");
                return false;
            }
        }
        else
        {
            alert("邮政编码错误!");
            return false;
        }
    }
    else    
    return true;
}

//
//' 函数名: checkEmail
//  功能描述  email
//	传入参数  :
//		email   待检邮件地址	
//	返回值 ：无
//	作者:  韩龙
//	创建时间:2005-01-19
//


function checkEmail(email) {
    var i,schar,batbegin,bdotbegin;
    if (email == "")
    {
        alert("E-mail不可为空!");
        return false;
    }
    schar=email.substr(i, 1);
    if ((schar == "@") || (schar == "."))
    {
        alert("E-mail错误!");
        return false;
    }
    for (i = 1;  i < email.length;  i++)
    {
        schar=email.substr(i, 1);
        if (email.substr(i, 1) == "@")
        {
            if (bdotbegin || batbegin)
            {
                alert("E-mail错误!");
                return false;
            }
            batbegin=true;
        }
        if (email.substr(i, 1) == ".")
        {
            if (!batbegin)
            {
                alert("E-mail错误!");
                return false;
            }
            bdotbegin=true;
        }
    }
    
    if ((!batbegin) || (!bdotbegin))
    {
        alert("E-mail错误!");
        return false;
    }
    return true;
}    


//
//
//' 函数名: checkCNCode
//  功能描述  中文字符判断
//	传入参数  :
//		str  待检字符
//	返回值 ：无
//	作者:  韩龙
//	创建时间:2005-01-19
//
function checkCNCode(str) {
  str=trim(str);
  var length=str.length;
    for (i=0; i < length; i++)
    {
        if (str.charCodeAt(i) > 255 || str.charCodeAt(i) < 0)
        {
          alert("不能使用中文!");
          return false;
        }
    }
}
