/* Minification failed. Returning unminified contents.
(917,41-42): run-time error JS1195: Expected expression: >
(917,58-59): run-time error JS1004: Expected ';': )
(918,37-38): run-time error JS1195: Expected expression: >
(925,26-27): run-time error JS1195: Expected expression: )
(926,17-18): run-time error JS1002: Syntax error: }
(931,17-18): run-time error JS1002: Syntax error: }
(935,13-14): run-time error JS1002: Syntax error: }
(942,25-26): run-time error JS1004: Expected ';': {
 */

(function (i, s, o, g, r, a, m) {
    i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
        (i[r].q = i[r].q || []).push(arguments)
    }, i[r].l = 1 * new Date(); a = s.createElement(o),
    m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

var par = location.href;

if (par.toLowerCase().indexOf("/m/") > -1) {
    ga('create', 'UA-167953736-1', 'auto');
}
else {
    ga('create', 'UA-37193510-5', 'setn.com');
}

//ga('create', 'UA-117496391-1', 'auto');

ga('create', 'UA-126192848-1', { 'name': 'setnRate', 'sampleRate': 5 });

ga('require', 'GTM-MZ5FX2T');

ga('send', 'pageview');
ga('setnRate.send', 'pageview');
ga('ent.send', 'pageview');
ga('Live.send', 'pageview');
ga('Videos.send', 'pageview');
;


String.format = function () {
    var s = arguments[0];
    for (var i = 0; i < arguments.length - 1; i++) {
        var reg = new RegExp("\\{" + i + "\\}", "gm");
        s = s.replace(reg, arguments[i + 1]);
    }

    return s;
}

function WaitRead(szNewsID) {
    //if (typeof cookie_Type === 'undefined' || !cookie_Type)
    cookieHelper.SetWaitRead(szNewsID).ShowWaitRead($('#divWaitReadCnt'));
    //else
    //cookieHelper.SetWaitRead(szNewsID, cookie_Type).ShowWaitRead($('#divWaitReadCnt'));

    $("span[id='af'] > a[onclick='WaitRead(" + szNewsID + ")']").hide();
}

//ga tracking event
$(function () {
    ga_track('');
});

// ajax 事件後的 ga track binding action
function ga_track(selector, debug) {
    if (selector) {
        selector += ' .gt';
    }
    else {
        selector = '.gt';
    }

    $("body").on('click', selector, function () {

    //$(selector).on('click', function () {
        
        var pa;
        var pg_name = '';
        if (typeof pg == 'object') {
            pg_name = pg.Name;
        }

        var pl = '';
        if ($(this).attr('pl')) { pl = $(this).attr('pl'); }

        pa = $(this).attr('pa');
        pa = pa ? pa : pg_name;

        var lb = '';
        if ($(this).attr('lb')) {
            lb = $(this).attr('lb');
        }
        else {
            if ($(this).has("img").length > 0) {
                if ($(this).find('img').first().attr('alt')) {
                    lb = $(this).find('img').first().attr('alt');
                }
                else {
                    lb = $(this).find('img').first().attr('src');
                }
            }
            else {
                lb = $(this).text();
            }
        }

        if (debug === true) { 
            alert(pa + ',' + pl + ',' + lb);
            return false;
        }

        ga('send', 'event', pa, pl, lb);
    });
}

;
/*!
 * jQuery Cookie Plugin v1.3.1
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2013 Klaus Hartl
 * Released under the MIT license
 */
(function ($, document, undefined) {

	var pluses = /\+/g;

	function raw(s) {
		return s;
	}

	function decoded(s) {
		return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
	}

	function unRfc2068(value) {
		if (value.indexOf('"') === 0) {
			// This is a quoted cookie as according to RFC2068, unescape
			value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
		}
		return value;
	}

	function fromJSON(value) {
		return config.json ? JSON.parse(value) : value;
	}

	var config = $.cookie = function (key, value, options) {

		// write
		if (value !== undefined) {
			options = $.extend({}, config.defaults, options);

			if (value === null) {
				options.expires = -1;
			}

			if (typeof options.expires === 'number') {
				var days = options.expires, t = options.expires = new Date();
				t.setDate(t.getDate() + days);
			}

			value = config.json ? JSON.stringify(value) : String(value);

			return (document.cookie = [
				encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
				options.path    ? '; path=' + options.path : '',
				options.domain  ? '; domain=' + options.domain : '',
				options.secure  ? '; secure' : ''
			].join(''));
		}

		// read
		var decode = config.raw ? raw : decoded;
		var cookies = document.cookie.split('; ');
		var result = key ? null : {};
		for (var i = 0, l = cookies.length; i < l; i++) {
			var parts = cookies[i].split('=');
			var name = decode(parts.shift());
			var cookie = decode(parts.join('='));

			if (key && key === name) {
				result = fromJSON(cookie);
				break;
			}

			if (!key) {
				result[name] = fromJSON(cookie);
			}
		}

		return result;
	};

	config.defaults = {};

	$.removeCookie = function (key, options) {
		if ($.cookie(key) !== null) {
			$.cookie(key, null, options);
			return true;
		}
		return false;
	};

})(jQuery, document);
;
//手風琴折
function SlideView(e, a)
{
    try{
        for (var i = 0, o = document.getElementById(e).getElementsByTagName('DL'), d; d = o[i++];) (function (e, c, m, s, t, k, h)
        {
            (s = e.style).height = (h = 52) + "px"; //主標題高度，如要修改需等同下方.max
            e.onmouseover = function () { t = setTimeout(e.open, 10); } //滑鼠停留多久時間開啟 
            e.onmouseout = function () { clearTimeout(t); }
            e.open = function ()
            {
                if (a == e) return;
                c(k); a && a.close();
                (a = e).className = "on";
                k = m(function () { if (h > 155) c(k); else s.height = (h = Math.min(h + 30, 140)) + "px"; }, 44);
                if (e === "idSlideViewProgram") {
                    k = m(function () { if (h > 280) c(k); else s.height = (h = Math.min(h + 60, 230)) + "px"; }, 44);
                }
            }
            e.close = function ()
            {
                c(k); e.className = "";
                k = m(function () { if (h < 33) c(k); else s.height = (h = Math.max(h - 30, 52)) + "px"; }, 44);
            }
        })(d, clearInterval, setInterval);
        o[0].open();
    }
    catch (err) {}
}
new SlideView("idSlideView3");

$(document).ready(function () {
    //slideviewJquery('idSlideView3');
    slideviewJquery('idSlideViewProgram');
});

function slideviewJquery(id) {
    $('#' + id + ' > dl > dd').eq(0).show();
    $('#' + id + ' > dl > dt').bind('mouseenter', function () {
        var $obj = $(this);
        setTimeout(function () {
            $('#' + id + ' > dl > dd').hide();
            $('#' + id + ' > dl').removeClass('on');
            $obj.parent().addClass('on');
            $obj.next().slideDown();
        }, 300);
    });
}
;
(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/zh_TW/sdk.js#xfbml=1&version=v11.0";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

;
//選單列 下拉
$(document).ready(function () {

    $("#navigation li").bind("mouseout", function () {

        var _Block = $(this).find("div.NavContentBox");
        _Block.hide();
    });

    $(".socialNum").each(function () {
        $(this).text(thousandComma($(this).text()));
    });



    $("body").on('click', '.openvod', function () {
        var url = $(this).data("vodurl");
        var pa = $(this).data("pa");
        var pl = $(this).data("pl");
        ga('send', 'event', pa, pl, "");
        $("#iframeCover").append('<iframe id="vodIframe" src="' + url + '" type="text/html" scrolling="no" style="width:100%;min-height:380px;border:none;"></iframe>');
    });



    $('#video_view').on('hidden.bs.modal', function () {
        $("#iframeCover #vodIframe").remove();
    });


});

var thousandComma = function (number) {
    var num = number.toString();

    var numM = Math.floor(parseInt(number) / 10000).toString();
    var numT = (parseInt(number) % 10000).toString();
    var numTs = Math.round(parseInt(numT) / 1000).toString();

    var pattern = /(-?\d+)(\d{3})/;

    while (pattern.test(numT)) {
        numT = numT.replace(pattern, "$1,$2");
    }

    var reNum = "";
    if (numM != "0") {
        reNum += numM + "萬";
        if (numTs != "0") {
            reNum += numTs;
        }
        return reNum;

    }

    if (numT != "0") {
        reNum += numT;
    }

    if (reNum == "") reNum = "0";
    return reNum;
};


function displaySubMenu(li) {
    var subMenu = li.getElementsByTagName("ul")[0];
    if (subMenu != undefined)
        subMenu.style.display = "block";
};

function hideSubMenu(li) {
    var subMenu = li.getElementsByTagName("ul")[0];
    if (subMenu != undefined)
        subMenu.style.display = "none";
};



//側邊固定滑出式選單-FB你可能也會喜歡
$(function () {
    var w = $("#mwt_slider_content").width();
    $('#mwt_slider_content').css('height', ($(window).height() - 20) + 'px'); //將區塊自動撐滿畫面高度

    $("#mwt_fb_tab").click(function () { //滑鼠滑入時
        if ($("#mwt_mwt_slider_scroll").css('left') == '-' + w + 'px') {
            $("#mwt_mwt_slider_scroll").animate({ left: '0px' }, 600, 'swing');
        }
    });


    $("#mwt_slider_content").click(function () {　//滑鼠離開後
        $("#mwt_mwt_slider_scroll").animate({ left: '-' + w + 'px' }, 600, 'swing');
    });
});



//置頂
var isAffix = false;

$(document).ready(function () {

    $("#gotop").click(function () {
        jQuery("html,body").animate({
            scrollTop: 0
        }, 1000);
    });

    //SocialIcon();

    $(window).resize(function () {
        //SocialIcon();

        if (!/iPad/i.test(navigator.userAgent)) {

            $(".contLeft").removeAttr("style").removeClass("affix").removeClass("affix-top").removeClass("affix-bottom");
            $(".contRight").removeAttr("style").removeClass("affix").removeClass("affix-top").removeClass("affix-bottom");

            isAffix = false;
        }
    });


    $(window).on("orientationchange", function () {
        $(".contLeft").removeAttr("style").removeClass("affix").removeClass("affix-top").removeClass("affix-bottom");
        $(".contRight").removeAttr("style").removeClass("affix").removeClass("affix-top").removeClass("affix-bottom");

        isAffix = false;
    });


    var lastScrollTop = 0;
    $(window).scroll(function () {
        if ($('#mainMenu').length > 0) {
            $('#mainMenu').affix({
                offset: {
                    top: $("#header").offset().top + $("#header").height()
                }
            });

            if ($("#mainMenu").hasClass("affix")) {
                $(".curtain").css({ top: "90px" });

            } else {
                var mh = $("#mainMenu").offset().top + 90;

                $(".curtain").css({ top: mh });
            }
        }

        if ($(this).scrollTop() > 300) {
            $('#gotop').fadeIn("fast");
        } else {
            $('#gotop').stop().fadeOut("fast");
        }

        if ($(".videoLay").length > 0) {
            floatVideo($(".videoLay"), $(".videoLayBlock"), $(this).scrollTop());
        }

        if ($(".contRight").length > 0 && $(".contRight").length > 0) {
            var RcontH = $(".contRight").height() + $("#contFix").offset().top - window.screen.availHeight;
            var LcontH = $(".contLeft").height() + $("#contFix").offset().top - window.screen.availHeight;
            var bottom = $('footer').outerHeight(true);

            if ($(".contRight").length > 0 && $(".contLeft").length && $(window).width() >= 768 && !$("#contFix").hasClass("viewallNewsList")) {
                contAffix($(".contRight").outerWidth() - 1, $(".contLeft").outerWidth() - 1, RcontH, LcontH, bottom);
            }

            if ($(".contRight").length > 0 && $(".contLeft").length && $(window).width() >= 768 && $("#contFix").hasClass("viewallNewsList")) {
                fixSidebar($(".contRight").outerWidth(), RcontH, bottom);
            }
        }

        if ($("#newsTextAD").length > 0 && $("#linefriendModal").length > 0 ) {
            
            if (getCookie('linefriendModal') === '' && linefriendModal === false && $(this).scrollTop() > lastScrollTop && $("#idleAD").is(':hidden')) {

                if ($(this).scrollTop() > $("#newsTextAD").offset().top - (window.screen.availHeight / 2)) {
                    $("#linefriendModal").modal('show');
                    linefriendModal = true;
                }
            }
        }

        lastScrollTop = $(this).scrollTop();

    });
});

function SocialIcon() {
    if ($(window).width() <= 1595) {
        if (("#HeaderAD").length > 0) {
            $(".social_side_links").hide();
            $(".social-top-area").show();
        }
    }
    else {
        $(".social_side_links").show();
        $(".social-top-area").hide();
    }
}

function contAffix(RcontW, LcontW, RcontH, LcontH, bottom) {

    if (isAffix == false && $('.contLeft').is(":visible") && $('.contRight').is(":visible")) {
        if ($(this).scrollTop() > RcontH) {

            fixSidebar(RcontW, RcontH, bottom);

        }
        else if ($(this).scrollTop() > LcontH) {

            $(".contLeft").css({ width: LcontW + "px" });

            $('.contLeft').affix({
                offset: {
                    top: LcontH+ 100,
                    bottom: function () {
                        return (this.bottom = bottom);
                    }
                }
            }).on('affix.bs.affix', function () {
            }).on('affix-top.bs.affix', function () {
            }).on('affix-bottom.bs.affix', function () {
            });
            isAffix = true;
        }
    }

}

function fixSidebar(RcontW, RcontH, bottom) {
    var r = document.body.offsetWidth - ($("#contFix").offset().left + $("#contFix").outerWidth());
    $(".contRight").css({
        width: RcontW + "px"
    });

    $('.contRight').affix({
        offset: {
            top: RcontH + 120,
            bottom: function () {
                return (this.bottom = bottom);
            }
        }
    }).on('affix.bs.affix', function () {
        $(".contRight").css({ right: r + "px" });
    }).on('affix-top.bs.affix', function () {
        $(".contRight").css({ right: "auto" });
    }).on('affix-bottom.bs.affix', function () {
        $(".contRight").css({ right: "auto" });
    });

    isAffix = true;
}


function marketingNews(id) {
    var dt = AjaxGetData('/Extensions/SetMainServices.asmx/GetMarketingNews', '', false, false, null);
    if (dt != null) {
        var str = '';
        for (var i = 0; i < dt.length; i++) {
            var vm = dt[i];
            str += '<div class="dd">' +
                   '    <div class="ddimg"><img src="' + GetImageURL(vm.Image.ImageID, vm.Image.ImageFile, "L") + '"></div>' +
                   '    <div class="dda"><a href="News.aspx?NewsID=' + vm.NewsID + '">' + vm.ShortSlug + '</a></div>' +
                   '</div>';
        }
    }
    $('#' + id).html(str);
}








;
/*
    所有 mobile、娛樂、desktop 版本共用的 js function
*/

$(document).ready(function () {

    $("#btnPrivacy").click(function () {
        $(".privacy-area").remove();
        cookieHelper.SetClickPrivacy();
        $(".eHeader").removeAttr("style");
        ga('send', 'event', "隱私權", "關閉隱私權", "");
        return false;
    });

    if ($("#owl-news-flash").length > 0) {
        $("#owl-news-flash").owlCarousel({
            items: 1,
            loop: true,
            margin: 0,
            autoplay: true,
            autoplayTimeout: 5000,
            autoplayHoverPause: true,
            mergeFit: false,
            dots: false,
            nav: false

        });
    }

    $("img").each(function () {
        var alt = $(this).attr("alt");
        if (alt != null) {

            if (alt.indexOf("業配") > -1) {

                $(this).attr("alt", "特稿");
            }
        }
    });

    $(".sbNewsList").each(function () {
        var id = $(this).data("layid");
        if (id != "") {
            $("#" + id).append($(this));

            //$("#" + id + " img.lazy").lazyload({ effect: "fadeIn" });

        }
    });


    $(".accordionTitle").mouseover(function () {
        $(".accordionMain").removeClass("active");

        var $_mainItem = $(this).parent();

        var $_img = $_mainItem.find("img");
        $_img.each(function () {
            var src = $(this).attr("src");
            if (src == "") {
                $(this).attr("src", $(this).data("imglink"));
            }
        });

        $_mainItem.addClass("active");
    });


    $(".area18-bt.bt-left").on("click", function () {
        var bUrl = document.referrer;
        //alert(bUrl);
        if (bUrl.indexOf("setmoney") != -1 || bUrl.indexOf("setmoney") != -1 || bUrl.indexOf("localhost") != -1) {
            history.back();
        }
        else {
            location.href = '/';
        }

    });

    var PageGroupID = 0;
    if ($("#hfPageGroupId").length > 0) {
        PageGroupID = $("#hfPageGroupId").val();

        //if (PageGroupID == 10 || PageGroupID == 0) {
        //    PageGroupID = 1;
        //}
    }

    //內文頁文字廣告
    if ($("#newsTextAD").length > 0) {

        var url = "https://ad.setn.com/Ads/TextAD";
        try {
            if (PageGroupID != null) {
                if (PageGroupID != "" && PageGroupID != "0" && PageGroupID != "1") {
                    url = url + "?PageGroupID=" + PageGroupID;
                }
            }
        }
        catch (ex) {
        }

        try {
            if (customtagid != null && customtagid != "") {
                if (url.indexOf("?") > -1) {
                    url = url + "&customtagid=" + customtagid;
                }
                else {
                    url = url + "?customtagid=" + customtagid;
                }
            }
        }
        catch (ex) {
        }

        $.ajax({
            url: url,
            dataType: 'text',
            type: 'GET',
            success: function (result) {
                var obj = $.parseJSON(result);
                var contItem = "";
                if (obj.length > 0) {
                jQuery.each(obj, function (i, item) {
                    $("#newsTextAD").append('<li data-layid="' + item.ADPage + '"><a href="https://ad.setn.com/AdsDataCollect/AdsClick/' + item.ADRowid + '" target="_blank" data-layid="' + item.ADRowid + '" class="gt newsTextADItem" pa="新聞內頁文字廣告" pl="' + item.ADPage + "_" + item.ADRowid + '">' + item.Text + '</a><span class="sponsored"></span></li>');
                    });
                }

            },
            error: function (result, status, jqXHR) { }
        }).done(function () {

            var domainAD = location.href.split("//")[1].split(".")[0];

            if (domainAD.toLocaleLowerCase().indexOf("www") > -1 || domainAD.toLocaleLowerCase().indexOf("setn") > -1) {
                domainAD = "";
            }

            if (location.pathname.toLocaleLowerCase().indexOf("/e/") > -1) {
                domainAD = "ent";
            }

            if (domainAD.length > 0) {
                domainAD += "_";
            }

            domainAD = domainAD.replace("/", "");

            var ad2 = $("#newsTextAD").find('[data-layid="textAD2"]');
            var ad3 = $("#newsTextAD").find('[data-layid="textAD3"]');
            var ad5 = $("#newsTextAD").find('[data-layid="textAD5"]');

            var showpopinad = true;
            try {
                showpopinad = $("#newsTextAD").data("showpopinad");
            } catch (e) {

            }

            if (showpopinad == "true" || showpopinad == "True") {
                if (ad2.length <= 0) {
                    $("#newsTextAD").append('<li><div id="_popIn_recommend_' + domainAD + 'word"></div></li>');
                }
                if (ad3.length <= 0) {
                    $("#newsTextAD").append('<li><div id="_popIn_recommend_' + domainAD + 'word_2"></div></li>');
                }
                if (ad5.length <= 0) {
                    $("#newsTextAD").append('<li><div id="_popIn_recommend_' + domainAD + 'word_3"></div></li>');
                }
            }


            TravelTextAD();

        });



    }


    $(".curtainBtn").click(function () {
        $(".curtain-center").toggleClass("active");
        $("#gad_curtain_open").empty();

        if ($(".curtain-center").hasClass("active") && $("#gad_curtain_open").is(':empty')) {

            GoogleADExecute([{ plate: '/21685920852/setn_boom_1200x500_open', size: [[1200, 500], [1, 1]], id: 'div-gpt-ad-1513936386313-0', area: 'gad_curtain_open', marginTop: 0 }]);

        }
    });


    var para = [
        { plate: '/21685920852/setn_door_120x500_L', size: [120, 500], id: 'div-gpt-ad-1511931519524-0', area: 'gad_curtain_L', marginTop: 0 },
        { plate: '/21685920852/setn_door_120x500_R', size: [120, 500], id: 'div-gpt-ad-1511931611574-0', area: 'gad_curtain_R', marginTop: 0 },
        { plate: '/21685920852/setn_boom_1200x500_open', size: [[1200, 500], [1, 1]], id: 'div-gpt-ad-1513936386313-0', area: 'gad_curtain_open', marginTop: 0 },
        { plate: '/21685920852/setn_boom_1200x150_close', size: [[1, 1], [1200, 150]], id: 'div-gpt-ad-1513936354463-0', area: 'gad_curtain_close', marginTop: 0 }
    ];

    GoogleADExecute(para);

    var VoteId = 0;
    if ($("#hfVoteId").length > 0) {
        VoteId = $("#hfVoteId").val();
    }


    $(".closefloatVideo").click(function () {
        toggleVideo(0);
        $(".videoLayBlock").addClass("removedFloat").removeClass("floatVideo").removeAttr("style");

        $(".ima-ad-container > div").first().css({ position: "absolute", width: 640, height: 320 });
        $(".ima-ad-container > div > iframe").attr("width", 640).attr("height", 320);

    });

    //**右側新浮水印
    $(".floatL").click(function () {
        $("#divFloatToolsView").toggle("slow");

        var $_arrow = $(this).find(".arrowBlock span");
        $_arrow.toggleClass("arrowR");

    });

    $owlFloat = $('#owl-Float');
    $owlFloatSlides = $owlFloat.children('div');

    if ($owlFloatSlides.length > 1) {
        $("#owl-Float").owlCarousel({
            items: 1,
            loop: true,
            margin: 10,
            autoplay: true,
            autoplayTimeout: 6000,
            autoplayHoverPause: true,
            controlsClass: "edm_controls",
            animateOut: 'fadeOut'
        });
    }
    else {
        $owlFloat.removeClass();
        $("#owl-Float").height(270);
    }

    $owlFloat2 = $('#owl-Float2');
    $owlFloatSlides2 = $owlFloat2.children('div');

    if ($owlFloatSlides2.length > 1) {
        $("#owl-Float2").owlCarousel({
            items: 1,
            loop: true,
            margin: 10,
            autoplay: true,
            autoplayTimeout: 6000,
            autoplayHoverPause: true,
            controlsClass: "edm_controls",
            animateOut: 'fadeOut'
        });
    }
    else {
        $owlFloat2.removeClass();
        $("#owl-Float2").height(135);
    }

    //箭頭動畫
    var bottomArrowNum = $('.on_air_bottom > .arrow').length;
    setInterval(function () {
        for (var i = 0; i < $('.on_air_bottom > .arrow').length; i++) {
            if (bottomArrowNum > i) {
                $('.on_air_bottom > .arrow').eq(i).hide();
            }
            else {
                $('.on_air_bottom > .arrow').eq(i).show();
            }
        }
        bottomArrowNum--;
        if (bottomArrowNum === -1) { bottomArrowNum = $('.on_air_bottom > .arrow').length; }
    }, 500);

    //**右側新浮水印-結束


    //內文 img alt 加入識別
    if ($('#ckuse').length > 0) {
        $('#ckuse img').each(function () {
            try {
                var ha = document.createElement("a");
                var src = $(this).attr('src');
                ha.href = src;
                if ($(this).attr('alt') == "") {
                    var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;

                    if (RegExp.test(src)) {
                        var matchs = ha.pathname.split('/');
                        var imgId = matchs[matchs.length - 1].split('-')[0];
                        $(this).attr('alt', $(this).attr('alt') + " ID-" + imgId);
                    }
                }

            }
            catch (ex) {
            }
        });
    }

    try {
        if (cookieHelper.GetClickPrivacy() == true || cookieHelper.GetClickPrivacy() == "true") {
            $(".privacy-area").remove();
        }
        else {
            $(".privacy-area").show();

            if (screen.width <= 419) {
                $(".eHeader").css("top", $('.privacy-area').height() + 10);
            }
        }
    } catch (e) {

    }


    $(".textTagAD").each(function () {

        var $_textTagLay = $(this);
        var url = $_textTagLay.data("adurl");

        $.ajax({
            url: url,
            dataType: 'text',
            type: 'GET',
            success: function (result) {
                var obj = $.parseJSON(result);
                $_textTagLay.attr("href", obj[0].Url).find("span").text(obj[0].Text);

            },
            error: function (result, status, jqXHR) { }
        });


    });

    $(".copyLink").on("click", function() {
        window.Clipboard.copy(location.href);
        return false;
    });

    //userKey cookie 處理
    try {
        var userkeyCookie = getCookie('userKey');
        if (userkeyCookie == null || userkeyCookie == undefined || userkeyCookie.length === 0) {
            $.getJSON("https://www.setn.com/Extensions/ParamHandler.ashx?k=getnewuserid", function (data) {
                if (data) {
                    console.log(data);
                    var uid = data.uid;
                    setCookie('userKey', uid, 60 * 60 * 24 * 1080);
                }
            });
        }
    }
    catch (e) {
        console.log(e);
    }


    //聽新聞
    var audioObj = $('#newsAudio');
    var audioBtn = $('#newsAudioBtn');

    if (audioObj.length > 0 && !!document.createElement('audio').canPlayType) {
        audioObj.bind('canplaythrough', function () {
            window.URL.revokeObjectURL(audioObj.attr('data-file'));
        });
        audioBtn.click(function () {
            if (audioObj.get(0).paused) {
                if (audioObj.get(0).readyState === 0) {
                    fetch(audioObj.data('file'))
                        .then(response => response.blob())
                        .then(blob => {
                            var b = window.URL.createObjectURL(blob);
                            audioObj.attr('data-file', b);
                            audioObj.attr('src', b);
                            ga('send', 'event', '新聞內頁-聽新聞', '聽新聞', pageGroupID + '_' + $(this).data("newsid"));
                            audioObj.get(0).play();
                            $(this).hide();
                        });
                }
                else {
                    ga('send', 'event', '新聞內頁-聽新聞', '聽新聞', pageGroupID + '_' + $(this).data("newsid"));
                    audioObj.get(0).play();
                    $(this).hide();
                }
            }
            else {
                audioObj.get(0).pause();
            }
        });
    }

    
});

function TravelTextAD() {


    var urlTravel = "https://ad.setn.com/ads/TextADTravel";
    var textADdevice = 1;
    if (isMobile()) {
        textADdevice = 2;
    }
    urlTravel += "?device=" + textADdevice;

    var custTagIdUrl = "";
    try {
        if (customtagid != null && customtagid != "") {
            if (urlTravel.indexOf("?") > -1) {
                custTagIdUrl = "&customtagid=" + customtagid;
            }
            else {
                custTagIdUrl =  "?customtagid=" + customtagid;
            }
        }
    }
    catch (ex) {
    }


    $.ajax({
        url: urlTravel + custTagIdUrl,
        dataType: 'text',
        type: 'POST',
        success: function (result) {
            var item = $.parseJSON(result);
            if (item.length > 0) {
                $("#newsTextAD").append('<li><a href="' + item.Url + '" target="_blank" data-layid="' + item.ADRowid + '" class="gt newsTextADItem_T" pa="新聞內頁旅遊文字廣告" pl="TravelAD_' + item.ADRowid + '">' + item.Text + '</a><span class="sponsored"></span></li>');
            }
        },
        error: function (result, status, jqXHR) { }
    }).done(function () {
        ga_track("#newsTextAD");

        $('body').on("click", '.newsTextADItem_T', function () {
            var id = $(this).data("layid");


            $.ajax({
                url: "https://ad.setn.com/api/Travels/PostTravelAD/" + id + "/2/" + textADdevice + custTagIdUrl,
                dataType: 'text',
                type: 'POST',
                success: function (result) {
                },
                error: function (result, status, jqXHR) { }
            });
        });
    });
}


//function loadCurtainAD(openAD) {
//    if (openAD) {
//        var para = [
//              { plate: '/21685920852/setn_boom_1200x500_open', size: [[1200, 500], [1, 1]], id: 'div-gpt-ad-1513936386313-0', area: 'gad_curtain_open', marginTop: 0 },
//        ];
//        GoogleADExecute(para);
//    }
//    else {
//        $("#gad_curtain_open").empty();
//    }
//}




function sidebarBaseLay(box, list) {
    var count = 10;
    if (box.count != null) count = box.count;
    var reItem = "";
    reItem += '<div class="sbNewsList ' + box.typev + '">';
    if (box.typev == "FBAnchor") {
        reItem += '<div class="sbTitle"><a href="AnchorSET.aspx">' + box.title + '</a></div>';
    }
    else {
        reItem += '<div class="sbTitle">' + box.title + '</div>';
    }

    reItem += '<div class="sbNewsItem">';
    jQuery.each(list, function (i, cItem) {
        if (i >= count) {
            return false;
        }

        switch (box.layout) {
            case "LivePrg":
                reItem += sidebarPrgItem(box.pa, box.pl, cItem);
                break;
            case "Prg":
            case "News":
            default:
                if (i <= 0 && box.hasPoint) {
                    reItem += sidebarPointItem(box.pa, box.pl, cItem);
                }
                else {
                    reItem += sidebarBaseItem(box, cItem, i + 1);
                }

                break;
        }
    });
    reItem += '</div>';
    if (box.moreView != null) {
        if (box.typev == "MarketingNews") {
            reItem += '<div class="more"><a href="' + box.moreView + '">看更多 &gt;&gt;</a></div>';
        }
        else {
            reItem += '<div class="more"><a href="' + box.moreView + '">看更多' + box.title + '&gt;&gt;</a></div>';
        }
    }

    reItem += '</div>';

    return reItem

}

function QueryString(name, url) {

    if (url == "" || url == null || url == "undefined") {
        url = window.location.search.substring(1);
    }

    var allvars = url;
    var _vars = allvars.split("&");
    for (i = 0; i < _vars.length; i++) {
        var _var = _vars[i].split("=");
        if (_var[0] == name) return _var[1];
    }
    return "";
}



function sidebarBaseItem(box, cItem, i) {
    var link = cItem.Link;
    if (cItem.Link == null) {
        link = "/News.aspx?NewsID=" + cItem.Id
    }
    var reItem = "";
    reItem += '<div>';
    if (box.Circle) {
        reItem += '<span class="ListCircle">' + i + '</span>';
    }
    reItem += '<a class="gt" pa="' + box.pa + '" pl="' + box.pl + '" href="' + link + '" target="_blank">';
    if (box.showImg) {
        var errImg = "this.src = 'http://attach2.setn.com/newsimages/Default/Working-XL.jpg'"
        reItem += '<img src="' + cItem.Image + '" onerror="' + errImg + '" width="' + box.imgWidth + '" alt="' + cItem.Title + '" />';
    }

    if (box.showSummary) {
        reItem += '<span><b>' + cItem.Title + '</b></span>';
        reItem += '<p>' + cItem.Summary + '</p>';
    }
    else {
        reItem += '<span>' + cItem.Title + '</span>';
    }

    reItem += '</a>';
    reItem += '</div>';
    return reItem;
}

function sidebarPointItem(pa, plate, cItem) {
    var link = cItem.Link;
    if (cItem.Link == null) {
        link = "/News.aspx?NewsID=" + cItem.Id;
    }
    var reItem = "";
    reItem += '<div class="sbNewsItemPoint">';
    reItem += '<a class="gt" pa="' + pa + '" pl="' + plate + '" href="' + link + '"><img src="' + cItem.Image + '" onerror="" width="300" height="169" alt="' + cItem.Title + '" /></a>';
    reItem += '<span class="f_16"><strong><a class="gt" pa="' + pa + '" pl="' + plate + '" href="' + link + '">' + cItem.Title + '</a></strong></span>';
    reItem += '<p>';
    if (cItem.Summary.length > 60) {
        reItem += cItem.Summary.substring(0, 60) + "...";
    }
    else {
        reItem += cItem.Summary;
    }
    reItem += '</p>';
    reItem += '</div>';

    return reItem;

}

function sidebarPrgItem(pa, plate, cItem) {
    var link = cItem.Link;
    if (cItem.Link == null) {
        link = "/News.aspx?NewsID=" + cItem.Id;
    }
    var reItem = "";

    reItem += '<div class="sbNewsItemPoint">';
    reItem += '<div>';
    reItem += '<span class="f_16"><strong><a class="gt" pa="' + pa + '" pl="' + plate + '" href="' + link + '">' + cItem.Title + '</a></strong></span>';
    reItem += '<p>' + cItem.Summary + '</p>';
    reItem += '</div>';
    reItem += '<a class="gt" pa="' + pa + '" pl="' + plate + '" href="' + link + '"><img src="' + cItem.Image + '" onerror="" width="300" height="169" alt="' + cItem.Title + '" /></a>';
    reItem += '</div>';

    return reItem;
}

function sidebarVoteLay(box, list) {
    var count = 10;
    if (box.count != null) count = box.count;
    var reItem = "";
    reItem += '<div class="sbNewsList ' + box.typev + '">';
    reItem += '<div class="sbTitle">' + box.title + '</div>';
    jQuery.each(list, function (i, item) {

        reItem += '<div class="VoteTitle">' + item.Title + '</div>';
        reItem += '<ul>';
        jQuery.each(item.StrObj, function (j, cItem) {
            if (j >= count) {
                return false;
            }
            reItem += '<li>' + cItem + '</li>';
        });
        reItem += '</ul>';
        if (item.StrObj.length > 10) {
            reItem += '<div style="text-align: right; color: #999; margin: 5px 10px;" class="f_14"><a href="/Vote.aspx?VoteID=' + item.Id + '" >......更多選項</a></div>';
        }
        reItem += '<div style="margin: 10px;" class="sidebarVoteBtn">';
        reItem += '<a href="/Vote.aspx?VoteID=' + item.Id + '"><img src="/images/vote/vote-bt-3.png" /></a>';
        var cFn = "setCookie('ViewVote', '1')";
        reItem += '<a href="/Vote.aspx?VoteID=' + item.Id + '" onclick="' + cFn + '" class="Vote">【我想直接看結果】</a>';
        reItem += "</div>";
    });

    reItem += '</div>';
    return reItem;
}


$.ajaxWebService = function (url, dataMap, fnSuccess) {
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: url,
        data: dataMap,
        dataType: "json",
        success: fnSuccess
    });
}

