var SelectQuote = 17;
var BibleQuote = new Array();
var BibleRef = new Array();
var WiseQuote = new Array();
var WiseAuth = new Array();
var xmlQuotes=null;
if (window.ActiveXObject)
	{
// code for IE
		xmlQuotes=new ActiveXObject("Microsoft.XMLDOM");
//		alert("IE Entered");
	}
else 
	{
		if (document.implementation.createDocument)
		{
//		alert("Mozilla Entered");

// code for Mozilla, Firefox, Opera, etc.
		xmlQuotes=document.implementation.createDocument("","",null);
		}
		else
		{
		alert('Your browser cannot handle this script');
		}
	}
if (xmlQuotes!=null)
	{ 
	xmlQuotes.async=false;
	xmlQuotes.validateOnParse="false";
// check whether errors created by use of Chrome and Safari
	var cerr = "";
	try 
		{
		xmlQuotes.load("QuoteList.xml");
		}
	catch(e)
 		{
		  try //using XMLHttpRequest instead
		  {
		   var xmlhttp = new window.XMLHttpRequest();
		   xmlhttp.open("GET","QuoteList.xml",false);
		   xmlhttp.send(null);
		   xmlQuotes = xmlhttp.responseXML.documentElement;
		  }
		  catch(e)
		  {
		   cerr=e.message;
		  }
		}


	var Bible_texts=xmlQuotes.getElementsByTagName("BIBLE");
	var numBibleQ = Bible_texts.length;
// alert ("No of Bible texts  "+numBibleQ);
	for (i=0;i<numBibleQ;i++)
	 { 
	  BibleQuote[i]=Bible_texts[i].getElementsByTagName("BTEXT")[0].childNodes[0].nodeValue;
	  BibleRef[i]=Bible_texts[i].getElementsByTagName("BVERSE")[0].childNodes[0].nodeValue;
	 }

	var Wise_texts=xmlQuotes.getElementsByTagName("WISDOM");
	var numWiseQ = Wise_texts.length;
// alert ("No of wise quotes  "+numWiseQ);
	for (i=0;i<numWiseQ;i++)
	 { 
	  WiseQuote[i]=Wise_texts[i].getElementsByTagName("WTEXT")[0].childNodes[0].nodeValue;
	  WiseAuth[i]=Wise_texts[i].getElementsByTagName("WAUTH")[0].childNodes[0].nodeValue;
	 }

	}
else
	{
	alert('The document containing sermon details is either missing or unavailable. You will not be able to access sermons 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.');
	}



function giveWinwidth()
{
if (window.innerWidth)
 	theWidth=window.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth)
	 theWidth=document.documentElement.clientWidth;
else if (document.body)
 	theWidth=document.body.clientWidth;
return (theWidth);
}

function giveWinheight()
{
if (window.innerHeight)
 	theHeight=window.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight)
	 theHeight=document.documentElement.clientHeight;
else if (document.body)
	 theHeight=document.body.clientHeight;
return (theHeight);
}

