$(function() {
  homeScroller();
  //clientLogin();
  casestudyScroller();
  servicesDropdowns();
  //stickSomeShit()
});

function homeScroller(){
  /* Calculate width of work items */
  var scrollWidth = 0;
  $(".work-item").each(function(){
    scrollWidth = scrollWidth + 35;
    scrollWidth = scrollWidth + $(this).width();
  });
  //console.log(scrollWidth);
  $("#work-scroller").width(scrollWidth);
  
  /* Init Scroll Pane */
  $('#work-window').jScrollPane();
}

function clientLogin(){
  $("#client_login").click(function(e){
    e.preventDefault();
    
    $(this).next("#login_tab").slideToggle("fast");
  
    return false;
  });
}

function casestudyScroller(){
  $("#case_study_scroller").cycle({
    pager: '#case_study_pager',
    timeout: 4000,
    speed: 500
  });
}

function servicesDropdowns(){
  $(".service_list li a").click(function(e){
    e.preventDefault();
    $(this).next("section").slideToggle();
    $(this).toggleClass("open");
    return false;
  });
}

function stickSomeShit(){
  $("#primary").Stickify({
    contentContainer: "#content-wrap"
  });
  
  var footerTotal = 0;
  
  footerTotal = footerTotal + $("#news-wrap").outerHeight();
  footerTotal = footerTotal + $("#footer-wrap").outerHeight();
  footerTotal = "-" + footerTotal
  
  //console.log(footerTotal);
  
  $("#primary").css("margin-bottom", footerTotal);
}
