/* 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);
}

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 5: // 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;
}


var content = new Array('<a href="/internal/emergency/alertu.html" border="0"><img src="/services/marketing/homepage_images/alertu.jpg" width="200" height="305" alt="New mobile alert notification system. Free no spam. Instant notice of campus closure or emergency." border="0"></a>',
'<a href="/home/schedules/" border="0"><img src="/services/marketing/homepage_images/winter10.jpg" width="200" height="305" alt="Get your Wintersession schedule online, classes start January 4" border="0"></a>'
);

/*
var content = new Array('<a href="http://cabrillobooks.net/ePOS?this_category=45&store=215&level1_category=45&form=shared3%2fgm%2fmain.html&design=215" border="0"><img src="/services/marketing/homepage_images/sindesserts.jpg" width="200" height="305" alt="Original Sin Desserts now available at the Bookstore." border="0"></a>',
'<a href="/home/schedules/" border="0"><img src="/services/marketing/homepage_images/fall_schedule4.jpg" width="200" height="305" alt="Surf Online for your fall classes! Schedule is online and in the bookstore." border="0"></a>',
'<a href="/home/schedules/" border="0"><img src="/services/marketing/homepage_images/Fall_schedule3.jpg" width="200" height="305" alt="Go Green and get your fall schedule on line. Enrollment is now open." border="0"></a>'
);
*/


/*var content = new Array('<a href="/academics/archtech/" border="0"><img src="/images/rotating/2005/archedig1.jpg" width="200" height="305" alt="Archeaology students measuring the depth of a site." border="0"></a>',
'<a href="/academics/biology/" border="0"><img src="/images/rotating/2005/bio-anatomy.jpg" width="200" height="305" alt="Student and biology instructor consulting during an Anatomy and Physiology class" border="0"></a>',
'<a href="/academics/astronomy/" border="0"><img src="/images/rotating/2005/groupintree.jpg" width="200" height="305" alt="Astronomy students and instructor" border="0"></a>',
'<a href="/academics/astronomy/" border="0"><img src="/images/rotating/2005/insidefuge.jpg" width="200" height="305" alt="Astronomy student inside a bullet-riddled object" border="0"></a>',
'<a href="/academics/chinese/" border="0"><img src="/images/rotating/2005/yamingshen.jpg" width="200" height="305" alt="Chinese Instructor Yaming Shen demonstrating chinese calligraphy" border="0"></a>',
'<a href="/academics/music/" border="0"><img src="/images/rotating/2005/garageband.jpg" width="200" height="305" alt="Student composing music at a workstation" border="0"></a>',
'<a href="/services/puente/" border="0"><img src="/images/rotating/2005/rocioburgos.jpg" width="200" height="305" alt="Student in the Puente Program" border="0"></a>',
'<a href="/academics/earthscience/" border="0"><img src="/images/rotating/2005/geology4.jpg" width="200" height="305" alt="California Geology lecture on top of Lembert Dome" border="0"></a>',
'<a href="/academics/artstudio/" border="0"><img src="/images/rotating/2005/silkscreen.jpg" width="200" height="305" alt="Student and silkscreen instructor" border="0"></a>',
'<img src="/images/rotating/2005/surfer.jpg" width="200" height="305" alt="Monument to the Unknown Surfer overlooking the ocean on Westcliff Drive" border="0">',
'<img src="/images/rotating/2005/boat.jpg" width="200" height="305" alt="The Cement Ship at nearby Seacliff State Beach" border="0">',
'<a href="/academics/astronomy/" border="0"><img src="/images/rotating/2005/milkyway-c.jpg" width="200" height="305" alt="The Milky Way captured by Photoastronomy instructor Richard Nolthenius" border="0"></a>',
'<a href="/academics/athletics/soccer/" border="0"><img src="/images/rotating/2005/soccerstudents.jpg" width="200" height="305 alt="Soccer students on the field" border="0"></a>',
'<a href="/academics/engineering/" border="0"><img src="/images/rotating/2005/engr2007-2.jpg" width="200" height="305" alt="Engineering student" border="0"></a>',
'<a href="/academics/engineering/" border="0"><img src="/images/rotating/2005/engr2007-1.jpg" width="200" height="305" alt="Engineering students building a scale with found materials" border="0"></a>',
'<a href="/academics/cahm/" border="0"><img src="/images/rotating/2005/bakingbuns.jpg" width="200" height="305" alt="Culinary Arts instructor glazing buns."  border="0"></a>' 
 );  
*/