function AjaxGetData(service, json, isAsync, isTextMode, errShowType) {
    return this.ajax_base(service, json, isAsync, isTextMode, errShowType);
};

function ajax_base(service, json, isAsync, isTextMode, errShowType) {

    if (service === null | service === undefined | typeof (service) !== 'string') {
        alert('AjaxGetData操作錯誤!');
        return;
    }

    //json 的處理
    var jSonData = "{}";
    if (json.length > 0) { jSonData = json; }

    //錯誤的 Func 處理
    var errFunc = AjaxErrorAlert;
    if (errShowType !== null | errShowType !== undefined) {
        if (errShowType === 'box') { errFunc = AjaxErrorShowMsg; }
    }

    var reDt = null;
    var cType = "application/json; charset=utf-8";
    var dType = "json";
    if (isTextMode === true) {
        cType = "application/x-www-form-urlencoded";
        dType = "text";
    }

    try {
        jQuery.ajax({
            type: "POST",
            url: service,
            cache: false,
            async: isAsync,
            contentType: cType,
            data: jSonData,
            dataType: dType,
            success: function (dt, arg1, arg2) {
                if (isTextMode === true) {
                    reDt = dt;

                }
                else {
                    reDt = dt.d;
                }
            },
            error: errFunc
        });
    }
    catch (ex) {
        //alert(ex.toString());
    }
    return reDt;
};


