//************************************************************************
// To change the schedule templates, modify this section.
//
// Format for schedule:
//      schedule([mon am], [tue am], [wed am], [thu am], [fri am],
//                 [mon noon], [tue noon], [wed noon], [thu noon], [fri noon],
//                 [mon tots], [tue tots], [wed tots], [thu tots], [fri tots],
//                 [mon teen], [tue teen], [wed teen], [thu teen], [fri teen],
//                 [mon child], [tue child], [wed child], [thu child], [fri child],
//                 [mon beg], [tue beg], [wed beg], [thu beg], [fri beg],
//                 [mon int], [tue int], [wed int], [thu int], [fri int],
//                 [mon adv], [tue adv], [wed adv], [thu adv], [fri adv],
//                 [sat am], [sat spar])
//
// NOTES:
//  * Schedules are relative to 0 (i.e. Schedule #1 = schedules[0]).
//  * The schedules have nothing to do with the actual hours during which
//    these classes are offered. To change the time for a class, you must
//    modify buildSchedule().
//  * Empty placeholders have been created for non-existent classes
//    (e.g. a Tuesday noon class) to facilitate adding new classes to the
//    schedule if desired.
//************************************************************************
      var schedules = new Array();
	  
	  // these are schedules that are a simple rotation
	  var am = new Array();
	  var noon  = new Array();
	  var juniorTTh = new Array();
	  var juniorMWF = new Array();
	  var teens = new Array();
	  var sat = new Array();
	  var satSpar;
	  var schedIdx;
	  
	  am[0] = "Kicks/Kick Def.";
	  am[1] = "Hand/Striking Tech.";
	  am[2] = "Throws/Falling";
	  am[3] = "Punch Def.";
	  am[4] = "Tech. Review";
	  am[5] = "Tech. Review<br>Sparring (Int/Adv)";
	  noon[0] = "Kick Def.<br>Striking Tech.<br>Throws/Falling";
	  noon[1] = "Kicks<br>Hand Tech.<br><nobr>Sparring (Int/Adv)</nobr>";
	  noon[2] = "Kicks<br><nobr>Striking Tech.</nobr><br>Punch Def.";
	  juniorTTh[0] = "Kicks";
	  juniorTTh[1] = "Punching";
	  juniorMWF[0] = "Coordination<br>Balance/Kicks<br>Striking Tech.<br>Hand Tech.<br>Punch Def.";
	  juniorMWF[1] = "Striking Tech.<br>Hand Tech.<br>Punch Def.<br>Rolling/Jumping";
	  juniorMWF[2] = "Balance/Kicks<br>Hand Tech.<br>Punch Def.<br>Obstacle Course";
	  teens[0] = "Kicks<br><nobr>Striking Tech.</nobr><br>Punch Def.";
	  teens[1] = "Kick Def.<br>Striking Tech.<br>Throws/Falling";
	  teens[2] = "Kicks<br>Hand Tech.<br><nobr>Sparring (Int/Adv)</nobr>";
	  sat[0] = "Kicks<br>Hand Tech.";
	  sat[1] = "Kicks<br><nobr>Striking Tech.</nobr><br>Punch Def.";
	  sat[2] = "Kick Def.<br>Striking Tech.<br>Throws/Falling";
	  satSpar = "Sparring"
	  
// Schedule #1:
      schedules[0] = new schedule(am[0], am[1], am[2], am[3], am[5], noon[0], "", noon[1], "", noon[2],
                                  juniorMWF[0], "", juniorMWF[1], "", juniorMWF[2],
                                  teens[0], "", teens[1], "", teens[2],
                                  juniorMWF[0], "", juniorMWF[1], "", juniorMWF[2],
                                  "Kicks<br>Falling", "Hand Tech.<br>Falling", "Kicks", "", "Punch Def.", // beg
                                  "Kicks", "Hand Tech.<br>Kick Def.<br>Throws/Falling",					  // int
                                  "Sparring<br><nobr>& Techniques</nobr>", "Punch Def.<br><nobr>Garment Holds</nobr>", "",
                                  "Kicks", "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>",	  // adv
                                  "Sparring", "Kick Def.<br>Hand Tech.<br>Throws/Falling", "",
                                  sat[0], satSpar);
