var gameover = '1';
//var sidArray=;
var isMobile_check = '';
//Detect Device
var isMobile = false;
(function (a) {
(/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) ? isMobile = true: isMobile = false;
})(navigator.userAgent || navigator.vendor || window.opera, true, false);
if(isMobile) {
//window.location.href="http://www.fisherprice.com.tw/a-film-by-you/mobile/index.php?i=1731457882";
isMobileWeb='1';
}else{
isMobileWeb='0';
}
// alert(isMobileWeb);
/////////// Kuei Start ////////////
function SetCookie(name,value)
{
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)//删除cookie
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
//function clickga(url){
// ga('send','event',url,url,url);
// if(window.console) console.log('clickga:'+url);
//}
if(facebook_app_id!='')
{
window.fbAsyncInit = function() {
FB.init({
appId : facebook_app_id,
xfbml : true,
version : 'v2.3'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
}
function checkLoginStatus(response) {
if(window.console) console.log('checkLoginStatus');
if(response && response.status == 'connected') {
/*
if(window.console) {
if(window.console) console.log('Access Token: ' + response.authResponse.accessToken);
if(window.console) console.log(response);
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
console.log(response);
});
}
*/
FB.api('/me', function(response) {
$('#_fb_name').val(response.name);
$('#_fb_email').val(response.email);
$('#_fb_uid').val(response.id);
$('#_fb_gender').val(response.gender);
$('#_fb_link').val(response.link);
});
} else {
}
}
function getQueryString_kuei(param) {
var q = document.location.search || document.location.hash;
if (param == null) { return q; }
if (q) {
var pairs = q.substring(1).split("&");
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
return pairs[i].substring((pairs[i].indexOf("=") + 1));
}
}
}
}
var utm_source = getQueryString_kuei('utm_source');
var utm_content = getQueryString_kuei('utm_content');
var utm_campaign = getQueryString_kuei('utm_campaign');
var utm_medium = getQueryString_kuei('utm_medium');
var utm_term = getQueryString_kuei('utm_term');
var utm_source_cookie = getCookie('utm_source');
var utm_content_cookie = getCookie('utm_content');
var utm_campaign_cookie = getCookie('utm_campaign');
var utm_medium_cookie = getCookie('utm_medium');
var utm_term_cookie = getCookie('utm_term');
if((utm_source=='' || utm_source==undefined) && utm_source_cookie!='') utm_source = utm_source_cookie;
if((utm_content=='' || utm_content==undefined) && utm_content_cookie!='') utm_content = utm_content_cookie;
if((utm_campaign=='' || utm_campaign==undefined) && utm_campaign_cookie!='') utm_campaign = utm_campaign_cookie;
if((utm_medium=='' || utm_medium==undefined) && utm_medium_cookie!='') utm_medium = utm_medium_cookie;
if((utm_term=='' || utm_term==undefined) && utm_term_cookie!='') utm_term = utm_term_cookie;
function IsNumber(string,sign)
{
var number;
if (string==null) return false;
if ((sign!=null) && (sign!='-') && (sign!='+'))
{
alert('IsNumber(string,sign)的參數出錯:\nsign為null或"-"或"+"');
return false;
}
number = new Number(string);
if (isNaN(number))
{
return false;
}
else if ((sign==null) || (sign=='-' && number<0) || (sign=='+' && number>0))
{
return true;
}
else return false;
}
function ValidEmail(emailtoCheck)
{
var regExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if ( emailtoCheck.match(regExp) )
return true;
else
return false;
}
function checkField() {
//msg_trigger('msg-alert','親愛的客戶您好,由於活動報名踴躍,為維護體驗品質,暫停接受報名,歡迎稍後再訪報名','感謝您的參與!');
//return false;
if($('#try-name').val()=='' || $('#try-name').val()=='姓名'){
msg_trigger('msg-alert','請填寫您的姓名!!');
return false;
}
if($('#try-phone').val()=='' || $('#try-phone').val()=='手機號碼'){
msg_trigger('msg-alert','請填寫您的行動電話!!');
return false;
}
if (($('#try-phone').val()!="") && (IsNumber($('#try-phone').val())==false)) {
msg_trigger('msg-alert','手機電話需全為數字!!(請勿以符號或全形數字輸入)');
return false;
}
if (($('#try-phone').val()!="") && ($('#try-phone').val().length != 10)) {
msg_trigger('msg-alert','手機電話號碼有問題請檢查!! 謝謝!!(請勿以符號或全形數字輸入)');
return false;
}
if ($('#try-phone').val().substring(2,0)!='09') {
msg_trigger('msg-alert','請填寫正確的手機號碼!! 謝謝!!');
return false;
}
if ($('#try-email').val()=="") {
msg_trigger('msg-alert','請填寫email');
return false;
}
if ((!$('#try-email').val() == "" && $('#try-email').val().indexOf('@',0) == -1) || (!$('#try-email').val() == "" && $('#try-email').val().indexOf('.',0) == -1))
{
msg_trigger('msg-alert',"請填寫正確的email。");
return false;
}
/*
if(!ValidEmail($('#try-email').val()))
{
msg_trigger('msg-alert',"請填寫正確的email!!");
return false;
}*/
/*
if (!$('#try-zone').val()) {
msg_trigger('msg-alert',"請選擇區域!! 謝謝!!");
return false;
}
if (!$('#try-store').val()) {
msg_trigger('msg-alert',"請選擇櫃點!! 謝謝!!");
return false;
}
*/
if(!$('#try-agree-rule').prop("checked")){
msg_trigger('msg-alert','您必須年滿20歲並詳閱活動辦法及同意隱私權政策始能參加本活動.');
return false;
}
return true;
}
$().ready(function(){
//$('#_name').prop('disabled', true);
//$('#_tel').prop('disabled', true);
//return true;
if(gameover=='1'){
//alert('本活動已截止,感謝您的參與!');
msg_trigger('msg-alert',"本活動已截止,感謝您的參與!");
}
//add facebook input
$( "body" ).append("");
var json_callback = function(msg){
//alert(msg);
if(window.console) console.log(msg);
var json = [msg];
var s = msg.Statuss;
if(s=='success') {
msg_trigger('msg-try-success')
$("#try-tracking").attr('src', 'tracking-try-submit.html?v2')
$('#try-name').val('');
$('#try-phone').val('');
$('#try-email').val('');
wait_callback = '';
}
else if(s=='already') {
msg_trigger('msg-alert',"謝謝粉絲的熱烈支持! 您已經參加過本活動!");
clickga('重複填寫');
wait_callback = '';
}
//else if(s=='shareSuccess') swal('分享成功');
else {
msg_trigger('msg-alert',s);
wait_callback = '';
}
}
var wait_callback = '';
var agree_send = '';
var ad1 = '';
var ad2 = '';
var area = '';
var shop = '';
var user_date = '';
//msg_trigger('msg-alert','親愛的客戶您好,由於活動報名踴躍,為維護體驗品質,暫停接受報名,歡迎稍後再訪報名','感謝您的參與!');
if(window.console) console.log('actCode = '+actCode);
if(gameover!='1'){
//send
$('#try-submit').bind('click', function() {
_lt('send', 'cv', {
type: 'AR202009'
},['8014ccf1-9f87-48f1-95e6-dc43a27a0b3c']);
if(window.console) {console.log('確認送出 click');}
var a = checkField();
if(a){
if(wait_callback==''){
wait_callback = '1';
if($('#try-agree-send').prop("checked")) agree_send = '1';
$.ajax({
url: 'https://sp.artstudio.com.tw/reg2020_guerlain.php',
crossDomain: true,
dataType: 'jsonp',
contentType: "application/json",
jsonpCallback: 'json_callback',
data: {
actCode: 'guerlain-youth-watery-oil-2023',
uname: $('#try-name').val(),
phone: $('#try-phone').val(),
email: $('#try-email').val(),
//store_area: $('#try-zone').val(),
store_name: $('#try-store').val(),
//vote: $('#try-game-result').val(),
//recaptcha_response: $('#recaptcha_response').val(),
//agree: $('input[name=agree]:checked').val(),
eletter:$('input[name=try-agree-promo]:checked').val(),
utm_campaign:utm_campaign,
utm_medium:utm_medium,
utm_term:utm_term,
utm_source:utm_source,
utm_content:utm_content,
isMobileWeb:isMobileWeb
},
success:json_callback
//error: json_callback3
}).done(function(data){
//dddone();
});
}
}
});
}
});
$( window ).load(function() {
if(window.console){console.log(window.location.host);}
});