   
   //此两个变量用于判断是那种浏览器
   var ns4 = (document.layers)? true:false;
   var ie4 = (document.all)? true:false;

  ///////////////////////////////////////////////////
  //	检查数据格式是否为number(bit)
  //	传入参数：thetext--文本框名称
  //		      bit--该整数应不超过的位数
  ///////////////////////////////////////////////////
  function Check_Int(thetext, bit)
  {
     // 定义匹配模式
     regexp = new RegExp("^\\d{0," + bit + "}$");
     if (!(regexp.test(thetext.value) && thetext.value!= '' && thetext.value != null))
	 {
         alert("对不起，请在此输入位数不超过"+bit+"的整数!");
	     thetext.focus();
		 return false;
     }
	 return true;
  }



  ///////////////////////////////////////////////////
  //	检查数据格式是否为number(bit1+bit2, bit2)
  //	传入参数：thetext--文本框名称
  //		     bit1--整数部分应不超过的位数
  //		     bit2--小数部分应不超过的位数
  ///////////////////////////////////////////////////

  function Check_Float(thetext, bit1, bit2)
  { 
     // 定义匹配模式
     regexp = new RegExp("^\\d{0," + bit1 + "}(\\.\\d{1," + bit2 + "})?$");
     if (!regexp.test(thetext.value) && thetext.value != '' && thetext.value != null) 
	 {
        //alert("对不起，请在此输入最大整数位为" + bit1 + "位，最大小数位为" + bit2 + "位的数字!");
	    thetext.focus();
		return false;
     }
	 return true;
  }


  ///////////////////////////////////////
  //	检查字符串是否为空
  //	传入参数：thetext--文本框名称
  ///////////////////////////////////////

  function Check_Str(thetext,dispmsg)
  {
     var regexp = / /g;
     // 去除字串空格
     var Str = thetext.value.replace(regexp,"");
     // 判断去除空格后的字串是否为空，为空则提示
     if (Str=="" || Str == null)
	 {
	    alert(dispmsg);
	    thetext.focus();
		return false;
     }
	 return true;
  }

 ///////////////////////////////////////
  //	返回去所有空格的字符串
  //	传入参数：thetext--文本框名称
  ///////////////////////////////////////

  function Trim_Str(thetext)
  {
     var regexp = /^ $/g;
     // 去除字串空格
     var Str = thetext.replace(regexp,"");
	 return Str;
	 
  }

 ///////////////////////////////////////////////////
  //	检查数据格式是否为number(bit)
  //	传入参数：thetext--文本框名称
  //		      bit--该文件名称应不超过的位数
  ///////////////////////////////////////////////////

  function Check_FileName(thetext,bit)
  {
     // 定义匹配模式
     regexp = new RegExp("^\\w{0," + bit + "}$");
     if (!regexp.test(thetext.value) || thetext.value == '' || thetext.value == null)
	 {
        alert("对不起，文件名称写错!");
	    thetext.focus();
        return false; 
     }
	 return true;
  }


  ///////////////////////////////////////
  //	检查数据是否为bit位整数
  //	传入参数：thetext--文本框名称
  //		      bit--位数
  ///////////////////////////////////////

  function Check_Fixed_Int(thetext, bit){ 
     // 定义匹配模式，匹配数字bit次
     regexp = new RegExp("^\\d{" + bit + "}$")
      if (!regexp.test(thetext.value)) {
        alert("对不起，请在此输入位数为"+bit+"的整数!")
	    thetext.focus()
	    return 0
      } else return 1 
  }



  ////////////////////////////////////////////
  //  检查年度、月份函数
  //  说明： 年度文本框名称--Year
  //	     月份文本框名称--Month
  //		   表单名称--form1
  ///////////////////////////////////////////////

  function Check_Year_Month()
  {
	var month = document.form1.Month.value;
	// 检查是否输入年度
	if (document.form1.Year.value == "" || document.form1.Year.value == null)
	{
		alert("请输入年度！");
		document.form1.Year.focus();
		return false;
	}
	// 检查是否输入月份
	if (document.form1.Month.value == "" || document.form1.Month.value == null)
	{
		alert("请输入月份！");
		document.form1.Month.focus();
		return false;
	}
	// 检查是否输入日期
	if (document.form1.Day.value == "" || document.form1.Day.value == null)
	{
		alert("请输入日期！");
		document.form1.Day.focus();
		return false;
	}

	// 取输入的月份转换为整数
	parseInt(month)
	// 判断输入的月份是否正确 
	if (isNaN(document.form1.Month.value) || month>12 || month <1)
	{
		alert("请输入正确的月份！");
		document.form1.Month.focus();
		return false;
	}
	// 判断年度是否为4位整数
	if (!Check_Fixed_Int(document.form1.Year, 4))
	{
		// 提交表单
		return false;
	}
	return true;
  }

  ///////////////////////////////////////////////////
  //
  //	检查数据格式是否为有效日期
  //	传入参数：strDate--要校验的字符串
  //
  ///////////////////////////////////////////////////

  function Check_Date(strDate)
  {
    // 检查串是否为8位数字
    regexp = new RegExp("^\\d{8}$");
    if (!regexp.test(strDate)) return false;
    // 取串中年份
    intYear = strDate.substr(0, 4);
    // 年份不在1900-3000之间
    if (intYear < 1900 || intYear > 3000) return false;
    // 取串中月份
	intMonth = strDate.substr(4, 2);
    // 月份不在1-12之间
    if (intMonth < 1 || intMonth > 12) return false;
    // 取串中日
	intDay = strDate.substr(6, 2);
    if (intDay < 1) return false;
    // 月份为大月，且日期大于31
    if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8
      || intMonth == 10 || intMonth == 12) && intDay > 31) return false;
    // 月份为2月外小月，且日期大于30
    if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && intDay > 30) return false;
    // 月份为2月，根据闰年与否，判断日期是否大于28或29
    if ((intMonth == 2) && intDay > 28 + (intYear % 4 == 0)) return false;
    return true;
  }

  ///////////////////////////////////////////////////
  //
  //	隐藏或显示某个对象
  //	传入参数：obj--隐藏或显示某个对象
  //
  ///////////////////////////////////////////////////
  function showObject(obj)
  {
  	   if (ns4) obj.visibility = "show"
 	   else if (ie4) obj.visibility = "visible"
  }

  function hideObject(obj)
  {
      if (ns4) obj.visibility = "hide"
	  else if (ie4) obj.visibility = "hidden"
  }
  
 //转义处理
 function ConvertChar(strObj)
 {
	  var strDes="";
      for(i=0;i<strObj.length;i++)
	  {
	        ch=strObj.charAt(i);
			if(ch=='&') strDes=strDes+"&amp;";
			else if(ch=='<') strDes=strDes+"&lt;";
			else if(ch=='>') strDes=strDes+"&gt;";
			else if(ch=='\n') strDes=strDes+"<br>";
			else if(ch=='\"') strDes=strDes+"&quot;";
			else if(ch=='\'') strDes=strDes+"&acute;";
			else if(ch==' ')  strDes=strDes+"&nbsp;";
			else strDes=strDes+ch;
			
	   }
	   return strDes;
 }