// Schedule #2:
      schedules[1] = new schedule(am[1], am[2], am[3], am[0], am[5], noon[2], "", noon[0], "", noon[1],
                                  juniorMWF[2], "", juniorMWF[0], "", juniorMWF[1],
                                  teens[2], "", teens[0], "", teens[1],
                                  juniorMWF[2], "", juniorMWF[0], "", juniorMWF[1],
                                  "Punch Def.", "Kicks<br>Falling", "Hand Tech.<br>Falling", "", "Kicks",  // beg 
                                  "Punch Def.<br><nobr>Garment Holds</nobr>", "Kicks", 					   // int
                                  "Hand Tech.<br>Kick Def.<br>Throws/Falling", "Sparring<br><nobr>& Techniques</nobr>", "",
                                  "Kick Def.<br>Hand Tech.<br>Throws/Falling", "Kicks", 				   // adv
                                  "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>", 
                                  "Sparring", "",
                                  sat[1], satSpar);
// Schedule #3:
      schedules[2] = new schedule(am[2], am[3], am[0], am[1], am[5], noon[1], "", noon[2], "", noon[0],
                                  juniorMWF[1], "", juniorMWF[2], "", juniorMWF[0],
                                  teens[1], "", teens[2], "", teens[0],
                                  juniorMWF[1], "", juniorMWF[2], "", juniorMWF[0],
                                  "Kicks", "Punch Def.", "Kicks<br>Falling", "", "Hand Tech.<br>Falling",	// beg  
                                  "Sparring<br><nobr>& Techniques</nobr>", "Punch Def.<br><nobr>Garment Holds</nobr>", 	// int
                                  "Kicks", "Hand Tech.<br>Kick Def.<br>Throws/Falling", "",
                                  "Sparring", "Kick Def.<br>Hand Tech.<br>Throws/Falling",					// adv
                                  "Kicks", "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>", "",
                                  sat[2], satSpar);
// Schedule #4:
      schedules[3] = new schedule(am[3], am[0], am[1], am[2], am[5], noon[0], "", noon[1], "", noon[2],
                                  juniorMWF[0], "", juniorMWF[1], "", juniorMWF[2],
                                  teens[0], "", teens[1], "", teens[2],
                                  juniorMWF[0], "", juniorMWF[1], "", juniorMWF[2],
                                  "Hand Tech.<br>Falling", "Kicks", "Punch Def.", "", "Kicks<br>Falling",  // beg 
                                  "Hand Tech.<br>Kick Def.<br>Throws/Falling",							   // int
                                  "Sparring<br><nobr>& Techniques</nobr>", "Punch Def.<br><nobr>Garment Holds</nobr>", "Kicks", "",
                                  "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>", "Sparring",	   // adv
                                  "Kick Def.<br>Hand Tech.<br>Throws/Falling","Kicks", "",
                                  sat[0], satSpar);
// Schedule #5:
      schedules[4] = new schedule(am[4], am[1], am[2], am[3], am[5], noon[2], "", noon[0], "", noon[1],
                                  juniorMWF[2], "", juniorMWF[0], "", juniorMWF[1],
                                  teens[2], "", teens[0], "", teens[1],
                                  juniorMWF[2], "", juniorMWF[0], "", juniorMWF[1],
                                  "Kicks<br>Falling", "Hand Tech.<br>Falling", "Kicks", "", "Punch Def.",	// beg
                                  "Kicks", "Hand Tech.<br>Kick Def.<br>Throws/Falling",						// int
                                  "Sparring<br><nobr>& Techniques</nobr>", "Punch Def.<br><nobr>Garment Holds</nobr>", "",
                                  "Kicks", "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>",		// adv
                                  "Sparring", "Kick Def.<br>Hand Tech.<br>Throws/Falling", "",
                                  sat[1], satSpar);
