$(function(){

  var btn = $(".menu li"),
      url = "js/jquery.carouFredSel-6.2.1-packed.js",
      url2 = "//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js";

  // INITIAL CAROUSEL LOAD
  $('#foo0').carouFredSel({
    auto: { duration: 600, delay: 300 },
    scroll: { fx: "uncover-fade", easing: "quadratic" },
    pagination: { container: ".menu", anchorBuilder: false },
    queue: false,
    mousewheel: true,
    swipe: { onMouse: true },
  });

  btn.on("click",function(){
    $("#quest,.csr,.circle").hide();
  });

  // SECONDARY CIRCLE PAGES - Hide/Show on click btn
  function menuBtn(){

    $.getScript(url, function(){

        for(i=0;i< btn.length;i++){
          (function(j){
            //console.log(j);
            btn.eq(j).on('click',function(){

              // Add/Remove "selected" class
              $(this).addClass('selected').siblings('li').removeClass('selected');

              // fadeIn new circle
              $('.circle'+(j+1)).stop().fadeIn('fast');

              // Secondary carousels initialing
              $('#foo'+(j+1)).carouFredSel({
                auto: {duration: 600},
                pagination: ".pager",
                queue: false,
                mousewheel: true,
                swipe: { onMouse: true }
              });
              return false;
            });
          })(i);
        }

    });

  }menuBtn();
  
  // ACCORDION
  $.getScript( url2, function() {
    $( ".accordion" ).accordion();
  });

});