  // Source file for scrolling calendar http://hotshift.tripod.com
  var LONGheading = "  San Diego Fire & Life Safety Services  ";
  //Please do not remove the URL below, I request the link for my services
  var HotShift = "http://hotshift.tripod.com";
  var SMPLtitle = "Firefighter";
  var SMPLcodes = "ABC";
  var SMPLsequence = "ABCBCBCACABABABCBCACACAB";
  var SMPLstartdate = new Date("January 1, 1997");
  var SMPLcolors = "#FF0000#0000FF#008000#000000";
  var SMPLon = 1;
  var ALIASon = 0;
  var OTdate = new Date("October 25, 1996");
  var OTcycle = 28;
  var OTon = 1;
  var Rotcycle = 28;
  var Rotdate = new Date("November 22, 1996");
  var Paycycle = 14;
  var Paydate = new Date("December 27, 1996");
  var TableBGColor = "#FFFFCC";
  var HeadingColor = "#000000";
  var LinkColor = "#FFFFFF";

  var Current_Date = new Date();
  var Current_Month = Current_Date.getMonth();
  var Current_Year = Current_Date.getFullYear();



var Days_in_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var Month_Label = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');


var Today = Current_Date.getDate();
var HTML_String = "";



function Header(Year, Month) {

   if (Month == 1) {
      if ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 != 0))) {
         Days_in_Month[1] = 29;
      }
   }
   var Header_String = Month_Label[Month] + ' ' + Year;
   return Header_String;
}

	

