function DelConfirm(fmdel){
	return confirm("確定刪除？");
}
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 CkFloat(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;
		}
	}
}
function CkPhoto(text){
	extname=GetExtName(text);
	if(!(extname=="jpg" || extname=="jpeg" || extname=="gif")){
		alert("相片格式錯誤！\n僅接受\"JPG\"或\"GIF\"檔案格式！");
		return false;
	}		
	return true;
}
function CkZip(text){
	extname=GetExtName(text);
	if(!(extname=="zip" || extname=="rar")){
		alert("檔案格式錯誤！\n僅接受\"zip\"或\"rar\"之壓縮檔格式！");
		return false;
	}		
	return true;
}
function GetExtName(text){
	var extname='';
	var pointno=text.value.lastIndexOf('.');
	var len=text.value.length;
	for(i=pointno+1;i<len;i++){
		extname=extname + text.value.charAt(i);
	}
	extname=extname.toLowerCase();
	return extname;
}
function CkFileName(text){
	filename=GetFileName(text);
	var tomatch=filename.match(/[^A-Za-z0-9_-]/g);
	if(tomatch)
	{
		alert("上傳檔案檔名必需為英文字母、數字或底線，\n不可使用中文或包含特殊符號。!!");
		return false;
	}
	return true;
}
function GetFileName(text){
	var filename='';	//相片檔名
	var pointno1=text.value.lastIndexOf('\\');
	var pointno2=text.value.lastIndexOf('.');
	for(i=pointno1+1;i<pointno2;i++){
		filename=filename + text.value.charAt(i);
	}
	return filename;
}
function IsReadyMemLogin(form){
	if(form.loginname.value==''){
		alert("請輸入帳號。");
		form.loginname.focus();
		return false;
	}
	if(form.pass_word.value==''){
		alert("請輸入密碼");
		form.pass_word.focus();
		return false;
	}
}

function IsReadyMember(form){
	if(form.username.value==''){
		alert("請輸入使用者帳號！！");
		form.username.focus();
		return false;
	}
	if(form.pass_word.value==''){
		alert("請輸入使用者密碼！！");
		form.pass_word.focus();
		return false;
	}
	if(form.pass_word2.value==''){
		alert("請輸入確認密碼！！");
		form.pass_word2.focus();
		return false;
	}
	if(form.pass_word.value!='' || form.pass_word2.value!=''){
		if(form.pass_word.value!=form.pass_word2.value){
			alert("使用者密碼與確認密碼不符合，請重新輸入！！");
			form.pass_word.focus();
			form.pass_word.select();
			return false;
		}
	}
	if(form.realname.value==''){
		alert("請輸入姓名！！");
		form.realname.focus();
		return false;
	}
	if(form.tel_no.value=='' && form.mobile.value==''){
		alert("聯絡電話及行動電話請至少填寫一項！！");
		form.tel_no.focus();
		return false;
	}
	if(form.e_mail.value==''){
		alert("請輸入E-Mail信箱！！");
		form.e_mail.focus();
		return false;
	}
	if(form.zip_code.value==''){
		alert("請選擇郵遞區號！！");
		form.zip_code.focus();
		return false;
	}
	if(form.address.value==''){
		alert("請輸入聯絡地址！！");
		form.address.focus();
		return false;
	}
	if(form.tree_house_name.value==''){
		alert("請輸入我的樹屋名稱！！");
		form.tree_house_name.focus();
		return false;
	}
	for($kk=0; $kk<1; $kk++){
		if(eval('form.uppic_' + $kk).value!=''){
			var text=eval('form.uppic_' + $kk);
			if(!CkFileName(text)){
				text.focus();
				text.select();
				return false;
			}
			if(!CkPhoto(text)){
				text.focus();
				text.select();
				return false;
			}
		}
	}
}
function IsReadyMemberEdit(form){
	if(form.tel_no.value=='' && form.mobile.value==''){
		alert("聯絡電話及行動電話請至少填寫一項！！");
		form.tel_no.focus();
		return false;
	}
	if(form.e_mail.value==''){
		alert("請輸入E-Mail信箱！！");
		form.e_mail.focus();
		return false;
	}
	if(form.zip_code.value==''){
		alert("請選擇地址郵遞區號！！");
		form.zip_code.focus();
		return false;
	}
	if(form.address.value==''){
		alert("請輸入聯絡地址！！");
		form.address.focus();
		return false;
	}
	if(form.tree_house_name.value==''){
		alert("請輸入我的樹屋名稱！！");
		form.tree_house_name.focus();
		return false;
	}
	for($kk=0; $kk<1; $kk++){
		if(eval('form.uppic_' + $kk).value!=''){
			var text=eval('form.uppic_' + $kk);
			if(!CkFileName(text)){
				text.focus();
				text.select();
				return false;
			}
			if(!CkPhoto(text)){
				text.focus();
				text.select();
				return false;
			}
		}
	}
}

