﻿// JavaScript Document

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>常用JavaScript函数                                      <<
//>>作者：bulrush                                           <<
//>>日期：2006-08-23                                        <<
//>>- - - - - - - - - - - - - - - - - - - - - - - - - - - -<<
//>>
//>>
//>>
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：弹出新窗口
//>>时间：2006-08-23
//>>参数：windowURL...页面地址 string
//>>参数：windowName...窗口名称 string
//>>参数：windowWidth...宽度 int
//>>参数：windowHeight...高度 int
//>>参数：scrolling...滚动条 yes / no

function OpenNewWindow(windowURL,windowName,windowWidth,windowHeight,scrolling){
	window.open(windowURL,windowName,"width="+windowWidth+",height="+windowHeight+",scrollbars ="+scrolling)
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：返回getElementById方法获取的对象
//>>时间：2006-08-25使用

function $(thisElementId){return document.getElementById(thisElementId);}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：确认对话框
//>>时间：2006-11-21
//>>参数：

function DoConfirm(alertWord,actionStr){
	if (confirm(alertWord)){
		eval(actionStr);
	}
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证文本域中的值是否和指定的值相同
//>>时间：2006-12-18
//>>参数：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;	
	}
	
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证文本域是否为空
//>>时间：2006-12-18
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckNull(fieldId,printWord){
	if ($(fieldId).value == null || $(fieldId).value == ""){
		$("_"+fieldId).innerHTML = printWord;
		$(fieldId).focus();
		return 1;
	}else{
		$("_"+fieldId).innerHTML = "";
		return 0;
	}
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证复选框和单选框是否选中
//>>时间：2006-12-18
//>>参数：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;
	}
	
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证email格式
//>>时间：2006-12-18
//>>参数：fieldId   域ID
//>>参数：printWord   输出提示信息
function CheckEmail(fieldId,printWord){
	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;	
	return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证字符和数字格式
//>>时间：2006-12-18
//>>参数：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);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证字符格式
//>>时间：2006-12-18
//>>参数：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);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证数字格式
//>>时间：2006-12-18
//>>参数：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);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证中文格式
//>>时间：2006-12-18
//>>参数：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);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证日期格式
//>>时间：2006-12-18
//>>参数：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);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证日期时间格式
//>>时间：2006-12-18
//>>参数：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);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：验证电话格式
//>>时间：2006-12-18
//>>参数：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}$/;
    return CheckWithReg(fieldId,reg,printWord);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：正则表达式验证函数
//>>时间：2006-12-19
//>>参数：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; 
	}
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：读取cookies
//>>时间：2007-02-12
//>>参数：name：cookies 名称
//>>返回：cookies 值
function GetCookie(name){
    var allcookies = document.cookie;
    var pos = allcookies.indexOf(name+"=");
    if (pos != -1){
        var start = pos + 9;
        var end = allcookies.indexOf(";", start);
        if (end == -1) end = allcookies.length;
        var value = allcookies.substring(start, end);  
        value = unescape(value);
    }
    return value;
    
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：翻页调用的表单提交函数
//>>时间：2007-05-22
//>>参数：actionMode...up上一页，down下一页，jump跳转
//>>参数：pageCount...总页数
function TrunPageSubmit(actionMode,pageCount){
	var thisLocation = window.location.href;
	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;
	}
	thisLocation = thisLocation+nextPage;
	window.location.href=thisLocation;
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：
//>>时间：
//>>参数：
//>>参数：
//>>参数：
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：
//>>时间：
//>>参数：
//>>参数：
//>>参数：
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：
//>>时间：
//>>参数：
//>>参数：
//>>参数：
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：
//>>时间：
//>>参数：
//>>参数：
//>>参数：
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>功能：
//>>时间：
//>>参数：
//>>参数：
//>>参数：
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

