// JavaScript Document
function getMsgModule() {
	div = document.getElementById('rest_mem_content');
	divID = 'rest_mem_content';
	var sUrl='classes/func.rest_mem_reg.php';
	var postdata = 'regmessage=1';
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('rest_mem_content').innerHTML='<img src=images_icon/loading.gif>';
}

//自助廣告開始
function getAdMsg(adtype) {
	div = document.getElementById('ad_content');
	divID = 'ad_content';
	adname='自助廣告刊登';
	var sUrl='classes/func.ad_website.php';
	var postdata = 'regmessage=1';
	postdata += '&adtype=' + adtype;
	postdata += '&adname=' + adname;
	postdata += '&b2bmno=' + document.getElementById('b2bmno');
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('ad_content').innerHTML='<img src=images_icon/loading.gif>';
}

function sendAdMsg(){
	div = document.getElementById('showmessage');
	divID = 'showmessage';
	var sUrl='classes/func.ad_website.php';
	var postdata = 'regmessage=2';
	postdata += '&company=' + document.getElementById('company').value;
	postdata += '&cname=' + document.getElementById('cname').value;
	postdata += '&adname=' + document.getElementById('adname').value;
	postdata += '&selectday=' + document.getElementById('selectday').value;
	postdata += '&tel=' + document.getElementById('tel').value;
	postdata += '&mobile=' + document.getElementById('mobile').value;
	postdata += '&fax=' + document.getElementById('fax').value;
	postdata += '&email=' + document.getElementById('email').value;
	postdata += '&b2bmno=' + document.getElementById('b2bmno').value;
	postdata += '&syscode=' + document.getElementById('syscode').value;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('showmessage').innerHTML='<img src=images_icon/loading.gif>';
	
	regularExpression = /^[^\s]+@[^\s]+\.[^\s]{2,3}$/;
	if(document.getElementById('company').value!= '' && document.getElementById('cname').value != '' && (document.getElementById('tel').value != '') && document.getElementById('email').value!='' && regularExpression.test(document.getElementById('email').value) && document.getElementById('syscode').value != ''){
		document.getElementById('company').value=='';
		document.getElementById('cname').value=='';
		document.getElementById('tel').value=='';
		document.getElementById('mobile').value=='';
		document.getElementById('fax').value=='';
		document.getElementById('email').value=='';
		document.getElementById('syscode').value=='';
		alert('刊登廣告方案送出中！請勿按任何鍵！\n我們將有專人於二天個工作天內(不含假日)與你連絡！');
		window.open('index.php','_self');
	}
}
function selfad_check_data(){
	if(sendad.name.value=='' || sendad.name.value.length < 5){
		alert("請輸入餐廳名稱");
		event.returnValue=false;
	}
	if(sendad.tel.value=='' || sendad.tel.value.length < 5){
		alert("請輸入電話");
		event.returnValue=false;
	}
	if(sendad.addr.value=='' || sendad.addr.value.length < 5){
		alert("請輸入地址");
		event.returnValue=false;
	}
	if(sendad.hours.value=='' || sendad.hours.value.length < 5){
		alert("請輸入營業時間");
		event.returnValue=false;
	}
	if(sendad.title.value=='' || sendad.title.value.length < 5){
		alert("請輸入招攬口號");
		event.returnValue=false;
	}
	if(sendad.intro.value=='' || sendad.intro.value.length < 5){
		alert("請輸入餐廳介紹");
		event.returnValue=false;
	}
}

//自助廣告結束

function RecInfo(sametype, modifytype){
	switch (sametype){
		case 1:
			document.getElementById('contact').value=document.getElementById('charge').value;
			document.getElementById('ctel').value=document.getElementById('tel').value;
			if(modifytype==''){
				document.getElementById('cgender').value=document.getElementById('gender').value;
			}
		break;
		case 2:
			document.getElementById('rcname').value=document.getElementById('company').value;
		break;
		case 3:
			document.getElementById('rcontact').value=document.getElementById('contact').value;
			document.getElementById('rgender').value=document.getElementById('cgender').value;
		break;
		case 4:
			document.getElementById('rtel').value=document.getElementById('tel').value;
		break;
		case 5:
			document.getElementById('rcity').value=document.getElementById('city').value;
			document.getElementById('radd').value=document.getElementById('addr').value;
		break;
		default:
	}
}



