function aClock(){
  var now=new Date();
  var hour=now.getHours();
  var min=now.getMinutes();
  var sec=now.getSeconds();
  var year=now.getYear();
  var month=now.getMonth()+1;
  var date=now.getDate();
  var dateStr = year+"-"+month+"-"+date;
  var timeStr = " " + hour;
  timeStr+=((min<10)?":0":":")
                  +min;
  timeStr+=((sec<10)?":0":":")+sec;
  document.all.clock_date.innerText = dateStr;
  document.all.clock_time.innerText = timeStr;
  clockId = setTimeout("aClock()",1000);
}


function autoCheck(){
  var fm = document.forms[0];
  var count = fm.elements.length;
  var varStartDate = "";
  for (var i = 0 ; i <count; i++){
  	 //只检查:type=text的input、textarea、select
	 if( typeof fm[i]!='object' //对象
	 		|| !(
	 		fm[i].tagName=='INPUT' && (fm[i].type.toUpperCase()=='TEXT' || fm[i].type.toUpperCase()=='PASSWORD')
	 		|| fm[i].tagName=='TEXTAREA'
	 		|| fm[i].tagName=='SELECT'
	 		) ) continue;
	 //只读、失效、设置为非自动检查的不检查
	 if( fm[i].readOnly || //只读
	 	  fm[i].disabled || //失效
	 	  ((typeof fm[i].autocheck) != "undefined" && fm[i].autocheck == "false") ){ //设置为非自动检查
		continue;
		  }
	 var varTitle = fm[i].title;
    //检查title
    if((typeof varTitle) == "undefined" || varTitle == ""){
      alert("系统错误！当前输入域没有定义title 属性！");
      fm[i].focus();
      return false;
    }
    //检查minLength属性
    if( (typeof fm[i].minLength) == "undefined" || fm[i].minLength == "" ){
      alert("系统错误！"+varTitle+"没有定义minLength属性！");
      fm[i].focus();
      return false;
    }
    if( fm[i].minLength>0){
    	if(getLength( trim(fm[i].value) )==0){
    		alert(varTitle+"不能为空！");
      	fm[i].focus();
      	return false;
      }
   	else if(getLength( trim(fm[i].value) ) < fm[i].minLength){
   		alert(varTitle+"长度不够，不能少于"+fm[i].minLength+"个字符！");
      	fm[i].focus();
      	return false;
   	}
    }
	 if(fm[i].tagName=='SELECT') continue;
    //检查maxLength属性
		if( ((typeof fm[i].maxLength) == "undefined" || fm[i].maxLength == "" || fm[i].maxLength == "2147483647")){
		  alert("系统错误！"+varTitle+"没有定义maxLength属性！");
		  fm[i].focus();
		  return false;
		}
	svalue=fm[i].value
    if( fm[i].checkClass != "IsAmt"){
		if( (getLength(trim(svalue)) > fm[i].maxLength)){
			alert(varTitle+"长度过长，不能超过"+fm[i].maxLength+"个字符！");
		  fm[i].focus();
		  return false;
		}
	}
	 //数据类型
	 var classStr = fm[i].checkClass;
	 var varValue = fm[i].value;
    //检查输入域数据类型
    if( (typeof classStr) == "undefined" || classStr == "" ) continue;
	//整型
	if(classStr=='isInteger' && !isInteger(varValue)){
	 	alert(varTitle+"只能输入整数！");
	   fm[i].focus();
	   return false;
	}
	//不为0的数字
	if(classStr=='isInteger0' && !isPstInteger(varValue)){
	 	alert(varTitle+"只能输入正整数！");
	   fm[i].focus();
	   return false;
	}
	//金额
	if(classStr=='IsAmt'&&!IsAmt(i,varTitle)){
	   fm[i].focus();
	   return false;
	}
	//和当前日期比较
	if( classStr=='IsOverStepToday' &&  trim(varValue)!='' && (!isDate(varValue) || varValue>getCurrentDate()) ){
	 	alert(varTitle+"不能大于当前日期或日期输入不合法！");
	   fm[i].focus();
	   return false;
	}
	//和开始日期比较1
	if( classStr=='CompareDate1' && trim(varValue)!='' &&  (!isDate(varValue) || varValue<fm[i-1].value) ){
	 	alert(varTitle+"不能小于"+fm[i-1].title+"或日期输入不合法！");
	   fm[i].focus();
	   return false;
	}
	//和开始日期比较2
	if( classStr=='CompareDate2' && trim(varValue)!='' && (!isDate(varValue) || varValue<=fm[i-1].value) ){
	 	alert(varTitle+"必须大于"+fm[i-1].title+"或日期输入不合法！");
	   fm[i].focus();
	   return false;
	}
if( classStr=='isDate' && trim(varValue)!='' && (!isDate(varValue)) ){
	 	alert(varTitle+"日期输入不合法！");
	   fm[i].focus();
	   return false;
	}	
 }
	if((typeof fm['PAGE'])!="undefined") fm['PAGE'].value="1";
	return true;
}

//获取字符的长度,考虑中文
function getLength(inputValue){
  var j = 0;
  for (var i = 0;i< inputValue.length;i++){
    if (inputValue.charAt(i) >"~")
      j = j + 2
    else
      j = j + 1
  }
  return j;
}

function trim(srcstr){
  return lTrim(rTrim(srcstr))
}

function lTrim(srcstr){
  var ltnStr;
  ltnStr="";
  for (var i=0;i<srcstr.length;i++){
    if (srcstr.charAt(i)!=" " && srcstr.charAt(i)!="　"){
      ltnStr=srcstr.substr(i);
      break;
    }
  }
  return ltnStr;
}

function rTrim(srcstr){
  var rtnStr;
  rtnStr="";
  for (var i=srcstr.length-1;i>=0;i--){
    if (srcstr.charAt(i)!=" " && srcstr.charAt(i)!="　"){
      rtnStr=srcstr.substring(0,i+1);
      break;
    }
  }
  return rtnStr;
}
function sizeChangeForAd(heigetValue) 
{ 
    if(parent.document.all.ad!=null&&document!=null) {
		if(arguments.length==1){
			parent.document.all.ad.height=heigetValue;
		}else{
			parent.document.all.ad.height=document.body.scrollHeight; 
		}
	}
}