function Make_Calendar(Year, Month) {
   var SMPLkeyday;
   var Rotkey;
   var Paykey;
   var SMPLcodeStr=" ";
   var SMPLcolorcode;   
   var Day_Counter = 1;
   var Loop_Counter = 1;
   var u="";
   var uu="";
   var SMPLhtml = new Array();
   
   if (Year <= 1970) {
	Year = 1970;
   }
   	
   if (Year >= 2029) {
	Year = 2029;
   }
   var First_Date = new Date(Year, Month, 1);

   if (Current_Year == Year && Current_Month == Month){
	HTML_String += '<a name="#Now"></a>';
   }
	
   SMPLnumcodes = SMPLcodes.length
   SMPLcycle = SMPLsequence.length

   var Heading = Header(Year, Month);
   var First_Day = First_Date.getDay() + 1;
   if (((Days_in_Month[Month] == 31) && (First_Day >= 6)) ||
       ((Days_in_Month[Month] == 30) && (First_Day == 7))) {
      var Rows = 6;
   }
   else if ((Days_in_Month[Month] == 28) && (First_Day == 1)) {
      var Rows = 4;
   }
   else {
      var Rows = 5;
   }

   HTML_String += '<center><table width=60%><tr><td valign="top"><table BORDER=5 CELLSPACING=1 cellpadding=3 BGCOLOR="C0C0C0" BORDERCOLORLIGHT="808080">';
	HTML_String += '<tr><th colspan=7 BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">' + LONGheading + '</th></tr>';

	
	
	
	HTML_String += '<tr><td align="center" BGCOLOR="'+TableBGColor+'" height="5%" colspan="7" width="100%" nowrap><strong>'
	
	//Print each shift code in color



		for(i=0; i<=(SMPLnumcodes-1); i++){
			SMPLcodeStr=SMPLcodes.substr(i,1);
			SMPLhtml[i]=SMPLcodeStr.fontcolor(SMPLcolors.substr(i*7,7));
			HTML_String += SMPLhtml[i];
		}
	HTML_String += "D";
	HTML_String += '</strong></td>';
	HTML_String += '</tr>';
	
	
	
	   HTML_String += '<tr><th colspan=7 BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">' + Heading + '</th></tr>';

	
	//HTML_String += '<tr><th width=33% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'"><font COLOR="Red">' +'A'+ '</font></th><th width=33% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'"><font COLOR="Blue">' +'B'+ '</font></th><th width=33% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'"><font COLOR="Green">' +'C'+ '</font></th></tr>';


   HTML_String += '<tr><th width=14% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">Sun</th><th width=14% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">Mon</th><th width=14% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">Tue</th><th width=14% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">Wed</th>';

   HTML_String += '<th width=14% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">Thu</th><th width=14% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">Fri</th><th width=14% ALIGN="CENTER" BGCOLOR="'+TableBGColor+'" BORDERCOLOR="000000">Sat</th></tr>';
	
   for (var j = 1; j <= Rows; j++) {
     HTML_String += '<tr ALIGN="center" VALIGN="top">';
     
      for (var i = 1; i < 8; i++) {
         if ((Loop_Counter >= First_Day) && (Day_Counter <= Days_in_Month[Month])) {
                  
  	  var Current = new Date(Year, Month, Day_Counter);

  	  var SMPLdaysdiff = days_diff(SMPLstartdate,Current);
     var OTdaysdiff = days_diff(OTdate,Current);
	  var Rotdaysdiff = days_diff(Rotdate,Current);
	  var Paydaysdiff = days_diff(Paydate,Current);
	  	
     SMPLkeyday = SMPLdaysdiff % SMPLcycle;
     SMPLcodeStr=SMPLsequence.substr(SMPLkeyday,1);
     SMPLcolorcode=SMPLcolors.substr(SMPLcodes.indexOf(SMPLcodeStr.substr(0,1))*7,7);
	  Rotkey = Math.floor(Rotdaysdiff / Rotcycle) % 3;
	  Paykey = Paydaysdiff % Paycycle;
	  
	  var daystr = Day_Counter.toString();
	  
	  if (SMPLdaysdiff > -1){
	  
	  if (Rotkey == SMPLcodes.indexOf(SMPLcodeStr.substr(0,1))) {
	  	if ((Rotdaysdiff % Rotcycle) > 1) {
	  	daystr=daystr + "-D";
	  	}
	  }
	  
	  
	  if (Paykey == 0) {
	  daystr = daystr + "*";
	  }
	  
	  }
	  
	  
	  
	  
	  dayStr=(SMPLdaysdiff>=0 ? daystr.fontcolor(SMPLcolorcode) : daystr.fontcolor("black"));
	  
	  
	  if (OTon==1){
		 if (OTdaysdiff>=0){
			if(Math.floor(OTdaysdiff/OTcycle/2)*2==Math.floor(OTdaysdiff/OTcycle)){
				u="";
				uu="";
			}
			else{
				u="<u>";
				uu="</u>";
			}
		 }
		 else{
			u="";
			uu="";
	    }
	  }
	  else{
		u="";
		uu="";
	  }
	
               if ((Day_Counter == Today) && (Year == Current_Year) && (Month == Current_Month)) {
   				 HTML_String += '<td BGCOLOR="white"  BORDERCOLOR="'+SMPLcolorcode+'"><strong><I>' +u+ dayStr +uu+ '</I></strong></td>';
            }
            else {
   				 HTML_String += '<td BGCOLOR="'+TableBGColor+'"  BORDERCOLOR="000000"><strong>'+u+ dayStr +uu+ '</strong></td>';
            }
   
   
   
            Day_Counter++;
         }
         else {
            HTML_String += '<td BORDERCOLOR="C0C0C0">&nbsp;</td>';
         }
         Loop_Counter++;
      }
      HTML_String += '</tr>';
   }
   HTML_String += '</table></td></tr></table><p>&nbsp;</p></center>';
   //document.write(HTML_String);
   //HTML_String = ""	

}



//Get number of days from start date to date on calendar
function days_diff(start,current){
	var currentdays = Math.floor(current.getTime() / (1000 * 60 * 60 * 24)*1);
	var startdays = Math.floor(start.getTime() / (1000 * 60 * 60 * 24)*1);
	var daysdiff = currentdays-startdays;
	return daysdiff;
}


function Calendar(n,nn) {
   //if (!document.all)
   //return
   //var Mid_Screen = Math.round(document.body.clientWidth / 2);
   
   var yr=0;

   yr=Current_Year += n;

   HTML_String += '<center><p><a name="Top"></a><a href="#Bottom">Bottom</a>' + ' '
   if (n == 0){
	 HTML_String += '<a href="#Now">"Now"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></center>';
   }

for(c=0; c<=nn; c++){

yr=Current_Year += c;

for(i=0; i<=11; i++){
   Make_Calendar(yr, i);
}
}

   HTML_String += '<center><a name="Bottom"></a><a href="#Top">Top</a>' + ' '
   if (n == 0){
	 HTML_String += '<a href="#Now">"Now"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</center>';
   }

   HTML_String += '<p><center><a href="'+HotShift+'">'+HotShift+'</a></center></p>';

document.write(HTML_String);
   
   
}

// End of source file