var countMin = 0; 
var countMax = 30; 
var count = 0; 
function addField() {
	if(count == countMax) { 
		alert("最多"+countMax+"個分店資料，如有更多分店資料需新增，請電洽「英卓美食網」"); 
	} else { 
		//新增分店名稱
		var myText = document.createTextNode(count+1+") =======================================================");
		var font = document.createElement("font");	
		font.style.color = "#990000";
		font.appendChild(myText);
		document.getElementById("fieldSpace").appendChild(font);

		var div_oname = document.createElement("div");
		var input_oname = document.createElement("input"); 
		input_oname.setAttribute("type", "text"); 
		input_oname.setAttribute("name", "oname["+(count+1)+"]");
		input_oname.setAttribute("id", "oname["+(count+1)+"]");
		input_oname.setAttribute("size", 25);
		input_oname.setAttribute("maxlength", 50);
		input_oname.setAttribute("className", "inputform");
		var space_oname = document.createTextNode("分店名稱：");
		div_oname.appendChild(space_oname);
		div_oname.appendChild(input_oname);
		document.getElementById("fieldSpace").appendChild(div_oname);
		//新增聯絡人姓名
		var div_ocontact = document.createElement("div");
		var input_ocontact = document.createElement("input");
		input_ocontact.setAttribute("type","text");
		input_ocontact.setAttribute("name","ocontact["+(count+1)+"]");
		input_ocontact.setAttribute("id","ocontact["+(count+1)+"]");
		input_ocontact.setAttribute("size", 25);
		input_ocontact.setAttribute("maxlength", 20);
		input_ocontact.setAttribute("className", "inputform");
		var select_ocontact = document.createElement("select");
		select_ocontact.setAttribute("name", "ogender["+(count+1)+"]");
		select_ocontact.setAttribute("id", "ogender["+(count+1)+"]");
		select_ocontact.setAttribute("className", "inputform");
		select_ocontact.options.add(new Option("先生","先生"));
		select_ocontact.options.add(new Option("小姐","小姐"));	
		var space_ocontact = document.createTextNode("聯絡人姓名：");
		div_ocontact.appendChild(space_ocontact);
		div_ocontact.appendChild(input_ocontact);
		div_ocontact.appendChild(select_ocontact);
		document.getElementById("fieldSpace").appendChild(div_ocontact);
		//新增電話
		var div_otel = document.createElement("div");
		var input_otel = document.createElement("input");
		input_otel.setAttribute("type","text");
		input_otel.setAttribute("name","otel["+(count+1)+"]");
		input_otel.setAttribute("id","otel["+(count+1)+"]");
		input_otel.setAttribute("size", 25);
		input_otel.setAttribute("className", "inputform");
		var space_otel = document.createTextNode("電話：");
		div_otel.appendChild(space_otel);
		div_otel.appendChild(input_otel);
		document.getElementById("fieldSpace").appendChild(div_otel);
		//新增地址
		var div_oadd = document.createElement("div");
		var input_oadd = document.createElement("input");
		input_oadd.setAttribute("type","text");
		input_oadd.setAttribute("name","oadd["+(count+1)+"]");
		input_oadd.setAttribute("id","oadd["+(count+1)+"]");
		input_oadd.setAttribute("size", 45);
		input_oadd.setAttribute("maxlength", 255);
		input_oadd.setAttribute("className", "inputform");
		var select_ocity = document.createElement("select");
		select_ocity.setAttribute("name", "ocity["+(count+1)+"]");
		select_ocity.setAttribute("id", "ocity["+(count+1)+"]");
		select_ocity.setAttribute("className", "inputform");
		select_ocity.options.add(new Option("請選擇縣市","0"));
		select_ocity.options.add(new Option("基隆市","基隆市"));
		select_ocity.options.add(new Option("台北市","台北市"));
		select_ocity.options.add(new Option("台北縣","台北縣"));
		select_ocity.options.add(new Option("桃園縣","桃園縣"));
		select_ocity.options.add(new Option("新竹市","新竹市"));
		select_ocity.options.add(new Option("新竹縣","新竹縣"));
		select_ocity.options.add(new Option("苗栗縣","苗栗縣"));
		select_ocity.options.add(new Option("台中市","台中市"));
		select_ocity.options.add(new Option("台中縣","台中縣"));
		select_ocity.options.add(new Option("彰化縣","彰化縣"));
		select_ocity.options.add(new Option("南投縣","南投縣"));
		select_ocity.options.add(new Option("雲林縣","雲林縣"));
		select_ocity.options.add(new Option("嘉義市","嘉義市"));
		select_ocity.options.add(new Option("嘉義縣","嘉義縣"));
		select_ocity.options.add(new Option("台南市","台南市"));
		select_ocity.options.add(new Option("台南縣","台南縣"));
		select_ocity.options.add(new Option("高雄市","高雄市"));
		select_ocity.options.add(new Option("高雄縣","高雄縣"));
		select_ocity.options.add(new Option("屏東縣","屏東縣"));
		select_ocity.options.add(new Option("台東縣","台東縣"));
		select_ocity.options.add(new Option("花蓮縣","花蓮縣"));
		select_ocity.options.add(new Option("宜蘭縣","宜蘭縣"));
		select_ocity.options.add(new Option("澎湖縣","澎湖縣"));
		select_ocity.options.add(new Option("金門縣","金門縣"));
		select_ocity.options.add(new Option("連江縣","連江縣"));
		var space_oadd = document.createTextNode("地址：");
		div_oadd.appendChild(space_oadd);
		div_oadd.appendChild(select_ocity);
		div_oadd.appendChild(input_oadd);
		document.getElementById("fieldSpace").appendChild(div_oadd);
		var div_s = document.createElement("div");
		var space_s = document.createTextNode("　");
		div_s.appendChild(space_s);
		document.getElementById("fieldSpace").appendChild(div_s);
		count++;
		document.getElementById('countr').value=count;
	}
	
} 
function delField() { 
	if (count > countMin) { 
		for (var i=1;i<=6;i++){
			var fs = document.getElementById("fieldSpace"); 
			fs.removeChild(fs.lastChild); 
		}
		count--;
		document.getElementById('countr').value=count;
	} else { 
		alert("無新增分店資料可以刪除"); 
	}	 
} 