function resetbgimg()
{
	
	wwidth = giveWinwidth();
	if (wwidth <= 650)	
		document.body.style.backgroundImage="url(images/Border640.png)";
	else if (wwidth <= 810)
		document.body.style.backgroundImage="url(images/Border800.png)";
	else if (wwidth <= 1040)
		document.body.style.backgroundImage="url(images/Border1024.png)";
	else if (wwidth <= 1160)
		document.body.style.backgroundImage="url(images/Border1152.png)";
	else if (wwidth <= 1300)
		document.body.style.backgroundImage="url(images/Border1280.png)";
	else if (wwidth <= 1620)
		document.body.style.backgroundImage="url(images/Border1600.png)";
	else if (wwidth <= 1810)
		document.body.style.backgroundImage="url(images/Border1792.png)";
	else if (wwidth <= 1870)
		document.body.style.backgroundImage="url(images/Border1856.png)";
	else if (wwidth <= 1950)
		document.body.style.backgroundImage="url(images/Border1920.png)";
	else if (wwidth >= 1950)
	  	document.body.style.backgroundImage="url(images/Border2048.png)";
}
// Display LH menu
function putupmenuL(){
document.getElementById("menupanel").innerHTML = '<p><strong>Please select..</strong></p>\
  <ul>\
  <li><a href="index.html">Sunday<br />Services</a></li>\
  <li><a href="BCCMeetings.html">Meetings<br />& Diary</a></li>\
  <li><a href="BCCLocation.html">How to<br />Find us</a></li>\
  <li><a href="BCCcontact.html">How to<br />Contact us</a></li>\
  <li><a href="BCCBeliefs.html">What we<br />believe</a></li>\
  <li><a href="BCCSermons.html">Access<br />Sermons</a></li>\
  <li><a href="BCCLinks.html">Links<br />Elsewhere</a></li>\
  <li><a href="BCCPhotos.html">Photo<br />Gallery</a></li>\
  <li><a href="BCCQns.html">QTAs<br />not FAQs</a></li>\
  </ul>';

}

// Display bottom menu
function putupmenuB(){

document.getElementById("bottomenu").innerHTML =  '<a href="index.html">Home</a> | '+
 '<a href="BCCMeetings.html">Meetings</a> | '+
 '<a href="BCCLocation.html">Location</a> | '+
 '<a href="BCCcontact.html">Contact</a> | '+
 '<a href="BCCBeliefs.html">Beliefs</a> | '+
 '<a href="BCCSermons.html">Sermons</a> | '+
 '<a href="BCCLinks.html">Links</a> | '+
 '<a href="BCCPhotos.html">Photos</a> | '+
 '<a href="BCCQns.html">QTAs</a><p id="smallitalic">Copyright Bulkington Congregational Church         '+
 'last modified '+dlmodd()+'</p>';
 
}

// Set picture displayed top left
function showpicture(){
    var Pictures = new Array() 

    wwidth = giveWinwidth();

    if (wwidth >= 1600)
	{   
	    Pictures[0] = 'images/BCC_Chapel5lge.gif'
	    Pictures[1] = 'images/ChapelwithManselge.gif'
	    Pictures[2] = 'images/ChapelfromRdlge.gif'
	}
    else
	{
	    if (wwidth >= 850)
		{
	 	   Pictures[0] = 'images/BCC_Chapel5.gif'
		   Pictures[1] = 'images/ChapelwithManse.gif'
		   Pictures[2] = 'images/ChapelfromRd.gif'
		}
	    else
		{
	 	   Pictures[0] = 'images/BCC_Chapel5sm.gif'
		   Pictures[1] = 'images/ChapelwithMansesm.gif'
		   Pictures[2] = 'images/ChapelfromRdsm.gif'
		}
	}

    var p = Pictures.length;
    var picArray = new Array()
    for (i = 0; i < p; i++){
    picArray[i] = new Image()
    picArray[i].src = Pictures[i]
    }
    var SelectPic = Math.round(Math.random()*(p-1));
    document.write('<img src="'+Pictures[SelectPic]+'">');
}

