var has_fancybox = 1;
var has_responsive_tabs = 1;

$(document).ready(function(){
    $(document).PS("Utils", "init_cart_display", {
        "user_greeting_logged_in_mobile":'<span class="welcome"><span class="bold">Welcome</span><br/><%firstname%></span>',
        "user_greeting_logged_out":'<a href="<%login_url%>">LOGIN</a> | <a href="<%register_url%>">REGISTER</a>',
        "user_greeting_logged_out_mobile":'<a href="<%login_url%>">LOGIN</a> | <a href="<%register_url%>">REGISTER</a>'
    }).PS("Utils","init_user_greeting");
        
    $('.menu-left > li.has-dropdown > a').click(function(){ 
        window.open($(this).attr("href"), '_parent');
    });
    
    var pathname = window.location.pathname.split("/");
    $(".home").removeClass("active");
    if(pathname[1] == "" || pathname[1] == 'index.cfm')
        $(".home").addClass("active");
    else
        $("."+pathname[2]).addClass("active");
    
    /* BX Slider - Start */
    var slider = $("ul.bxslider > li").length;
    if(slider > 1) {
        $('.bxslider').bxSlider( {
            controls:false,
            pager:true,
            auto:true,
            mode:'fade',
            pagerSelector: '#slider-pager',
            pagerLocation: 'bottom'
        });
    }
    else if(slider <= 0 ) {
        $('.logged-out #slider').hide();
        $('.logged-out:not(.system-page) main, .logged-out:not(.system-page) header').addClass('noSlider');
    }
    /* BX Slider - End */
    



    $(".bb2").on('click', function() {
$(".custom-model-main").addClass('model-open');
}); 
$(".close-btn, .bg-overlay, .ccc").click(function(){
 $(".custom-model-main").removeClass('model-open');
 
});

                   $(document).ready(function () {
    $('.career--slider1').slick({
      slidesToShow: 1,
        centerMode: true,

      slidesToScroll: 1,
      sliderMargin: 10,
      autoplay: true,
      autoplaySpeed: 2500,
      arrows: true,
      dots: false,
      pauseOnHover: false,
    prevArrow: '<div class="slick-arrow-left"><img src="//s3-ap-southeast-1.amazonaws.com/assets-powerstores-com/data/org/24209/theme/40362/img/left.png"></div>',
    
          nextArrow: '<div class="slick-arrow-right"><img src="//s3-ap-southeast-1.amazonaws.com/assets-powerstores-com/data/org/24209/theme/40362/img/right.png"></div>',
responsive: [
        {
          breakpoint: 900,
          settings: {
            slidesToShow: 1
          }
        }, {
          breakpoint: 700,
          settings: {
            slidesToShow: 1,
            slidesToScroll: 1
          }
        }, {
          breakpoint: 500,
          settings: {
            slidesToShow: 1
          }
        }
      ]
    });
});

    
    
    /* BX Slider - Media Gallery Type 2 */
    var mg2Slider = $("ul#media-gallery-2 > li").length;
    var mg2Auto = ( ( $('#media-gallery-2').attr('auto') > 0) ? true : false);
    var mg2Pager = ( ( $('#media-gallery-2').attr('pager') > 0) ? true : false);
    var mg2Controls = ( ( $('#media-gallery-2').attr('control') > 0) ? true : false);
    var mg2AdaptiveHeight = ( ( $('#media-gallery-2').attr('adaptiveHeight') > 0) ? true : false);
        
    if(mg2Slider > 1) {
        $('#media-gallery-2').bxSlider({
            captions: false,
            auto: mg2Auto,
            pager: mg2Pager,
            pagerCustom: '#media-gallery-2-thumbnails',
            autoControls: false,
            mode: 'fade',      
            controls: mg2Controls,
            infiniteLoop: true,
            adaptiveHeight : mg2AdaptiveHeight
        });
        $('#media-gallery-2-thumbnails').bxSlider({
            width:1000,
            left:0,
            minSlides: 3,
            maxSlides: 6,
            infiniteLoop: false,
            slideWidth: 110,
            slideMargin: 15,
            pager:false,
            auto:false,
            pause:14000,
            controls:true,
        });
    }
    /* BX Slider - End */
$('.moreless-button1').click(function() {
  $('.moretext1').slideToggle();
  /*if ($('.moreless-button1').text() == "Read more") {
    $(this).text("Read less")
  } else {
    $(this).text("Read more")
  }*/
});

$('.moreless-button2').click(function() {
  $('.moretext2').slideToggle();
  /*if ($('.moreless-button2').text() == "Read more") {
    $(this).text("Read less")
  } else {
    $(this).text("Read more")
  }*/
});  

$('.moreless-button3').click(function() {
  $('.moretext3').slideToggle();
  /*if ($('.moreless-button3').text() == "Read more") {
    $(this).text("Read less")
  } else {
    $(this).text("Read more")
  }*/
});  

    if(has_fancybox){
    /* FancyBox */
    var fancyBoxExists = $("main .fancybox").length;
    if(fancyBoxExists >= 1) {
        $('.fancybox').attr('rel', 'media-gallery').fancybox({
            prevEffect : 'fade',
            nextEffect : 'fade',
            openEffect    : 'fade',
            closeEffect    : 'fade',
            arrows : true,
            helpers : {
                media : {},
                buttons : {}
            }
        });
    }
    /* EndFancy Box */
    }
    
    if(has_responsive_tabs){
    /* Responsive Tabs */
    var responsiveTabsDefault = $("main .responsiveTab").length;
    if(responsiveTabsDefault >= 1) {
        $('.responsiveTab.default').easyResponsiveTabs({
            type: 'default', //Types: default, vertical, accordion
            width: 'auto', //auto or any width like 600px
    		fit: true, // 100% fit in a container
            closed: false,
      	});
        $('.responsiveTab.vertical').easyResponsiveTabs({
            type: 'vertical', //Types: default, vertical, accordion
            width: 'auto', //auto or any width like 600px
    		fit: true, // 100% fit in a container
            closed: false,
      	});
        $('.responsiveTab.accordion').easyResponsiveTabs({
            type: 'accordion', //Types: default, vertical, accordion
            width: 'auto', //auto or any width like 600px
        	fit: true, // 100% fit in a container
            closed: false,
      	});
        $('.responsiveTab.accordionclosed').easyResponsiveTabs({
            type: 'accordion', //Types: default, vertical, accordion
            width: 'auto', //auto or any width like 600px
        	fit: true, // 100% fit in a container
            closed: true,
      	});
    }
    /* EndFancy Box */
    }

    $('a.smooth-anchor[href*=.]').click(function(event){
        $('html, body').animate({
            scrollTop: $( $.attr(this, 'href') ).offset().top + -200
        }, 2000);
        event.preventDefault();
    });
});
