/*
//Check whether string s is empty.
	function IsDate(str)
	function IsDateValid(aDate) 
	function IsPositionValid(strDate)
	function IsInteger(str)
	function isEmpty(s) {
	function isWhitespace (s) { 	// Returns true if string  is empty or whitespace characters only.
	function isEmail(s) {
	function isNumber(s)   //字符串是否由数字构成
	function isDigitNumber(s)   //字符串是否由数值构成
	function warnEmpty (theField, s)
	function warnInvalid (theField, s)
//以下为检验函数（使用以上函数）
	function CheckDate(theField,s)  //日期
	function CheckNumeric(theField,s)  //整数或小数
	function CheckInteger(theField,s)  //整数
	function checkString (theField,s)  //字符串（是否为空或空格）
	function checkEmail (theField,s)  //E_Mail
	function checkSelect(theSelect,s)  //下拉框是否选择
	function checkNumber (theField,s)  //字符串是否由数字组成
	function checkzip (theField,s)   //邮编
	function checkPhone(theField,s)  //电话
	function checkPassWordLen(theField,s,num)
	function openwindow(strUrl)
	function openimg(strUrl)
	function repSQsign(thestr)  //用两个单引号替换单引号
	//是否为合法的日期
	function IsValidDate(year,month,day)
	function getMaxDay(year,month)   //该函数根据年份和月份得到该年该月的最大天数
   	//该函数导航各页面，结合分页之页面使用
	function NaviPage(theForm,PageNo) {
	//用一个value匹配select中的选项option
	function matchSelect(theSelect,value){
*/

	function isnumeric(p) 
	{ 
	 if (p == "") 
	  return false; 
	 var l = p.length; 
	 var count=0; 
	 for(var i=0; i<l; i++) 
	 { 
	  var digit = p.charAt(i); 
	  if(digit == "." ) 
	 { 
	    ++count; 
	    if(count>1) return false; 
	   } 
	  else if(digit < "0" || digit > "9") 
	  return false; 
	 } 
	 return true; 
	} 


