//返回getElementById方法获取的对象
function $(thisElementId){return document.getElementById(thisElementId);}

//全选按钮点击事件
function CheckAll(formName,fieldName){
	var thisObj=eval("document."+formName+"."+fieldName);
	if (thisObj){
		if (thisObj.length){
			for (var i=0; i<thisObj.length; i++){
				thisObj[i].checked = document.getElementById("checkAll").checked;
			}
		}
		else{
			thisObj.checked = document.getElementById("checkAll").checked;
		}
	}
}

//所选信息提交操作
function DoSubmit(act){
	var errNo = 0;
	errNo += CheckSelect("form1","optionId","请选择进行操作的信息。")
	if (errNo==0){
		if (act=="del"){
			DoConfirm("删除确认","DoDel()")
		}
		else{
			document.form1.action.value = act;
			document.form1.submit();
		}
	}
}
//删除操作
function DoDel(){
	document.form1.action.value = "del";
	document.form1.submit();
}


//确认对话框
function DoConfirm(alertWord,actionStr){
	if (confirm(alertWord)){
		eval(actionStr);
	}
}

function doStudentClass(){
	var errNo = 0;
	errNo += CheckNull("studentClassName1","请填写门类名称")
	if(errNo==0){
	   document.form2.submit();	
	}
}

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：翻页调用的表单提交函数
//>>参数：actionMode...up上一页，down下一页，jump跳转
//>>参数：pageCount...总页数
function TrunPageSubmit(actionMode,pageCount){
	var thisLocation = window.location.href;
	if(thisLocation.indexOf(".html")>0){
		var thisHtml = true;
		if(thisLocation.indexOf("_")>0){
			var b=thisLocation.lastIndexOf("_");
			thisLocation=thisLocation.substring(0,b);
		}
		else{
			var b=thisLocation.lastIndexOf(".html");
			thisLocation=thisLocation.substring(0,b);
		}
	}
	else{
		if (thisLocation.indexOf("page")>0){
			var b=thisLocation.lastIndexOf("&");
			thisLocation=thisLocation.substring(0,b);
		}
		if (thisLocation.indexOf(".asp?")>0){
			thisLocation=thisLocation+"&page="
		}
		else{
			thisLocation=thisLocation+"?page="
		}
	}
	var nextPage=0;
	var thisPage=parseInt($("page").value);
	switch (actionMode){
		case "first":
			nextPage=1;
			break;
		case "prev":
			nextPage=thisPage-1;
			break;
		case "next":
			nextPage=thisPage+1;
			break;
		case "last":
			nextPage=pageCount;
			break;
		case "jump":
			nextPage=thisPage;
			break;
	}
	if (nextPage<1){nextPage=1;}
	if (nextPage>pageCount){nextPage=pageCount;}
	if(thisHtml){
		thisLocation = thisLocation+"_"+nextPage+".html";
	}
	else{
		thisLocation = thisLocation+nextPage;
	}
	window.location.href=thisLocation;
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证文本域中的值是否和指定的值相同
//>>参数：fieldId...文本域的ID
//>>参数：valueStr...指定的值
//>>参数：printWord...输出的错误信息
function CheckValue(fieldId,valueStr,printWord){
	if ($(fieldId).value != valueStr){
		$("_"+fieldId).innerHTML = printWord;
		$(fieldId).focus();
		return 1;
	}else{
		$("_"+fieldId).innerHTML = "";
		return 0;	
	}
	
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证文本域是否为空
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckNull(fieldId,printWord){
	if ($(fieldId).value.replace(/[ ]/g,"") == null || $(fieldId).value.replace(/[ ]/g,"") == ""){
		$("_"+fieldId).innerHTML = printWord;
		//$(fieldId).focus();
		return 1;
	}else{
		$("_"+fieldId).innerHTML = "";
		return 0;
	}
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证复选框和单选框是否选中
//>>参数：formName   表单名称
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckSelect(formName,fieldId,printWord){
	
	var errNo=0;
	var thisObj = eval("document."+formName+"."+fieldId);
	var j;
	if (thisObj){
		j=thisObj.length;
		if (j > 1){
			for (var i=0;i<j;i++){
				if (thisObj[i].checked){
					errNo += 1;
				}
			}
		}
		else{
			if (thisObj.checked){
				errNo += 1;	
			}
		}
	}
	
	if (errNo == 0){
		$("_"+fieldId).innerHTML = printWord;	
		return 1;
	}
	else{
		$("_"+fieldId).innerHTML = "";
		return 0;
	}
	
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证下拉列表是否选择
//>>参数：formName   表单名称
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckGetDown(formName,fieldId,printWord){
	var errNo=0;
	var thisObj = eval("document."+formName+"."+fieldId);
	var value;
	if (thisObj){
		value = thisObj.value;
		if (value == ""){
			errNo += 1;	
		}
	}
	
	if (errNo != 0){
		$("_"+fieldId).innerHTML = printWord;	
		return 1;
	}
	else{
		$("_"+fieldId).innerHTML = "";
		return 0;
	}
	
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证email格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckEmail(fieldId,printWord){
	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;	
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证字符和数字格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckCharOrNumber(fieldId,printWord,minLength,maxLenght){
	if (minLength == null || minLength == ""){minLength = 0}
	//var reg = /^[a-zA-Z0-9]{0,}$/;
	var reg = new RegExp ("^[a-zA-Z0-9_]{"+minLength+","+maxLenght+"}$");
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证字符格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckChar(fieldId,printWord,minLength,maxLenght){
	if (minLength == null || minLength == ""){minLength = 0}
	var reg = new RegExp ("^[a-zA-Z_]{"+minLength+","+maxLenght+"}$");
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证数字格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckNumber(fieldId,printWord,minLength,maxLenght){
	if (minLength == null || minLength == ""){minLength = 0}
	var reg = new RegExp ("^[0-9]{"+minLength+","+maxLenght+"}$");
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证中文格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckChinese(fieldId,printWord,minLength,maxLenght){
	if (minLength == null || minLength == ""){minLength = 0}
	var reg = new RegExp ("^[^u4E00-u9FA5]{"+minLength+","+maxLenght+"}$");
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证日期格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckDate(fieldId,printWord){
	var reg = new RegExp ("^(((19|20)(([02468][048])|([13579][26]))-02-29)|((19[0-9][0-9])|(20[0-9][0-9]))-((0[0-9])|(1[0-2]))-(([01][0-9])|(2[0-8]))|(((19[0-9][0-9])|(20[0-9][0-9]))-((0[469])|(1[1]))-(([012][0-9])|(3[0])))|(((19[0-9][0-9])|(20[0-9][0-9]))-((0[13578])|(1[02]))-(([012][0-9])|(3[01]))))$$");
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证日期时间格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckDateTime(fieldId,printWord){
	var reg = new RegExp ("^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$");
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证电话格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckTel(fieldId,printWord){
    //var reg = /^\(?0?(10|2[0-57-9]|[3-9]\d{2}|1(3\d|59))\)?-?\d{8}$/;
	var reg = /\d{3}-\d{8}|\d{4}-\d{7}|\d{11}$/;
    return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证手机格式
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckMobile(fieldId,printWord){
	var reg = /^(13|15|18)\d{9}$/;
    return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：正则表达式验证函数
//>>参数：field...域ID
//>>参数：reg...正则表达式
//>>参数：printWord...提示信息
function CheckWithReg(fieldId,reg,printWord){
	if(reg.test($(fieldId).value)){
		$("_"+fieldId).innerHTML = "";
		return 0;
	}else{
		$("_"+fieldId).innerHTML = printWord;
		//$(fieldId).focus();
		return 1; 
	}
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

function CopyOrderSource(referrer){
	window.clipboardData.setData('Text',referrer);
	alert('复制来源成功');
}
