month/*
    File: wrestler_of_the_hour.js
    Author: Clifford Hayashi
    Date: 03 November 2009
*/



function wrestler_of_the_hour() {
   var calendarDate = new Date();  // INITIALIZE DATE TO TODAY'S DATE
   var year  = calendarDate.getFullYear();
   var day_of_month = calendarDate.getUTCDate(); // 0-31
   //document.write('<p>'+day_of_month+'</p>');
   var month = calendarDate.getUTCMonth();       // 0-11
   //document.write('<p>'+month+'</p>');
   var hour = calendarDate.getUTCHours(); // 0-23

   // SELECT WRESTLER BASED ON HOUR OF YEAR
   var day_of_year = 0;
   var hour_of_year = 0;
   // Compute Day of Year
   var days = new Array( 31,
                         28,
                         31,
                         30,
                         31,
                         30,
                         31,
                         31,
                         30,
                         31,
                         30,
                         31 );
   for (var i = 0; i<month; i++) {
      day_of_year += days[i];
      // ACCOUNT FOR LEAP YEAR
      if ( month == 1 && ( (year % 4 == 0 && year % 100 != 0) || ( year % 400 == 0 ) ) ) {
         day_of_year += 1;
      }
   }
   day_of_year += day_of_month;
   //document.write('<p>day_of_year='+day_of_year+'</p>');

   hour_of_year = day_of_year*24 + hour;
   //document.write('<p>hour_of_year='+hour_of_year+'</p>');


   var number_of_wrestlers = wrestlers.length;
   //document.write('<p>number_of_wrestlers='+number_of_wrestlers+'</p>');
   //var index = day_of_year % number_of_wrestlers;
   var index = hour_of_year % number_of_wrestlers;
   //document.write('<p>index='+index+'</p>');


   var id = wrestlers[index][0];
   var last_name = wrestlers[index][1];
   var first_name = wrestlers[index][2];
   var last_lower = "last";
   var first_lower = "first";
   last_lower = last_name.toLowerCase();
   first_lower = first_name.toLowerCase();


   document.write('<div ');
   document.write('style="width:250px; height:350px; text-align:center; background-color:maroon; margin:2px; color:white; letter-spacing: 0.03em;');
   document.write('font-size: 8pt; font-weight: bold; text-decoration: none; font-family: Arial, Helvetica, sans-serif;');
   document.write('padding: 1px;"><span>Meet One of Our Wrestlers<br />');
   document.write('<a style="color:white;" href="http://www.gostanford.com/sports/m-wrestl/mtt/'+last_lower+'_'+first_lower+'00.html'+'" target="_new">');
   document.write(first_name+' '+last_name+'</a></span>');
   //document.write('</div>');


   document.write('<a href="http://www.gostanford.com/sports/m-wrestl/mtt/'+last_lower+'_'+first_lower+'00.html'+'" target="_new">');
   document.write('<img border="0" ');
   document.write('src="http://www.stanfordwrestling.com/images/');
   document.write(last_lower+'_'+first_lower);
   document.write('.jpeg" ');
   document.write('title="Click picture for information about ' + first_name + ' '+ last_name +'" ');
   document.write('alt="Wrestler of the Hour" ');
   document.write('width="210" height="290" ');
   document.write('style="margin-left:2px;" />');
   document.write('</a>');
   document.write('</div>');

}



