var testimonial_count;
var intervalOrTimeout;
var testimonial_interval = 0;
var old_testimonial = 0;
var current_testimonial = 0;
var ticker_hovered = false;
var rotateOnHoverOff = false;
var initialDelay = 10000;
var intervalPeriod = 8000;
 
$(document).ready(function(){
  testimonial_count = $("div.content-ticker").size();
  $("div.content-ticker:eq("+current_testimonial+")").css('top','0px');
  
  intervalOrTimeout = "T";
  testimonial_interval = setTimeout(first_rotate, initialDelay);
  /*$('#testimonal-wrapper').hover(function() {
      ticker_hovered = true;
    }, function() {
      ticker_hovered = false;
      if (rotateOnHoverOff) {
	if (testimonial_interval != 0) {
	  if (intervalOrTimeout == "T") {
	    clearTimeout(testimonial_interval);
	  } else {
	    clearInterval(testimonial_interval);
	  }

	  testimonial_interval = 0;
	}

        rotateOnHoverOff = false;

        first_rotate();
      }
    });*/
});
 
function testimonial_rotate() {
  //if (!ticker_hovered) {
    current_testimonial = (old_testimonial + 1) % testimonial_count; 
    $("div.content-ticker:eq(" + old_testimonial + ")").fadeOut(300, function() {
      $(this).css('top', '90px');
      $("div.content-ticker:eq(" + current_testimonial + ")").show().animate({top: 0},"slow");
    });
    old_testimonial = current_testimonial;
  //} else {
   // rotateOnHoverOff = true;
  // }
}

function first_rotate() {
  testimonial_rotate();

  intervalOrTimeout = "I";
  testimonial_interval = setInterval(testimonial_rotate, intervalPeriod);
}