//Ajax 錯誤訊息 alert
function AjaxErrorAlert(msg, args) {
    //alert(msg.responseText);
};
//Ajax 錯誤訊息 show box
function AjaxErrorShowMsg(msg, args) {
    //this.showMsg(msg.responseText, 0);
};

function JSON_ToJsonString(obj) {
    var restr = "";
    for (var k in obj) {
        if (restr) { restr += ","; }
        restr += "\"" + k + "\":\"" + obj[k] + "\"";
    }
    restr = "{" + restr + "}";
    return restr;
}

function DisableDFPAD() {
    var pathname = window.location.pathname;
    var site = 0;

    if (pathname.indexOf("/m/") > -1) {
        site = 1;
    }
    else if (pathname.indexOf("/e/") > -1) {
        site = 2;
    }

    var result = true;

    try {
        if (EnableADsBySite.length > 0) {
            jQuery.each(EnableADsBySite, function (i, item) {
                if (item.Site == site) {
                    result = item.EnableADs;
                    return false;
                }
            });
        }

    } catch (e) {

    }


    return result;
}

function GoogleADExecute(exPara, cbEvent) {

    var result = DisableDFPAD();
    if (result === false || result === "false") {
        return false;
    }

    //移除沒有區塊的參數
    var para = new Array();
    for (var i = 0; i < exPara.length; i++) {
        if ($('#' + exPara[i].area).length > 0) { para.push(exPara[i]); }
    }

    googletag.cmd.push(function () {
        var mapping = googletag.sizeMapping().
            addSize([320, 100], [320, 100]).
            addSize([468, 60], [468, 60]).
            addSize([728, 90], [728, 90]).
            addSize([970, 90], [970, 400], [970, 250]).build();


        var id_obj = null;
        var dfpSlots = [];
        for (var i = 0; i < para.length; i++) {
            var slot;
            if (para[i].isrwd === true) {
                slot = googletag.defineSlot(para[i].plate, para[i].size, para[i].id)
                    .defineSizeMapping(mapping)
                    .addService(googletag.pubads());
            }
            else {
                slot = googletag.defineSlot(para[i].plate, para[i].size, para[i].id).addService(googletag.pubads());
            }

            if (para[i].adRecycleCount) {
                googletag.pubads().setTargeting('pagenum', para[i].adRecycleCount);
            }

            dfpSlots.push(slot);
            if (para[i].identifier) { id_obj = para[i].identifier }     //廣告指定參數時 , ** key 大小寫有差
        }

        /*try {
            CriteoRefreshDFP(dfpSlots);
        } catch (ex) {
        }*/

        try {
            var crtg_split = (crtg_content || '').split(';');
            var pubads = googletag.pubads();
            for (var i = 1; i < crtg_split.length; i++) {
                pubads.setTargeting("" + (crtg_split[i - 1].split('='))[0] + "", "" + (crtg_split[i - 1].split('='))[1] + "");
            }

        } catch (ex) {
            console.log("crtg_content pubads err");
        }


        try {
            if ($("#hfWebsite").length > 0) {
                googletag.pubads().setTargeting('website', $("#hfWebsite").val().trim());
            }
        } catch (ex) {
            //console.log("hfWebsite err");
        }

        try {
            if ($("#hfPageGroupId").length > 0) {
                googletag.pubads().setTargeting('pagegroupid', $("#hfPageGroupId").val().trim());
            }
        } catch (ex) {
            //console.log("hfPageGroupId err");
        }

        try {
            if ($("#hfTagId").length > 0) {
                var hftag = $("#hfTagId").val().replace(" ", "").split(",");
                googletag.pubads().setTargeting('Tagid', hftag);
            }
        } catch (ex) {
            //console.log("hfTagId err");
        }

        try {
            if ($("#hfFamousId").length > 0) {
                googletag.pubads().setTargeting('famousid', $("#hfFamousId").val().trim());
            }
        } catch (ex) {
            //console.log("hfFamousId err");
        }

        try {
            if ($("#hfNewsID").length > 0) {
                googletag.pubads().setTargeting('newsid', $("#hfNewsID").val().trim());
            }
        } catch (ex) {
            //console.log("hfNewsID err");
        }

        try {
            if (personalTag && personalTag != '[]') {
                googletag.pubads().setTargeting('personal', personalTag);
            }
        } catch (ex) {
            console.log("pk_id err");
        }


        googletag.pubads().enableSingleRequest();
        googletag.pubads().collapseEmptyDivs();

        if (id_obj) {
            googletag.pubads().setTargeting(id_obj.key, id_obj.value);
        }
        //廣告回傳事件
        if (cbEvent !== null && typeof (cbEvent) === 'function') {
            googletag.pubads().addEventListener('slotRenderEnded', cbEvent);
        }

        try {
            if ($("#hfHasVideo").length > 0) {
                googletag.pubads().setTargeting('isvideo', [$("#hfHasVideo").val().trim()]);
            }
        } catch (ex) {
            console.log("hfHasVideo err");
        }

        try {
            if (customtagid && customtagid != '') {
                googletag.pubads().setTargeting('customtagid', customtagid);
            }
        } catch (ex) {
            console.log("customtagid err");
        }

        googletag.enableServices();
    });

    for (var i = 0; i < para.length; i++) {
        $('#' + para[i].area).html(GetAdContent(para[i]));
    }
}

function GetAdContent(p) {

    try {
        if (p.marginTop == undefined || p.marginTop == null) {
            p.marginTop = 15;
        }
        if (p.marginBottom == undefined || p.marginBottom == null) {
            p.marginBottom = 0;
        }
        var wh = '';
        if (p.size !== null && p.size != undefined) {
            if (typeof (p.size[0]) === 'number') {
                //if (p.size[0] < 970) {
                wh = 'width:' + p.size[0] + 'px; height:' + p.size[1] + 'px;';
                //}
            }
        }
        return '<div id="' + p.id + '" style="' + wh + 'margin-top:' + p.marginTop + 'px;margin-left:auto;margin-right:auto;margin-bottom:' + p.marginBottom + 'px">' +
            '    <scr' + 'ipt type="text/javascript">googletag.cmd.push(function() { googletag.display("' + p.id + '"); });' +
            '    </scr' + 'ipt>' +
            '</div>';
    }
    catch (ex) {
        console.log('DFP-AD', ex);
    }
    return '';
};