function IsReadyPassword(form){
	if(form.username.value==''){
		alert("請輸入使用者帳號！！");
		form.username.focus();
		return false;
	}
	if(form.pass_word_old.value==''){
		alert("請輸入使用者舊密碼！！");
		form.pass_word_old.focus();
		return false;
	}
	if(form.pass_word.value==''){
		alert("請輸入使用者新密碼！！");
		form.pass_word.focus();
		return false;
	}
	if(form.pass_word2.value==''){
		alert("請輸入確認新密碼！！");
		form.pass_word2.focus();
		return false;
	}
	if(form.pass_word.value!='' || form.pass_word2.value!=''){
		if(form.pass_word.value!=form.pass_word2.value){
			alert("使用者新密碼與確認新密碼不符合，請重新輸入！！");
			form.pass_word.focus();
			form.pass_word.select();
			return false;
		}
	}
}
function IsReadyForgetPW(form){
	if(form.username.value==''){
		alert("請輸入帳號。");
		form.username.focus();
		return false;
	}
	if(form.e_mail.value==''){
		alert("請輸入申請加入會員時所填寫的信箱。");
		form.e_mail.focus();
		return false;
	}
}
function CkUserNamePw(text){
	if(text.value!='' && text.value.length<6){
		alert("帳號與密碼必須為6 至 20 個字元的英文字母、數字、橫線或底線，英文字母區分大小寫！！");
		text.focus();
		text.select();
		return false;
	}
}
function CkUserName(id,username,userkind) { 
	if(CkUserNamePw(username) != false && CkNumAlphaUnder(username) != false && username.value != ''){
		OpenPage('../lib/ckusername.php?id=' + id + '&username=' + username.value + '&userkind=' + userkind,'ckusername','280','250','no','no');
	}
}


//跳出視窗定位
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);
}
//跳出視窗定位，完整
function OpenPage_Full(topage,pagename,w,h,directories,location,menubar,resizable,scrollbars,staus,toolbar) { 
	x = (screen.width - w)/2;
	y = (screen.height - h)/2;
	window.open(topage,pagename,'left=' + x + ',top=' + y + ',width=' + w + ',height=' + h + ',directories=' + directories + ',location=' + location + ',menubar=' + menubar + ',resizable=' + resizable + ',scrollbars=' + scrollbars + ',staus=' + staus + ',toolbar=' + toolbar);
}

//-- Start 編輯我的樹屋圖片資料 --------------------------------------------------------------
function IsReadyArray(form){
	if(form.array_no.value==''){
		alert("請輸入顯示順序！！");
		form.array_no.focus();
		return false;
	}
}

function SetOpenNews(id,topage,open_news,direct) { 
	switch(direct){
		case 'open_news':
			location.href='park_my_tree_edit_list.php?id=' + id + '&topage=' + topage + '&open_news=' + open_news;
			break;
	}
}

function IsReadyMyTree(form){
	if(form.subject.value==''){
		alert("請輸入標題！！");
		form.subject.focus();
		return false;
	}
	for($kk=0; $kk<1; $kk++){
		if(eval('form.uppic_' + $kk).value!=''){
			var text=eval('form.uppic_' + $kk);
			if(!CkFileName(text)){
				text.focus();
				text.select();
				return false;
			}
			if(!CkPhoto(text)){
				text.focus();
				text.select();
				return false;
			}
		}
	}
}
//-- End 編輯我的樹屋圖片資料 --------------------------------------------------------------