// Set Scripture Text displayed centrally 
// options are 0 - first display, 1 - random, 2 - reset, 3-pause, 8 - fwd, 9-back
function showtext(Quoteopt) {


 if (Quoteopt == 0 ) 
    {
    SelectQuote = 0;
    }
 else 
    {
    if (Quoteopt == 1 )
     {
     SelectQuote = Math.round(Math.random()*(numBibleQ-1));
     }
    else
     {
     if (Quoteopt == 8)
       {
         SelectQuote += 1;
         if (SelectQuote == numBibleQ) {
          SelectQuote = 0; 
          }        
       }
     else
       {
         if (Quoteopt == 9)
          {
            SelectQuote -= 1;
            if (SelectQuote < 0) {
              SelectQuote = numBibleQ - 1;
             }        
          }
       }
     }
    }

    nextbible = '<div id="bqscroll" style="visibility:hidden;"><img src="images/scrollbk.png" alt="scroll back" align="left" onclick="showtext(9)"/><img src="images/scrollfwd.png" alt="scroll forward" align="right" onclick="showtext(8)"/></div><span style="font-size:1.15em; font-weight:bold;">'+BibleQuote[SelectQuote]+'  <i>'+BibleRef[SelectQuote]+'</i></span>';
    if (Quoteopt == 0)
      {
        document.write(nextbible);
        t=setTimeout("showtext(1)",14000);
      }
    if (Quoteopt == 1)
      {
        document.getElementById("renewquote").innerHTML = nextbible;
        t=setTimeout("showtext(1)",14000);
      }
    if (Quoteopt == 2)
      {
        document.getElementById('bqscroll').style.visibility="hidden";
        t=setTimeout("showtext(1)",14000);
      }
     if (Quoteopt == 3)
      {
        clearTimeout(t);
      }
     if (Quoteopt > 3)
      {
    clearTimeout(t);
    nextbible = '<div id="bqscroll" style="visibility:visible;"><img src="images/scrollbk.png" alt="scroll back" align="left" onclick="showtext(9)"/><img src="images/scrollfwd.png" alt="scroll forward" align="right" onclick="showtext(8)"/></div><span style="font-size:1.15em; font-weight:bold;">'+BibleQuote[SelectQuote]+'  <i>'+BibleRef[SelectQuote]+'</i></span>';
        document.getElementById("renewquote").innerHTML = nextbible;
        t=setTimeout("showtext(2)",8000);
      }
}

// Set wise quote displayed top right
    function show_wisdom(Quoteopt) {

    if (Quoteopt == 0 )
     {
     SelWQuote = Math.round(Math.random()*(numWiseQ-1));
     }

    if (Quoteopt == 1 )
     {
     SelWQuote = Math.round(Math.random()*(numWiseQ-1));
     }
    else
     {
     if (Quoteopt == 8)
       {
         SelWQuote += 1;
         if (SelWQuote == numWiseQ) {
          SelWQuote = 0; 
          }        
       }
     else
       {
         if (Quoteopt == 9)
          {
            SelWQuote -= 1;
            if (SelWQuote < 0) {
              SelWQuote = numWiseQ - 1;
             }        
          }
       }
     }

    nextbible = '<div id="wqscroll" style="visibility:hidden;"><img src="images/scrollbk.png" alt="scroll back" align="left" onclick="show_wisdom(9)"/><img src="images/scrollfwd.png" alt="scroll forward" align="right" onclick="show_wisdom(8)"/></div><i><br/>'+WiseQuote[SelWQuote]+'</i><br/>'+WiseAuth[SelWQuote];
    if (Quoteopt == 0)
      {
        document.write(nextbible);
        tw=setTimeout("show_wisdom(1)",14000);
      }
    if (Quoteopt == 1)
      {
        document.getElementById("renewisdom").innerHTML = nextbible;
        tw=setTimeout("show_wisdom(1)",14000);
      }
    if (Quoteopt == 2)
      {
        document.getElementById('wqscroll').style.visibility="hidden";
        tw=setTimeout("show_wisdom(1)",14000);
      }
     if (Quoteopt == 3)
      {
        clearTimeout(tw);
      }
     if (Quoteopt > 3)
      {
    clearTimeout(tw);
    nextbible = '<div id="wqscroll" style="visibility:visible;"><img src="images/scrollbk.png" alt="scroll back" align="left" onclick="show_wisdom(9)"/><img src="images/scrollfwd.png" alt="scroll forward" align="right" onclick="show_wisdom(8)"/></div><i><br/>'+WiseQuote[SelWQuote]+'</i><br/>'+WiseAuth[SelWQuote];
        document.getElementById("renewisdom").innerHTML = nextbible;
        tw=setTimeout("show_wisdom(2)",8000);
      }
}

// Set email address from components

