// Testimonial object.
function testimonial(name, title, company, body) {
  this.name = name;
  this.title = title;
  this.company = company;
  this.body = body;
}

// Array of testimonials.
var testimonials = [
  new testimonial( "Neil Black", "CTO", "ExtendMedia Inc.", "Dave is an outstanding technical resource who consistently produces high quality technical design and engineering deliverables. He works well with clients and can explain concepts and solutions in a manner that non-technologists will understand. Dave will always go out of his way to deliver beyond expectations. He has my unqualified recommendation." ),
  new testimonial( "Ethan Dreilinger", "Executive Producer", "Cablevision / News", "For the engagements I had with Dave, I found the level of his work to be above reproach, and his ability to problem solve on the fly to be very impressive. As a client of Dave's it was great that Dave took the time to explain options and cost/benefit to me." ),
  new testimonial( "Burt Heymanson", "Director of Engineering", "ClickStar Inc.", "Dave is a creative engineer, understanding the products he has built and works with amazingly well. His ability to provide seemingly simple solutions to difficult problems in a very timely manner is impressive. I'd work with Dave again anytime, even though he likes bad beer." ),
  new testimonial( "Robinson Kelly", "CEO and Founder", "Clay Tablet Technologies Inc.", "A wunderkind. Smarter than the average Cray - more helpful than a ripcord and sharper than a tack. I simply love having this guy back on our team." ),
  new testimonial( "Sean Doyle", "Chief Systems Architect", "InfoMedx.com", "Dave is a brilliant and focused engineer, architect and leader. Always competant and trustworthy, he can be relied upon to deliver solid solutions on budget and on time. Most importantly he always stands behind what he builds and is willing to go the extra mile to ensure success." )
];

// Changes a testimonial (called on page load and by cycle).
function change_testimonial() {
  var testimonial = testimonials[Math.floor(Math.random()*testimonials.length)];
  $("#testimonial").html(
    "<p>" + testimonial.body + "</p>"
  );
  $("#testimonial_author").html(
    "-- " + testimonial.name + ", " + testimonial.title + " " + testimonial.company
  );
}

$(document).ready(function() {
  // font compatibility using Cufon
  Cufon.replace('h1, h2');

  // Home page portfolio slider.
  $('#slider').nivoSlider({ effect:'fade', pauseTime: 5000 });

  // mouseover / out for intro CTAs
  $("#callout a").hover(
    function () {
      src = $(this).find("img").attr('src').replace('_off', '_on');
      $(this).find("img").attr('src', src);
    },
    function () {
      src = $(this).find("img").attr('src').replace('_on', '_off');
      $(this).find("img").attr('src', src);
    }
  );

  // Show an initial testimonial then start cycling.
  change_testimonial();

});