//获得Radio的值
function getRadioValue(objName)
{
     var RadioObj = document.all.item(objName);

     if (RadioObj!=null)
	 {
	     if (RadioObj.length!=null)
		 {
             for (i=0; i<RadioObj.length; i++) 
		     {
				  if(RadioObj(i).checked==true) return RadioObj(i).value;
             }
         }
		 else
         {
		    return RadioObj.value;
		 } 
     }
}

/**判断上传的文件路径中是否包括中文（文件名称不支持中文格式）***/
function CheckFileName(filePath)
{
	 //判断文件名称是否包含中文
	 var pos=filePath.lastIndexOf('\\');
	 var fileName=filePath.substring(pos+1,filePath.length);
	 for(var i=0;i<fileName.length;i++)
	 {
		 if(fileName.charCodeAt(i)<0||fileName.charCodeAt(i)>127)
		{
			alert("文件路径中不支持中文");
			return false;
		}
	 }
	 return true;
}											  

function CheckEmail(EmailAddress)
{
	var EmailFormat="^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+$";
	regexp = new RegExp(EmailFormat);
    if (!regexp.test(EmailAddress)) return false;
	return true;
}
  
function CheckIsSel(object)
{
	var flag;
	var classlen=object.length;
	if(classlen)
	{
		for(var i=0;i<classlen;i++)
	   {
			if(object[i].checked)
			{
			   flag=true;
			   break;
			}
			else
		   {
			  flag=false;
		   }
	  }
	}
	else
	{
		if(object.checked==true)   
			flag=true;
		else
			flag=false;
	}
	
    if (flag==false) return false;
	else return true;
}


function newWindow(url,winwidth,winheight)
{

		var newheight=parseInt(winheight);
		var newwidth=parseInt(winwidth);
        var options="scrollbars=no,resizable=no,status=no,menubar=no,toolbar=no,width=" + newwidth + ",height=" + newheight + "'";
        window.open(url, 'newpopup', options);

}

function goToSelectedAllPage(selectObject)
{ 
	 var path = selectObject.options[selectObject.options.selectedIndex].value 
     	if( path.toUpperCase() == "NONE" ) 
        	return false; 
            	location=selectObject.options[selectObject.options.selectedIndex].value; 
            return true; 
} 

function CheckDelAction(obj)
{
		
		j=obj.length;
		if(j)
	    {
			for (i=0; i<obj.length; i++)
			{
			   if (obj[i].checked)
			   {
					j=j-1;
			   }
			}
			
			if (j==obj.length)
			{
				alert("请选择预操作的记录!");
				return false;
			}
				
			for (i=0; i<obj.length; i++)
			{
				if(obj[i].checked)
				{
					if(confirm("确实要操作对应记录吗？")) 
					{
						return true;
					}
					break;
				}
			 }	
		}
		else 
	    {
			if(obj.checked==false)   
			{
				alert("请选择预操作的记录!");
				return false;
			}
			else
			{
				 if(confirm("确实要操作对应记录吗？")) 
				 {
				 	return true;
				 }
			}
	    }
		 return false;
}
function isNumberString(InString,RefString)
{
	if(InString.length==0) return (false);
	for (Count=0; Count < InString.length; Count++)
	{
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
		return (false);
	}
	return (true);
}

//---居中显示一个无下拉条的对话框
function dialog(mywidth,myheight,func)
{
    var myleft=Math.max(0,(screen.availWidth-mywidth-10)/2);
    var mytop=Math.max(0,(screen.availHeight-myheight-30)/2);
    var t=window.open(func,'_blank','left='+myleft+',top='+mytop+',height='+myheight+',width='+mywidth+',status=no,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no');
    t.focus();
}