function mailit(mailname)
{
var maildom = "bulkingtoncongregational.org";
document.write('<a href=\"mailto:' + mailname + '@' + maildom + '\" style=\"color:blue; text-decoration:underline;\">');
document.write(mailname + '@' + maildom + '</a><br />(Click to mail)');
}

/* Set Calendar values to be displayed
	5 rows (0-4) of 7 days (0-6)
	index is 0-6 row 1, 7-13 row 2, 14-20 row 3, 21-27 row 4, 28-34 row 5  */

    var CalWkDayNo = new Array()
    var CalEntry = new Array()
    var CalWk = 0;
    var CalDay = 0;

/* do not change the next line containing Diary Start - it marks the start of a section recreated
   each month by a KIX script  */

//  Diary Start - Monthly updates from here
    var CalMonth = "March 2010";
// Week 1
// Sunday 1
  CalWkDayNo[0] = "";
  CalEntry[0] = "";
// Monday 1
  CalWkDayNo[1] = "1st";
  CalEntry[1] = "";
// Tuesday 1
  CalWkDayNo[2] = "2nd";
  CalEntry[2] = "<br />";
// Wednesday 1
  CalWkDayNo[3] = "3rd";
  CalEntry[3] = "7:30pm Midweek Prayer \& Bible Study including The Lord\'s Supper.";
// Thursday 1
  CalWkDayNo[4] = "4";
  CalEntry[4] = "1:45pm Young at Heart. Speaker: Gerald Sayers.<br /><br />6:00pm Good News Club.";
// Friday 1
  CalWkDayNo[5] = "5";
  CalEntry[5] = "7:30pm to 9:00pm Fun and Bible (FAB) 11-14 yr olds.";
// Saturday 1
  CalWkDayNo[6] = "6";
  CalEntry[6] = "";
// Week 2
// Sunday 2
  CalWkDayNo[7] = "7";
  CalEntry[7] = "Sunday Services<br />10:30am \& 6:00pm<br />Preacher: Pastor<br />pm service to include The Lord\'s Supper.<br />";
// Monday 2
  CalWkDayNo[8] = "8";
  CalEntry[8] = "EFCC Committee Meeting at Bulkington.<br /><br />7:30pm SGA at Mount Rd Hinckley.<br />";
// Tuesday 2
  CalWkDayNo[9] = "9";
  CalEntry[9] = "EFCC Committee Meeting at Bulkington.<br /><br />7:30pm SGA at Holbrooks Coventry.";
// Wednesday 2
  CalWkDayNo[10] = "10";
  CalEntry[10] = "7:30pm Midweek Prayer \& Bible Study.<br />";
// Thursday 2
  CalWkDayNo[11] = "11";
  CalEntry[11] = "10:00am Meeting Point At Mount Rd Hinckley. Speaker:Mandy Johnson (AWM) on \"The life of Lilias Trotter\"<br />6:00pm Good News Club";
// Friday 2
  CalWkDayNo[12] = "12";
  CalEntry[12] = "9:30am Manse Working Party.<br />7:30pm to 9:00pm Fun and Bible.(FAB) 11-14 yr olds.";
// Saturday 2
  CalWkDayNo[13] = "13";
  CalEntry[13] = "EFCC Studies Conf: Speakers Rev. Dr George Speers \& Rev. Dr Robert Oliver.<br />";
// Week 3
// Sunday 3
  CalWkDayNo[14] = "14 Sunday Services";
  CalEntry[14] = "10:30am \& 6:00pm<br />Preacher: Pastor";
// Monday 3
  CalWkDayNo[15] = "15";
  CalEntry[15] = "<strong>7:30pm Church History Lecture:</strong><br />Speaker: Phil Arthur on \"Adoniram Judson- Pioneer Missionary to Myanmar\".<br />";
// Tuesday 3
  CalWkDayNo[16] = "16";
  CalEntry[16] = "<br />";