function checkMemData(type) {
	div = document.getElementById('showmessage');
	divID = 'showmessage';
	var sUrl='classes/func.rest_mem_reg.php';
	var postdata = 'regmessage=2';
	postdata += '&restmtype=' + type;
	postdata += '&charge=' + document.getElementById('charge').value;
	postdata += '&addr=' + document.getElementById('addr').value;
	postdata += '&tel=' + document.getElementById('tel').value;
	postdata += '&tel2=' + document.getElementById('tel2').value;
	postdata += '&fax=' + document.getElementById('fax').value;
	postdata += '&website=' + document.getElementById('website').value;
	postdata += '&passwd=' + document.getElementById('passwd').value;
	postdata += '&rpasswd=' + document.getElementById('rpasswd').value;
	postdata += '&contact=' + document.getElementById('contact').value;
	postdata += '&ctel=' + document.getElementById('ctel').value;
	postdata += '&mobile=' + document.getElementById('mobile').value;
	postdata += '&email=' + document.getElementById('email').value;
	postdata += '&selectday=' + document.getElementById('selectday').value;
	
	if(type==1){
		postdata += '&company=' + document.getElementById('company').value;
		postdata += '&account=' + document.getElementById('account').value;
		postdata += '&cursic=' + document.getElementById('cursic').value;
		postdata += '&rcname=' + document.getElementById('rcname').value;
		postdata += '&rename=' + document.getElementById('rename').value;
		postdata += '&rcontact=' + document.getElementById('rcontact').value;
		postdata += '&rgender=' + document.getElementById('rgender').value;
		postdata += '&rtel=' + document.getElementById('rtel').value;
		postdata += '&rcity=' + document.getElementById('rcity').value;
		postdata += '&radd=' + document.getElementById('radd').value;
		postdata += '&syscode=' + document.getElementById('syscode').value;		
		postdata += '&gender=' + document.getElementById('gender').value;
		postdata += '&city=' + document.getElementById('city').value;
		postdata += '&cgender=' + document.getElementById('cgender').value;
		
	
		var countr=document.getElementById('countr').value;
		if(countr > 0){
			postdata += '&countr=' + countr;
			var oname_v = new Array();
			var ocontact_v = new Array();
			var ogender_v = new Array();
			var otel_v = new Array();
			var oadd_v = new Array();
			
			for(c=1; c<=count; c++){
				oname_v[c]=document.getElementById('oname['+c+']').value;
				ocontact_v[c]=document.getElementById('ocontact['+c+']').value;
				ogender_v[c]=document.getElementById('ogender['+c+']').value;
				otel_v[c]=document.getElementById('otel['+c+']').value;
				oadd_v[c]=document.getElementById('ocity['+c+']').value+document.getElementById('oadd['+c+']').value;
			}
			postdata += '&oname_v=' + oname_v;
			postdata += '&ocontact_v=' + ocontact_v;
			postdata += '&ogender_v=' + ogender_v;
			postdata += '&otel_v=' + otel_v;
			postdata += '&oadd_v=' + oadd_v;
		}
	}
	
	
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('showmessage').innerHTML='<img src=images_icon/loading.gif align=absmiddle><font color=green><b>資料傳送中，請勿按任何鍵！</b></font>';

	regularExpression = /^[^\s]+@[^\s]+\.[^\s]{2,3}$/;
	var checkp=0;
	
	if(type==1){
		if(document.getElementById('company').value!='' && document.getElementById('charge').value!='' && document.getElementById('addr').value!='' && document.getElementById('tel').value!='' && document.getElementById('account').value!='' && document.getElementById('passwd').value!='' && document.getElementById('rpasswd').value!='' && (document.getElementById('passwd').value==document.getElementById('rpasswd').value) && document.getElementById('contact').value!='' && document.getElementById('ctel').value!='' && (document.getElementById('rcname').value !='' || document.getElementById('rename').value!='') && document.getElementById('rcontact').value!='' && document.getElementById('radd').value!='' && document.getElementById('rtel').value !='' && document.getElementById('syscode').value!=''){
			if(document.getElementById('email').value != ''){
				if(!(regularExpression.test(document.getElementById('email').value))){
					checkp++;
				}
			}
			if(countr>0){
				for(c=1; c<=countr; c++){
					if(!(document.getElementById('oname['+c+']').value!='' && document.getElementById('otel['+c+']').value!='' && document.getElementById('oadd['+c+']').value!='')){
						checkp++;
					}
				}
			}
		} else {
			checkp++;
		}
		if(checkp==0){
			//document.getElementById('company').value='';
			//document.getElementById('charge').value='';
			//document.getElementById('addr').value='';
			//document.getElementById('tel').value='';
			//document.getElementById('account').value='';
			//document.getElementById('passwd').value='';
			//document.getElementById('rpasswd').value='';
			//document.getElementById('contact').value='';
			//document.getElementById('ctel').value='';
			//document.getElementById('rcname').value='';
			//document.getElementById('rename').value='';
			//document.getElementById('rcontact').value='';
			//document.getElementById('radd').value='';
			//document.getElementById('rtel').value='';
			//document.getElementById('syscode').value='';
			alert('感謝您的加入，我們將於二天工作天審核您的資料\n並以Email通知您登入系統！');
			//window.open('rest_mem_reg.php','_self');
		} else {
			alert('資料填寫不正確，請確認！');
		}
	} else if(type==2){
		if(document.getElementById('charge').value!='' && document.getElementById('addr').value!='' && document.getElementById('tel').value!='' && document.getElementById('passwd').value!='' && document.getElementById('rpasswd').value!='' && (document.getElementById('passwd').value==document.getElementById('rpasswd').value) && document.getElementById('contact').value!='' && document.getElementById('ctel').value!=''){
			if(document.getElementById('email').value != ''){
				if(!(regularExpression.test(document.getElementById('email').value))){
					checkp++;
				}
			}
		} else {
			checkp++;
		}
		if(checkp==0){
			alert('基本資料修改完成！\n如您有修改密碼，請重新登錄！');
			window.open('rest_mem_reg.php','_self');
		} else {
			alert('資料填寫不正確，請確認！');
		}
	}
}

