$(function(){

    var autoPlay = true;
    var autoSpeed = 8000;
    var fadeSpeed = 200;

    $('#slidecontent .slide:first').css('display','block').addClass('current')
    $('#slidecontrols li:first').addClass('active')

    SlideshowContent = function(Id,StopAuto){

      if(StopAuto===true) clearInterval(play)

      var target = $('#slidecontent #'+Id)
      if( Id == false ) target = $('#slidecontent .current').next()
      if(!target.hasClass('slide')) target = $('#slidecontent .slide:first')
      if(target.hasClass('slide') && !target.hasClass('current')){
        $('#slidecontent .current').fadeOut(fadeSpeed).removeClass('current')
        target.fadeIn(fadeSpeed).addClass('current')
      }

      $('#slidecontrols li.active').removeClass('active')
      $('#slidecontrols li.' + target.attr('id')).addClass('active')
    }

    if( autoPlay == true ){
      var play = setInterval(function(){ SlideshowContent(false) }, autoSpeed)
    }

	// TESTIMONIALS
    var testimonialSpeed = 4000;

    $('.testimonial').css('display','none').filter(':first').css('display','block').addClass('current')

    ChangeTestimony = function(){
      var current = $('#testimonials .current');
      var target = current.next()
      if(!target.hasClass('testimonial'))
        target = $('.testimonial:first')
      current.fadeOut().removeClass('current')
      target.fadeIn().addClass('current')
    }

    var playTestimonials = setInterval(function(){ ChangeTestimony() }, autoSpeed)

})