// Schedule #6:
      schedules[5] = new schedule(am[0], am[1], am[2], am[3], am[5], noon[1], "", noon[2], "", noon[0],
                                  juniorMWF[1], "", juniorMWF[2], "", juniorMWF[0],
                                  teens[1], "", teens[2], "", teens[0],
                                  juniorMWF[1], "", juniorMWF[2], "", juniorMWF[0],
                                  "Punch Def.", "Kicks<br>Falling", "Hand Tech.<br>Falling", "", "Kicks", 	// beg
                                  "Punch Def.<br><nobr>Garment Holds</nobr>", "Kicks", 						// int
                                  "Hand Tech.<br>Kick Def.<br>Throws/Falling", "Sparring<br><nobr>& Techniques</nobr>", "",
                                  "Kick Def.<br>Hand Tech.<br>Throws/Falling", "Kicks", 					// adv
                                  "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>", "Sparring", "",
                                  sat[2], satSpar);
// Schedule #7:
      schedules[6] = new schedule(am[1], am[2], am[3], am[0], am[5], noon[0], "", noon[1], "", noon[2],
                                  juniorMWF[0], "", juniorMWF[1], "", juniorMWF[2],
                                  teens[0], "", teens[1], "", teens[2],
                                  juniorMWF[0], "", juniorMWF[1], "", juniorMWF[2],
                                  "Kicks", "Punch Def.", "Kicks<br>Falling", "", "Hand Tech.<br>Falling", 	// beg
                                  "Sparring<br><nobr>& Techniques</nobr>", "Punch Def.<br><nobr>Garment Holds</nobr>", 	// int
                                  "Kicks", "Hand Tech.<br>Kick Def.<br>Throws/Falling", "",
                                  "Sparring", "Kick Def.<br>Hand Tech.<br>Throws/Falling",					// adv
                                  "Kicks", "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>", "",
                                  sat[0], satSpar);
// Schedule #8:
      schedules[7] = new schedule(am[2], am[3], am[0], am[1], am[5], noon[2], "", noon[0], "", noon[1],
                                  juniorMWF[2], "", juniorMWF[0], "", juniorMWF[1],
                                  teens[2], "", teens[0], "", teens[1],
                                  juniorMWF[2], "", juniorMWF[0], "", juniorMWF[1],
                                  "Hand Tech.<br>Falling", "Kicks", "Punch Def.", "", "Kicks<br>Falling", 	// beg  
                                  "Hand Tech.<br>Kick Def.<br>Throws/Falling",								// int
                                  "Sparring<br><nobr>& Techniques</nobr>", "Punch Def.<br><nobr>Garment Holds</nobr>", "Kicks", "",
                                  "Punch Def.<br>Body Holds<br><nobr>Garment Holds</nobr>", "Sparring",		// adv
                                  "Kick Def.<br>Hand Tech.<br>Throws/Falling","Kicks", "",
                                  sat[1], satSpar);
