<!--
var Mtg_title = new Array(); var Mtg_here = new Array();
var Mtg_dateinfo = new Array(); var Mtg_desc = new Array(); var Mtg_speak = new Array();
var mtg2come = 0;
var nf_total = -1;
var nf_here = -1;
var nf_away = -1;
var n_h_away = 0;
var n_a_here = 0;
var awayhead = 0;
var nowdate = new Date();
var nowday = nowdate.getDate();
var nowmon = nowdate.getMonth()+1;
var nowyr = nowdate.getFullYear() - 2000;
var nowval = (nowyr * 10000)+(nowmon * 100)+nowday;
var code4here = "<h3>At Bulkington:</h3>";
var code4away ="";
var xmlDates=null;
if (window.ActiveXObject)
	{
// code for IE
		xmlDates=new ActiveXObject("Microsoft.XMLDOM");
//		alert("IE Entered");
	}
else 
	{
		if (document.implementation.createDocument)
		{
//		alert("Mozilla Entered");

// code for Mozilla, Firefox, Opera, etc.
		xmlDates=document.implementation.createDocument("","",null);
		}
		else
		{
		alert('Your browser cannot handle this script');
		}
	}
if (xmlDates!=null)
	{ 
	xmlDates.async=false;
	xmlDates.validateOnParse="false";
// check whether errors created by use of Chrome and Safari
	var cerr = "";
	try 
		{
		xmlDates.load("DateList.xml");
		}
	catch(e)
 		{
		  try //using XMLHttpRequest instead
		  {
		   var xmlhttp = new window.XMLHttpRequest();
		   xmlhttp.open("GET","DateList.xml",false);
		   xmlhttp.send(null);
		   xmlDates = xmlhttp.responseXML.documentElement;
		  }
		  catch(e)
		  {
		   cerr=e.message;
		  }
		}

	var mtg_entries=xmlDates.getElementsByTagName("FORTH");
	var mtg2come = mtg_entries.length;
// alert ("No of Forthcoming events  "+mtg2come+" Date val="+nowval);
	for (i=0;i<mtg2come;i++)
	 { 
	  ishere = mtg_entries[i].getElementsByTagName("MHERE")[0].childNodes[0].nodeValue;
	  j = mtg_entries[i].getElementsByTagName("MFY")[0].childNodes[0].nodeValue;
	  if (j > 2000)
	  {
	    j -= 2000;
	  }
	  fromdate = j * 10000;
	  j = mtg_entries[i].getElementsByTagName("MFM")[0].childNodes[0].nodeValue;
	  fromdate += (j * 100);
	  j = mtg_entries[i].getElementsByTagName("MFD")[0].childNodes[0].nodeValue;
	  fromdate += (j * 1);
	  if (fromdate <= nowval)
		{
		j = mtg_entries[i].getElementsByTagName("MTY")[0].childNodes[0].nodeValue;
		if (j > 2000)
		{
	  	j -= 2000;
		}
		todate = j * 10000;
		j = mtg_entries[i].getElementsByTagName("MTM")[0].childNodes[0].nodeValue;
		todate += (j * 100);
		j = mtg_entries[i].getElementsByTagName("MTD")[0].childNodes[0].nodeValue;
		todate += (j * 1);
		if (todate >= nowval)
		  {
			nf_total += 1;
			Mtg_here[nf_total] = ishere;
			Mtg_title[nf_total] = mtg_entries[i].getElementsByTagName("MTITLE")[0].childNodes[0].nodeValue;
			Mtg_dateinfo[nf_total] = mtg_entries[i].getElementsByTagName("MDATE")[0].childNodes[0].nodeValue;
			Mtg_desc[nf_total] = mtg_entries[i].getElementsByTagName("MDESC")[0].childNodes[0].nodeValue;
			Mtg_speak[nf_total] = mtg_entries[i].getElementsByTagName("MSPEAK")[0].childNodes[0].nodeValue;
			if (ishere == 1)
			{
				nf_here += 1;
			}
			else
			{
				nf_away +=1;
			}
		  }
// next bracket closes fromdate vs nowval comparison
		}
// next  bracket closes for loop
	 }
	}
else
	{
	alert('The document containing details of forthcoming events is either missing or unavailable. You will not be able to access this information until this fault is rectified. Please go to our Contacts page www.bulkingtoncongregational.org/BCCcontact.html and report the problem via e-mail.Thank you, and many apologies for any inconvenience caused.');
	}

// calculate the overflow to balance columns if one list is at least 2 greater than the other
j = Math.floor((Math.abs(nf_here - nf_away))/2);
if (j > 0)
	{
	awayhead = 0;
	if (nf_here > nf_away)
		{ nf_hmax = nf_here - j;
		  nf_afirst = -1;
		  code4away ="<h3><i>At Bulkington (continued):</i></h3>";
		}
	else
		{ nf_afirst = j-1;
		  nf_hmax = nf_here;
		  code4away ="<h3><i>Elsewhere (continued):</i></h3>";
		}
	}
else
	{
	nf_hmax = nf_here;
	nf_afirst = -1;
	}

// PROCESS HOME EVENTS ..............................
if (nf_here < 0)
  {
	code4here = code4here + "<p><i>None to display at present.</i></p>";
  }
if (nf_total >= 0)
 {
// scan through for local events
var nf_curr = -1;
for (i=0;i<=nf_total;i++)
  {
	j = Mtg_here[i];
	if (j == 1)
	{
	  var mtg_details = "<p><strong>"+Mtg_title[i]+"</strong><br />"+Mtg_dateinfo[i]+"<br /><strong><i>";
	  mtg_details = mtg_details + Mtg_desc[i]+"</i></strong><br />"+Mtg_speak[i];

	  nf_curr += 1;
	  if (nf_curr <= nf_hmax)
	  {
		code4here = code4here + mtg_details;
	  }
	  else
	  {
		code4away = code4away + mtg_details;
	  }
	}
  }
// PROCESS AWAY EVENTS ..............................
var nf_curr = -1;
for (i=0;i<=nf_total;i++)
  {
	j = Mtg_here[i];
	if (j != 1)
	{
	  var mtg_details = "<p><strong>"+Mtg_title[i]+"</strong><br />"+Mtg_dateinfo[i]+"<br /><strong><i>";
	  mtg_details = mtg_details + Mtg_desc[i]+"</i></strong><br />"+Mtg_speak[i];

	  nf_curr += 1;
	  if (nf_curr > nf_afirst)
	  {
		if (awayhead == 0)
		{
			code4away = code4away + "<h3>Elsewhere:</h3>";
			awayhead = 1;
		}
		code4away = code4away + mtg_details;
	  }
	  else
	  {
		if (awayhead == 0)
		{
			code4here = code4here + "<h3>Elsewhere:</h3>";
			awayhead = 1;
		}
		code4here = code4here + mtg_details;
	  }
	}
  }
 }
if (awayhead == 0)
{
	code4away = code4away + "<h3>Elsewhere:</h3><p><i>None to display at present.</i></p>";
}

function PutHere()
{
document.getElementById("forthhere").innerHTML = code4here;
}

function PutAway()
{
document.getElementById("forthaway").innerHTML = code4away;
}

//-->

