var Cookies = {};
Cookies.createCookie = function (c, d, e) {
var a;
if (e) {
var b = new Date();
b.setTime(b.getTime() + (e * 24 * 60 * 60 * 1000));
a = "; expires=" + b.toGMTString()
} else {
a = ""
}
document.cookie = encodeURIComponent(c) + "=" + encodeURIComponent(d) + a + "; path=/"
};
Cookies.readCookie = function (b) {
var e = encodeURIComponent(b) + "=";
var a = document.cookie.split(";");
for (var d = 0; d < a.length; d++) {
var f = a[d];
while (f.charAt(0) === " ") {
f = f.substring(1, f.length)
}
if (f.indexOf(e) === 0) {
return decodeURIComponent(f.substring(e.length, f.length))
}
}
return null
};
function popupOpen(pNaviPtn, pInqPtn, type) {
var naviPtnArray = [1, 2, 3, 4, 5];
var inqPtnArray = [1, 2];
if ( $.inArray( pNaviPtn, naviPtnArray ) < 0) {
naviPtn = 1;
}
if ( $.inArray( pInqPtn, inqPtnArray ) < 0) {
inqPtn = 1;
}
var param = "?pp_naviPtn=" + pNaviPtn + "&pp_inquiryPtn=" + pInqPtn;
var url = "/special/tags/contact/popup/" + type + "/input.html" + param;
var mainClass = "mfp-content-" + type;
$.magnificPopup.close();
$.magnificPopup.open({
tClose: "Close",
type: 'iframe',
items: {
src: url,
type: 'iframe'
},
iframe: {
markup:
''
},
disableOn: 200,
mainClass: mainClass,
removalDelay: 200,
preloader: false,
fixedContentPos: false,
callbacks: {
open: function(){
var h = $('.mfp-bg').height() + 80;
$('.mfp-bg').css({height:(h + "px")});
},
close: function(){
}
}
});
}
$(window).on("load",function() {
if (!Date.now) {
Date.now = function() {
return +new Date()
}
}
// 表示対象判定
var firstFlg= true;
if (Cookies.readCookie("popup_inquiry_visited")) {
firstFlg= false;
} else {
Cookies.createCookie("popup_inquiry_visited", "1", "365");
}
// 表示幅設定
var type = "large";
if (window.matchMedia('(max-width:479px)').matches) {
type = "small";
}
// ポップアップ画面表示
var msg = ["もっとTAGSを知りたい"
, "今すぐTAGS製品の資料
請求をする"
, "今すぐTAGS製品の概算
費用を知りたい"
, "今すぐTAGSを導入する"
, "TAGSの無料トライアル
を試したい"];
var naviPtn = 1;
var inqPtn = 1;
if (firstFlg) {
$('#contact').text(msg[0]);
naviPtn = 1;
inqPtn = 1;
} else {
var scoreing = $('#Scorering').val();
if (scoreing !== null) {
if ($('#Scorering').val() == "3") {
$('#flow_box_pc').html(msg[4]);
$('#flow_box_sp').html(msg[4]);
naviPtn = 5;
inqPtn = 2;
} else {
var min = 2;
var max = 5;
var n = Math.floor( Math.random() * (max + 1 - min) ) + min ;
$('#flow_box_pc').html(msg[n - 1]);
$('#flow_box_sp').html(msg[n - 1]);
naviPtn = n;
if ( naviPtn == 5) {
inqPtn = 2;
}
}
}
}
$('#flow_box_pc_a,#flow_box_sp_a').on("click",function() {
popupOpen(naviPtn, inqPtn, type);
});
});