//光箱相關
//------------------------------------------------------------------------------------------------------------
//光箱開啟且無關閉按鈕
function fancyboxOpenAndCloseNo(){
var fbeSpeed=300;
$('.box1Class').fancybox({
type : "iframe",
autoHeight : false, //Default False
autoWidth : false, //Default False
autoResize : true, //Default False
openEffect : 'fade', //elastic/fade/none
openSpeed : fbeSpeed,
closeEffect : 'fade',
closeSpeed : fbeSpeed,
padding : 0,
margin : [20, 60, 20, 60], // Increase left/right margin
closeBtn : false,
helpers : {
overlay : {closeClick: false} // prevents closing when clicking OUTSIDE fancybox
}
});
}
//光箱開啟且有關閉按鈕
function fancyboxOpenAndCloseYes(){
var fbeSpeed=300;
$('.box2Class').fancybox({
type : "iframe",
autoHeight : false, //Default False
autoWidth : false, //Default False
autoResize : true, //Default False
openEffect : 'fade', //elastic/fade/none
openSpeed : fbeSpeed,
closeEffect : 'fade',
closeSpeed : fbeSpeed,
padding : 0,
margin : [20, 60, 20, 60], // Increase left/right margin
closeBtn : true,
helpers : {
overlay : {closeClick: true} // prevents closing when clicking OUTSIDE fancybox
}
});
}
//光箱開啟且無關閉按鈕
function fancyboxOpenAutoAndCloseNo(width, url){
var fbeSpeed=300;
$.fancybox({
type : "iframe",
width : parseInt(width, 10),
autoHeight : false, //Default False
autoWidth : false, //Default False
autoResize : true, //Default False
openEffect : 'fade', //elastic/fade/none
openSpeed : fbeSpeed,
closeEffect : 'fade',
closeSpeed : fbeSpeed,
padding : 0,
margin : [20, 60, 20, 60], // Increase left/right margin
href : url,
closeBtn : false,
helpers : {
overlay : {closeClick: false} // prevents closing when clicking OUTSIDE fancybox
}
});
}
//基礎判斷
//------------------------------------------------------------------------------------------------------------
//確認是否為數值
function checkNumber(number) {
a = number;
date = a.match(/[^0-9]/g);
if(date || !a){
return false;
}else{
return true;
}
}
//判斷是否為數字及字母
function checkPwString(number) {
a = number;
date = a.match(/[^0-9A-Za-z]/g);
if(date || !a){
return false;
}else{
return true;
}
}
//確認是否為小數(格式為123.123或0.23456)
function checkFloat(floatNumber){
a = floatNumber;
date = a.match(/^[0-9].[0-9]+$/);
if(date != a){
return false;
}else{
return true;
}
}
//確認是否為Email
function checkEmail(strEmail) {
// emailRule = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/;
emailRule = /^([a-zA-Z0-9_.+-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/;
if(strEmail.search(emailRule)!= -1){
return true;
}else{
return false;
}
}
//確認聯絡電話(市話)
function checkTel(strTel){
if (strTel.search(/^([0][1-9]{1,3}-([0-9]{5,8}))+((#([0-9]){1,5}){0,1})$/)!=-1) {
return true;
}else {
return false;
}
}
//確認手機號碼
function checkMobile(strMobile){
if (strMobile.search(/^09[0-9]{8}$/)!=-1) {
return true;
}else {
return false;
}
}
//確認日期格式
function checkDate(strDate){
var re = /^\d{4}[-]\d{1,2}[-]\d{1,2}$/;
if(re.test(strDate)) {
return true;
}else{
return false;
}
}
//確認內容是否為[ 英/數字及部份符號(_ -)]
function checkString(strValue) {
strRule = /^([a-zA-Z0-9_-])+$/;
if(strValue.search(strRule)!= -1){
return true;
}else{
return false;
}
}
//判斷身份證字號
function checkIdNumber(id_number){
if(id_number.length > 0){
var data = id_number;
if(data.length != 10){return false;}
data1=data.substr(0,1);
data1=data1.match(/[a-zA-Z]{1}/);
if(data1 == null){return false;}
data2=data.substr(1,9);
data3=data2.match(/\d{9}/);
if(data3 == null){return false;}
}
//驗證格式
var acc = 0,d0 = id_number.charAt(0),d1 = id_number.charAt(1),d2 = id_number.charAt(2),d3 = id_number.charAt(3),d4 = id_number.charAt(4),
d5 = id_number.charAt(5),d6 = id_number.charAt(6),d7 = id_number.charAt(7),d8 = id_number.charAt(8),d9 = id_number.charAt(9);
if ((d0 == "A") || (d0 == "a")) { acc = 10; }else if ((d0 == "B") || (d0 == "b")) { acc = 11; }else if ((d0 == "C") || (d0 == "c")) { acc = 12; }
else if ((d0 == "D") || (d0 == "d")) { acc = 13; }else if ((d0 == "E") || (d0 == "e")) { acc = 14; }else if ((d0 == "F") || (d0 == "f")) { acc = 15; }
else if ((d0 == "G") || (d0 == "g")) { acc = 16; }else if ((d0 == "H") || (d0 == "h")) { acc = 17; }else if ((d0 == "J") || (d0 == "j")) { acc = 18; }
else if ((d0 == "K") || (d0 == "k")) { acc = 19; }else if ((d0 == "L") || (d0 == "l")) { acc = 20; }else if ((d0 == "M") || (d0 == "m")) { acc = 21; }
else if ((d0 == "N") || (d0 == "n")) { acc = 22; }else if ((d0 == "P") || (d0 == "p")) { acc = 23; }else if ((d0 == "Q") || (d0 == "q")) { acc = 24; }
else if ((d0 == "R") || (d0 == "r")) { acc = 25; }else if ((d0 == "S") || (d0 == "s")) { acc = 26; }else if ((d0 == "T") || (d0 == "t")) { acc = 27; }
else if ((d0 == "U") || (d0 == "u")) { acc = 28; }else if ((d0 == "V") || (d0 == "v")) { acc = 29; }else if ((d0 == "X") || (d0 == "x")) { acc = 30; }
else if ((d0 == "Y") || (d0 == "y")) { acc = 31; }else if ((d0 == "W") || (d0 == "w")) { acc = 32; }else if ((d0 == "Z") || (d0 == "z")) { acc = 33; }
else if ((d0 == "I") || (d0 == "i")) { acc = 34; }else if ((d0 == "O") || (d0 == "o")) { acc = 35; }
if (acc == 0) {
return false;
} else {
accstr = new String(acc);
acc_1 = (accstr).charAt(0);
acc_2 = (accstr).charAt(1);
certsum = 1*acc_1 + 9*acc_2 + 8*d1 + 7*d2 + 6*d3 + 5*d4 + 4*d5 + 3*d6 + 2*d7 + 1*d8;
certsum_2 = parseInt(certsum%10);
certsum_3 = 10 - certsum_2;
if(certsum_2 == 0){
certsum_3 = 0;
}
if (certsum_3 != d9) {
return false;
}else{
return true;
}
}
}
//------------------------------------------------------------------------------------------------------------
function change_step(step){
$("#go_step").val(step);
}
function setcookie(){
$.ajax({
type: "POST",
url: "ajax/setcookie.php",
dataType: "json",
cache: false
})
.done(function(data) {
console.log("success");
location.reload();
});
return false;
}
function chkWebSearch(){
//關鍵字
if($("form#websearch #keyword").val() == ""){
alert("請輸入關鍵字");
$("form#websearch #keyword").focus();
return false;
}
}