$(function(){
    $('#slideshow img:gt(0)').hide();
    setInterval(function(){
      $('#slideshow :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('#slideshow');}, 
      3000);


// Accordion Menu


  $('#client-nav > ul > li > a').attr('href', '#');

  $('#client-nav > ul > li > a').click(function() {
    
    $(this).parents('li').siblings().children('ul').slideUp("slow");
    $(this).next().slideToggle('slow')
    return false;
  
  });



  $("a.read-more").click(function () {
      $("div.excerpt").hide();
      $("div.content").show();
      $(this).hide();
      // EDIT:
      return false; // this will stop default behaviour of jumping to the top of page for instance
  })


// Gallery Slideshow

    
    $('.slider li:first').addClass('active-img');                    // Here we are assigning a class "active" to the first image in the "slider" div.

    var imagewidth = $('.visible-area').width();                  // Width of 1 image (should be equal to the width of "visible-area" box)
    var totalimages = $('.slider li').size();                    // Total Number of images inside "slider" div.
    var sliderwidth = imagewidth * totalimages;                   // Total width of "slider" div.
    $('.slider').css({'width': sliderwidth});                     // Here we are assigning the width to the slider div (using the css method in jquery)

    $('.next').click(function(){                                  // This following function will be executed on click of "next" button
        $active = $('.slider li.active-img').next();                 // On click of next button, we are saving the image (next to "active" image) in a jQuery variable $active
        if ($active.length==0){                                   // If this is the last image inside the "slider" div, and there is no image after that, then go back to the first image in "slider" div and save it in a variable $active.
	        $active = $('.slider li:first');
        }
        $('.slider li').removeClass('active-img');                   // Remove class active from the images inside slider div.
        $active.addClass('active-img');                               // Add the class active to the $active (next image).

        var count = $active.attr('id') -1;
        var sliderposition = count * imagewidth;                  // Here we are calculating, how much "slider" div will slide on click of next button, and we are saving it in a variable "sliderposition".
        $('.slider').animate({'left': -sliderposition}, 500);     // Here we are using the jQuery animate method to slide the "slider" div.
    }); 

    $('.previous').click(function(){                              // This following function will be executed on click of "previous" button
        $active = $('.slider li.active-img').prev();                 // On click of previous button, we are saving the image (previous to "active" image) in a jQuery variable $active.
        if ($active.length==0){                                   // If this is the first image inside the "slider" div, and there is no image before that, then go back to the last image in "slider" div and save it in a variable $active.
	        $active = $('.slider li:last');
        }
        $('.slider li').removeClass('active-img');                   // Remove class active from the images inside slider div.
        $active.addClass('active-img');                               // Add the class active to the $active (next image).

        var count = $active.attr('id') -1;
        var sliderposition = count * imagewidth;                  // Here we are calculating, how much "slider" div will slide on click of next button, and we are saving it in a variable "sliderposition".
        $('.slider').animate({'left': -sliderposition}, 500);     // Here we are using the jQuery animate method to slide the "slider" div.
    });

    
});



