$(document).ready(function() {
  
  //displays the content panel when the tab is clicked
  $("#contact-tab").click(function() {
    if($("#contact").is(":hidden")){
      if($("#client").is(":visible")){
        $("#client").slideUp("slow");
        $("#contact").delay(800).slideDown("slow");
      }else{
        $("#contact").slideDown("slow");
      }
    }else{
    $("#contact").slideUp("slow");
    }
  });
  
  //displays the client panel when the tab is clicked
  $("#client-tab").click(function() {
    if($("#client").is(":hidden")){
      if($("#contact").is(":visible")){
        $("#contact").slideUp("slow");
        $("#client").delay(800).slideDown("slow");
      }else{
        $("#client").slideDown("slow");
      }
    }else{
    $("#client").slideUp("slow");
    }
  });
  
  //initiates the carousel on the .mainslider class
  $(function() {
  $(".mainSlider").jCarouselLite({
      btnNext: ".next",
      btnPrev: ".prev"
    });
  });
  
  $(function() {
  $(".photoSlider").jCarouselLite({
      auto: 1600,
      speed: 400
    });
  });
  
  $("img.b").stop().animate({"opacity": "0"});
  
  //image hover b&w to colour
  $("img.a").hover(
  function() {
  $(this).stop().animate({"opacity": "0"}, "slow");
  $("img.b").stop().animate({"opacity": "1"}, "fast");
  },
  function() {
  $(this).stop().animate({"opacity": "1"}, "slow");
  $("img.b").stop().animate({"opacity": "0"}, "slow");
  });
  
    //image hover b&w to colour
  $("img.logo-a").hover(
  function() {
  $(this).stop().animate({"opacity": "0"}, "slow");
  },
  function() {
  $(this).stop().animate({"opacity": "1"}, "slow");
  });
  
});

/*Fading slideshow script start*/

function slideSwitch() {
    var $active = $('#slidershow IMG.active');

    if ( $active.length == 0 ) $active = $('#slidershow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slidershow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

/*Fading slideshow script end*/

