// fpu.js
   var baseDate  = new Date("01/30/2012 12:00:00");
   var monthname = new Array("Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec.");
   var fullmonth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
   var dayticks = 86400000; // 1000 * 60 * 60 * 24;
   var weekticks = 604800000; // dayticks * 7;

   function WeekNumber(week_num) { // function WeekNumberInClass(week_num)
     var newdate = new Date(baseDate);
	 var weeksAdd = week_num - 1;
	 
     if (week_num >= 8)   // October 31 
	   weeksAdd = weeksAdd + 1;
	   
     newdate.setDate(newdate.getDate() + (weeksAdd * 7));    	 
     document.write("Week " + week_num + "<br><font size=1>(" + 
                    monthname[newdate.getMonth()] + " " + newdate.getDate() + 
                    ")</font>");
     }
  
   function WeekNumberNone(week_num) {  //function WeekNumberNone(week_num)     
     document.write("Week " + week_num + "<br><font size=1>&nbsp;</font>");         
     }   	 
   
   function WeekNumberInt(week_num) {
     var newdate;
     var newWed;

     //var x = (baseDate - 0) + ( (week_num - 1) * 604800000 );
     var x = (baseDate - 0) + ( (week_num - 1) * 605800000 );     
     newdate = new Date(x);     
     return "Week " + week_num + " <br> <font size=1> (" + 
                     monthname[newdate.getMonth()] + " " + newdate.getDate() + 
                     ") </font>";
     }

	function WeekNumberzzz(week_num) {
     var newdate;
     var newWed;

     var x = (baseDate - 0) + ( (week_num - 1) * 604800000 );
     //var x = (baseDate - 0) + ( (week_num - 1) * 605800000 );     
     newdate = new Date(x);     
     return "Week " + week_num + " <br> <font size=1> (" + 
                     monthname[newdate.getMonth()] + " " + newdate.getDate() + 
                     ") </font>";
     }

   function WeekNumberXX(week_num) {
     var newmon;
     var newWed;
     if (week_num > 0) // bizarre date math fix
       baseDate = new Date("September 10, 2007");
     var x = (baseDate - 0) + ((week_num - 1) * 605800000);     
     newmon = new Date(x);
     newWed = new Date(x + 172800000);
     document.write("Week " + week_num + "<br><font size=1>(" + 
                    monthname[newmon.getMonth()] + " " + newmon.getDate() + " / " +
                    monthname[newWed.getMonth()] + " " + newWed.getDate() + 
                    ")</font>");
     }

   function LastUpdate() {
     document.write('Last Update: ' + document.lastModified + '<BR>'); 
     }

   function BudgetCheck(week_num) {
     var newdate = baseDate;
     week_num;
     var x = (baseDate - 0) + ((week_num - 1) * 604800000);
     newdate = new Date(x);
     x = newdate.getDate();
     var m = newdate.getMonth() + 1;
     if (m > 12) m = 1;
     if (x >= 13 && x <= 19)
       document.write("<li>Also, start working on your " + fullmonth[m] + " budget.  Bring it to class next week so we can address questions and problems!");
     if (x >= 23)
       document.write("<li>Also, finalize your " + fullmonth[m] + " budget.  Problems?  Questions?  Let's talk about them!");
     return "";
   }    

   function ThisMonthName(week_num) {
     var newdate = baseDate;
     week_num;
     var x = (baseDate - 0) + ((week_num - 1) * 605800000);
     newdate = new Date(x);
     x = newdate.getDate();
     document.write(fullmonth[newdate.getMonth()]);
     }

   function NextMonthName(week_num) {
     var newdate = baseDate;
     week_num;
     var x = (baseDate - 0) + ((week_num - 1) * 605800000);
     newdate = new Date(x);
     x = newdate.getDate();
     var m = newdate.getMonth() + 1;
     if (m > 12) m = 1;
     document.write(fullmonth[m]);
     }

  // Email Link Hider/Helper variables and functions

  var Opener     = '<' + 'a ' + 'hr' + 'ef=\"ma';
  var Closer     = '</a>';
  var Resolver   = unescape("%" + "4" + "0");
  var Descriptor = unescape("%" + "3" + "F") + "sub";
  var Harmonizer = "ject" + unescape("%" + "3" + "D");

  function Soloist(Conductor, Hall, Seat) {
    return Conductor + Resolver + Hall + '.' + Seat;
    }

  function Orchestra(Conductor, Hall, Seat, Program, Title)  {
    document.write(Opener + 'il' + 'to' + ':' + Soloist(Conductor, Hall, Seat) + 
                   Descriptor + Harmonizer + Program + '\">');
    if (Title.length == 0)
      Title = Soloist(Conductor, Hall, Seat);
    document.write( Title + Closer);
    }

  function OrchestraInt(Conductor, Hall, Seat, Program, Title)  {
    // return ( '<pre><code>' + Opener + 'il' + 'to' + ':' + Soloist(Conductor, Hall, Seat) + '\">' + Closer) + '</code></pre>' );
	return "test@test.test";
    }	
	
  // Support functions for Lesson files

   function LessonStart(aTitle, nWeekNum)  {
     document.write('<table width="98%" cellspacing=0 cellpadding=0>' + 
	                '<tr><td align=center valign=middle width=224>' +
                    '<a href="../index.html"><img src="../art/gdlc_fpu_logo.gif" alt="Click to go to the class home page" border=0></a>' +
                    '</td><td align=center valign=middle><font face="Comic Sans MS,Arial,Helvetica,Helv" size="6" color="#000080">' +
                    aTitle + '</font></td><td align=center valign=bottom width=224><a href="http://www.daveramsey.com/fpu/home/">' +
                    '<img src="../art/fpu100x100_crest.jpg" border=0 alt="Click to go to Dave Ramsey\'s FPU Page"></a>' +
                    '</td></tr></table>'	 
	               ); 
	 document.write('<hr align="center">' +
                    '<table cellpadding=3 cellspacing=3 width="100%">' +
                     '<tr>' +
                      '<td colspan=2>' +
                       '<table width="100%" border=0 cellpadding=5 cellspacing=0>' +
	                    '<tr>' +
                         '<td bgcolor="#d0ffd0" colspan=2>' +
                          '<font face="Verdana,Arial,Helv" color="#000000" size=5>This Week\'s Assignment, etc.</font>' +
	                     '</td>' +
	                    '</tr>' +
                       '<tr>' +
                      '<td align=center valign=top bgcolor="#ffffd0" width=100>' +
					  WeekNumberInt( nWeekNum ) + 
					  '</td>' +
                      '<td valign=top>'
                   );					
		return "";		   
     }  	 
	 
   function LessonMiddle()  {
     document.write('</td></tr></table>' + 
	                '</td><tr><td bgcolor="#d0ffd0" colspan=2>'+
                    '<font face="Verdana,Arial,Helv" color="#000000" size=5>Worksheets from the FPU Workbook for this lesson</font>' +
                    '</td>'
				   );					
     return "";				   
     } 

   function WorkSheet(aFile, aDesc)   {
     document.write('<tr>' + 
	                '<td align=left valign=top> ' +
                    '<a href="../worksheets/' + aFile + '">' + aFile + '</a> </td>' +
                    '<td align=left valign=top>' + aDesc + '</td></tr>'	 
				   );					
	return "";			   
     } 	 
	 
   function LessonEnd() {
     document.write('</table>' +
	                '<P><center><hr>Go back to the <a href="../index.html">FPU Class Home Page</a><br><hr>' +
	                '<font face="Arial,Helvetica,Helv">Send your message or file to ' +
					'<a href=\"mailto:FPU@Chuvala.com\">FPU@Chuvala.com</a>' +
					'<br><i><font size=2>Site maintained by <a href="../../kgcsig.html">kgc</a>.</font></i></font></center>' +
                    '<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src="http://www.w3.org/Icons/valid-html401"' +
                    'alt="Valid HTML 4.01!" height="31" width="88"></a></p>' 
	               );					
    return "";
   } 	 	 

 function Test()   {
	 var s = WeekNumber( 1 )
     document.write( s );
     }
 
// EOF: fpu.js