// Check whether string s is empty.
	function IsDate(str)
	{	
		var re = / /g;
		var strDate = str.replace(re,"");//除去空格
		if (strDate.length > 10 || strDate.length < 6) return false; //1998-11-11 98-1-1
		//判断字符串是否合理	
		var nType = IsPositionValid(strDate);
		var aDate;
		switch (nType)
		{
			case 0:
				return false;
			case 1:
				aDate = strDate.split('-');
				return IsDateValid(aDate);
			case 2:			
				aDate = strDate.split('/');	
				return IsDateValid(aDate);
			default:
		}
		return true;

	}

	function IsDateValid(aDate) 
	{
	    var nYear = parseInt(aDate[0] , 10);    //change to number
	    var nMonth = parseInt(aDate[1] , 10) - 1;   //change to number
	    var nDay = parseInt(aDate[2] , 10);     //change to number
		
		var dtTemp = new Date(nYear , nMonth , nDay);    
		/*dtTemp.setFullYear(nYear);
		dtTemp.setMonth(nMonth);
		dtTemp.setDate(nDay);*/
		
		if (dtTemp.getFullYear() == nYear.toString() && 
		   dtTemp.getMonth() == nMonth.toString() && 
		   dtTemp.getDate() == nDay.toString())
			return true;
		else
		    return false;	
	}
	

	function IsPositionValid(strDate)
	{
		var cSplit = new Array(2); 
		cSplit[0] = '-';
		cSplit[1] = '/';
		nLength = strDate.length;	
		/*var re = new RegExp("/" , "g");
		var strTemp = strDate.replace(re,"");
		if (nLength - strTemp.length == 2 && IsInteger(strTemp))  return 2;*/
		re = /-/g;
		strTemp = strDate.replace(re,"");
		if (nLength - strTemp.length == 2 && IsInteger(strTemp))  return 1; 
		return 0;
	}

	function IsInteger(str)
	{
		var ret = true;
		var i;
		var Temp = new Number(str);
		
		if (str.length == 0)
		{
			ret = false;
		}
		
		if (ret)
		{
			if (str.indexOf("." , 0) != -1)
			{
				ret = false;
			}
		}
		
		if (ret)
		{
			if (Temp.valueOf() != Temp.valueOf())
			{
				ret = false;
			}
		}

		return ret;
	}
		
	function isEmpty(s) {
	    return ((s == null) || (s.length == 0));
	}


	function isWhitespace (s) { 	// Returns true if string  is empty or whitespace characters only.
		var whitespace = " \t\n\r";

		// Is s empty?
		if (isEmpty(s)) return true;

		// Search through string's characters one by one
		// until we find a non-whitespace character.
		// When we do, return false; if we don't, return true.
		var i;		
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character isn't whitespace.
			var c = s.charAt(i);

			if (whitespace.indexOf(c) != -1) 
			   continue;
			else
			  return false;
		}

		// All characters are whitespace.
		return true;
	}
	
	function isEmail(s) {
		// there must be >= 1 character before @, so we
		// start looking at character position 1
		// (i.e. second character)
		var i = 1;
		var sLength = s.length;

		// look for @
		while ((i < sLength) && (s.charAt(i) != "@"))
		{ 
			i++;
		}

		if ((i >= sLength) || (s.charAt(i) != "@")) return false;
		else i += 2;

		// look for .
		while ((i < sLength) && (s.charAt(i) != "."))
		{ 
			i++;
		}

		// there must be at least one character after the .
		if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
		else return true;
	}

	function isNumber(s)   //字符串是否由数字构成
	{
		var digits = "0123456789";
		var i = 0;
		var sLength = s.length;

		while ((i < sLength))
		{ 
			var c = s.charAt(i);
			if (digits.indexOf(c) == -1) return false; 
			i++;
		}
		
		return true;
	}

	function isDigitNumber(s)   //字符串是否由数值构成
	{
		var digits = "0123456789.";
		var i = 0;
		var sLength = s.length;
		if (sLength == 0) return true;
		while ((i < sLength))
		{ 
			var c = s.charAt(i);
			if (digits.indexOf(c) == -1) return false; 
			i++;
		}
		
		return true;
	}
	
	function warnEmpty (theField, s)
	{ 	alert(s);
	    theField.focus();
		return false;
	}

	function warnInvalid (theField, s)
	{	alert(s);
	    theField.focus();
		theField.select();
		return false;
	}

