
var content = new Array( 
 "<i>I have dealt with Associated Telecom for over ten years. We are a large company with six locations. Their customer service has gone above and beyond. I have always been able to count on them solving any problems that arrive.</i><p><b>Orco Block</b></p>",
 "<i>Associated Telecom has been our vendor for about six years. During our continuous growth, they have always been there for us. From the courteous front desk ladies to the knowledgeable technicians they send out to our campus, the customer service is impeccable.</i><p><b>Westwood College</b></p>",
 "<i>Our Ophthalmology office purchased our phone system 15 years ago from Associated Telecom.  We have made some upgrades to our phone system as our business has grown over the years.  We have been very happy with our system and the quality of service Associated Telecom has provided to us. <br /><br />We highly recommend them to anyone that is looking for excellent products, quality service, customer satisfaction, and delightful people to work with. <br /><br />Sincerely,</i><p><b>Dr. Blau, Kaplan, Karageozian and Secor</b></p>",
 "<i>The staff at Associated Telecom is always helpful and professional. We have done business with them for many years and we have always received prompt, courteous, and quality service. They are the best!</i><p><b>Manhattan Beach Toyota</b></p>"
)


/* 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 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
}

