  var tc_class = "tc1";
  var spaceNeeded = true;
  
  // Start a series
  function beginSeries(title, subtitle, preacher) {
    if (tc_class == "tc1") {
    	tc_class = "tc2";
    }
		
	// Make a bit of space if necessary
	if (spaceNeeded) {
	  document.write('<tr><td ><br /></td></tr>');
	}

	if (title == "") {
	  return;
	}
	
	if (tc_class == "tc3") {
		document.write('<tr><td class="startspecialseries" colspan="2"><center><strong>' + title + '</strong>');
	} else {
		document.write('<tr><td class="startseries" colspan="2"><center><strong>' + title + '</strong>');
	}
	if (subtitle != '') {
	  document.write('<br />' + subtitle);
    }
	if (preacher != '') {
	  document.write('<br />' + preacher);
    }
	document.write('</center></td></tr>');
  }

  // Start a special series
  function beginSpecialSeries(title, subtitle, preacher) {
    tc_class = "tc3";
	beginSeries(title, subtitle, preacher);
  }
  
  // End a series
  function endSeries() {
	if (tc_class == "tc3") {
		document.write('<tr><td class="endspecialseries" colspan=2></td></tr>');
	} else {
		document.write('<tr><td class="endseries" colspan=2></td></tr>');
	}
    tc_class = "tc1";
	spaceNeeded = false; // Don't need space if another series started now
  }
  
  // Puts in the rest of a diary event and closes off the row
  function tcEvent(date, title, scriptref, preacher, extra) {
    spaceNeeded = true;
	document.write('<tr><td class="' + tc_class + '">' + date + '</td>');
	document.write('<td class="' + tc_class + '"><strong>' + title + '</strong>');
	if (scriptref != '') {
	  document.write('<br /><em>' + scriptref + '</em>');
//	  document.write('<br /><cite class="bibleref" title="' + scriptref + '" style="font-style: normal;"><em>' + scriptref + '</em></cite>');
    }
	if (preacher != '') {
	  document.write('<br />' + preacher);
    }
	if (extra != '') {
	  document.write('<br />' + extra);
    }
	document.write('</td></tr>');
  }
  
  // Functions for various extras    
  function communion() {
    return ('<em><strong>Communion Service</strong></em>');
  }

  function baptism() {
    return ('<em><strong>Baptism Service</strong></em>');
  }
  
  function dedication() {
    return ('<em><strong>Infant Dedication Service</strong></em>');
  }

  function tagref(scriptref) {
    return ('<cite class="bibleref" title="' + scriptref + '">' + scriptref + '</cite>');
  }
