jQuery(document).ready(function () {
  var testimonial = $('.testimonial');
  
  testimonial.hide();
  $(testimonial[0]).show();
  
  for (var i=0; i < testimonial.length; i++) {
    $(testimonial[i]).attr('id', i);
  };   
  
  $('#testimonial').at_intervals(function(){
    $.each(testimonial, function(){
      if($(this).css('display') == 'block') {
        var getPos = $(this).attr('id');
        $(testimonial[getPos]).fadeOut(1000);
        if(parseInt(getPos)+1 == testimonial.length) {
          $(testimonial[0]).delay(1000).fadeIn(1000);
        } else {
          $(testimonial[parseInt(getPos)+1]).delay(1000).fadeIn(1000);
        }
      }
    });
  }, {delay: 5000});
  
  $('.relySection p').hide();
  
  $('.relySection a').hover(function() {
    $($(this).children()[1]).stop().fadeTo(500, .8);
  }, 
  function() {
    $($(this).children()[1]).stop().fadeTo(500, 0);
  });
  
  $('div.scrollable').scrollable({
    size: 4
  });
  
  jQuery.preloadImages = function(arguments) {
    for(var i = 0; i<arguments.length; i++) {
      $('<img />').attr('src', arguments[i]);
    }
  }
  
  $.preloadImages(['images/videoLinkHover_bg.png', 'images/left_hover.png', 'images/right_hover.png', 'images/goHover_bg.png']);
}); 
