function PageDate()
{
	currentDate = new Date();
	with (currentDate) {
		day = getDay();
		month = getMonth() + 1;
		this.document.write(getFullYear() + '年' + month + '月' + getDate() + '日');
	}
	if (day==1) document.write(' 星期一');                                                
	if (day==2) document.write(' 星期二');
	if (day==3) document.write(' 星期三');
	if (day==4) document.write(' 星期四');
	if (day==5) document.write(' 星期五');
	if (day==6) document.write(' 星期六');
	if (day==0) document.write(' 星期日');
	document.write('');
}
function PageTime()
{
	clocktimer = setTimeout("PageTime()", 1000);
	var today = new Date();
	var sec = today.getSeconds();
	var hr = today.getHours();
	var min = today.getMinutes();
	var timeday = (hr<12 ? " 上午" : " 下午");
	if (hr <= 9) hr = "0" + hr;
	if (min <= 9) min = "0" + min;
	if (sec <= 9) sec = "0" + sec;
	var clocktext = timeday + " " + hr + ":" + min + ":" + sec;
	pTime.innerHTML = clocktext;
}

function mOver(theObj)
{
	theObj.style.color = 'red';
}
function mOut(theObj)
{
	theObj.style.color = 'white';
}

function about()
{
	window.showModalDialog("/other/server.asp","","dialogWidth:480px;dialogHeight:350px;scroll:no;status:no;help:no");
}

function check_user_pwd(theForm)
{
	if (theForm.username.value.length < 3) {
		alert("用户名最少要有3个字符!");
		theForm.username.focus();
		theForm.username.select();
		return false;
	}
	if (theForm.password.value.length < 3) {
		alert("密码也至少要有3个字符!");
		theForm.password.focus();
		theForm.password.select();
		return false;
	}
}

function check_search_value(theForm)
{
	var temp='';
	var theString = theForm.byvalue.value.toString();
	var pos = theString.indexOf("%");
	for(var i=0; i<theForm.byvalue.value.length; i++) {
		if (theString.charAt(i) != " ")
			temp += theString.charAt(i);
	}
	if (pos > -1 || temp.length < 1) {
		alert("检索值不能为空,最少也要有1个字符且不含字符\'%\' !");
		theForm.byvalue.focus();
		theForm.byvalue.select();
		return false;
	}
}

function check_space(strVal)
{
	sgnSpace = strVal.toString();
	result1 = sgnSpace.indexOf(" ");
	if (result1 > 0) {
		return true;
	} else {
		return false;
	}
}

function chk_mail(strVal)
{
	strEmail = strVal.toString();
	result1 = strEmail.indexOf("@");
	result2 = strEmail.indexOf(".");
	return !((strEmail.length < 6) || (result1 < 1) || (result1 > strEmail.length - 2) || (result2 < 3)  || (result2 > strEmail.length-2))
}

function isNum(theObj)
{
	var asciiStr = "0123456789";
	inputStr = theObj.value.toLowerCase();
	for (var i=0; i<inputStr.length; i++) {
		var OneChar = inputStr.charAt(i);
		var pos = asciiStr.indexOf(OneChar);
		if (pos < 0) {
			alert("请输入正确的数字格式字符！");
			theObj.focus();
			theObj.select();
			return false;
		}
	}
	return true;
}

function isPrice(iObj)
{
	vObj = iObj.value;
	for (var i=0; i<vObj.length; i++) {
		var oneChar = vObj.charAt(i);
		if ((oneChar < "0" || oneChar > "9") && (oneChar != ".")) {
			alert("请输入正确的数字格式字符，可输入 小数点！");
			iObj.value=0;
			iObj.focus();
			iObj.select();
			return false;
		}
	}return true;
}

// get rid of the sign of HTML
function get_real_length(inputVal)
{
	var strTemp = "";
	var flag = false;
	var inputStr = inputVal.toString();
	for (var i=0; i<inputStr.length; i++) {
		var oneChar = inputStr.charAt(i);
		if (oneChar == "<")
			flag = true;
		else if (oneChar == ">")
			flag = false;
		else if (!flag)
			strTemp += oneChar;
	}return strTemp.length;
}

function format(expr, decplaces)
{
	var str = "" + Math.round(eval(expr) * Math.pow(10, decplaces))
	while (str.length <= decplaces) {
		str = "0" + str
	}
	var decpoint = str.length - decplaces
	return str.substring(0, decpoint) + "." + str.substring(decpoint, str.length);
}

function isPosInteger(inputVal)
{
	var inputStr = inputVal.toString();
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i);
		if (oneChar < "0" || oneChar > "9") {
			return false;
		}
	}
	return true;
}

function isPosFloat(inputVal)
{
	inputStr = inputVal.toString();
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i);
		if ((oneChar < "0" || oneChar > "9") && (oneChar != ".")) {
			return false;
		}
	}
	return true;
}

function MM_openBarWindow(theURL, winName, feature)
{
	window.open(theURL, winName, feature);
}
function popWin(surl, sWidth, sHeight, sNo)
{
	var w = (screen.width - sWidth)/2;
	var h = (screen.height - sHeight)/2;
	f = 'width='+sWidth+', height='+sHeight+', left='+w+', top='+h+', directories=no, status=no, scrollbars='+sNo+', resizable=no, menubar=no';
	MM_openBarWindow(surl, 'about', f);
}


function show_menu(iObj, x, y, jObj)
{
	var Bdy = document.body;
	jObj.style.display = 'block';
	jObj.style.pixelTop =  iObj.getBoundingClientRect().top + iObj.offsetHeight + Bdy.scrollTop - x;
	jObj.style.pixelLeft = iObj.getBoundingClientRect().left + Bdy.scrollLeft - y;
}
function vOver(vObj)
{
	vObj.style.display='block';
}
function vOut(vObj)
{
	vObj.style.display='none';
}