function checkaccount() {	//check account & passwd
	div = document.getElementById('accountmsg');
	divID = 'accountmsg';
	var sUrl='classes/func.rest_mem_reg.php';
	var postdata = 'regmessage=3&account=' + document.getElementById('account').value;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('accountmsg').innerHTML='<img src=images_icon/loading.gif>';
	
}

function checkpasswd(type) {	//check account & passwd
	div = document.getElementById('accountmsg');
	divID = 'accountmsg';
	var sUrl='classes/func.rest_mem_reg.php';
	var postdata = 'regmessage=4&passwd=' + document.getElementById('passwd').value;
	postdata += '&rpasswd=' + document.getElementById('rpasswd').value;
	postdata += '&type=' + type;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('accountmsg').innerHTML='<img src=images_icon/loading.gif>';
	if(type==1){
		if(document.getElementById('passwd').value == document.getElementById('rpasswd').value){
			alert('密碼修改完成！請重新登入會員！');
			window.open('mem_reg.php','_self');
		}
	}
}

function checkcoupon(type) {	//check coupon
	if(type==1){
		var coupon_rno = new Array();
		countr=document.getElementById('rbccount').value;
		for(i=0,countt=0; i<countr; i++){
			if(document.getElementById('couponcheck['+i+']').checked==true){
				coupon_rno[countt]=document.getElementById('couponcheck['+i+']').value;
				countt++;
			}
		}
		if(countt==0){
			alert('您未選取任何參與優惠券活動餐廳！');
		} else {
			div = document.getElementById('couponmsg');
			divID = 'couponmsg';
			var sUrl='classes/func.rest_mem_reg.php';
			var postdata = 'regmessage=5';
			postdata += '&couponmtype=' + type;
			postdata += '&nmno=' + document.getElementById('nmno').value;
			postdata += '&rbccount=' + countt;
			postdata += '&couponcheck=' + coupon_rno;
			postdata += '&ncontent=' + document.getElementById('ncontent').value;
			postdata += '&ny1=' + document.getElementById('ny1').value;
			//postdata += '&nm1=' + document.getElementById('nm1').value;
			//postdata += '&nd1=' + document.getElementById('nd1').value;
			//ostdata += '&ny2=' + document.getElementById('ny2').value;
			//postdata += '&nm2=' + document.getElementById('nm2').value;
			//postdata += '&nd2=' + document.getElementById('nd2').value;
			postdata += '&nremark=' + document.getElementById('nremark').value;
			var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
			document.getElementById('couponmsg').innerHTML='<img src=images_icon/loading.gif>';
			if(document.getElementById('ncontent').value !=''){
				alert('感謝您的加入餐廳優惠券行列\n於二個工作天內將有專人與您處理簽約事宜！');
				window.open('rest_mem_reg.php','_self');
			}
		}
	} else if(type==2){
		div = document.getElementById('couponmsg');
		divID = 'couponmsg';
		var sUrl='classes/func.rest_mem_reg.php';
		var postdata = 'regmessage=5';
		postdata += '&couponmtype=' + type;
		postdata += '&ncpno=' + document.getElementById('ncpno').value;
		postdata += '&nrno=' + document.getElementById('nrno').value;
		postdata += '&naddr=' + document.getElementById('naddr').value;
		postdata += '&ntel=' + document.getElementById('ntel').value;
		postdata += '&nrname=' + document.getElementById('nrname').value;
		postdata += '&ncontent=' + document.getElementById('ncontent').value;
		postdata += '&ny1=' + document.getElementById('ny1').value;
		postdata += '&nm1=' + document.getElementById('nm1').value;
		postdata += '&nd1=' + document.getElementById('nd1').value;
		postdata += '&ny2=' + document.getElementById('ny2').value;
		postdata += '&nm2=' + document.getElementById('nm2').value;
		postdata += '&nd2=' + document.getElementById('nd2').value;
		postdata += '&nremark=' + document.getElementById('nremark').value;
		var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
		document.getElementById('couponmsg').innerHTML='<img src=images_icon/loading.gif>';
		if(document.getElementById('ncontent').value !=''){
			alert('於二個工作天內將有專人處理！');
			window.open('rest_mem_reg.php','_self');
		}
	}
}

