// MILESTONES
function Milestone(sTitle, sDescription, sURL, sImageSrc) {
  this.sTitle = sTitle;
  this.sDescription = sDescription;
  this.sURL = sURL;
  this.sImageSrc = sImageSrc;
}

function getRandomIndex(nLength) {
  var n = Math.floor(Math.random() * nLength);
  return n == nLength ? 0 : n;
}

function showMilestone() {
  var $milestone = $('#milestone');
  if(window.aMilestones == undefined || !aMilestones.length || !$milestone.length) return;
  oMilestone = aMilestones[getRandomIndex(aMilestones.length)];
  $milestone.find('a').attr('href', oMilestone.sURL);
  $('#milestone_image').attr({src: oMilestone.sImageSrc, alt: oMilestone.sTitle});
  $('#milestone_description').html(oMilestone.sDescription);
  $milestone.find('h5').html(oMilestone.sTitle);
}


// EXTERNAL LINKS
function initExternalLinks() {
  $("a[href][rel='external']").attr('target', '_blank');
}


//MENUJUMPER
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}

// DOCUMENT READY
function documentReadyHandler() {
  showMilestone();
  initExternalLinks();
}
$(document).ready(documentReadyHandler);