//以下为检验函数（使用以上函数）

	function CheckDate(theField,s)  //日期
	{
		if(!IsDate(theField.value))
			return warnInvalid (theField, s);
		else return true;
	}

	function CheckNumeric(theField,s)  //整数或小数
	{
		var ret = true;
		var i;
		var str=theField.value;
		var Temp = new Number(str);
		
		if (str.length == 0)
		{
  		    return warnInvalid (theField, s);
  		    ret=false;
		}
		
		if (ret)
		{
			if (Temp.valueOf() != Temp.valueOf())
			{
  				return warnInvalid (theField, s);
			}
		}
		
		return ret;
	}


	function CheckInteger(theField,s)  //整数
	{
		var ret = true;
		var i;
		var str=theField.value;
		var Temp = new Number(str);
		
		if (str.length == 0 || str.indexOf("." , 0) != -1)
		{
  		    return warnInvalid (theField, s);
  		    ret=false;
		}
		
		if (ret)
		{
			if (Temp.valueOf() != Temp.valueOf())
			{
  				return warnInvalid (theField, s);
			}
		}
		
		return ret;
	}


	function checkString (theField,s)  //字符串（是否为空或空格）
	{   // Make sure the field exists before completing the test
		if (theField == null) return true;
		if (isWhitespace(theField.value))
		   return warnEmpty (theField, s);
		else return true;
	}

	function checkEmail (theField,s)  //E_Mail
	{
		if (!isEmail(theField.value))
		   return warnInvalid (theField, s);
		else return true;
	}

	function checkSelect(theSelect,s)  //下拉框是否选择
	{
		if (theSelect.options[theSelect.selectedIndex].value != "")	return true;
		else
		{
			theSelect.focus();
			warnEmpty(theSelect,s);
			return false;
		}
	} 

	function checkNumber (theField,s)  //字符串是否由数字组成
	{
		if (!isNumber(theField.value)) return false;
		if (isWhitespace(theField.value))
		   return warnEmpty (theField, s);
		else return true;	
	}


	function checkzip (theField,s)   //邮编
	{
		var ss=theField.value;
		var digits = "0123456789";
		var i = 0;
		var sLength = ss.length;
		
		if(sLength<6)
		    return warnInvalid (theField, s);
		    
		while ((i < sLength))
		{ 
			var c = ss.charAt(i);
			if (digits.indexOf(c) == -1) 
					return warnInvalid (theField, s);

			i++;		
		}
		
		return true;
	}

	function checkPhone(theField,s)  //电话
	{
		var ss=theField.value;
		var digits = "0123456789-";
		var i = 0;
		var sLength = ss.length;

		while ((i < sLength))
		{ 
			var c = ss.charAt(i);
			if (digits.indexOf(c) == -1) 
				return warnInvalid (theField, s);

			i++;
		}

		c = "--";
		if (ss.indexOf(c) != -1) 
			return warnInvalid (theField, s);

		return true;
	}

	function checkPassWordLen(theField,s,num)
	{
		if (theField.value.length < num)
		    return warnEmpty (theField, s);			
		else return true;		
	}

/////////	

	function openwindow(strUrl)
	{
	    //var iw,ih;
	    //iw=window.screen.width;
	    //ih=window.screen.height;
		window.open(strUrl ,null,'menubar=no,toolbar=no,location=no,directories=no,status=YES,scrollbars=1,resizable=0,width=690,top=5,left=5,height=320')
		//window.open(strUrl ,null,'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=1,resizable=0,width='+iw+',top=0,left=0,height='+ih)
	}
	
	function openimg(strUrl)
	{
	    var iw,ih;
	    iw=window.screen.width;
	    ih=window.screen.height;
		//window.open(strUrl ,null,'menubar=no,toolbar=no,location=no,directories=no,status=YES,scrollbars=1,resizable=1,width=690,top=5,left=5,height=320')
		//window.open(strUrl ,null,'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=1,resizable=yes,width='+iw+',top=0,left=0,height='+ih)
		window.open(strUrl ,null,'fullscreen=1,resizable=yes,toolbar=no,menubar=no,scrollbars=1,width='+iw+',height='+ih)
	}

	function repSQsign(thestr)  //用两个单引号替换单引号
	{
		var str,rep;
		rep=/'/g;
		str=thestr.replace(rep,"''");
		return str;
	}
	
	//是否为合法的日期
	function IsValidDate(year,month,day)
	{
              switch (month)
                {
                  case '1':
                  case '3':      
                  case '5':
                  case '7':
                  case '8':
                  case '10':
                  case '12': if (day>31) 
                                return (false);
                             else
                                return (true);
                             break;
                  case '4':
                  case '6':
                  case '9':
                  case '11': if (day>30) 
                                return (false);
                             else 
                                return (true);
                             break;
                  case '2':
                           if (((year%4)==0) && (year%100!=0) || (year%400==0))
                              {if (day>29) 
                                  return false;
                              else
                                  return true;}
                           else             
                              {if (day>28) 
                                  return false;
                              else
                                  return true;}
                           break;
                  default: break;
                }
           
    }
   
	function getMaxDay(year,month)   //该函数根据年份和月份得到该年该月的最大天数
	{
		  var day;
		  month = (month.length==2)?month:('0'+month)
		  switch (month)
                {
                  case '01':
                  case '03':      
                  case '05':
                  case '07':
                  case '08':
                  case '10':
                  case '12':
							 day = 31;
                             break;
                  case '04':
                  case '06':
                  case '09':
                  case '11': 
							 day = 30;
							 break;
                  case '02':
                           if (((year%4==0) && (year%100!=0)) || (year%400==0))
                                 day = 29;
                            else             
								 day = 28;	
                           break;
                  default: break;
                }
           return day;
   }   
   
   	//该函数导航各页面，结合分页之页面使用
	function NaviPage(theForm,PageNo) {
		if (PageNo!=0)
			theForm.jumpto.value = PageNo;
		theForm.submit();
	}
	//该函数导航各页面，结合分页之页面使用
	function NaviPage1(theForm,PageNo) {
		if (PageNo!=0)
			theForm.hidPage.value = PageNo;
		theForm.submit();
	}
	//该函数用于检测跳转页面是否在指定范围内
	function checkPage(theForm,PageNo,maxPage){
		if(!isnumeric(PageNo)){
			alert("请输入正确的数字！");
			theForm.jumpto.focus();
			return false;
		}else{
			if(!IsInteger(PageNo)){
				alert("请输入正整数！");
				theForm.jumpto.focus();
				return false;
				
			}else{
				if(PageNo<1||PageNo>maxPage){
					alert("您选择的页面超出页码范围！");
					theForm.jumpto.focus();
					return false;
				}else{
					return true;
				}
			}
		}
	}
	
	//用一个value匹配select中的选项option
	function matchSelect(theSelect,value){
		var i = 0;
		for(i=0;i<theSelect.options.length;i++){
			if(theSelect.options[i].value == value){
				theSelect.options[i].selected = true;
			}
		}	
	}