function checkRestData(type) {
	if(type==1){
		div = document.getElementById('uprestmsg');
		divID = 'uprestmsg';
		var sUrl='classes/func.rest_mem_reg.php';
		var postdata = 'regmessage=6';
		postdata += '&upresttype=' + type;
		postdata += '&ncursic=' + document.getElementById('ncursic').value;
		postdata += '&ncname=' + document.getElementById('ncname').value;
		postdata += '&nename=' + document.getElementById('nename').value;
		postdata += '&naddr=' + document.getElementById('naddr').value;
		postdata += '&ntel=' + document.getElementById('ntel').value;
		postdata += '&ntel2=' + document.getElementById('ntel2').value;
		postdata += '&nhour=' + document.getElementById('nhour').value;
		postdata += '&nparking=' + document.getElementById('nparking').value;
		postdata += '&ncontact=' + document.getElementById('ncontact').value;
		postdata += '&nemail=' + document.getElementById('nemail').value;
		postdata += '&nmno=' + document.getElementById('nmno').value;
		postdata += '&nrno=' + document.getElementById('nrno').value;
		var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
		document.getElementById('uprestmsg').innerHTML='<img src=images_icon/loading.gif>';
		regularExpression = /^[^\s]+@[^\s]+\.[^\s]{2,3}$/;
		if(!(document.getElementById('ncname').value=='' && document.getElementById('nename').value=='')&& document.getElementById('naddr').value!='' && !(document.getElementById('ntel').value=='' && document.getElementById('ntel2').value == '') ){
			if(document.getElementById('nemail').value !=''){
				if(regularExpression.test(document.getElementById('nemail').value)){
					alert('修改完成！');
					window.open('rest_mem_reg.php','_self');
				}
			} else {
				alert('修改完成！');
				window.open('rest_mem_reg.php','_self');
			}
		}
	}
}

