/* Specifies the period of time between updates:
    month - once a month
    date - once per every day of the month (repeats the next month)
    weekday - once per every day of the week (repeats the next week)
    hour - once per hour (repeats the next day)
    request - once per browser request (default)
*/

var updatePeriods = new Array("month","date","weekday","hour","request")

// Invoked to display rotated HTML content in a Web page. The period
// argument should be an element of the updatePeriods array.

function displayRotatedContent(period) {
 var updatePeriod = -1
 for(var i=0;i<content.length;++i) {
  if(period.toLowerCase() == updatePeriods[i].toLowerCase()) {
   updatePeriod = i
   break
  }
 }
 var s = selectHTML(updatePeriod)
 document.write(s)
}


var content = new Array(
'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/dog_wash_fall_2009sm.png" width="250" border="2" alt="Fall 2009 Dog Wash"><br>A pooch gets pampered at the Fall 2009 Dog Wash.</p></td></tr></table>',

'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/savma_symposium_2011sm.jpg" width="250" border="2" alt="SAVMA Symposium 2011"><br>A group of Tufts students enjoy themselves at the SAVMA Symposium 2011.</p></td></tr></table>',

'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/SVECCSsm.jpg" width="250" border="2" alt="SVECCS booth at Fall BBQ"><br>A leader of the student group, SVECCS, promotes her club at the annual Fall BBQ.</p></td></tr></table>'



/*
'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/winter9sm.jpg" width="250" border="2" alt="Winter White Party"><br>Students break into the spring semester at the Winter White Party 2007.</p></td></tr></table>',

'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/wash01sm.jpg" width="250" border="2" alt="Dog Wash 2006"><br>Families line up for some pooch pampering at the SCAVMA Dog Wash.</p></td></tr></table>',

'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/springfest0sm.jpg" width="250" border="2" alt="Spring Festival"><br>Students wash dogs at our 1st annual Spring Festival in 2007.</p></td></tr></table>',

'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/wazespeakers.jpg" width="250" border="2" alt="WAZE Speakers"><br>SCAVMA student groups bring in speakers to campus from all over the country.</p></td></tr></table>',

'<table width="250" align="right"><tr><td align="center"><p class="small"><img src="Album/vgs.jpg" width="250" border="1" alt="Open House"><br>SCAVMA student groups show their spirit at the annual Tufts Open House.</p></td></tr></table>' */

) 



function selectHTML(updatePeriod) {
 var n = 0
 var max = content.length
 var d = new Date()
 switch(updatePeriod) {
  case 0: // Month (0 - 11)
   n = d.getMonth()
   break
  case 1: // Date (1 - 31 scaled to 0 - 30)
   n = d.getDate() - 1
   break
  case 2: // Weekday (0 - 6)
   n = d.getDay()
   break
  case 3: // Hour (0 - 23)
   n = d.getHours()
   break
  case 4: // Request (Default)
  default:
   n = selectRandom(max)
 }
 n %= max 
 return content[n]
}

// Select a random integer that is between 0 (inclusive) and max (exclusive)
function selectRandom(max) {
 var r = Math.random()
 r *= max
 r = parseInt(r)
 if(isNaN(r)) r = 0
 else r %= max
 return r
}
