/* Minification failed. Returning unminified contents.
(40,11-12): run-time error JS1014: Invalid character: `
(40,12-13): run-time error JS1195: Expected expression: .
(40,59-60): run-time error JS1004: Expected ';': :
(40,71-72): run-time error JS1193: Expected ',' or ')': {
(40,91-92): run-time error JS1002: Syntax error: }
(40,93-94): run-time error JS1014: Invalid character: `
(41,11-12): run-time error JS1014: Invalid character: `
(41,82-83): run-time error JS1002: Syntax error: }
(41,84-85): run-time error JS1014: Invalid character: `
(42,11-12): run-time error JS1014: Invalid character: `
(42,69-70): run-time error JS1197: Too many errors. The file might not be a JavaScript file: (
 */
$(document).ready(function() {

  var c2 = $('.sk-yoursites'),
    c3 = $('.sk-interactive'),
    c4 = $('.sk-yourideas'),
    ih = $('.sk-carousel-image-holder'),
    h2 = $('.sk-carousel-content-holder > h2'),
    ch = $('.sk-carousel-content-holder');

  c2.find(ih).each(function() {

    $(this).insertAfter(c2.find(h2));
  });

  c3.find(ih).each(function() {

    $(this).insertAfter(c3.find(h2));
  });

  c4.find(ih).each(function() {

    $(this).insertAfter(c4.find(h2));
  });

});
$(document).ready(function() {

  var choiceCount = $('.featureClass .quiz-container .question-content:nth-child(4) > *').length;
  var questionCount = choiceCount + 1;
  var firstQuestionIndex = 8;
  var choiceIndex;
  var questionIndex;

  var inactiveHandler = function(questionIndex) {

    for (var i=2; i<=questionCount; i++) {
      var hiddenQuestionIndex = 4*i;
      var hiddenQuestionValidation = hiddenQuestionIndex + 1;
      if (hiddenQuestionIndex !== questionIndex) {
        $(`.featureClass .quiz-container .question-content:nth-child(${hiddenQuestionIndex})`).hide();
        $(`.featureClass .quiz-container div:nth-child(${hiddenQuestionValidation})`).hide();
        $(`.featureClass .quiz-container .question-content:nth-child(${hiddenQuestionIndex}) label`).each(function(i, v) {
          if($(this).text().toLowerCase().indexOf('empty') >= 0 ) {
            $(this).find('input').prop('checked', true);
          }
        });
      }
    }

  }

  var activeHandler = function(questionIndex) {

    var questionValidation = questionIndex + 1;

    $(`.featureClass .quiz-container .question-content:nth-child(${questionIndex})`).show();
    $(`.featureClass .quiz-container div:nth-child(${questionValidation})`).show();

    $(`.featureClass .quiz-container .question-content:nth-child(${questionIndex}) label`).each(function(i, v) {
      if($(this).text().toLowerCase().indexOf('empty') >= 0 ) {
        $(this).find('input').prop('checked', false);
      }
    });

  }

  $('.featureClass .quiz-container .question-content:nth-child(4) label').click(function(){

    choiceIndex = $('.featureClass .quiz-container .question-content label').index(this);
    questionIndex = (choiceIndex+2)*4;

    inactiveHandler(questionIndex);

    activeHandler(questionIndex);

  });

  $('.featureClass .quiz-container .question-content label').each(function(i, v) {

    if($(this).text().toLowerCase().indexOf('clearasil') >= 0 ) {
      $(this).find('input').prop('checked', true);
    }

    if($(this).text().toLowerCase().indexOf('empty') >= 0 ) {
      $(this).hide();
    }

    inactiveHandler(firstQuestionIndex);

  });

});
$(document).ready(function() {
  var d = $('.cdc-form-group-advanced-main div.checkbox').add($('div.form-group > div')),
    l = d.children('label'),
    c = $('input:checkbox'),
    a = $('label > a');
  d.find(l).each(function() {
    $(this).children('input').prependTo($(this).parent(d));
  });
  d.find(c).each(function() {
    name = $(this).attr('name');
    $(this).attr('id', name);
    $(this).next('label').attr('for', name);
  });
});
$(document).ready(function() {
  $(function(){
    $(window).scroll(function(){
      if($(this).scrollTop()>=100) {
        $(".sk-sidebar-menu").css({"margin-top" : "0px"});
        $(".sk-sidebar-main-links li.open ul").css({"margin-top" : "0px"});
      }
      else {
        $(".sk-sidebar-menu").css({"margin-top" : "100px"});
        $(".sk-sidebar-main-links li.open ul").css({"margin-top" : "100px"});
      }
    });
  });
  if ( $(window).width() > 1200) {
    $(".sk-sidebar-container-nav").addClass("sk-sidebar-collapsed-back");
  }
  else {
    $(".sk-sidebar-container-nav").addClass("sk-sidebar-collapsed");
    $(".sk-sidebar-icon").removeClass("open");
  }
});
$(document).ready(function() {
  $('.sk-productpage-demo .sk-product-header').prependTo('.sk-leftnav-template');
});

$(document).ready(function() {
  if ($('body').hasClass('sk-solutionfinderresultsk')) {
    $("a[href$='#tips']").html('Campaigns');
    $("a[href$='#articles']").html('Promotions');
  }
});
$(document).ready(function() {
  var landing = $(".sk-landing");
  landing.addClass("sk-show");

  $(".other-brands .sk-promo-row .col-md-4:first-child .sk-promo-link").on("click", function(e) {
    var first = $(".sk-dobendan").first();
    bannerChange(first);
    e.preventDefault();
  });
  $(".other-brands .sk-promo-row .col-md-4:nth-child(2) .sk-promo-link").on("click", function(e) {
    var first = $(".sk-woolite").first();
    bannerChange(first);
    e.preventDefault();
  });
  $(".other-brands .sk-promo-row .col-md-4:last-child .sk-promo-link").on("click", function(e) {
    var first = $(".sk-cilitbang").first();
    bannerChange(first);
    e.preventDefault();
  });
})

var bannerChange = function (first) {
  var landing = $(".sk-landing");
  var second = first.next();
  var third = second.next();
  var fourth = third.next();
  var bannerArray = [ first, second, third, fourth, landing ];
  var otherBrands = $(".other-brands")
  otherBrands.addClass("sk-hide");
  landing.removeClass("sk-show").hide();
  var bannerId = 0;
  var changeView = function() {
    if (bannerId > 0) {
      $(bannerArray[bannerId-1]).removeClass("sk-show").hide();
      $(bannerArray[bannerId]).addClass("sk-show").hide().fadeIn();
    }
    else {
      first.addClass("sk-show").hide().fadeIn();
    }
    bannerId++;
    var counter = 5;
    var timer = function() {
      if (counter > 0) {
        $(".banner .sk-grid-richtext h2:last-child").not(".landing .sk-grid-richtext h2").html(counter);
      }
      if (counter == -1) {
        clearTimeout(timer);
      }
      else {
        setTimeout(timer, 1000);
      }
      counter--;
    }
    if (bannerId !== bannerArray.length) {
      timer();
    }
    if (bannerId == bannerArray.length) {
       clearTimeout(changeView);
       otherBrands.removeClass("sk-hide");
       landing.addClass("sk-show");
    }
    else {
      setTimeout(changeView, 5000);
    }
  };
  changeView();
};