function Check(reg, str){
	if( reg.test(str)){
		return true;
	}
	return false;
}

function CheckMobile(str) {
	var regMobile = /^\d{8,11,12}$/;
	return Check(regMobile, str );
}


function CheckZip(str) {
	var reg = /^\d{6}$/;
	return Check( reg, str );
}

function CheckEmail(str){
	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	return Check( reg, str );
}

function Checkradio(str) {
	if(str[0].checked==true){
		return true;
	}
}

function validate(theform) {

	if (theform.username.value==""){
		alert("姓名不能为空");
		theform.username.focus();
		return false;
	}
	
	if (theform.sitename.value==""){
		alert("网站名称不能为空");
		theform.sitename.focus();
		return false;
	}
	
	if (theform.siteurl.value==""){
		alert("网站地址不能为空");
		theform.siteurl.focus();
		return false;
	}
	
	if (theform.email.value == "" || !CheckEmail(theform.email.value)) {
		alert("E-Mail 为空或不合法");
		theform.email.focus();
		return false;
	}
	if (theform.qq.value == "" ) {
		alert("MSN 或 QQ 不能为空");
		theform.qq.focus();
		return false;
	}

	if ( theform.mobile.value==""){
		alert("电话号码为空或不合法!");
		theform.mobile.focus();
		return false;
	}
	if ( theform.address.value==""){
		alert("通信地址不能为空!");
		theform.address.focus();
		return false;
	}
	if ( theform.zipcode.value=="" || !CheckZip(theform.zipcode.value)){
		alert("邮政编码为空或者不合法!");
		theform.zipcode.focus();
		return false;
	}
	
	if ( theform.siteabout.value=="" && Checkradio(theform.join)){
		alert('网站简介不少于200字');
		theform.siteabout.focus();
		return false;
	}
	
	if ( theform.siteword.value=="" && Checkradio(theform.join)){
		alert("建站感言不少于200字!");
		theform.siteword.focus();
		return false;
	}
}
function $(id) {
	return document.getElementById(id);
}

function joingame(stats) {
	var dp = $('siteinfo').style;
	if(stats == 'on') {
		dp.display = '' ;
	} else if(stats == 'off') {
		dp.display = 'none' ;
	}
}
