function chkRegUpdateMail(){errornum=0;var a=Trim($("form#updateMailForm #user_name").val());return""==a?(alert("請填寫電子郵件!"),errornum++,$("form#updateMailForm #user_name").focus(),!1):checkEmail(a)?void(errornum<=0&&$.ajax({type:"POST",url:"/ajax/customer_update_mail.php",data:$("form#updateMailForm").serialize(),dataType:"json",cache:!1,success:function(a){"true"==a.status?(parent.location.replace(a.reUrlAddress),closeFancyBox()):alert(a.msg)}})):(alert("電子郵件格式有誤,請重新填寫!"),errornum++,$("form#updateMailForm #user_name").focus(),!1)}function chkRegLogin(){errornum=0,$(".loginBtn").prop("disabled","true");var a=Trim($("form#loginForm #check_uname").val());return""==a?(alert("請填寫電子郵件!"),errornum++,$("form#loginForm #check_uname").focus(),$(".loginBtn").prop("disabled",""),!1):checkEmail(a)?""==$("form#loginForm #check_upw").val()?(alert("請填寫密碼!"),errornum++,$("form#loginForm #check_upw").focus(),$(".loginBtn").prop("disabled",""),!1):void(errornum<=0&&$.ajax({type:"POST",url:"/ajax/customer_login.php",data:$("form#loginForm").serialize(),dataType:"json",cache:!1,success:function(a){$(".loginBtn").prop("disabled",""),console.log("data['status']:::"+a.status),console.log("data['reUrlAddress']:::"+a.reUrlAddress),"true"==a.status?(parent.location.replace(a.reUrlAddress),closeFancyBox()):"write"==a.status?location.replace(a.link):alert(a.msg)}})):(alert("電子郵件格式有誤,請重新填寫!"),errornum++,$("form#loginForm #check_uname").focus(),$(".loginBtn").prop("disabled",""),!1)}function chkloginWrite(a){if($("form#writeForm #type").val(a),"Y"==a){if(errornum=0,""==$("form#writeForm #surname").val())return alert("請填寫姓氏!"),errornum++,$("form#writeForm #surname").focus(),!1;if(""==$("form#writeForm #first_name").val())return alert("請填寫名字!"),errornum++,$("form#writeForm #first_name").focus(),!1;if(""==$("form#writeForm #another_name").val())return alert("請填寫別稱!"),errornum++,$("form#writeForm #another_name").focus(),!1;if(""==$("form#writeForm #country_code").val())return alert("請填寫國碼!"),errornum++,$("form#writeForm #country_code").focus(),!1;if(""==$("form#writeForm #mobile").val())return alert("請填寫手機號碼!"),errornum++,$("form#writeForm #mobile").focus(),!1;if(""==$("form#writeForm #sex").val())return alert("請填寫性別!"),errornum++,$("form#writeForm #sex").focus(),!1;if(birthdayNone=$("form#writeForm #birth_y").val()+$("form#writeForm #birth_m").val()+$("form#writeForm #birth_d").val(),birthday=$("form#writeForm #birth_y").val()+"-"+$("form#writeForm #birth_m").val()+"-"+$("form#writeForm #birth_d").val(),""==birthdayNone)return alert("請填寫出生日期!"),$("form#writeForm #birth_y").focus(),!1;var b=birthday,c=/^\d{4}[-]\d{1,2}[-]\d{1,2}$/;if(!c.test(b))return alert("日期格式錯誤!"),!1;var d=b.match(/\d+/g),e=parseInt(d[0])+"/"+parseInt(d[1])+"/"+parseInt(d[2]),f=new Date(e);if(isNaN(f))return alert("日期格式錯誤!"),!1;var g=f.getFullYear()+"/"+(f.getMonth()+1)+"/"+f.getDate();if(g!=e)return alert("日期錯誤!"),!1;if(""==$("form#writeForm #country_list_id").val())return alert("請選擇國籍!"),errornum++,$("form#writeForm #country_list_id").focus(),!1;if(""==$("form#writeForm #residence").val())return alert("請填寫居住地"),errornum++,$("form#writeForm #residence").focus(),!1;errornum<=0&&$.ajax({type:"POST",url:"/ajax/customer_login_write.php",data:$("form#writeForm").serialize(),dataType:"json",cache:!1,success:function(a){"true"==a.status&&(alert(a.msg),parent.location.replace(a.reUrlAddress),closeFancyBox())}})}else"N"==a&&$.ajax({type:"POST",url:"/ajax/customer_login_write.php",data:$("form#writeForm").serialize(),dataType:"json",cache:!1,success:function(a){"true"==a.status&&(parent.location.replace(a.reUrlAddress),closeFancyBox())}})}function chkRegRegister(){errornum=0;var b=Trim($("form#sendForm #email").val());if(""==b)return alert("請填寫電子郵件!"),errornum++,$("form#sendForm #email").focus(),!1;if(!checkEmail(b))return alert("電子郵件格式有誤,請重新填寫!"),errornum++,$("form#sendForm #email").focus(),!1;if(userpw_data=Trim($("form#sendForm #user_pw").val()),userpw_rdata=$("form#sendForm #re_pw").val(),""==userpw_data)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),errornum++,$("form#sendForm #user_pw").focus(),!1;if(userpw_data.length<6)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),errornum++,$("form#sendForm #user_pw").focus(),!1;if(""!=userpw_data){if(a=userpw_data,date=userpw_data.match(/^(?=^.{6,}$)((?=.*[A-Za-z0-9])(?=.*[0-9])(?=.*[a-zA-Z]))^.*$/),null==date)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),errornum++,$("form#sendForm #user_pw").focus(),!1;if(userpw_data!=userpw_rdata)return alert("密碼不一致,請重新填寫!"),errornum++,$("form#sendForm #re_pw").focus(),!1}return""==$("form#sendForm #checkCode").val()?(alert("請填寫驗證碼!"),$("form#sendForm #checkCode").focus(),!1):void(errornum<=0&&$.ajax({type:"POST",url:"/ajax/customer_register.php",data:$("form#sendForm").serialize(),dataType:"json",cache:!1,success:function(a){"true"==a.status?(alert(a.msg),parent.window.location.reload(),closeFancyBox()):(reSIImage(),alert(a.msg))}}))}function chkRegForegt(){errornum=0;var a=Trim($("form#sendForm #email").val());return""==a?(alert("\u8acb\u586b\u5bebE-mail\uff01"),errornum++,$("form#sendForm #email").focus(),!1):checkEmail(a)?void(errornum<=0&&$.ajax({type:"POST",url:"/ajax/customer_foregt.php",data:$("form#sendForm").serialize(),dataType:"json",cache:!1,success:function(a){"true"==a.status?(alert(a.msg),parent.window.location.reload(),closeFancyBox()):alert(a.msg)}})):(alert("電子郵件格式有誤,請重新填寫!"),errornum++,$("form#sendForm #email").focus(),!1)}function chkRegForegtEmpty(){$("form#sendForm #email").val("")}function chkRegForegtReset(){var b=Trim($("form#sendForm #new_upw").val()),c=Trim($("form#sendForm #check_upw").val());if(""==b)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),$("form#sendForm #new_upw").focus(),!1;if(b.length<6)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),$("form#sendForm #new_upw").focus(),!1;if(""!=b){if(a=b,date=b.match(/^(?=^.{6,}$)((?=.*[A-Za-z0-9])(?=.*[0-9])(?=.*[a-zA-Z]))^.*$/),null==date)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),$("form#sendForm #new_upw").focus(),!1;if(b!=c)return alert("密碼不一致,請重新填寫!"),$("form#sendForm #check_upw").focus(),!1}}function chkRegProfile(){var b=Trim($("form#sendForm #pwcheck").val());if("Y"==b)var c=Trim($("form#sendForm #old_user_pw").val());{var d=Trim($("form#sendForm #n_upw").val());Trim($("form#sendForm #check_upw").val())}if(""==c&"Y"==b&&""==d)return alert("請填寫密碼!"),$("form#sendForm #n_upw").focus(),!1;if(""!=d){if("Y"==b&&""==$("form#sendForm #o_upw").val()&c.length>0)return alert("請填寫密碼!"),$("form#sendForm #o_upw").focus(),!1;if(d.length<6)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),$("form#sendForm #n_upw").focus(),!1;if(a=d,date=d.match(/^(?=^.{6,}$)((?=.*[A-Za-z0-9])(?=.*[0-9])(?=.*[a-zA-Z]))^.*$/),null==date)return alert("密碼為最低6個字元以上之英數位組合,\n至少必須有一個英文或數字,並請留意大小寫!"),$("form#sendForm #n_upw").focus(),!1;if($("form#sendForm #n_upw").val()!=$("form#sendForm #check_upw").val())return alert("密碼不一致,請重新填寫!"),$("form#sendForm #check_upw").focus(),!1}if(""==$("form#sendForm #surname").val())return alert("請填寫姓氏!"),$("form#sendForm #surname").focus(),!1;if(""==$("form#sendForm #first_name").val())return alert("請填寫名字!"),$("form#sendForm #first_name").focus(),!1;if(birthdayNone=$("form#sendForm #birth_y").val()+$("form#sendForm #birth_m").val()+$("form#sendForm #birth_d").val(),birthday=$("form#sendForm #birth_y").val()+"-"+$("form#sendForm #birth_m").val()+"-"+$("form#sendForm #birth_d").val(),""==birthdayNone)return alert("請填寫出生日期!"),$("form#sendForm #birth_y").focus(),!1;var f=birthday,g=/^\d{4}[-]\d{1,2}[-]\d{1,2}$/;if(!g.test(f))return alert("日期格式錯誤!"),!1;var h=f.match(/\d+/g),i=parseInt(h[0])+"/"+parseInt(h[1])+"/"+parseInt(h[2]),j=new Date(i);if(isNaN(j))return alert("日期格式錯誤!"),!1;var k=j.getFullYear()+"/"+(j.getMonth()+1)+"/"+j.getDate();return k!=i?(alert("日期錯誤!"),!1):void 0}function deleteTravelData(a){$.ajax({type:"POST",url:"/ajax/customer_delete_travel.php",data:{travelId:a},dataType:"json",cache:!1,success:function(a){"true"==a.status&&window.location.reload()}})}function prepareUpload(a){$("div.coverText").show(),$("div.photoupLoad").hide(),files=a.target.files;var b=new FormData;$.each(files,function(a,c){b.append(a,c)}),$.ajax({url:"ajax/upload_picture_customer.php?files",type:"POST",data:b,cache:!1,dataType:"json",processData:!1,contentType:!1,success:function(a){$("div.coverText").hide(),$("div.photoupLoad").show(),"N"==a.errorStatus?window.location.reload():alert("IMAGE_TYPE"==a.errorStatus?"圖片只能上傳JPG!":"您所上傳的檔案有誤,請重新上傳!謝謝!")},error:function(a,b){console.log("ERRORS: "+b)}})}function deleteCusPic(){$.ajax({type:"POST",url:"/ajax/customer_delete_picture.php",data:$("form#uploadForm").serialize(),dataType:"json",cache:!1,success:function(a){"true"==a.status&&window.location.reload()}})}function chkRegPhone(a,b){errornum=0;var c=Trim($("form#sendPhoneForm #oc_code_"+a).val()),d=Trim($("form#sendPhoneForm #oc_"+a).val());if(""==c)return alert("請填寫國碼!"),errornum++,$("form#sendPhoneForm #oc_code_"+a).focus(),!1;if(""==d)return alert("請填寫手機號碼!"),errornum++,$("form#sendPhoneForm #oc_"+a).focus(),!1;if(errornum<=0){if("1"==b){var e="phone_01.php?oc_code="+c+"&oc_value="+d;showFancyBoxByCloseBtn(275,300,e,!0,!1,!1)}"2"==b&&$.ajax({type:"POST",url:"/ajax/customer_sendsms.php",data:$("form#sendPhoneForm").serialize(),dataType:"json",cache:!1,success:function(a){"false"==a.status&&alert(a.msg),"no_login"==a.status&&parent.location.replace(a.reUrlAddress),"true"==a.status&&location.replace(a.reUrlAddress)}})}}function chkRegPhoneEmpty(){$("form#sendForm #auth_code").val("")}function chkRegPhoneVerify(){errornum=0;var a=Trim($("form#sendForm #auth_code").val());return""==a?(alert("請填寫認證碼!"),errornum++,$("form#sendForm #auth_code").focus(),!1):void(errornum<=0&&$.ajax({type:"POST",url:"/ajax/customer_verify_mtel.php",data:$("form#sendForm").serialize(),dataType:"json",cache:!1,success:function(a){"false"==a.status&&alert(a.msg),"true"==a.status&&(alert(a.msg),parent.window.location.reload(),closeFancyBox())}}))}function chkOrderScore(){return""==$("form#sendForm #score_1").val()|$("form#sendForm #score_1").val()<=0?(alert("請評分整體體驗!"),$("form#sendForm #score_1").focus(),!1):""==$("form#sendForm #score_2").val()|$("form#sendForm #score_2").val()<=0?(alert("請評分符合描述!"),$("form#sendForm #score_2").focus(),!1):""==$("form#sendForm #score_3").val()|$("form#sendForm #score_3").val()<=0?(alert("請評分行程安排!"),$("form#sendForm #score_3").focus(),!1):""==$("form#sendForm #score_4").val()|$("form#sendForm #score_4").val()<=0?(alert("請評分專業導覽!"),$("form#sendForm #score_4").focus(),!1):""==$("form#sendForm #score_5").val()|$("form#sendForm #score_5").val()<=0?(alert("請評分溝通交流!"),$("form#sendForm #score_5").focus(),!1):""==$("form#sendForm #score_6").val()|$("form#sendForm #score_6").val()<=0?(alert("請評分服務態度!"),$("form#sendForm #score_6").focus(),!1):""==$("form#sendForm #score_7").val()|$("form#sendForm #score_7").val()<=0?(alert("請評分物超所值!"),$("form#sendForm #score_7").focus(),!1):""==$("form#sendForm #msg_con").val()?(alert("請填寫留言!"),$("form#sendForm #msg_con").focus(),!1):void 0}function chkEnterprise(){return errornum=0,""==$("form#enterpriseForm #uniform_number").val()?(alert("請填寫企業統一編號"),errornum++,$("form#enterpriseForm #uniform_number").focus(),!1):""==$("form#enterpriseForm #enterprise_code").val()?(alert("請填寫企業專屬碼"),errornum++,$("form#enterpriseForm #enterprise_code").focus(),!1):void(errornum<=0&&$.ajax({type:"POST",url:"/ajax/customer_enterprise.php",data:$("form#enterpriseForm").serialize(),dataType:"json",cache:!1,success:function(a){"true"==a.status?(alert(a.msg),parent.window.location.reload()):alert(a.msg)}}))}var files;$(function(){$("div.coverText").hide(),$("input[type=file]").on("change",prepareUpload)});