// Wednesday 3
  CalWkDayNo[17] = "17";
  CalEntry[17] = "7:30pm Midweek meeting at Thurlaston.<br />Film:\"God\'s Outlaw\" The story of William Tyndale.";
// Thursday 3
  CalWkDayNo[18] = "18";
  CalEntry[18] = "1:45pm Young at Heart,speaker: Peter Beale.<br /><br />6:00pm Good News Club";
// Friday 3
  CalWkDayNo[19] = "19";
  CalEntry[19] = "7:30pm to 9:00pm Fun and Bible (FAB) 11 -14yr olds.";
// Saturday 3
  CalWkDayNo[20] = "20";
  CalEntry[20] = "9-30am to noon, Leicester Ladies Conf: at Bethel Wigston.<br />Speaker:Barbara Sherwood.(London)";
// Week 4
// Sunday 4
  CalWkDayNo[21] = "21 Sunday Services";
  CalEntry[21] = "10:30am \& 6:00pm<br />Preacher : Pastor<br />pm service to include The Lord\'s Supper.";
// Monday 4
  CalWkDayNo[22] = "22";
  CalEntry[22] = "<br />";
// Tuesday 4
  CalWkDayNo[23] = "23";
  CalEntry[23] = "10-30am Ladies Bible Study \& Fellowship.<br />1 Timothy At Dorothy\'s 35, Warwick Green";
// Wednesday 4
  CalWkDayNo[24] = "24";
  CalEntry[24] = "7:30pm Midweek Prayer \& Bible Study.";
// Thursday 4
  CalWkDayNo[25] = "25";
  CalEntry[25] = "6:00pm Good News Club<br /><br />8:00pm Men\'s Meeting.";
// Friday 4
  CalWkDayNo[26] = "26";
  CalEntry[26] = "9:30am Manse Working Party.<br />7:30pm to 9:00pm Fun and Bible (FAB) 11-14yr olds.";
// Saturday 4
  CalWkDayNo[27] = "27";
  CalEntry[27] = "";
// Week 5
// Sunday 5
  CalWkDayNo[28] = "28 Sunday Services";
  CalEntry[28] = "10:30am \& 6:00pm<br />Preacher: Pastor.<br />pm service followed with an After Church Fellowship.";
// Monday 5
  CalWkDayNo[29] = "29";
  CalEntry[29] = "<strong>Day Of Prayer</strong><br />Sessions at:<br /> 9:00am, 12noon, 4:00pm, 8:00pm.";
// Tuesday 5
  CalWkDayNo[30] = "30";
  CalEntry[30] = "";
// Wednesday 5
  CalWkDayNo[31] = "31";
  CalEntry[31] = "2:00pm Easter Service at Leonard Perkins.<br />7:30pm Midweek Meeting. Speaker: Phil Roberts.<br />";
// Thursday 5
  CalWkDayNo[32] = "1st April";
  CalEntry[32] = "9:00am Deacons\' Meeting.<br />No Good News Club.<br />";
// Friday 5
  CalWkDayNo[33] = "2nd";
  CalEntry[33] = "7:30pm Good Friday Service<br />";
// Saturday 5
  CalWkDayNo[34] = "3rd";
  CalEntry[34] = "";
// Diary End 
/* do not change the line above containing Diary End - it marks the end of
   a section which is recreated by a KIX script  */

function c_entry(cellno){
	x = "<b>"+CalWkDayNo[cellno]+"</b><br />"+CalEntry[cellno];
	document.write(x);

}
// Set last modified date as Month(text) day year hour min

var docdate = new Date(document.lastModified);
var modded = new String();
modded ="Not Set";

function dlmodd(){
var dmday = docdate.getDate();
var dmmon = docdate.getMonth();
var dmyr = docdate.getFullYear();
var dmhr = docdate.getHours();
var dmmin = docdate.getMinutes();
dmmon = ++dmmon;
modded =dmday+"/"+dmmon+"/"+dmyr+" at "+dmhr+":"+dmmin;
return (modded);
}

//-->