function GetDfpVideoAd(container, w, h, autoPlay) {
    var dateTick = new Date().valueOf();
    var url = 'https://pubads.g.doubleclick.net/gampad/ads?sz=1024x768&iu=/21685920852/TonyAD1&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=[referrer_url]&description_url=[description_url]&correlator=' + dateTick;
    console.log(url);
    $.ajax({
        url: url,
        data: '',
        success: function (dt, arg1, arg2) {
            var str = '';

            if ($(dt).find('MediaFiles').length > 0) {
                str = '<video id="videoDFP" style="width:' + w + 'px;height:' + h + 'px;" controls>';
                var mf = $(dt).find('MediaFiles').eq(0).find('MediaFile');
                for (var i = 0; i < mf.length; i++) {
                    var dom_f = mf[i];
                    str += '<source src="' + dom_f.textContent + '" type="' + dom_f.attributes['type'].value + '">';
                }
                str += '</video>';
            }

            //clickThrough
            if ($(dt).find('ClickThrough').length > 0) {
                //alert($(dt).find('ClickThrough')[0]);
            }


            //for (var i = 0; i < dt.childNodes[0].childNodes[0].childNodes[0].childNodes.length; i++) {
            //    var dom = dt.childNodes[0].childNodes[0].childNodes[0].childNodes[i];
            //    alert(dom.tagName);
            //    if(dom.tagName === 'Creatives'){
            //        for (var j = 0; j < dom.childNodes[0].childNodes[0].childNodes.length; j++) {
            //            var dom_m = dom.childNodes[0].childNodes[0].childNodes[j];
            //            if (dom_m.tagName === 'MediaFiles') {
            //                for (var k = 0; k < dom_m.childNodes.length; k++) {
            //                    var dom_f = dom_m.childNodes[k];
            //                    //var dom_f = dom_m.children[j];
            //                }
            //            }
            //        }
            //    }

            $('#' + container).html(str);

            if (autoPlay) {
                document.getElementById("videoDFP").play();
            }
        },
        dataType: 'xml'
    });
}

function setCookie(cname, cvalue, seconds) {
    var d = new Date();
    d.setTime(d.getTime() + (seconds * 1000));
    var expires = "expires=" + d.toGMTString();
    if (seconds > 0) {
        document.cookie = cname + "=" + cvalue + "; " + expires;
    }
    else {
        document.cookie = cname + "=" + cvalue;
    }
}

function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
    }
    return "";
}

function delCookie(name, value, hours) {
    var expires = "";
    var date = new Date();
    date.setTime(date.getTime() + (hours * 60 * 60 * 1000));
    expires = "; expires=" + date.toUTCString();
    document.cookie = name + "=" + (value || "") + expires + ";path=/";
}

var parseQueryString = function () {

    var str = window.location.search;
    var objURL = {};

    str.replace(
        new RegExp("([^?=&]+)(=([^&]*))?", "g"),
        function ($0, $1, $2, $3) {
            objURL[$1.toString().toLowerCase()] = $3;
        }
    );
    return objURL;
};


/// <summary>Web Service 傳回的時間處理</summary>
var WebService_DateTimeFormat = function (dateTime) {
    if (dateTime == null) { alert("呼叫前須先判斷為非null"); }
    var ticks = parseInt(dateTime.replace("Date(", "")
        .replace(")", "")
        .replace("\"", "")
        .replace("\/", ""), 10);
    var d = new Date(ticks);
    return d;
}
var WebService_DateTimeFormat_AMFM = function (dateTime) {
    if (dateTime === null || dateTime === undefined || dateTime === "") { return ""; }
    var d = WebService_DateTimeFormat(dateTime);
    var HourFormat = " AM " + d.getHours();
    if (d.getHours() > 12) {
        HourFormat = " PM " + (d.getHours() - 12);
    }
    var tStr = ((d.getHours() < 10) ? '0' + d.getHours() : d.getHours()) + ":" + ((d.getMinutes() < 10) ? '0' + d.getMinutes() : d.getMinutes());
    return d.getFullYear().toString() + "/" + (d.getMonth() + 1).toString() + "/" + d.getDate().toString() + " " + tStr;
}
var WebService_DateTimeFormat_NoTime = function (dateTime, label) {
    if (dateTime === null || dateTime === undefined || dateTime === "") { return ""; }
    var d = WebService_DateTimeFormat(dateTime);

    if (label) {
        return d.getFullYear().toString() + label + (d.getMonth() + 1).toString() + label + d.getDate().toString();
    }
    else {
        return d.getFullYear().toString() + "/" + (d.getMonth() + 1).toString() + "/" + d.getDate().toString();
    }

}
var WebService_DateTimeFormat_HasTime = function (dateTime) {
    if (dateTime === null || dateTime === undefined || dateTime === "") { return ""; }
    var d = WebService_DateTimeFormat(dateTime);
    var tStr = ((d.getHours() < 10) ? '0' + d.getHours() : d.getHours()) + ":" + ((d.getMinutes() < 10) ? '0' + d.getMinutes() : d.getMinutes());
    return d.getFullYear().toString() + "/" + (d.getMonth() + 1).toString() + "/" + d.getDate().toString() + " " + tStr;
}


function shareFacebookUrl(url) {
    try {
        FB.ui(
            {
                method: 'share',
                href: url
            }, function (response) { });
    }
    catch (e) {

    }

}

function GetImageURL(szImageID, szImagePath, ImgSize, isAdult) {
    if ($("#IMAGESHOST").length > 0) {
        image_shost = $("#IMAGESHOST").val();
    }

    if (isAdult === true) {
        return image_shost + "/Adult/Working-" + ImgSize + ".jpg";
    }

    var sImageFile = image_shost + "/Default/Working-" + ImgSize + ".jpg";

    if (szImageID != null && szImageID != "") {
        sImageFile = image_shost + "/" + szImagePath + szImageID + "-" + ImgSize + ".jpg";
    }
    return sImageFile;
}


function toggleVideo(state) {
    // if state == 'hide', hide. Else: show video
    var iframe = document.getElementById("vodIframe");
    if (iframe != null) {
        document.getElementById("vodIframe").contentWindow.pauseVideo(state);
    }
}

function floatVideo($_anchorPoint, $_videoObj, winScrollTop) {
    if ($("#contFix").length > 0) {
        var contScrollLeft = $("#contFix").offset().left;
        if (!isMobile() && contScrollLeft >= 250) {
            var vScrollbottom = $_anchorPoint.offset().top + ($_anchorPoint.height() / 2);
            var vScrolltop = $_anchorPoint.offset().top;
            if (winScrollTop > vScrollbottom && !$_videoObj.hasClass("floatVideo") && !$_videoObj.hasClass("removedFloat")) {

                $_videoObj.addClass("floatVideo");
                $_videoObj.find("span").show();

                $(".floatVideo").draggable({
                    containment: "window",
                    scroll: false,
                    handle: ".movefloatVideo",
                    stop: function () {
                        var top = $(this).position().top;
                        var left = $(this).position().left;

                        cookieHelper.SetFloatVideo(top, left);
                    }
                }).css({ width: contScrollLeft, height: contScrollLeft * 9 / 16, });

                var floatvb = cookieHelper.GetFloatVideo();

                if (floatvb !== null) {

                    if (floatvb.left <= screen.width && floatvb.top <= screen.height) {
                        $(".floatVideo").css({ left: floatvb.left, top: floatvb.top });
                    }
                }
            }
            else if (winScrollTop <= vScrollbottom && $_videoObj.hasClass("floatVideo")) {
                $_videoObj.removeClass("floatVideo").removeAttr("style");

            }
        }
    }
}


function SetCarouselAD() {
    $(".adCarousel").each(function () {
        var $_adCarousel = $(this);
        var url = $_adCarousel.data("adcode");

        var result = GetAD(url);
        if (result.length > 0) {
            var obj = result[0];

            var item = "";

            item += '<a class="gt" pa="首頁" pl="焦點新聞輪播-廣告" href="' + obj.Url + '" target="_brank"><img class="owl-lazy" data-src="' + obj.ImgUrl + '" alt="' + obj.Text + '" /></a > ';
            item += '<div class="captionText"> <a class="gt" pa="PC首頁" pl="焦點新聞輪播-廣告" href="' + obj.Url + '" target="_brank"><strong>' + obj.Text + '</strong></a></div> ';

            $_adCarousel.html(item);
        }

    });

}


function GetFlowAD(url, para, eletag) {
    var reAD = GetAD(url);

    var custTagIdUrl = "";
    try {
        if (customtagid != null && customtagid != "") {
            custTagIdUrl = "?customtagid=" + customtagid;
        }
    }
    catch (ex) {
    }


    try {
        if (reAD != null) {
            if (reAD.IsShow) {
                if (reAD.IsVideo) {
                    $("#" + eletag).append('<iframe id="iframeAD" src="' + reAD.Url + custTagIdUrl + '" frameborder="0" allowfullscreen scrolling="no" width="970" height="400"></iframe>');
                }
            }
            else {
                GoogleADExecute(para);
            }
        }
        else {
            GoogleADExecute(para);
        }

    } catch (e) {
        GoogleADExecute(para);
    }

    $("#" + eletag).show();

}

function GetAD(url) {
    var obj;
    $.ajax({
        url: url,
        dataType: 'text',
        type: 'GET',
        tradition: true,
        async: false,
        success: function (result) {
            obj = $.parseJSON(result);
        }
    });

    return obj;
}

function isMobile() {
    return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
}

function isChrome() {

    var is_chrome = false;
    try {
        var navi = getBroswer();
        if (navi.broswer === 'Chrome') {
            is_chrome = true;
        }
    }
    catch (ex) {
    }
    return is_chrome;
}

function isntChrome() {
    var isnot_chrome = false;
    try {
        var uAgent = (/fbav|line|micromessenger/i.test(navigator.userAgent.toLowerCase()));
        var navi = getBroswer();
        if (uAgent || navi.broswer !== 'Chrome') {
            isnot_chrome = true;
        }
    }
    catch (ex) {

    }

    return isnot_chrome;
}

function getBroswer() {
    var sys = {};
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/edge\/([\d.]+)/)) ? sys.edge = s[1] :
        (s = ua.match(/rv:([\d.]+)\) like gecko/)) ? sys.ie = s[1] :
            (s = ua.match(/msie ([\d.]+)/)) ? sys.ie = s[1] :
                (s = ua.match(/firefox\/([\d.]+)/)) ? sys.firefox = s[1] :
                    (s = ua.match(/chrome\/([\d.]+)/)) ? sys.chrome = s[1] :
                        (s = ua.match(/crios\/([\d.]+)/)) ? sys.chrome = s[1] :
                            (s = ua.match(/opera.([\d.]+)/)) ? sys.opera = s[1] :
                                (s = ua.match(/version\/([\d.]+).*safari/)) ? sys.safari = s[1] : 0;

    if (sys.edge) return { broswer: "Edge", version: sys.edge };
    if (sys.ie) return { broswer: "IE", version: sys.ie };
    if (sys.firefox) return { broswer: "Firefox", version: sys.firefox };
    if (sys.chrome) return { broswer: "Chrome", version: sys.chrome };
    if (sys.opera) return { broswer: "Opera", version: sys.opera };
    if (sys.safari) return { broswer: "Safari", version: sys.safari };

    return { broswer: "", version: "0" };
}

//內文關鍵字 formating to link
function ContentTagsFormating(contentSelector, isMVCSite) {
    if ($('#ckuse').length === 0 || $('.keyword').length === 0) { return; }
    let pattern = '<a class="tagFormating" href="/Klist.aspx?TagID=0123456789&utm_source=setn.com&utm_medium=dictionary&utm_campaign=wordnews" target="_self"></a>';
    let tagArray = new Array();
    let exChars = ['+', '?', '*', '.', '$', '^', '|'];          //keyword excape letter replace proc.
    $('.keyword > ul > li > a').each(function (index, elem) {
        let w = elem.innerText.replace('#', '');    //原字
        let wreg = w;                               //reg 字
        for (var j = 0; j < exChars.length; j++) {
            if (w.indexOf(exChars[j]) != -1) {
                wreg = w.replace(exChars[j], '\\' + exChars[j]);
            }
        }
        
        let src = elem.pathname + elem.search + '&utm_source=setn.com&utm_medium=dictionary&utm_campaign=wordnews';
        if ((elem.pathname + elem.search).indexOf("?") <= -1) {
             src = elem.pathname + elem.search + '?utm_source=setn.com&utm_medium=dictionary&utm_campaign=wordnews';
        }
        let regExpTag = new RegExp(w, 'i');
        if (regExpTag.test(pattern) === false) {
            tagArray.push({ kw: w, href: src, used: false, kreg: wreg  });
        }
    });


    //內文 (只處理P下方的文字)
    $(contentSelector).each(function (index, elem) {
        let content = $(elem).html();

        if (content.indexOf('<img') != -1) { return; }

        if (content.indexOf('<a') != -1) { return; }

        for (var i = 0; i < tagArray.length; i++) {
            if (tagArray[i].used === false) {
                var regH = new RegExp(tagArray[i].kreg, 'i');
                if (regH.test(content)) {
                    content = content.replace(regH, '<a class="tagFormating" href="' + tagArray[i].href + '" target="_self">' + tagArray[i].kw + "</a>");
                    tagArray[i].used = true;
                }
            }
        }
        $(elem).html(content);
        //console.log(index, elem);
    });


    /*
    if ($(document).width() > 769) {
        $(contentSelector + ' img').each(function (index, img) {
            if (img.height > img.width) {
                img.style.width = "70%";
            }
            else {
                img.style.width = "90%";
            }
            img.style.height = 'auto';
        });
    };*/
}

var setnSearchFunc = null;


function searchAutoComplete(targetId, offsetW, offsetH, completeListId, isEnt, searchFunc, pagegroupID) {
    var jsonLink = 'https://webapi.setn.com/api/APPv6/GetPredictKeyword/1/';
    if (isEnt) {
        jsonLink = 'https://webapi.setn.com/api/APPv6/GetPredictKeyword/8/';
    }
    if (pagegroupID) {
        jsonLink = 'https://webapi.setn.com/api/APPv6/GetPredictKeyword/' + pagegroupID + '/';
    }
    var $target = $("#" + targetId);

    if ($target.length == 0) { return; }

    if (!completeListId) {
        completeListId = 'keywordList';
    }


    if (searchFunc && typeof (searchFunc) === 'function') {
        setnSearchFunc = searchFunc;
    }

    if (!offsetW) { offsetW = 2; }
    if (!offsetH) { offsetH = 8; }

    var w = $target.val();
    if (w.length >= 1) { jsonLink = jsonLink + w; }

    $.getJSON(jsonLink, null, function (data) {
        var kList = document.getElementById(completeListId);
        if (!kList) {
            kList = document.createElement('ul');
            kList.id = completeListId;
            kList.className = 'keywordList';
            document.body.appendChild(kList);

            var pos = $target.offset();
            var ht = pos.top + $target.height() + offsetH;
            var wt = pos.left + offsetW;

            $(kList).css({ top: ht, left: wt, width: $target.width() });

            $("#" + targetId).blur(function () {

                setTimeout(function () {
                    $(kList).hide('slow', function () {
                        var kList = document.getElementById(completeListId);
                        kList.innerHTML = '';
                    });
                }, 1000);
                
            });
        }
        $(kList).show();
        var html = '';
        if (data.length > 0) {
            for (var i = 0; i < data.length; i++) {
                var vo = data[i];
                html += '<li onclick="setkeyword(\'' + vo.tagText + '\', \'' + targetId + '\',\'' + completeListId + '\');">' + vo.tagText + '</li>';
            }
        }
        kList.innerHTML = html;
    });
}

