var quotes=[
  {'quote':"I've worked with other pupil tracking systems and this is by far the best product. It's so fast! I can access it from anywhere and if parents call and say their children aren't making enough progress I can drill straight down to their details.",'name':"Michael John",'school':"Knebworth Primary"},
  {'quote':"Systems to provide academic guidance are outstanding.",'name':"Recreation Road Infants",'school':"Ofsted Report, 2009"},
  {'quote':"...everyone is totally inspired by this system - and to get us inspired to do tracking and target setting is no easy task!",'name':"Beccy Dewing",'school':"Garrick Green Infants"}
];

function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }
var numRes=8500103; // Conservative P*A result count as at 9/2/2012
var rightNow=new Date();
var startOfDay=new Date(rightNow.getFullYear(),rightNow.getMonth(),rightNow.getDate(),8);
var endOfDay=new Date(rightNow.getFullYear(),rightNow.getMonth(),rightNow.getDate(),Math.min(rightNow.getHours(),21));
var epoch=new Date(2012, 01, 09); // Number results accurate as of epoch date (note: JS month is -1, e.g. Jan=0)
var daysAdded=Math.ceil((endOfDay.getTime()-epoch.getTime())/(1000*60*60*24)); // 1000*60*60*24 = 1 day in milliseconds
var msAdded=rightNow.getTime()-startOfDay.getTime();
numRes+=(6046*(daysAdded-1)); // Add conservative estimate of results added, based on historic P*A data
numRes+=Math.floor(msAdded/200); // Catch up today based on 5/sec added by JS
var running=true;
var updateResultsTracked=function() {
  if (!running) $('#numResults').html(numberWithCommas(numRes++));
  if (Math.floor(Math.random() * 10)==1) running=!running;
}
$(document).ready(function(){
  // $('#cover-image').delay(750).animate({opacity: "0"}, 1500);
  var i=Math.floor(Math.random()*quotes.length);
  $(".testimonial-bubble").html("<p>"+quotes[i]['quote']+"</p><p><span>"+quotes[i]['name']+"</span><br />"+quotes[i]['school']+"</p><img src='/img/bubble-point.jpg' alt=''>");
  if (rightNow.getHours()>=8 && rightNow.getHours()<=21) {
    $("#resultsTracked").html("<span id='numResults'>"+numberWithCommas(numRes)+"</span> results tracked&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    $("#resultsTracked").animate({'line-height':'36px','opacity':1},'slow');
    setInterval(updateResultsTracked,100);
  }
});