function checkRestState(type) {
	div = document.getElementById('statemsg');
	divID = 'statemsg';
	var sUrl='classes/func.rest_mem_reg.php';
	var postdata = 'regmessage=7';
	postdata += '&nmno=' + document.getElementById('nmno').value;
	postdata += '&nrno=' + document.getElementById('nrno').value;
	postdata += '&nrname=' + document.getElementById('nrname').value;
	postdata += '&ntel=' + document.getElementById('ntel').value;
	postdata += '&naddr=' + document.getElementById('naddr').value;
	postdata += '&nreason=' + document.getElementById('nreason').value;
	postdata += '&nremark=' + document.getElementById('nremark').value;
	postdata += '&ncontact=' + document.getElementById('ncontact').value;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('statemsg').innerHTML='<img src=images_icon/loading.gif>';
	alert('英卓美食網於1至2天工作天\n由專人確認更改完成！')
	window.open('rest_mem_reg.php','_self');
}

function checkNewRest(type) {
	div = document.getElementById('showmessage');
	divID = 'showmessage';
	var sUrl='classes/func.rest_mem_reg.php';
	var postdata = 'regmessage=8';
	postdata += '&nmno=' + document.getElementById('nmno').value;
	postdata += '&cursic=' + document.getElementById('cursic').value;
	postdata += '&rcname=' + document.getElementById('rcname').value;
	postdata += '&rename=' + document.getElementById('rename').value;
	postdata += '&rcontact=' + document.getElementById('rcontact').value;
	postdata += '&rgender=' + document.getElementById('rgender').value;
	postdata += '&rcity=' + document.getElementById('rcity').value;
	postdata += '&radd=' + document.getElementById('radd').value;
	postdata += '&rtel=' + document.getElementById('rtel').value;
	postdata += '&ncompany=' + document.getElementById('ncompany').value;
	
	var countr=document.getElementById('countr').value;
	if(countr > 0){
		postdata += '&countr=' + countr;
		var oname_v = new Array();
		var ocontact_v = new Array();
		var ogender_v = new Array();
		var otel_v = new Array();
		var oadd_v = new Array();
		
		for(c=1; c<=count; c++){
			oname_v[c]=document.getElementById('oname['+c+']').value;
			ocontact_v[c]=document.getElementById('ocontact['+c+']').value;
			ogender_v[c]=document.getElementById('ogender['+c+']').value;
			otel_v[c]=document.getElementById('otel['+c+']').value;
			oadd_v[c]=document.getElementById('ocity['+c+']').value+document.getElementById('oadd['+c+']').value;
		}
		postdata += '&oname_v=' + oname_v;
		postdata += '&ocontact_v=' + ocontact_v;
		postdata += '&ogender_v=' + ogender_v;
		postdata += '&otel_v=' + otel_v;
		postdata += '&oadd_v=' + oadd_v;
	}
	
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('showmessage').innerHTML='<img src=images_icon/loading.gif>';
	
	var checkp=0;
	
	if(!(document.getElementById('rcname').value=='' && document.getElementById('rename').value=='') && document.getElementById('rcontact').value!='' && document.getElementById('radd').value!='' && document.getElementById('rtel').value!=''){

		if(countr>0){
			for(c=1; c<=countr; c++){
				if(!(document.getElementById('oname['+c+']').value!='' && document.getElementById('otel['+c+']').value!='' && document.getElementById('oadd['+c+']').value!='')){
					checkp++;
				}
			}
		}
	} else {
		checkp++;
	}
	
	if(checkp==0){
		alert('新增餐廳資料已送出！');
		window.open('rest_mem_reg.php','_self');
	}
	
}

function checkService() {
	div = document.getElementById('showmessage');
	divID = 'showmessage';
	var sUrl='classes/func.rest_mem_reg.php';
	var postdata = 'regmessage=9';
	postdata += '&mno=' + document.getElementById('nmno').value;
	postdata += '&company=' + document.getElementById('company').value;
	postdata += '&tel=' + document.getElementById('tel').value;
	postdata += '&contact=' + document.getElementById('contact').value;
	postdata += '&email=' + document.getElementById('email').value;
	postdata += '&remark=' + document.getElementById('remark').value;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, { success:successHomeHandler, failure:failureHandler },postdata);
	document.getElementById('showmessage').innerHTML='<img src=images_icon/loading.gif>';
	regularExpression = /^[^\s]+@[^\s]+\.[^\s]{2,3}$/;
	if(document.getElementById('contact').value!='' && document.getElementById('email').value !='' && regularExpression.test(document.getElementById('email').value) && document.getElementById('remark').value !=''){
		alert('您的訊息已送出！');
		window.open('rest_mem_reg.php','_self');
	}
}