function getdate(lang) {
	var now = new Date();
	if (lang == "en") {
		dayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
		monthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
		document.write(dayName[now.getDay()] + "<br /><span style=\"font-family: Impact; font-size: 36px;\">" + now.getDate() + "</span><br />" + monthName[now.getMonth()] + ", " + now.getFullYear() + "<br />");
	} else {
		dayName = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
		monthName = new Array("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月");
		yearName = new Array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九");
		var ynum = now.getFullYear().toString();
		var ystring = yearName[ynum.charAt(0)] + yearName[ynum.charAt(1)] + yearName[ynum.charAt(2)] + yearName[ynum.charAt(3)] + "年";
		document.write(dayName[now.getDay()] + "<br /><span style=\"font-family: Impact; font-size: 36px;\">" + now.getDate() + "</span><br />" + ystring + monthName[now.getMonth()] + "<br />");
	}
}
// Provide background music
function bgsound(src) {
	if (navigator.appName == "Netscape") {
		document.write("<embed src=\"" + src + "\" loop=\"true\" width=\"0\" height=\"0\" autostart=\"true\" autoplay=\"true\" />");

	} else {
		document.write("<bgsound src=\"" + src + "\" loop=\"-1\" />");
	}
}
// Opens homepage version 1.0
function homepage_v1(relative_path, window_name) {
	window.open(relative_path, window_name, 'status=yes, width=550, height=550');
}
// Opens homepage version 2.0
function homepage_v2(relative_path, window_name) {
	window.open(relative_path, window_name, 'status=no, width=920, height=580');
}
// Opens homepage version 2.0
function homepage_v3(relative_path, window_name) {
	window.open(relative_path, window_name, 'status=no, width=1015, height=700');
}
// Opens frontpage of GlobalTalk
function globaltalk(relative_path, window_name) {
	window.open(relative_path, window_name, 'status=no, width=825, height=570');
}
// Opens full broswer window with URL
function open_window(path) {
	window.open(path, '_blank', 'menubar, toolbar, location, direction, status, \
				scrollbars, resizable, dependent, width=980, height=600, left=0, top=0');
}

// discussion related functions
function validRegForm(aForm) {
	if (aForm.user_name.value == "") {
		alert("您没有填写笔名");
		aForm.user_name.focus();
		return false;
	}
	if (aForm.password1.value == "") {
		alert("您没有填写密码");
		aForm.password1.focus();
		return false;
	}
	if (aForm.password2.value == "") {
		alert("您没有重填密码");
		aForm.password2.focus();
		return false;
	}
	if (aForm.password1.value != aForm.password2.value) {
		alert("您两次填写的密码不相同");
		aForm.password2.focus();
		return false;
	}
	if (aForm.intro.value.length > 300) {
		alert("您的个人简介太长");
		aForm.intro.focus();
		return false;
	}

	return true;
}
function validPostForm(aForm) {
	if (aForm.article_content.value == "") {
		alert("请输入评论内容");
		aForm.article_content.focus();
		return false;
	}
	if (aForm.article_content.value.length > 1000) {
		alert("很抱歉，您的评论字数为" + aForm.article_content.value.length + "， 超过了字数上限 1000");
		aForm.article_content.focus();
		return false;
	}
	return true;
}
function validPCForm(aForm) {
	if (aForm.passwd1.value == "") {
		alert("您没有填写当前密码");
		aForm.passwd1.focus();
		return false;
	}
	if (aForm.passwd2.value == "") {
		alert("您没有填写新密码");
		aForm.passwd2.focus();
		return false;
	}
	if (aForm.passwd3.value == "") {
		alert("您没有重填新密码");
		aForm.passwd3.focus();
		return false;
	}
	if (aForm.passwd2.value != aForm.passwd3.value) {
		alert("您两次填写的新密码不相同");
		aForm.passwd3.focus();
		return false;
	}

	return true;
}
function switchPage(url) {
	var command = "location.replace('" + url + "')";
	setTimeout(command, 1000);
}
function gotoPage(url) {
	window.location = url;
}
// beforer calling this function, the following variables needs to be defined:
// text1, text2, fgColor, bgColor
function welcome(index) {
	var iteration = 16;
	var tInc = 100;
	var spacingUnit = 1;
	if (index == iteration)
		if (document.getElementById("welcome").innerHTML == text1)
			document.getElementById("welcome").innerHTML = text2;
		else
			document.getElementById("welcome").innerHTML = text1;
	if (index == iteration * 2) index = 0;
	var newR = (Math.floor(parseInt(fgColor.substring(0,2),16)*Math.abs(iteration-index)/iteration +
		parseInt(bgColor.substring(0,2),16)*(iteration-Math.abs(iteration-index))/iteration)).toString(16);
	var newG = (Math.floor(parseInt(fgColor.substring(2,4),16)*Math.abs(iteration-index)/iteration +
		parseInt(bgColor.substring(2,4),16)*(iteration-Math.abs(iteration-index))/iteration)).toString(16);
	var newB = (Math.floor(parseInt(fgColor.substring(4,6),16)*Math.abs(iteration-index)/iteration +
		parseInt(bgColor.substring(4,6),16)*(iteration-Math.abs(iteration-index))/iteration)).toString(16);
	if (newR.length == 1) newR = "0" + newR;
	if (newG.length == 1) newG = "0" + newG;
	if (newB.length == 1) newB = "0" + newB;
	document.getElementById("welcome").style.color = "#" + newR + newG + newB;
		if (index < iteration)
		document.getElementById("welcome").style.letterSpacing = index*spacingUnit + "px";
	else
		document.getElementById("welcome").style.letterSpacing = (iteration*2-index-1)*spacingUnit + "px";
	if (index == 0) tInc *= 20;
	if (index == 16) tInc *= 5;
	index++;
	setTimeout(function(){welcome(index);}, tInc);
}