function setkeyword(w, targetId, kListId) {
    $("#" + targetId).val(w);
    var kList = document.getElementById(kListId);
    if (kList) {
        kList.innerHTML = '';
        $(kList).hide();
    }

    if (setnSearchFunc) {
        setnSearchFunc();
    }
}

function formatDate(date, fmt) {
    if (typeof date === 'string') {
        return date;
    }

    if (!fmt) fmt = "yyyy-MM-dd hh:mm:ss";


    if (!date || date === null) return null;
    var o = {
        'M+': date.getMonth() + 1, // 月份
        'd+': date.getDate(), // 日
        'h+': date.getHours(), // 時
        'm+': date.getMinutes(), // 分
        's+': date.getSeconds(), // 秒
        'q+': Math.floor((date.getMonth() + 3) / 3), // 季
        'S': date.getMilliseconds() // 毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
    for (var k in o) {
        if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
    }
    return fmt;
}


function formatUTCDate(date, fmt) {

    if (!fmt) fmt = "yyyy-MM-dd hh:mm:ss";

    if (!date || date === null) return null;
    var o = {
        'M+': new Date(date).getUTCMonth() + 1, // 月份
        'd+': new Date(date).getUTCDate(), // 日
        'h+': new Date(date).getUTCHours(), // 時
        'm+': new Date(date).getUTCMinutes(), // 分
        's+': new Date(date).getUTCSeconds(), // 秒
        'q+': Math.floor((new Date(date).getUTCMonth() + 3) / 3), // 季度
        'S': new Date(date).getUTCMilliseconds() // 毫秒
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (new Date(date).getUTCFullYear() + '').substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
    }
    return fmt;
}

var thousandComma2 = function (number) {

    if (number < 1000) {
        return number.toString();
    }
    var reg = /\d{1,3}(?=(\d{3})+$)/g;
    return (number + '').replace(reg, '$&,');
};

window.Clipboard = (function(window, document, navigator) {
    var textArea,
    copy;

    function isOS() {
        return navigator.userAgent.match(/ipad|iphone/i);
    }

    function createTextArea(text) {
        textArea = document.createElement('textArea');
        textArea.value = text;
        document.body.appendChild(textArea);
    }

    function selectText() {
        var range,
        selection;

        if (isOS()) {
            range = document.createRange();
            range.selectNodeContents(textArea);
            selection = window.getSelection();
            selection.removeAllRanges();
            selection.addRange(range);
            textArea.setSelectionRange(0, 999999);
        } 
        else {
            textArea.select();
        }
    }

    function copyToClipboard() {
        document.execCommand("Copy");
        document.body.removeChild(textArea);
    }

    copy = function(text) {
        createTextArea(text);
        selectText();
        copyToClipboard();
    };

    return {
        copy: copy
    };
})(window, document, navigator);

;
/**
 * Owl Carousel v2.3.4
 * Copyright 2013-2018 David Deutsch
 * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
 */
!function(a,b,c,d){function e(b,c){this.settings=null,this.options=a.extend({},e.Defaults,c),this.$element=a(b),this._handlers={},this._plugins={},this._supress={},this._current=null,this._speed=null,this._coordinates=[],this._breakpoint=null,this._width=null,this._items=[],this._clones=[],this._mergers=[],this._widths=[],this._invalidated={},this._pipe=[],this._drag={time:null,target:null,pointer:null,stage:{start:null,current:null},direction:null},this._states={current:{},tags:{initializing:["busy"],animating:["busy"],dragging:["interacting"]}},a.each(["onResize","onThrottledResize"],a.proxy(function(b,c){this._handlers[c]=a.proxy(this[c],this)},this)),a.each(e.Plugins,a.proxy(function(a,b){this._plugins[a.charAt(0).toLowerCase()+a.slice(1)]=new b(this)},this)),a.each(e.Workers,a.proxy(function(b,c){this._pipe.push({filter:c.filter,run:a.proxy(c.run,this)})},this)),this.setup(),this.initialize()}e.Defaults={items:3,loop:!1,center:!1,rewind:!1,checkVisibility:!0,mouseDrag:!0,touchDrag:!0,pullDrag:!0,freeDrag:!1,margin:0,stagePadding:0,merge:!1,mergeFit:!0,autoWidth:!1,startPosition:0,rtl:!1,smartSpeed:250,fluidSpeed:!1,dragEndSpeed:!1,responsive:{},responsiveRefreshRate:200,responsiveBaseElement:b,fallbackEasing:"swing",slideTransition:"",info:!1,nestedItemSelector:!1,itemElement:"div",stageElement:"div",refreshClass:"owl-refresh",loadedClass:"owl-loaded",loadingClass:"owl-loading",rtlClass:"owl-rtl",responsiveClass:"owl-responsive",dragClass:"owl-drag",itemClass:"owl-item",stageClass:"owl-stage",stageOuterClass:"owl-stage-outer",grabClass:"owl-grab"},e.Width={Default:"default",Inner:"inner",Outer:"outer"},e.Type={Event:"event",State:"state"},e.Plugins={},e.Workers=[{filter:["width","settings"],run:function(){this._width=this.$element.width()}},{filter:["width","items","settings"],run:function(a){a.current=this._items&&this._items[this.relative(this._current)]}},{filter:["items","settings"],run:function(){this.$stage.children(".cloned").remove()}},{filter:["width","items","settings"],run:function(a){var b=this.settings.margin||"",c=!this.settings.autoWidth,d=this.settings.rtl,e={width:"auto","margin-left":d?b:"","margin-right":d?"":b};!c&&this.$stage.children().css(e),a.css=e}},{filter:["width","items","settings"],run:function(a){var b=(this.width()/this.settings.items).toFixed(3)-this.settings.margin,c=null,d=this._items.length,e=!this.settings.autoWidth,f=[];for(a.items={merge:!1,width:b};d--;)c=this._mergers[d],c=this.settings.mergeFit&&Math.min(c,this.settings.items)||c,a.items.merge=c>1||a.items.merge,f[d]=e?b*c:this._items[d].width();this._widths=f}},{filter:["items","settings"],run:function(){var b=[],c=this._items,d=this.settings,e=Math.max(2*d.items,4),f=2*Math.ceil(c.length/2),g=d.loop&&c.length?d.rewind?e:Math.max(e,f):0,h="",i="";for(g/=2;g>0;)b.push(this.normalize(b.length/2,!0)),h+=c[b[b.length-1]][0].outerHTML,b.push(this.normalize(c.length-1-(b.length-1)/2,!0)),i=c[b[b.length-1]][0].outerHTML+i,g-=1;this._clones=b,a(h).addClass("cloned").appendTo(this.$stage),a(i).addClass("cloned").prependTo(this.$stage)}},{filter:["width","items","settings"],run:function(){for(var a=this.settings.rtl?1:-1,b=this._clones.length+this._items.length,c=-1,d=0,e=0,f=[];++c<b;)d=f[c-1]||0,e=this._widths[this.relative(c)]+this.settings.margin,f.push(d+e*a);this._coordinates=f}},{filter:["width","items","settings"],run:function(){var a=this.settings.stagePadding,b=this._coordinates,c={width:Math.ceil(Math.abs(b[b.length-1]))+2*a,"padding-left":a||"","padding-right":a||""};this.$stage.css(c)}},{filter:["width","items","settings"],run:function(a){var b=this._coordinates.length,c=!this.settings.autoWidth,d=this.$stage.children();if(c&&a.items.merge)for(;b--;)a.css.width=this._widths[this.relative(b)],d.eq(b).css(a.css);else c&&(a.css.width=a.items.width,d.css(a.css))}},{filter:["items"],run:function(){this._coordinates.length<1&&this.$stage.removeAttr("style")}},{filter:["width","items","settings"],run:function(a){a.current=a.current?this.$stage.children().index(a.current):0,a.current=Math.max(this.minimum(),Math.min(this.maximum(),a.current)),this.reset(a.current)}},{filter:["position"],run:function(){this.animate(this.coordinates(this._current))}},{filter:["width","position","items","settings"],run:function(){var a,b,c,d,e=this.settings.rtl?1:-1,f=2*this.settings.stagePadding,g=this.coordinates(this.current())+f,h=g+this.width()*e,i=[];for(c=0,d=this._coordinates.length;c<d;c++)a=this._coordinates[c-1]||0,b=Math.abs(this._coordinates[c])+f*e,(this.op(a,"<=",g)&&this.op(a,">",h)||this.op(b,"<",g)&&this.op(b,">",h))&&i.push(c);this.$stage.children(".active").removeClass("active"),this.$stage.children(":eq("+i.join("), :eq(")+")").addClass("active"),this.$stage.children(".center").removeClass("center"),this.settings.center&&this.$stage.children().eq(this.current()).addClass("center")}}],e.prototype.initializeStage=function(){this.$stage=this.$element.find("."+this.settings.stageClass),this.$stage.length||(this.$element.addClass(this.options.loadingClass),this.$stage=a("<"+this.settings.stageElement+">",{class:this.settings.stageClass}).wrap(a("<div/>",{class:this.settings.stageOuterClass})),this.$element.append(this.$stage.parent()))},e.prototype.initializeItems=function(){var b=this.$element.find(".owl-item");if(b.length)return this._items=b.get().map(function(b){return a(b)}),this._mergers=this._items.map(function(){return 1}),void this.refresh();this.replace(this.$element.children().not(this.$stage.parent())),this.isVisible()?this.refresh():this.invalidate("width"),this.$element.removeClass(this.options.loadingClass).addClass(this.options.loadedClass)},e.prototype.initialize=function(){if(this.enter("initializing"),this.trigger("initialize"),this.$element.toggleClass(this.settings.rtlClass,this.settings.rtl),this.settings.autoWidth&&!this.is("pre-loading")){var a,b,c;a=this.$element.find("img"),b=this.settings.nestedItemSelector?"."+this.settings.nestedItemSelector:d,c=this.$element.children(b).width(),a.length&&c<=0&&this.preloadAutoWidthImages(a)}this.initializeStage(),this.initializeItems(),this.registerEventHandlers(),this.leave("initializing"),this.trigger("initialized")},e.prototype.isVisible=function(){return!this.settings.checkVisibility||this.$element.is(":visible")},e.prototype.setup=function(){var b=this.viewport(),c=this.options.responsive,d=-1,e=null;c?(a.each(c,function(a){a<=b&&a>d&&(d=Number(a))}),e=a.extend({},this.options,c[d]),"function"==typeof e.stagePadding&&(e.stagePadding=e.stagePadding()),delete e.responsive,e.responsiveClass&&this.$element.attr("class",this.$element.attr("class").replace(new RegExp("("+this.options.responsiveClass+"-)\\S+\\s","g"),"$1"+d))):e=a.extend({},this.options),this.trigger("change",{property:{name:"settings",value:e}}),this._breakpoint=d,this.settings=e,this.invalidate("settings"),this.trigger("changed",{property:{name:"settings",value:this.settings}})},e.prototype.optionsLogic=function(){this.settings.autoWidth&&(this.settings.stagePadding=!1,this.settings.merge=!1)},e.prototype.prepare=function(b){var c=this.trigger("prepare",{content:b});return c.data||(c.data=a("<"+this.settings.itemElement+"/>").addClass(this.options.itemClass).append(b)),this.trigger("prepared",{content:c.data}),c.data},e.prototype.update=function(){for(var b=0,c=this._pipe.length,d=a.proxy(function(a){return this[a]},this._invalidated),e={};b<c;)(this._invalidated.all||a.grep(this._pipe[b].filter,d).length>0)&&this._pipe[b].run(e),b++;this._invalidated={},!this.is("valid")&&this.enter("valid")},e.prototype.width=function(a){switch(a=a||e.Width.Default){case e.Width.Inner:case e.Width.Outer:return this._width;default:return this._width-2*this.settings.stagePadding+this.settings.margin}},e.prototype.refresh=function(){this.enter("refreshing"),this.trigger("refresh"),this.setup(),this.optionsLogic(),this.$element.addClass(this.options.refreshClass),this.update(),this.$element.removeClass(this.options.refreshClass),this.leave("refreshing"),this.trigger("refreshed")},e.prototype.onThrottledResize=function(){b.clearTimeout(this.resizeTimer),this.resizeTimer=b.setTimeout(this._handlers.onResize,this.settings.responsiveRefreshRate)},e.prototype.onResize=function(){return!!this._items.length&&(this._width!==this.$element.width()&&(!!this.isVisible()&&(this.enter("resizing"),this.trigger("resize").isDefaultPrevented()?(this.leave("resizing"),!1):(this.invalidate("width"),this.refresh(),this.leave("resizing"),void this.trigger("resized")))))},e.prototype.registerEventHandlers=function(){a.support.transition&&this.$stage.on(a.support.transition.end+".owl.core",a.proxy(this.onTransitionEnd,this)),!1!==this.settings.responsive&&this.on(b,"resize",this._handlers.onThrottledResize),this.settings.mouseDrag&&(this.$element.addClass(this.options.dragClass),this.$stage.on("mousedown.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("dragstart.owl.core selectstart.owl.core",function(){return!1})),this.settings.touchDrag&&(this.$stage.on("touchstart.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("touchcancel.owl.core",a.proxy(this.onDragEnd,this)))},e.prototype.onDragStart=function(b){var d=null;3!==b.which&&(a.support.transform?(d=this.$stage.css("transform").replace(/.*\(|\)| /g,"").split(","),d={x:d[16===d.length?12:4],y:d[16===d.length?13:5]}):(d=this.$stage.position(),d={x:this.settings.rtl?d.left+this.$stage.width()-this.width()+this.settings.margin:d.left,y:d.top}),this.is("animating")&&(a.support.transform?this.animate(d.x):this.$stage.stop(),this.invalidate("position")),this.$element.toggleClass(this.options.grabClass,"mousedown"===b.type),this.speed(0),this._drag.time=(new Date).getTime(),this._drag.target=a(b.target),this._drag.stage.start=d,this._drag.stage.current=d,this._drag.pointer=this.pointer(b),a(c).on("mouseup.owl.core touchend.owl.core",a.proxy(this.onDragEnd,this)),a(c).one("mousemove.owl.core touchmove.owl.core",a.proxy(function(b){var d=this.difference(this._drag.pointer,this.pointer(b));a(c).on("mousemove.owl.core touchmove.owl.core",a.proxy(this.onDragMove,this)),Math.abs(d.x)<Math.abs(d.y)&&this.is("valid")||(b.preventDefault(),this.enter("dragging"),this.trigger("drag"))},this)))},e.prototype.onDragMove=function(a){var b=null,c=null,d=null,e=this.difference(this._drag.pointer,this.pointer(a)),f=this.difference(this._drag.stage.start,e);this.is("dragging")&&(a.preventDefault(),this.settings.loop?(b=this.coordinates(this.minimum()),c=this.coordinates(this.maximum()+1)-b,f.x=((f.x-b)%c+c)%c+b):(b=this.settings.rtl?this.coordinates(this.maximum()):this.coordinates(this.minimum()),c=this.settings.rtl?this.coordinates(this.minimum()):this.coordinates(this.maximum()),d=this.settings.pullDrag?-1*e.x/5:0,f.x=Math.max(Math.min(f.x,b+d),c+d)),this._drag.stage.current=f,this.animate(f.x))},e.prototype.onDragEnd=function(b){var d=this.difference(this._drag.pointer,this.pointer(b)),e=this._drag.stage.current,f=d.x>0^this.settings.rtl?"left":"right";a(c).off(".owl.core"),this.$element.removeClass(this.options.grabClass),(0!==d.x&&this.is("dragging")||!this.is("valid"))&&(this.speed(this.settings.dragEndSpeed||this.settings.smartSpeed),this.current(this.closest(e.x,0!==d.x?f:this._drag.direction)),this.invalidate("position"),this.update(),this._drag.direction=f,(Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)&&this._drag.target.one("click.owl.core",function(){return!1})),this.is("dragging")&&(this.leave("dragging"),this.trigger("dragged"))},e.prototype.closest=function(b,c){var e=-1,f=30,g=this.width(),h=this.coordinates();return this.settings.freeDrag||a.each(h,a.proxy(function(a,i){return"left"===c&&b>i-f&&b<i+f?e=a:"right"===c&&b>i-g-f&&b<i-g+f?e=a+1:this.op(b,"<",i)&&this.op(b,">",h[a+1]!==d?h[a+1]:i-g)&&(e="left"===c?a+1:a),-1===e},this)),this.settings.loop||(this.op(b,">",h[this.minimum()])?e=b=this.minimum():this.op(b,"<",h[this.maximum()])&&(e=b=this.maximum())),e},e.prototype.animate=function(b){var c=this.speed()>0;this.is("animating")&&this.onTransitionEnd(),c&&(this.enter("animating"),this.trigger("translate")),a.support.transform3d&&a.support.transition?this.$stage.css({transform:"translate3d("+b+"px,0px,0px)",transition:this.speed()/1e3+"s"+(this.settings.slideTransition?" "+this.settings.slideTransition:"")}):c?this.$stage.animate({left:b+"px"},this.speed(),this.settings.fallbackEasing,a.proxy(this.onTransitionEnd,this)):this.$stage.css({left:b+"px"})},e.prototype.is=function(a){return this._states.current[a]&&this._states.current[a]>0},e.prototype.current=function(a){if(a===d)return this._current;if(0===this._items.length)return d;if(a=this.normalize(a),this._current!==a){var b=this.trigger("change",{property:{name:"position",value:a}});b.data!==d&&(a=this.normalize(b.data)),this._current=a,this.invalidate("position"),this.trigger("changed",{property:{name:"position",value:this._current}})}return this._current},e.prototype.invalidate=function(b){return"string"===a.type(b)&&(this._invalidated[b]=!0,this.is("valid")&&this.leave("valid")),a.map(this._invalidated,function(a,b){return b})},e.prototype.reset=function(a){(a=this.normalize(a))!==d&&(this._speed=0,this._current=a,this.suppress(["translate","translated"]),this.animate(this.coordinates(a)),this.release(["translate","translated"]))},e.prototype.normalize=function(a,b){var c=this._items.length,e=b?0:this._clones.length;return!this.isNumeric(a)||c<1?a=d:(a<0||a>=c+e)&&(a=((a-e/2)%c+c)%c+e/2),a},e.prototype.relative=function(a){return a-=this._clones.length/2,this.normalize(a,!0)},e.prototype.maximum=function(a){var b,c,d,e=this.settings,f=this._coordinates.length;if(e.loop)f=this._clones.length/2+this._items.length-1;else if(e.autoWidth||e.merge){if(b=this._items.length)for(c=this._items[--b].width(),d=this.$element.width();b--&&!((c+=this._items[b].width()+this.settings.margin)>d););f=b+1}else f=e.center?this._items.length-1:this._items.length-e.items;return a&&(f-=this._clones.length/2),Math.max(f,0)},e.prototype.minimum=function(a){return a?0:this._clones.length/2},e.prototype.items=function(a){return a===d?this._items.slice():(a=this.normalize(a,!0),this._items[a])},e.prototype.mergers=function(a){return a===d?this._mergers.slice():(a=this.normalize(a,!0),this._mergers[a])},e.prototype.clones=function(b){var c=this._clones.length/2,e=c+this._items.length,f=function(a){return a%2==0?e+a/2:c-(a+1)/2};return b===d?a.map(this._clones,function(a,b){return f(b)}):a.map(this._clones,function(a,c){return a===b?f(c):null})},e.prototype.speed=function(a){return a!==d&&(this._speed=a),this._speed},e.prototype.coordinates=function(b){var c,e=1,f=b-1;return b===d?a.map(this._coordinates,a.proxy(function(a,b){return this.coordinates(b)},this)):(this.settings.center?(this.settings.rtl&&(e=-1,f=b+1),c=this._coordinates[b],c+=(this.width()-c+(this._coordinates[f]||0))/2*e):c=this._coordinates[f]||0,c=Math.ceil(c))},e.prototype.duration=function(a,b,c){return 0===c?0:Math.min(Math.max(Math.abs(b-a),1),6)*Math.abs(c||this.settings.smartSpeed)},e.prototype.to=function(a,b){var c=this.current(),d=null,e=a-this.relative(c),f=(e>0)-(e<0),g=this._items.length,h=this.minimum(),i=this.maximum();this.settings.loop?(!this.settings.rewind&&Math.abs(e)>g/2&&(e+=-1*f*g),a=c+e,(d=((a-h)%g+g)%g+h)!==a&&d-e<=i&&d-e>0&&(c=d-e,a=d,this.reset(c))):this.settings.rewind?(i+=1,a=(a%i+i)%i):a=Math.max(h,Math.min(i,a)),this.speed(this.duration(c,a,b)),this.current(a),this.isVisible()&&this.update()},e.prototype.next=function(a){a=a||!1,this.to(this.relative(this.current())+1,a)},e.prototype.prev=function(a){a=a||!1,this.to(this.relative(this.current())-1,a)},e.prototype.onTransitionEnd=function(a){if(a!==d&&(a.stopPropagation(),(a.target||a.srcElement||a.originalTarget)!==this.$stage.get(0)))return!1;this.leave("animating"),this.trigger("translated")},e.prototype.viewport=function(){var d;return this.options.responsiveBaseElement!==b?d=a(this.options.responsiveBaseElement).width():b.innerWidth?d=b.innerWidth:c.documentElement&&c.documentElement.clientWidth?d=c.documentElement.clientWidth:console.warn("Can not detect viewport width."),d},e.prototype.replace=function(b){this.$stage.empty(),this._items=[],b&&(b=b instanceof jQuery?b:a(b)),this.settings.nestedItemSelector&&(b=b.find("."+this.settings.nestedItemSelector)),b.filter(function(){return 1===this.nodeType}).each(a.proxy(function(a,b){b=this.prepare(b),this.$stage.append(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)},this)),this.reset(this.isNumeric(this.settings.startPosition)?this.settings.startPosition:0),this.invalidate("items")},e.prototype.add=function(b,c){var e=this.relative(this._current);c=c===d?this._items.length:this.normalize(c,!0),b=b instanceof jQuery?b:a(b),this.trigger("add",{content:b,position:c}),b=this.prepare(b),0===this._items.length||c===this._items.length?(0===this._items.length&&this.$stage.append(b),0!==this._items.length&&this._items[c-1].after(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)):(this._items[c].before(b),this._items.splice(c,0,b),this._mergers.splice(c,0,1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)),this._items[e]&&this.reset(this._items[e].index()),this.invalidate("items"),this.trigger("added",{content:b,position:c})},e.prototype.remove=function(a){(a=this.normalize(a,!0))!==d&&(this.trigger("remove",{content:this._items[a],position:a}),this._items[a].remove(),this._items.splice(a,1),this._mergers.splice(a,1),this.invalidate("items"),this.trigger("removed",{content:null,position:a}))},e.prototype.preloadAutoWidthImages=function(b){b.each(a.proxy(function(b,c){this.enter("pre-loading"),c=a(c),a(new Image).one("load",a.proxy(function(a){c.attr("src",a.target.src),c.css("opacity",1),this.leave("pre-loading"),!this.is("pre-loading")&&!this.is("initializing")&&this.refresh()},this)).attr("src",c.attr("src")||c.attr("data-src")||c.attr("data-src-retina"))},this))},e.prototype.destroy=function(){this.$element.off(".owl.core"),this.$stage.off(".owl.core"),a(c).off(".owl.core"),!1!==this.settings.responsive&&(b.clearTimeout(this.resizeTimer),this.off(b,"resize",this._handlers.onThrottledResize));for(var d in this._plugins)this._plugins[d].destroy();this.$stage.children(".cloned").remove(),this.$stage.unwrap(),this.$stage.children().contents().unwrap(),this.$stage.children().unwrap(),this.$stage.remove(),this.$element.removeClass(this.options.refreshClass).removeClass(this.options.loadingClass).removeClass(this.options.loadedClass).removeClass(this.options.rtlClass).removeClass(this.options.dragClass).removeClass(this.options.grabClass).attr("class",this.$element.attr("class").replace(new RegExp(this.options.responsiveClass+"-\\S+\\s","g"),"")).removeData("owl.carousel")},e.prototype.op=function(a,b,c){var d=this.settings.rtl;switch(b){case"<":return d?a>c:a<c;case">":return d?a<c:a>c;case">=":return d?a<=c:a>=c;case"<=":return d?a>=c:a<=c}},e.prototype.on=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c)},e.prototype.off=function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c)},e.prototype.trigger=function(b,c,d,f,g){var h={item:{count:this._items.length,index:this.current()}},i=a.camelCase(a.grep(["on",b,d],function(a){return a}).join("-").toLowerCase()),j=a.Event([b,"owl",d||"carousel"].join(".").toLowerCase(),a.extend({relatedTarget:this},h,c));return this._supress[b]||(a.each(this._plugins,function(a,b){b.onTrigger&&b.onTrigger(j)}),this.register({type:e.Type.Event,name:b}),this.$element.trigger(j),this.settings&&"function"==typeof this.settings[i]&&this.settings[i].call(this,j)),j},e.prototype.enter=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]===d&&(this._states.current[b]=0),this._states.current[b]++},this))},e.prototype.leave=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]--},this))},e.prototype.register=function(b){if(b.type===e.Type.Event){if(a.event.special[b.name]||(a.event.special[b.name]={}),!a.event.special[b.name].owl){var c=a.event.special[b.name]._default;a.event.special[b.name]._default=function(a){return!c||!c.apply||a.namespace&&-1!==a.namespace.indexOf("owl")?a.namespace&&a.namespace.indexOf("owl")>-1:c.apply(this,arguments)},a.event.special[b.name].owl=!0}}else b.type===e.Type.State&&(this._states.tags[b.name]?this._states.tags[b.name]=this._states.tags[b.name].concat(b.tags):this._states.tags[b.name]=b.tags,this._states.tags[b.name]=a.grep(this._states.tags[b.name],a.proxy(function(c,d){return a.inArray(c,this._states.tags[b.name])===d},this)))},e.prototype.suppress=function(b){a.each(b,a.proxy(function(a,b){this._supress[b]=!0},this))},e.prototype.release=function(b){a.each(b,a.proxy(function(a,b){delete this._supress[b]},this))},e.prototype.pointer=function(a){var c={x:null,y:null};return a=a.originalEvent||a||b.event,a=a.touches&&a.touches.length?a.touches[0]:a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:a,a.pageX?(c.x=a.pageX,c.y=a.pageY):(c.x=a.clientX,c.y=a.clientY),c},e.prototype.isNumeric=function(a){return!isNaN(parseFloat(a))},e.prototype.difference=function(a,b){return{x:a.x-b.x,y:a.y-b.y}},a.fn.owlCarousel=function(b){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var d=a(this),f=d.data("owl.carousel");f||(f=new e(this,"object"==typeof b&&b),d.data("owl.carousel",f),a.each(["next","prev","to","destroy","refresh","replace","add","remove"],function(b,c){f.register({type:e.Type.Event,name:c}),f.$element.on(c+".owl.carousel.core",a.proxy(function(a){a.namespace&&a.relatedTarget!==this&&(this.suppress([c]),f[c].apply(this,[].slice.call(arguments,1)),this.release([c]))},f))})),"string"==typeof b&&"_"!==b.charAt(0)&&f[b].apply(f,c)})},a.fn.owlCarousel.Constructor=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._interval=null,this._visible=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoRefresh&&this.watch()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers)};e.Defaults={autoRefresh:!0,autoRefreshInterval:500},e.prototype.watch=function(){this._interval||(this._visible=this._core.isVisible(),this._interval=b.setInterval(a.proxy(this.refresh,this),this._core.settings.autoRefreshInterval))},e.prototype.refresh=function(){this._core.isVisible()!==this._visible&&(this._visible=!this._visible,this._core.$element.toggleClass("owl-hidden",!this._visible),this._visible&&this._core.invalidate("width")&&this._core.refresh())},e.prototype.destroy=function(){var a,c;b.clearInterval(this._interval);for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoRefresh=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._loaded=[],this._handlers={"initialized.owl.carousel change.owl.carousel resized.owl.carousel":a.proxy(function(b){if(b.namespace&&this._core.settings&&this._core.settings.lazyLoad&&(b.property&&"position"==b.property.name||"initialized"==b.type)){var c=this._core.settings,e=c.center&&Math.ceil(c.items/2)||c.items,f=c.center&&-1*e||0,g=(b.property&&b.property.value!==d?b.property.value:this._core.current())+f,h=this._core.clones().length,i=a.proxy(function(a,b){this.load(b)},this);for(c.lazyLoadEager>0&&(e+=c.lazyLoadEager,c.loop&&(g-=c.lazyLoadEager,e++));f++<e;)this.load(h/2+this._core.relative(g)),h&&a.each(this._core.clones(this._core.relative(g)),i),g++}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers)};e.Defaults={lazyLoad:!1,lazyLoadEager:0},e.prototype.load=function(c){var d=this._core.$stage.children().eq(c),e=d&&d.find(".owl-lazy");!e||a.inArray(d.get(0),this._loaded)>-1||(e.each(a.proxy(function(c,d){var e,f=a(d),g=b.devicePixelRatio>1&&f.attr("data-src-retina")||f.attr("data-src")||f.attr("data-srcset");this._core.trigger("load",{element:f,url:g},"lazy"),f.is("img")?f.one("load.owl.lazy",a.proxy(function(){f.css("opacity",1),this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("src",g):f.is("source")?f.one("load.owl.lazy",a.proxy(function(){this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("srcset",g):(e=new Image,e.onload=a.proxy(function(){f.css({"background-image":'url("'+g+'")',opacity:"1"}),this._core.trigger("loaded",{element:f,url:g},"lazy")},this),e.src=g)},this)),this._loaded.push(d.get(0)))},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this._core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Lazy=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(c){this._core=c,this._previousHeight=null,this._handlers={"initialized.owl.carousel refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&this.update()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&"position"===a.property.name&&this.update()},this),"loaded.owl.lazy":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&a.element.closest("."+this._core.settings.itemClass).index()===this._core.current()&&this.update()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._intervalId=null;var d=this;a(b).on("load",function(){d._core.settings.autoHeight&&d.update()}),a(b).resize(function(){d._core.settings.autoHeight&&(null!=d._intervalId&&clearTimeout(d._intervalId),d._intervalId=setTimeout(function(){d.update()},250))})};e.Defaults={autoHeight:!1,autoHeightClass:"owl-height"},e.prototype.update=function(){var b=this._core._current,c=b+this._core.settings.items,d=this._core.settings.lazyLoad,e=this._core.$stage.children().toArray().slice(b,c),f=[],g=0;a.each(e,function(b,c){f.push(a(c).height())}),g=Math.max.apply(null,f),g<=1&&d&&this._previousHeight&&(g=this._previousHeight),this._previousHeight=g,this._core.$stage.parent().height(g).addClass(this._core.settings.autoHeightClass)},e.prototype.destroy=function(){var a,b;for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoHeight=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._videos={},this._playing=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.register({type:"state",name:"playing",tags:["interacting"]})},this),"resize.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.video&&this.isInFullScreen()&&a.preventDefault()},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.is("resizing")&&this._core.$stage.find(".cloned .owl-video-frame").remove()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"===a.property.name&&this._playing&&this.stop()},this),"prepared.owl.carousel":a.proxy(function(b){if(b.namespace){var c=a(b.content).find(".owl-video");c.length&&(c.css("display","none"),this.fetch(c,a(b.content)))}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._core.$element.on("click.owl.video",".owl-video-play-icon",a.proxy(function(a){this.play(a)},this))};e.Defaults={video:!1,videoHeight:!1,videoWidth:!1},e.prototype.fetch=function(a,b){var c=function(){return a.attr("data-vimeo-id")?"vimeo":a.attr("data-vzaar-id")?"vzaar":"youtube"}(),d=a.attr("data-vimeo-id")||a.attr("data-youtube-id")||a.attr("data-vzaar-id"),e=a.attr("data-width")||this._core.settings.videoWidth,f=a.attr("data-height")||this._core.settings.videoHeight,g=a.attr("href");if(!g)throw new Error("Missing video URL.");if(d=g.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/),d[3].indexOf("youtu")>-1)c="youtube";else if(d[3].indexOf("vimeo")>-1)c="vimeo";else{if(!(d[3].indexOf("vzaar")>-1))throw new Error("Video URL not supported.");c="vzaar"}d=d[6],this._videos[g]={type:c,id:d,width:e,height:f},b.attr("data-video",g),this.thumbnail(a,this._videos[g])},e.prototype.thumbnail=function(b,c){var d,e,f,g=c.width&&c.height?"width:"+c.width+"px;height:"+c.height+"px;":"",h=b.find("img"),i="src",j="",k=this._core.settings,l=function(c){e='<div class="owl-video-play-icon"></div>',d=k.lazyLoad?a("<div/>",{class:"owl-video-tn "+j,srcType:c}):a("<div/>",{class:"owl-video-tn",style:"opacity:1;background-image:url("+c+")"}),b.after(d),b.after(e)};if(b.wrap(a("<div/>",{class:"owl-video-wrapper",style:g})),this._core.settings.lazyLoad&&(i="data-src",j="owl-lazy"),h.length)return l(h.attr(i)),h.remove(),!1;"youtube"===c.type?(f="//img.youtube.com/vi/"+c.id+"/hqdefault.jpg",l(f)):"vimeo"===c.type?a.ajax({type:"GET",url:"//vimeo.com/api/v2/video/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a[0].thumbnail_large,l(f)}}):"vzaar"===c.type&&a.ajax({type:"GET",url:"//vzaar.com/api/videos/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a.framegrab_url,l(f)}})},e.prototype.stop=function(){this._core.trigger("stop",null,"video"),this._playing.find(".owl-video-frame").remove(),this._playing.removeClass("owl-video-playing"),this._playing=null,this._core.leave("playing"),this._core.trigger("stopped",null,"video")},e.prototype.play=function(b){var c,d=a(b.target),e=d.closest("."+this._core.settings.itemClass),f=this._videos[e.attr("data-video")],g=f.width||"100%",h=f.height||this._core.$stage.height();this._playing||(this._core.enter("playing"),this._core.trigger("play",null,"video"),e=this._core.items(this._core.relative(e.index())),this._core.reset(e.index()),c=a('<iframe frameborder="0" allowfullscreen mozallowfullscreen webkitAllowFullScreen ></iframe>'),c.attr("height",h),c.attr("width",g),"youtube"===f.type?c.attr("src","//www.youtube.com/embed/"+f.id+"?autoplay=1&rel=0&v="+f.id):"vimeo"===f.type?c.attr("src","//player.vimeo.com/video/"+f.id+"?autoplay=1"):"vzaar"===f.type&&c.attr("src","//view.vzaar.com/"+f.id+"/player?autoplay=true"),a(c).wrap('<div class="owl-video-frame" />').insertAfter(e.find(".owl-video")),this._playing=e.addClass("owl-video-playing"))},e.prototype.isInFullScreen=function(){var b=c.fullscreenElement||c.mozFullScreenElement||c.webkitFullscreenElement;return b&&a(b).parent().hasClass("owl-video-frame")},e.prototype.destroy=function(){var a,b;this._core.$element.off("click.owl.video");for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Video=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this.core=b,this.core.options=a.extend({},e.Defaults,this.core.options),this.swapping=!0,this.previous=d,this.next=d,this.handlers={"change.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&(this.previous=this.core.current(),this.next=a.property.value)},this),"drag.owl.carousel dragged.owl.carousel translated.owl.carousel":a.proxy(function(a){a.namespace&&(this.swapping="translated"==a.type)},this),"translate.owl.carousel":a.proxy(function(a){a.namespace&&this.swapping&&(this.core.options.animateOut||this.core.options.animateIn)&&this.swap()},this)},this.core.$element.on(this.handlers)};e.Defaults={animateOut:!1,
animateIn:!1},e.prototype.swap=function(){if(1===this.core.settings.items&&a.support.animation&&a.support.transition){this.core.speed(0);var b,c=a.proxy(this.clear,this),d=this.core.$stage.children().eq(this.previous),e=this.core.$stage.children().eq(this.next),f=this.core.settings.animateIn,g=this.core.settings.animateOut;this.core.current()!==this.previous&&(g&&(b=this.core.coordinates(this.previous)-this.core.coordinates(this.next),d.one(a.support.animation.end,c).css({left:b+"px"}).addClass("animated owl-animated-out").addClass(g)),f&&e.one(a.support.animation.end,c).addClass("animated owl-animated-in").addClass(f))}},e.prototype.clear=function(b){a(b.target).css({left:""}).removeClass("animated owl-animated-out owl-animated-in").removeClass(this.core.settings.animateIn).removeClass(this.core.settings.animateOut),this.core.onTransitionEnd()},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this.core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Animate=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._call=null,this._time=0,this._timeout=0,this._paused=!0,this._handlers={"changed.owl.carousel":a.proxy(function(a){a.namespace&&"settings"===a.property.name?this._core.settings.autoplay?this.play():this.stop():a.namespace&&"position"===a.property.name&&this._paused&&(this._time=0)},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoplay&&this.play()},this),"play.owl.autoplay":a.proxy(function(a,b,c){a.namespace&&this.play(b,c)},this),"stop.owl.autoplay":a.proxy(function(a){a.namespace&&this.stop()},this),"mouseover.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"mouseleave.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.play()},this),"touchstart.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"touchend.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this.play()},this)},this._core.$element.on(this._handlers),this._core.options=a.extend({},e.Defaults,this._core.options)};e.Defaults={autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!1,autoplaySpeed:!1},e.prototype._next=function(d){this._call=b.setTimeout(a.proxy(this._next,this,d),this._timeout*(Math.round(this.read()/this._timeout)+1)-this.read()),this._core.is("interacting")||c.hidden||this._core.next(d||this._core.settings.autoplaySpeed)},e.prototype.read=function(){return(new Date).getTime()-this._time},e.prototype.play=function(c,d){var e;this._core.is("rotating")||this._core.enter("rotating"),c=c||this._core.settings.autoplayTimeout,e=Math.min(this._time%(this._timeout||c),c),this._paused?(this._time=this.read(),this._paused=!1):b.clearTimeout(this._call),this._time+=this.read()%c-e,this._timeout=c,this._call=b.setTimeout(a.proxy(this._next,this,d),c-e)},e.prototype.stop=function(){this._core.is("rotating")&&(this._time=0,this._paused=!0,b.clearTimeout(this._call),this._core.leave("rotating"))},e.prototype.pause=function(){this._core.is("rotating")&&!this._paused&&(this._time=this.read(),this._paused=!0,b.clearTimeout(this._call))},e.prototype.destroy=function(){var a,b;this.stop();for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.autoplay=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(b){this._core=b,this._initialized=!1,this._pages=[],this._controls={},this._templates=[],this.$element=this._core.$element,this._overrides={next:this._core.next,prev:this._core.prev,to:this._core.to},this._handlers={"prepared.owl.carousel":a.proxy(function(b){b.namespace&&this._core.settings.dotsData&&this._templates.push('<div class="'+this._core.settings.dotClass+'">'+a(b.content).find("[data-dot]").addBack("[data-dot]").attr("data-dot")+"</div>")},this),"added.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,0,this._templates.pop())},this),"remove.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,1)},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&this.draw()},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&!this._initialized&&(this._core.trigger("initialize",null,"navigation"),this.initialize(),this.update(),this.draw(),this._initialized=!0,this._core.trigger("initialized",null,"navigation"))},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._initialized&&(this._core.trigger("refresh",null,"navigation"),this.update(),this.draw(),this._core.trigger("refreshed",null,"navigation"))},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers)};e.Defaults={nav:!1,navText:['<span aria-label="Previous">&#x2039;</span>','<span aria-label="Next">&#x203a;</span>'],navSpeed:!1,navElement:'button type="button" role="presentation"',navContainer:!1,navContainerClass:"owl-nav",navClass:["owl-prev","owl-next"],slideBy:1,dotClass:"owl-dot",dotsClass:"owl-dots",dots:!0,dotsEach:!1,dotsData:!1,dotsSpeed:!1,dotsContainer:!1},e.prototype.initialize=function(){var b,c=this._core.settings;this._controls.$relative=(c.navContainer?a(c.navContainer):a("<div>").addClass(c.navContainerClass).appendTo(this.$element)).addClass("disabled"),this._controls.$previous=a("<"+c.navElement+">").addClass(c.navClass[0]).html(c.navText[0]).prependTo(this._controls.$relative).on("click",a.proxy(function(a){this.prev(c.navSpeed)},this)),this._controls.$next=a("<"+c.navElement+">").addClass(c.navClass[1]).html(c.navText[1]).appendTo(this._controls.$relative).on("click",a.proxy(function(a){this.next(c.navSpeed)},this)),c.dotsData||(this._templates=[a('<button role="button">').addClass(c.dotClass).append(a("<span>")).prop("outerHTML")]),this._controls.$absolute=(c.dotsContainer?a(c.dotsContainer):a("<div>").addClass(c.dotsClass).appendTo(this.$element)).addClass("disabled"),this._controls.$absolute.on("click","button,div",a.proxy(function(b){var d=a(b.target).parent().is(this._controls.$absolute)?a(b.target).index():a(b.target).parent().index();b.preventDefault(),this.to(d,c.dotsSpeed)},this));for(b in this._overrides)this._core[b]=a.proxy(this[b],this)},e.prototype.destroy=function(){var a,b,c,d,e;e=this._core.settings;for(a in this._handlers)this.$element.off(a,this._handlers[a]);for(b in this._controls)"$relative"===b&&e.navContainer?this._controls[b].html(""):this._controls[b].remove();for(d in this.overides)this._core[d]=this._overrides[d];for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},e.prototype.update=function(){var a,b,c,d=this._core.clones().length/2,e=d+this._core.items().length,f=this._core.maximum(!0),g=this._core.settings,h=g.center||g.autoWidth||g.dotsData?1:g.dotsEach||g.items;if("page"!==g.slideBy&&(g.slideBy=Math.min(g.slideBy,g.items)),g.dots||"page"==g.slideBy)for(this._pages=[],a=d,b=0,c=0;a<e;a++){if(b>=h||0===b){if(this._pages.push({start:Math.min(f,a-d),end:a-d+h-1}),Math.min(f,a-d)===f)break;b=0,++c}b+=this._core.mergers(this._core.relative(a))}},e.prototype.draw=function(){var b,c=this._core.settings,d=this._core.items().length<=c.items,e=this._core.relative(this._core.current()),f=c.loop||c.rewind;this._controls.$relative.toggleClass("disabled",!c.nav||d),c.nav&&(this._controls.$previous.toggleClass("disabled",!f&&e<=this._core.minimum(!0)),this._controls.$next.toggleClass("disabled",!f&&e>=this._core.maximum(!0))),this._controls.$absolute.toggleClass("disabled",!c.dots||d),c.dots&&(b=this._pages.length-this._controls.$absolute.children().length,c.dotsData&&0!==b?this._controls.$absolute.html(this._templates.join("")):b>0?this._controls.$absolute.append(new Array(b+1).join(this._templates[0])):b<0&&this._controls.$absolute.children().slice(b).remove(),this._controls.$absolute.find(".active").removeClass("active"),this._controls.$absolute.children().eq(a.inArray(this.current(),this._pages)).addClass("active"))},e.prototype.onTrigger=function(b){var c=this._core.settings;b.page={index:a.inArray(this.current(),this._pages),count:this._pages.length,size:c&&(c.center||c.autoWidth||c.dotsData?1:c.dotsEach||c.items)}},e.prototype.current=function(){var b=this._core.relative(this._core.current());return a.grep(this._pages,a.proxy(function(a,c){return a.start<=b&&a.end>=b},this)).pop()},e.prototype.getPosition=function(b){var c,d,e=this._core.settings;return"page"==e.slideBy?(c=a.inArray(this.current(),this._pages),d=this._pages.length,b?++c:--c,c=this._pages[(c%d+d)%d].start):(c=this._core.relative(this._core.current()),d=this._core.items().length,b?c+=e.slideBy:c-=e.slideBy),c},e.prototype.next=function(b){a.proxy(this._overrides.to,this._core)(this.getPosition(!0),b)},e.prototype.prev=function(b){a.proxy(this._overrides.to,this._core)(this.getPosition(!1),b)},e.prototype.to=function(b,c,d){var e;!d&&this._pages.length?(e=this._pages.length,a.proxy(this._overrides.to,this._core)(this._pages[(b%e+e)%e].start,c)):a.proxy(this._overrides.to,this._core)(b,c)},a.fn.owlCarousel.Constructor.Plugins.Navigation=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(c){this._core=c,this._hashes={},this.$element=this._core.$element,this._handlers={"initialized.owl.carousel":a.proxy(function(c){c.namespace&&"URLHash"===this._core.settings.startPosition&&a(b).trigger("hashchange.owl.navigation")},this),"prepared.owl.carousel":a.proxy(function(b){if(b.namespace){var c=a(b.content).find("[data-hash]").addBack("[data-hash]").attr("data-hash");if(!c)return;this._hashes[c]=b.content}},this),"changed.owl.carousel":a.proxy(function(c){if(c.namespace&&"position"===c.property.name){var d=this._core.items(this._core.relative(this._core.current())),e=a.map(this._hashes,function(a,b){return a===d?b:null}).join();if(!e||b.location.hash.slice(1)===e)return;b.location.hash=e}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers),a(b).on("hashchange.owl.navigation",a.proxy(function(a){var c=b.location.hash.substring(1),e=this._core.$stage.children(),f=this._hashes[c]&&e.index(this._hashes[c]);f!==d&&f!==this._core.current()&&this._core.to(this._core.relative(f),!1,!0)},this))};e.Defaults={URLhashListener:!1},e.prototype.destroy=function(){var c,d;a(b).off("hashchange.owl.navigation");for(c in this._handlers)this._core.$element.off(c,this._handlers[c]);for(d in Object.getOwnPropertyNames(this))"function"!=typeof this[d]&&(this[d]=null)},a.fn.owlCarousel.Constructor.Plugins.Hash=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){function e(b,c){var e=!1,f=b.charAt(0).toUpperCase()+b.slice(1);return a.each((b+" "+h.join(f+" ")+f).split(" "),function(a,b){if(g[b]!==d)return e=!c||b,!1}),e}function f(a){return e(a,!0)}var g=a("<support>").get(0).style,h="Webkit Moz O ms".split(" "),i={transition:{end:{WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"}},animation:{end:{WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd",animation:"animationend"}}},j={csstransforms:function(){return!!e("transform")},csstransforms3d:function(){return!!e("perspective")},csstransitions:function(){return!!e("transition")},cssanimations:function(){return!!e("animation")}};j.csstransitions()&&(a.support.transition=new String(f("transition")),a.support.transition.end=i.transition.end[a.support.transition]),j.cssanimations()&&(a.support.animation=new String(f("animation")),a.support.animation.end=i.animation.end[a.support.animation]),j.csstransforms()&&(a.support.transform=new String(f("transform")),a.support.transform3d=j.csstransforms3d())}(window.Zepto||window.jQuery,window,document);;
function MM_changeProp(objID, theValue) {
    console.log(objID + "," + theValue);
    var $_obj = $("#" + objID);
    if ($_obj.length > 0) {
        var fontSize = cookieHelper.GetNewsFontSize();
        if (!fontSize != theValue) {
            cookieHelper.SetNewsFontSize(theValue);
        }
        $_obj.removeClass();
        $_obj.addClass(theValue);

        $(".magicword ul li").removeClass("active");
        $(".magicword ul li").each(function () {
            if ($(this).data("classname") == theValue) {
                $(this).addClass("active");
            }
        })

    }
}

$(function () {
    var fontSize = cookieHelper.GetNewsFontSize();
    if (fontSize) {
        MM_changeProp('ckuse', fontSize)
    }

    $(".magicword ul li").click(function () {
        MM_changeProp($(this).data("objid"), $(this).data("classname"))
    });

});

//ckeditor分頁內文友善列印
var prepare = function () {
    var visible = [];

    $('#ckuse > div[id^="Content"]').each(function (index) {
        visible[index] = $(this).is(":visible");
        $(this).show();
    });

    window.print();

    $('#ckuse > div[id^="Content"]').each(function (index) {
        visible[index] ? $(this).show() : $(this).hide();
    });

};;
// news 下的 ga 
$(document).ready(function () {
    $(".morenews").click(function () {

        $(this).parents(".news-boxlist").find("ul").find("li:nth-child(n+7)li").show();
        $(this).hide();
    });


    //ga track
    var gaObj = [
        { tag: '.share > a', pl: '四大分享', lb: ['分享FB', '分享plurk', '分享微博', '分享email'], gtTag: '.share' },
        { tag: '#involve > p > a', pl: '延伸閱讀', gtTag: '#involve' },
        { tag: '.hotnews > li > a', pl: '熱門新聞', gtTag: '.hotnews' },
        { tag: '.keyword > ul > li > a', pl: '關鍵字', gtTag: '.keyword' }
        //{ tag: '#prev > a', pl: '上一則', gtTag: '#prev' },
        //{ tag: '.nextR > a', pl: '下一則', gtTag: '.nextR' }
    ];

    for (var k = 0; k < gaObj.length; k++) {
        var o = gaObj[k];
        if ($(o.tag).length > 0) {
            var hasLb = false;
            if (o.lb && o.lb.length === $(o.tag).length) {
                hasLb = true;
            }

            for (var i = 0; i < $(o.tag).length; i++) {
                $(o.tag).eq(i).addClass('gt').attr('pa', '新聞內頁').attr('pl', o.pl);
                if (hasLb) {
                    $(o.tag).eq(i).attr('lb', o.lb[i]);
                }
            }
        }
        ga_track(o.gtTag);
    }

    //大數據推薦
    $('.BigDataTitle').each(function () {
        getNewsList($(this).attr('tag'), $(this).text().trim(), $(this).data('gadplate'), $(this).data('gadid'));
    });


    ContentTagsFormating('#ckuse > article > div > p');

});

function getNewsList(_tag, pl, gadplate, gadid) {

    var adPara = [{ plate: gadplate, size: [286, 105], id: gadid, marginTop: 5 }];

    if (($("." + _tag + " div").length > 0 && _tag != "BigDataNews") || (_tag == "BigDataNews") && $("." + _tag + " div").find(".newsimg-area-item").length > 0) {
        $('#contents .tab_content').css('display', 'none');
        $(".tab_content." + _tag).css('display', 'block');

        return;
    }

    var d = "";
    if (_tag != "BigDataNews") {
        //d = '{"newsID":' + parseInt($("#newsID").val()) + ',"pageGroupID":' + parseInt($("#pageGroupID").val()) + '}';
        //GetNewsItems(d, _tag, pl, adPara);
    }
    else {
        //setn_visitor_id = null;
        if (setn_visitor_id) {
            GetAiRecommandNews(_tag, pl, adPara);
        }
        else {
            GetUbaRecommandNews(_tag, pl, adPara);
        }
    }
}

var GetAiRecommandNews = function (_tag, pl, adPara) {
    var newsItems = [];
    var uid = setn_visitor_id;//'01E4C2A52453C781';
    if (!pageGroupID) { pageGroupID = 1; }
    var aiSource = null;

    var url = 'https://recommend.setn.com/recommend/news/v1/' + pageGroupID + '/' + uid;

    var tmpNewsIdObj = document.getElementById('newsID');
    if (tmpNewsIdObj !== null) {
        url = 'https://recommend.setn.com/recommend/news/v2/' + pageGroupID + '/' + tmpNewsIdObj.value + '/' + uid;
    }

    $.ajax({
        url: url,
        dataType: 'json',
        type: 'GET',
        success: function (result) {
            var targetNewsIds = null;
            try {
                if (result && result.recommend_news && result.recommend_news.length > 0) {
                    jQuery.each(result.recommend_news, function (i, item) {
                        newsItems.push(item);
                    });
                    aiSource = result.source;
                }
            }
            catch (ex) {
                targetNewsIds = null;
            }
        },
        error: function (result, status, jqXHR) { }
    }).done(function () {
        if (newsItems.length > 0) {
            var parms = JSON.stringify(newsItems);
            GetNewsItems(parms, _tag, pl, adPara, aiSource);

        }
        else {
            GetUbaRecommandNews(_tag, pl, adPara);
        }
    });
};

var GetUbaRecommandNews = function (_tag, pl, adPara) {
    var newsItems = [];
    var pagegroupid_url = '';
    if (pageGroupID) {
        pagegroupid_url = '&PageGroupID=' + pageGroupID;
    }
    $.ajax({
        url: "//ubas.setn.com/SimilarProductRecommand.ashx?dataid=" + parseInt($("#newsID").val()) + "&TopRec=20" + pagegroupid_url,
        dataType: 'text',
        type: 'GET',
        success: function (result) {
            var obj = $.parseJSON(result);
            jQuery.each(obj, function (i, item) {
                newsItems.push(item.DataID);
            });
        },
        error: function (result, status, jqXHR) { }
    }).done(function () {

        var parms = JSON.stringify(newsItems);
        GetNewsItems(parms, _tag, pl, adPara, null);

    });
};


var GetNewsItems = function (data, _tag, pl, adPara, bigDataType) {
    if (data.length <= 0) {
        return false;
    }
    var q = "";

    if (_tag === "BigDataNews") {
        q= "&newsIDs=" + data;
    }


    $.ajax({
        url: "/Extensions/NewsDatas.ashx?typev=" + _tag + q,
        contentType: "application/json; charset=utf-8",
        type: 'GET',
        success: function (result) {
            if (result != null) {
                var gad_id = 'gad_' + _tag;
                var newsItems = NewsPagePubItem(result, _tag, pl, '<div id="' + gad_id + '" class="tagAD"></div>', bigDataType);

                if ($('.tab_content.' + _tag).find("div").length <= 0) {

                    if (tag != "BigDataNews") {
                        $('.tab_content.' + _tag).prepend(newsItems);
                    }
                    if (adPara && adPara.length > 0) {
                        adPara[0].area = gad_id;
                        GoogleADExecute(adPara);
                    }
                }

                ga_track('.' + _tag);
            }
        },
        error: function (result, status, jqXHR) { }
    });

 

    //var url = '/Extensions/SetMainServices.asmx/Get' + _tag;
    //$.ajaxWebService(url, data,
    //    function (result) {
    //        if (result.d != null) {
    //            var gad_id = 'gad_' + _tag;
    //            var newsItems = NewsPagePubItem(result.d, _tag, pl, '<div id="' + gad_id + '" class="tagAD"></div>', bigDataType);

    //            if ($('.tab_content.' + _tag).find("div").length <= 0) {

    //                if (tag != "BigDataNews") {
    //                $('.tab_content.' + _tag).prepend(newsItems);
    //                }
    //                if (adPara && adPara.length > 0) {
    //                    adPara[0].area = gad_id;
    //                    GoogleADExecute(adPara);
    //                }
    //            }

    //            ga_track('.' + _tag);
    //        }
    //    });
};




var NewsPagePubItem = function (list, tag, pl, adArea, bigDataType) {

    var firstItemL = '', firstLtemR = '';
    var itemL = '', itemR = '';

    if (bigDataType) {
        pl = bigDataType;
    }

    if (tag == "BigDataNews") {
        jQuery.each(list, function (i, item) {
            var hyper = '<a class="gt" pa="新聞內頁" pl="' + pl + '" href="/News.aspx?NewsID=' + item.NewsID + '" lb="' + item.ShortSlug + '">';
            var hyper_a = hyper + item.ShortSlug + '</a>';

            if (i !== 0 && i !== 5) {

                if ((i % 2) === 0) {
                    if (i === 0) {
                        firstItemL += '<div class="newsimg-area-item">';
                        firstItemL += hyper;
                        firstItemL += '        <div class="player-icon-2 "></div>';
                        firstItemL += '        <div class="image-container">';
                        firstItemL += '            <img src="' + GetImageURL(item.ImageID, item.ImageFile, "XXL", item.IsAdult) + '" alt="' + item.ShortSlug + '"></div>';
                        firstItemL += '        <div class="newsimg-area-text ">' + item.ShortSlug + '</div>';
                        firstItemL += '    </a>';
                        firstItemL += '</div>';
                    }
                    itemL += '<li>' + hyper_a + '</li>';
                }
                else {
                    if (i === 5) {
                        firstLtemR += '<div class="newsimg-area-item">';
                        firstLtemR += hyper;
                        firstLtemR += '        <div class="player-icon-2 "></div>';
                        firstLtemR += '        <div class="image-container">';
                        firstLtemR += '            <img src="' + GetImageURL(item.ImageID, item.ImageFile, "XXL", item.IsAdult) + '" alt="' + item.ShortSlug + '"></div>';
                        firstLtemR += '        <div class="newsimg-area-text ">' + item.ShortSlug + '</div>';
                        firstLtemR += '    </a>';
                        firstLtemR += '</div>';
                    }
                    itemR += '<li>' + hyper_a + '</li>';
                }
            }
        });


        $("#BigDataNews_L").html(itemL);
        $("#BigDataNews_R").html(itemR);

    }

    return "";
};


;
