var Ishover = "";
var Isout = "";
//Banner
$(function () {

    $('.AD').slick({
        infinite: true,
        //centerMode: true,
        //slidesToShow: 1,
        autoplay: true,
        autoplaySpeed: 3000,
        //swipe: false,    //滑鼠滑動
        //responsive: [{
        //    breakpoint: 768,
        //    settings: {
        //        arrows: false,
        //    }
        //}]

    });

    Change_img_margin_left();  //視窗改變時
    // 向右
    $('.slick-next').on('click', function () {
        Change_img_margin_left();
    })
    //向左
    $('.slick-prev').on('click', function () {
        Change_img_margin_left();
    })

})


//改變視窗尺寸
$(window).resize(function () {
    Change_img_margin_left();
})

//視窗改變時
function Change_img_margin_left() {
    var self_width = $(window).width();                             //目前視窗寬度
    $('.slick-track').find('div').each(function () {
        $(this).find('img').css({ "margin-left": "" });            //初始化歸0
    });

    if (self_width > 0) {                                         //網頁時才執行
        setTimeout(function () {
            $('.slick-track').find('.slick-slide').each(function () {
                
                var img_width = $(this).find('img').width();            //先取得img的總寬度
                var $margin_left = img_width - self_width                 //圖片寬度 - 視窗寬度  在除2 等於目前位置
                $(this).find('img').css({ "margin-left": "-" + $margin_left / 2 + "px" });
                $('slick-current').css({ "position": "relative" });
                //var htmlstyle = $('.slick-slide').html();
                //alert(htmlstyle)
            })
        }, 0)
    }
}




//Tab
var _showTab = 0;
var $defaultLi = $('.tabs li').eq(_showTab).addClass('active');
$($defaultLi.find('a').attr('href')).siblings().hide();

$('.tabs li').click(function () {  //mouseover
    var $this = $(this),
        _clickTab = $this.find('a').attr('href');
    $this.addClass('active').siblings('.active').removeClass('active');
    $(_clickTab).stop(false, true).fadeIn().siblings().hide();
    return false;
}).find('a').focus(function () {
    this.blur();
});