//************************************************************************
//************************************************************************

	  // Initialize this field, because Netscape blows away on initial cookie retrieval.
      var dispDate = new Date(convertYear(today.getYear()), today.getMonth(), today.getDate(), 0, 0, 0); 

      // Determine the requested display date.
      var currWeek = getMondayDate(new Date(convertYear(today.getYear()), today.getMonth(), today.getDate(), 0, 0, 0));
      var nextWeek = getMondayDate(new Date(currWeek.getTime() + oneWeek));

      // Initialize these for cookie bug.
      var dispWeek = getMondayDate(new Date(convertYear(dispDate.getYear()), dispDate.getMonth(), dispDate.getDate(), 0, 0, 0));
      var dispTemplate = getTemplate(dispWeek);
      
      var scookie = unescape(document.cookie);
	  var scookie1 = "";
	  var scookie2 = "";

      var arg = "scheduledate=";
      var i = scookie.indexOf(arg);
	  var j = scookie.indexOf(";", i + 1);
	  if (j == 0) { j = scookie.length; }

      if (i == -1) {
		scookie1 = scookie;     
      }
      else {
        // Parse the cookie.
		var userDate = scookie.substring(i + arg.length, j);

		// Save other portions of the cookie.
		if (i > 1) { scookie1 = scookie.substring(0, i); }
		if (j != scookie.length) { scookie2 = scookie.substring(j + 1); }

        var yy;
        var mm;
        var dd;
        
        i = userDate.indexOf("/");
        j = userDate.indexOf("/", i + 1);
		if (i == -1 || j == -1) {
		  yy = convertYear(today.getYear());
		  mm = today.getMonth();
		  dd = today.getDate();
		}
		else {
          yy = userDate.substring(0, i);
		  mm = userDate.substring(i + 1, j);
		  dd = userDate.substring(j + 1);
		}
        dispDate = new Date(yy, mm, dd, 0, 0, 0);
      }

      // Determine the display week and the teaching schedule template to use.
      var dispWeek = getMondayDate(new Date(convertYear(dispDate.getYear()), dispDate.getMonth(), dispDate.getDate(), 0, 0, 0));
      var dispTemplate = getTemplate(dispWeek);
            
      function schedule(monAm, tueAm, wedAm, thuAm, friAm,
                        monNoon, tueNoon, wedNoon, thuNoon, friNoon,
                        monTots, tueTots, wedTots, thuTots, friTots,
                        monTeen, tueTeen, wedTeen, thuTeen, friTeen,
                        monChild, tueChild, wedChild, thuChild, friChild,
                        monBeg, tueBeg, wedBeg, thuBeg, friBeg, 
                        monInt, tueInt, wedInt, thuInt, friInt,
                        monAdv, tueAdv, wedAdv, thuAdv, friAdv,
                        satAm, satSparring) {
        this.monAm = monAm;
        this.tueAm = tueAm;
        this.wedAm = wedAm;
        this.thuAm = thuAm;
        this.friAm = friAm;
        this.monNoon = monNoon;
        this.tueNoon = tueNoon;
        this.wedNoon = wedNoon;
        this.thuNoon = thuNoon;
        this.friNoon = friNoon;
        this.monTots = monTots;
        this.tueTots = tueTots;
        this.wedTots = wedTots;
        this.thuTots = thuTots;
        this.friTots = friTots;
        this.monTeen = monTeen;
        this.tueTeen = tueTeen;
        this.wedTeen = wedTeen;
        this.thuTeen = thuTeen;
        this.friTeen = friTeen;
        this.monChild = monChild;
        this.tueChild = tueChild;
        this.wedChild = wedChild;
        this.thuChild = thuChild;
        this.friChild = friChild;
        this.monBeg = monBeg;
        this.tueBeg = tueBeg;
        this.wedBeg = wedBeg;
        this.thuBeg = thuBeg;
        this.friBeg = friBeg;
        this.monInt = monInt;
        this.tueInt = tueInt;
        this.wedInt = wedInt;
        this.thuInt = thuInt;
        this.friInt = friInt;
        this.monAdv = monAdv;
        this.tueAdv = tueAdv;
        this.wedAdv = wedAdv;
        this.thuAdv = thuAdv;
        this.friAdv = friAdv;
        this.satAm = satAm;
		this.satSpar = satSparring;
      }
      
      function getMondayDate(ddate) {
        // If date falls on a Sunday, roll forward to the following Monday,
        // otherwise roll back to the preceding Monday.
        switch (ddate.getDay()) {
          case 1:
            return ddate;
          case 0:
            // Sunday
            return new Date(ddate.getTime() + oneDay);
          default:
            return new Date(ddate.getTime() - (oneDay * (ddate.getDay() - 1)));
        }
      }
      
      function getTemplate(ddate) {
        // If new year starts this week (Monday through Friday only), default to schedule #1 (index 0).
        for (var i = 0; i < 5; i++) {
           if (yearStarts(new Date(ddate.getTime() + (oneDay * i)))) { return 0; }
        }
        
        // Check if studio is closed all week.
        if (studioCloses(ddate)) { return -1; }

        // Calculate weeks elapsed since beginning of year. Round for daylight savings time difference.
        var newYear = getMondayDate(new Date(convertYear(ddate.getYear()), yearStart.mm, yearStart.dd, 0, 0, 0));
        var weeksElapsed = Math.round((ddate.getTime() - newYear.getTime()) / oneWeek);
      
        return weeksElapsed % 8;
      }
      
      function dayOfMonth(ddate, incr) {
        ddate = new Date(ddate.getTime() + (oneDay * incr));
        return ddate.getDate();
      }
      
      function formatDate(ddate) {
        return days[ddate.getDay()] + ", " + months[ddate.getMonth()] + " " + 
               ddate.getDate() + ", " + convertYear(ddate.getYear());
      }
	  
	  function yearDropDown() {
        var thisYear = convertYear(today.getYear());
        var nextYear = convertYear(today.getYear()) + 1;
        document.write("<option value=\"" + thisYear + "\">" + thisYear + "</option>");
        document.writeln("<option value=\"" + nextYear + "\">" + nextYear + "</option>");
	  }
      
      function setDropDowns(form) {
        form.mm.options[dispDate.getMonth()].selected = true;
        form.dd.options[dispDate.getDate() - 1].selected = true;
        for (var i = 0; i < form.yy.length; i++) {
          if (form.yy.options[i].value == convertYear(dispDate.getYear())) {
            form.yy.options[i].selected = true;
            break;
          }
        }
        setDropDownDays(form);
      }
      
      function setDropDownDays(form) {
        // Determine the maximum days for the selected month/year.
        var maxDays;
        var mm = selectedOption(form.mm);
        var dd = selectedOption(form.dd);
        var yy = selectedOption(form.yy);

        switch (mm) {
          case "3":
          case "5":
          case "8":
          case "10":
            // April, June, September, November
            maxDays = 30; 
            break;
          case "1":
            // Calculate leap year
            if (isNaN(yy)) {
              maxDays = 28;
            }
            else { 
              var iyy = parseInt(yy);
              if ((iyy % 4) == 0) {
                maxDays = 29;
              }
              else {
                maxDays = 28;
              }
            }
            break;
          default:
            maxDays = 31;
            break;
        }
        
        // Add elements to the days dropdown accordingly.
        while (maxDays > form.dd.length) {
          if (isIE) {
            var newElem = document.createElement("OPTION");
            newElem.text = form.dd.length + 1;
            newElem.value = newElem.text;
            form.dd.options.add(newElem);
          }
          else if (isNav) {
            form.dd.options[form.dd.length] = new Option(form.dd.length + 1, form.dd.length + 1, false, false);
          }
        }

        // Remove elements from the days dropdown accordingly.
        while (maxDays < form.dd.length) {
          if (isIE) {
            form.dd.options.remove(form.dd.length - 1);
          }
          else if (isNav) {
            form.dd.options[form.dd.length - 1] = null;
          }
        }
        
        // Reposition on previously selected day, if not greater than available days.
        if (! isNaN(dd)) {
          if (dd <= form.dd.length) {
            form.dd.options[dd - 1].selected = true;
          }
          else {
            form.dd.options[form.dd.length - 1].selected = true;
          }
        }
      }
	  
	  function printSchedule(ddate) {
		if (isIE) {
          window.open("teachprt.htm", "schedule", "scrollbars,width=730,height=560,top=0,left=20");
		}
		else if(isNav) {
		  // Netscape bug requires opening an intermediate page, then rerouting to teachprt.htm.
          window.open("teachnav.htm", "schedule", "scrollbars,width=730,height=560,top=0,left=20");
		}
	  }

      function writeCookie(form) {
        var selectedmm = selectedOption(form.mm);
        var selecteddd = selectedOption(form.dd);
        var selectedyy = selectedOption(form.yy);
        if (selectedmm != "" && selecteddd != "" && selectedyy != "") {
          // Write date to cookie.
          document.cookie = escape(scookie1 + "scheduledate=" + selectedyy + "/" + selectedmm + "/" + selecteddd + 
		                           ";" + scookie2);
        }
        else {
          alert("Please select a date!");
        }
      }
      
      function writeCookie2(ddate) {
        // Write date to cookie.
        document.cookie = escape(scookie1 + "scheduledate=" + convertYear(ddate.getYear()) + "/" + ddate.getMonth() + 
		                         "/" + ddate.getDate() + ";" + scookie2);
      }
      
      function selectedOption(dropdown) {
        if (dropdown.selectedIndex == -1) {
          return "";
        }
        else {
          return dropdown.options[dropdown.selectedIndex].value;
        }
      }
 
       function buildSchedule(week, template, timeslot, prtversion) {
        // Don't use the <p> tag: substitute <br>&nbsp;<br> (Netscape bug)

        document.writeln("<div class=leftjustify>");
        switch (timeslot) {
          case "am":
		    if (prtversion) {
		      printScheduleDate(template, true);
		      document.writeln("<br>&nbsp;<br>");
		    }        
            document.writeln("Adult Morning Sessions");
            break;
          case "kids":
            document.writeln("Child/Teen Sessions");
            break;
          case "pm":
            document.writeln("Adult Evening Sessions");
            break;
        }
		if (!prtversion) {
		  printScheduleDate(template, false);
		}
		document.writeln("</div>");

        // Use the <div> tag to protect font and centering (Netscape bug)
		document.writeln("<div class=leftjustify>");		
        document.writeln("<br>");
        
        // Begin table
        document.writeln("<table border=0 cellpadding=7 cellspacing=2 width=671 class=schedtable>");

        // Calendar row
        document.writeln("<tr>");
        document.writeln("<td class=schedmid>" + months[week.getMonth()] + "</td>");
        document.writeln("<td class=schedmid>" + week.getDate() + "</td>");
        document.writeln("<td class=schedmid>" + dayOfMonth(week, 1) + "</td>");
        document.writeln("<td class=schedmid>" + dayOfMonth(week, 2) + "</td>");
        document.writeln("<td class=schedmid>" + dayOfMonth(week, 3) + "</td>");
        document.writeln("<td class=schedmid>" + dayOfMonth(week, 4) + "</td>");
        document.writeln("<td class=schedmid>" + dayOfMonth(week, 5) + "</td>");
        document.writeln("</tr>");
        
        // Day-of-week row
        document.writeln("<tr>");
        if (template < 0) {
          document.writeln("<td class=schedmid>&nbsp;</td>");
        }
        else {
          document.writeln("<td class=schedmid>Sched. #" + (template + 1) + "</td>");
        }
        document.writeln("<td class=schedmid>Monday</td>");
        document.writeln("<td class=schedmid>Tuesday</td>");
        document.writeln("<td class=schedmid>Wednesday</td>");
        document.writeln("<td class=schedmid>Thursday</td>");
        document.writeln("<td class=schedmid>Friday</td>");
        document.writeln("<td class=schedmid>Saturday</td>");
        document.writeln("</tr>");
          
        if (template == -1) {
          // Studio is closed all week
          document.writeln("<tr>");
          document.writeln("<td class=schedmid>&nbsp;</td>");
          document.writeln("<td class=schedmid>Studio<br>Closed</td>");
          document.writeln("<td class=schedmid>Studio<br>Closed</td>");
          document.writeln("<td class=schedmid>Studio<br>Closed</td>");
          document.writeln("<td class=schedmid>Studio<br>Closed</td>");
          document.writeln("<td class=schedmid>Studio<br>Closed</td>");
          document.writeln("<td class=schedmid>Studio<br>Closed</td>");
          document.writeln("</tr>");
        }
        else {
          switch (timeslot) {
            case "am":
              
              // 6:10 - 7:00am row
              document.writeln("<tr>");
              document.writeln("<td class=schedmid><nobr>6:10 - 7:00am</nobr></td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              if (closed(new Date(week.getTime() + tuesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Beg/Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].tueAm + "</td>");
              }
              if (closed(new Date(week.getTime() + wednesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Beg/Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].wedAm + "</td>");
              }
              if (closed(new Date(week.getTime() + thursday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Beg/Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].thuAm + "</td>");
              }
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("</tr>");
              
              // 7:00 - 8:30am row
//              document.writeln("<tr>");
//              document.writeln("<td class=schedmid><nobr>7:00 - 8:30am</nobr></td>");
//              if (closed(week)) {
//                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
//              }
//              else {
//                document.writeln("<td class=schedtop><b><nobr>YOGA</nobr></b><br>&nbsp;</td>");
//              }
//              document.writeln("<td class=schedblackout>&nbsp;</td>");
//              document.writeln("<td class=schedblackout>&nbsp;</td>");
//              document.writeln("<td class=schedblackout>&nbsp;</td>");
//              if (closed(new Date(week.getTime() + friday))) {
//                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
//              }
//              else {
//                document.writeln("<td class=schedtop><b><nobr>YOGA</nobr></b><br>&nbsp;</td>");
//              }
//              document.writeln("<td class=schedblackout>&nbsp;</td>");  
//              document.writeln("</tr>"); 
              
              // 10:00 - 10:50am row
              document.writeln("<tr>");
              document.writeln("<td class=schedmid><nobr>10:00 - 10:50am</nobr></td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");  
              if (closed(new Date(week.getTime() + saturday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Beg/Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].satAm + "</td>");
              }
              document.writeln("</tr>");
                            
              // 11:00 - 11:50am row
              document.writeln("<tr>");
              document.writeln("<td class=schedmid><nobr>11:00 - 11:50am</nobr></td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("<td class=schedblackout>&nbsp;</td>");  
              if (closed(new Date(week.getTime() + saturday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].satSpar + "</td>");
              }
              document.writeln("</tr>");
              
              // 12:00 - 12:50pm row
              document.writeln("<tr>");
              document.writeln("<td class=schedmid><nobr>12:00 - 12:50pm</nobr></td>");
              if (closed(week)) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Beg/Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].monNoon + "</td>");
              }
              if (closed(new Date(week.getTime() + tuesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>YOGA</nobr></b><br>&nbsp;</td>");
              }
              if (closed(new Date(week.getTime() + wednesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Beg/Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].wedNoon + "</td>");
              }
              if (closed(new Date(week.getTime() + thursday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>YOGA</nobr></b><br>&nbsp;</td>");
              }              if (closed(new Date(week.getTime() + friday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Beg/Int/Adv</nobr></b><br>&nbsp;<br>" + schedules[template].friNoon + "</td>");
              }
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("</tr>");

              break;
            case "kids":
              
              // 4:30 - 5:15pm row
              document.writeln("<tr>");
              document.writeln("<td class=schedmid><nobr>4:45 - 5:30pm</nobr></td>");
              if (closed(week)) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Junior 7-15yrs</nobr></b><br>&nbsp;<br>" + schedules[template].monTots + "</td>");
              }
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              if (closed(new Date(week.getTime() + wednesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Junior 7-15yrs</nobr></b><br>&nbsp;<br>" + schedules[template].wedTots + "</td>");
              }
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              if (closed(new Date(week.getTime() + friday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b><nobr>Junior 7-15yrs</nobr></b><br>&nbsp;<br>" + 
				                 schedules[template].friTots + sparring(new Date(week.getTime() + friday)) + "</td>");
              }
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("</tr>");
              
                           
              break;
            case "pm":
              // 6:30 - 7:30pm row
              document.writeln("<tr>");
              document.writeln("<td class=schedmid><nobr>6:30 - 7:30pm</nobr></td>");
              if (closed(week)) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b>Adv</b><br>&nbsp;<br>" + schedules[template].monAdv + "</td>");
              }
              if (closed(new Date(week.getTime() + tuesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b>Beg/Int</b><br>&nbsp;<br>" + schedules[template].tueInt + "</td>");
              }
              if (closed(new Date(week.getTime() + wednesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b>Adv</b><br>&nbsp;<br>" + schedules[template].wedAdv + "</td>");
              }
              if (closed(new Date(week.getTime() + thursday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedmid><b>Black<br>Belt<br>Program</b></td>");
              }
              if (closed(new Date(week.getTime() + friday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b>Beg/Int/Adv</b><br>&nbsp;<br></td>");
              }
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("</tr>");
              
              // 7:30 - 8:30pm row
              document.writeln("<tr>");
              document.writeln("<td class=schedmid><nobr>7:30 - 8:30pm</nobr></td>");
              if (closed(week)) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b>Beg/Int</b><br>&nbsp;<br>" + schedules[template].monInt + "</td>");
              }
              if (closed(new Date(week.getTime() + tuesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b>Adv</b><br>&nbsp;<br>" + schedules[template].tueAdv + "</td>");
              }
              if (closed(new Date(week.getTime() + wednesday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedtop><b>Beg/Int</b><br>&nbsp;<br>" + schedules[template].wedInt + "</td>");
              }
              if (closed(new Date(week.getTime() + thursday))) {
                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
              }
              else {
                document.writeln("<td class=schedmid><b>Black<br>Belt</b></td>");
              }
              if (closed(new Date(week.getTime() + friday))) {
                document.writeln("Studio<br>Closed");
              }
              else {
                document.writeln("<td class=schedblackout>&nbsp;</td>");
              }    
              document.writeln("<td class=schedblackout>&nbsp;</td>");
              document.writeln("</tr>");
              
              // 8:30 - 9:30pm row
//              document.writeln("<tr>");
//              document.writeln("<td class=schedmid><nobr>8:30 - 9:30pm</nobr></td>");
//              document.writeln("<td class=schedblackout>&nbsp;</td>");
//              document.writeln("<td class=schedblackout>&nbsp;</td>");
//              if (closed(new Date(week.getTime() + wednesday))) {
//                document.writeln("<td class=schedmid>Studio<br>Closed</td>");
//              }
//              else {
//                document.writeln("<td class=schedtop><b><nobr>YOGA</nobr></b><br>&nbsp;</td>");
//              }
//              document.writeln("<td class=schedblackout>&nbsp;</td>");
//              document.writeln("<td class=schedblackout>&nbsp;</td>");
//              document.writeln("<td class=schedblackout>&nbsp;</td>");  
//              document.writeln("</tr>");

              break;
          }
        }  

        // End table
        document.writeln("</table>");
        document.writeln("</div>");
      }

	  function printScheduleDate(template, prtversion) {
		document.write("<br>Schedule for ");
		if (prtversion) {
		  document.write("the week of &nbsp;");
		}
		else if (dispWeek.getTime() == currWeek.getTime()) {
		  document.write("current week, beginning ");
		}
		else if (dispWeek.getTime() == nextWeek.getTime()) {
		  document.write("next week, beginning ");
		}
		else {
		  document.write("the week of &nbsp;");
		}
		document.write("<span id=\"bold\">" + formatDate(dispWeek) + "</span>");
		
		if (!prtversion && ((isIE && ver > 4) || isNav) && template != -1) {
          document.writeln(" &nbsp; &nbsp; [ " + 
		                   "<a href=\"javascript:;\" class=link onclick=\"printSchedule(dispWeek)\">" + 
                           "print schedule</a> ]");
        }
		else {
		  document.writeln("");
        }
	  }
	  
      function sparring(ddate) {
        // Check if first or second Friday of the month.
        if (ddate.getDay() == 5 && ddate.getDate() < 15) {
		  return "<br>Sparring"; }
		else {
		  return "";
		}
      }
