function CkNumAlpha(text){
	var tomatch=text.value.match(/[^A-Za-z0-9]/g);	
	if(text.value!='')
	{		
		if(tomatch)
		{
			alert("必需輸入英文字母及數字!!");
			text.focus();
			text.select();
			return false;
		}
	}
}
function CkNumAlphaUnder(text){
	var tomatch=text.value.match(/[^A-Za-z0-9_\-]/g);
	if(text.value!=''){		
		if(tomatch)	{
			alert("必需輸入英文字母、數字、橫線或底線，區分大小寫!!");
			text.focus();
			text.select();
			return false;
		}
	}
}

function CkNum(text){
	var tomatch=text.value.match(/[^0-9]/g);	
	if(text.value!='')
	{		
		if(tomatch)
		{
			alert("必需輸入數字!!");
			text.focus();
			text.select();
			return false;
		}
	}
}
function CkMail(mail)
{
	var tomatch=/[A-Za-z0-9_\-\.]+@([0-9a-z][a-z0-9_\-\.]+)(\.)[A-Za-z\.]{2,}/;	
	if(mail.value!='')
	{		
		if(!tomatch.test(mail.value))
		{
			alert("E-mail 格式填寫錯誤 !!");
			mail.focus();
			mail.select();
			return false;
		}
	}
}
//訂閱/取消訂閱電子報
//傳入參數：cancel_subscribe 訂閱或取消訂閱，0 訂閱 1 取消訂閱
function IsReadyEpaperSubscriber(form, cancel_subscribe){
	var flg =false;
	
	//訂閱電子報需填寫資料
	if(cancel_subscribe=='0'){
		if(form.realname.value==''){
			alert("請輸入姓名！！");
			form.realname.focus();
			flg =true;
			return false;
		}
		if(form.job.value==''){
			alert("請輸入職業別！！");
			form.job.focus();
			flg =true;
			return false;
		}
		if(form.edu.value==''){
			alert("請輸入學歷！！");
			form.edu.focus();
			flg =true;
			return false;
		}
		if(form.country[1].checked){
			if(form.oversea.value==''){
				alert("請輸入海外地區名稱！！");
				form.oversea.focus();
				flg =true;
				return false;
			}
		}
	}
	
	if(form.e_mail.value==''){
		alert("請輸入E-Mail！！");
		form.e_mail.focus();
		flg =true;
		return false;
	}
	if(!flg){
		form.cancel_subscribe.value = cancel_subscribe;
		form.submit();
	}
}


//跳出視窗定位
function OpenPage(topage,pagename,w,h,bar,resize) { 
	x = (screen.width - w)/2;
	y = (screen.height - h)/2;
	window.open(topage,pagename,'left='+x+',top='+y+',width='+w+',height='+h+',scrollbars='+bar+',resizable='+resize);
}