function openPrintUrl() {
	window.open("","print","left=180,top=130,width=420,height=330,status=no,resizable=yes,scrollbars=yes");
}

function chkPrintCndtn(theForm) {
	if (theForm.chkMultiPage.checked) {
		if (theForm.txtPageSize.value=="")
		{
			alert("不能为空！");
			theForm.txtPageSize.focus();
			return false;
		}
		if (isNaN(theForm.txtPageSize.value)){
			alert("请输入一个合法的数字！");
			theForm.txtPageSize.focus();
			return false;
		}else if (parseInt(theForm.txtPageSize.value)<=0){
			alert("不能为负数或零！");
			theForm.txtPageSize.focus();
			return false;
		}		
		else 
			return true;
	}
	return true;	
}

function chkPrintCndtn1(theForm) {
	if (theForm.chkMultiPage.checked) {
		if (theForm.txtPageSize.value=="")
			return false;
		if (isNaN(theForm.txtPageSize.value))
			return false;
		else if (parseInt(theForm.txtPageSize.value)<=0)
			return false;
	}
	else 
		return true;	
}	

function goToPrint(theForm,pageno) {
	if (theForm.txtWidth.value=="")
	{
		alert("不能为空！");
		theForm.txtWidth.focus();
		return false;
	}
	if (isNaN(theForm.txtWidth.value)){
		alert("请输入一个合法的数字！");
		theForm.txtWidth.focus();
		return false;
	}else if (parseInt(theForm.txtWidth.value)<=0){
		alert("不能为负数或零！");
		theForm.txtWidth.focus();
		return false;
	}
	theForm.pageno.value = pageno;
	theForm.submit();
	return true;
}
function showDiv(thisform){
			if(document.thisform.mClassId.value.substr(0,3)=='001') {
					window.divAttr.style.display = 'block';
					document.thisform.sign.value = '1';					
			} else {
					window.divAttr.style.display = 'none';
					document.thisform.sign.value = '0';	
			}
		}

