function textCounter(field, countfield, maxlimit) {
	if (field.value.length >maxlimit) 
		field.value = field.value.substring(0,maxlimit);
	else 
	countfield.value = maxlimit - field.value.length;
}

function SelCol(theform,theurl){
	theform.action=theurl;
	theform.submit();
}

function ShowPic(PicPath,ThePic){
	box = eval(ThePic);
	if(PicPath.length==0) return;
	box.src=PicPath;
	box.style.display="";
}

function ShowPic1(PicPath,ThePic){
	box = eval(ThePic);
	if(PicPath.length==0) {
		box.style.display="none";
		return;
	}
	box.src="../../written/upfile/"+PicPath;
	box.style.display="";
}

function caidan(id){
	if (id.style.display!=""){
		id.style.display="";
	}
	else{
		id.style.display="none";
	}
}

function hid(id){
	id.style.display="none";
}

function show(id){
	id.style.display="";
}

//日历函数
function selectDate(objID,theform){
	var obj = eval('document.'+theform+'.'+objID);
	result = window.showModalDialog('../js/Calendar.htm',obj.value,'dialogWidth=185px;dialogHeight=230px');
	if (result!=null){
		obj.value = result;
	}
}

//日历函数
function IsDate(DateString , Dilimeter){
	if (DateString==null) return false;
	if (Dilimeter=='' || Dilimeter==null)
		Dilimeter = '-';
		var tempy='';
		var tempm='';
		var tempd='';
		var tempArray;
	if (DateString.length<8 && DateString.length>10)
		return false;       
	tempArray = DateString.split(Dilimeter);
	if (tempArray.length!=3)
		return false;
	if (tempArray[0].length==4){
		tempy = tempArray[0];
		tempd = tempArray[2];
	}
	else{
		tempy = tempArray[2];
		tempd = tempArray[0];
	}
	tempm = tempArray[1];
	var tDateString = tempy + '/'+tempm + '/'+tempd+' 8:0:0';//加八小时是因为我们处于东八区
	var tempDate = new Date(tDateString);
	if (isNaN(tempDate))
		return false;
	if (((tempDate.getUTCFullYear()).toString()==tempy) && (tempDate.getMonth()==parseInt(tempm,10) - 1) && (tempDate.getDate()==parseInt(tempd,10))){
		return true;
	}
	else{
		return false;
	}
}

function checkmail(mail){
	var maill ;
	maill="";
	for (i = 0;  i < mail.length;  i++){
		str = mail.charAt(i);
		strNm=str.charCodeAt(0);
		if (strNm!=32){
			maill=maill+str;
		}
	}
	var strr;
	re=/([a-zA-Z0-9_.-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+)(\.{0,1}[a-zA-Z0-9_-]*)(\.{0,1}[a-zA-Z0-9_-]*)/i;
	re.exec(maill);
	if (RegExp.$3!=""&&RegExp.$3!="."&&RegExp.$2!=".") {
		strr=RegExp.$1+RegExp.$2+RegExp.$3
	}
	else
		if (RegExp.$2!=""&&RegExp.$2!="."){
			strr=RegExp.$1+RegExp.$2
		}
		else{
			strr=RegExp.$1
		}
	//alert(strr);
	if (strr!=maill){
		alert("电子邮件地址无效!");
		return false;
	}
	return true;
}

//全选
function allselect(){
	for(i=0;i<DataList.del.length;i++){
		switch(DataList.del[i].checked){
			case true:
				DataList.del[i].checked=false;
				break;
			case false:
				DataList.del[i].checked=true;
		}
	}
}

//检测BBS
function checkbbs(theform){
	if (theform.userid.value==""){
		alert("请输入姓名！");
		return false;
	}
	if (theform.title.value==""){
		alert("请输入主题！");
		return false;
	}
	if (theform.content.value==""){
		alert("请输入内容！");
		return false;
	}
	if (theform.content.value.length > 2000){
		alert("你的信息太长了.\n\n请限制在 "+2000+" 字节以内.\n当前已有 "+theform.content.value.length+" 字节.");
		return false;
	}
return true;
}

function Login(form){
	var mesg = "";
	if(form.name.value == "") mesg += "用户\n";
	if(form.passwd.value == "") mesg += "密码\n";
	if(mesg != ""){
		//mesg = AlertInput + mesg;
		alert(mesg);
		return false;
	}

	if (form.language.value !="-") form.Lang.value = form.language.value;
	form.action = "http://mail.zsglj.com/igenus/login.php?Cmd=login";
	form.submit();
}

function CheckCarSearch(theform){
	if (theform.car_num.value==""){
		alert("请输入车牌号码！");
		theform.car_num.focus();
		return false;
	}
	if(!IsDate(theform.search_date.value)){
		alert("请检查日期格式是否正确！");
		theform.search_date.focus();
		return false;
	}
	return true;
}
