var SelectQuote = 17;
var BibleID = new Array();
var BibleQuote = new Array();
var BibleRef = new Array();
var WiseID = 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++)
	 { 
	  BibleID[i]=Bible_texts[i].getElementsByTagName("BIBID")[0].childNodes[0].nodeValue;
	  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++)
	 { 
	  WiseID[i]=Wise_texts[i].getElementsByTagName("WTXID")[0].childNodes[0].nodeValue;
	  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 findBible(bibref)
{
  j=-1;
  for (i=0;i<numBibleQ;i++)
  {
	x = BibleID[i];
	if (x == bibref)
	{
	  j = i;
	  i = numBibleQ + 1;
	}
  } 
 return j;
}

function findWise(wisref)
{
  j=-1;
  for (i=0;i<numWiseQ;i++)
  {
	x = WiseID[i];
	if (x == wisref)
	{
	  j = i;
	  i = numWiseQ + 1;
	}
  } 
 return j;
}

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.write('<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.write('<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="Go back" align="left" onclick="showtext(9)"/><img src="images/scrollfwd.png" alt="Go fwd" align="right" onclick="showtext(8)"/></div><span style="font-size:1.15em; font-weight:bold;">'+BibleQuote[SelectQuote]+'<i><br />'+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="Go back" align="left" onclick="showtext(9)"/><img src="images/scrollfwd.png" alt="Go fwd" align="right" onclick="showtext(8)"/></div><span style="font-size:1.15em; font-weight:bold;">'+BibleQuote[SelectQuote]+'<i><br />'+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="Go back" align="left" onclick="show_wisdom(9)"/><img src="images/scrollfwd.png" alt="Go fwd" 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="Go back" align="left" onclick="show_wisdom(9)"/><img src="images/scrollfwd.png" alt="Go fwd" 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 = "July 2010";
// Week 1
// Sunday 1
  CalWkDayNo[0] = "27th June Sunday Services";
  CalEntry[0] = "10-30am \& 6-00pm<br />Preacher: Pastor.<br />pm service followed by after church fellowship";
// Monday 1
  CalWkDayNo[1] = "28";
  CalEntry[1] = "";
// Tuesday 1
  CalWkDayNo[2] = "29";
  CalEntry[2] = "";
// Wednesday 1
  CalWkDayNo[3] = "30";
  CalEntry[3] = "7-30pm Church Members Meeting";
// Thursday 1
  CalWkDayNo[4] = "1st July";
  CalEntry[4] = "1-45pm Young at Heart. Strawberry Tea. Speaker: Peter Mackenzie.<br /><br />6-00pm Good News Club.";
// Friday 1
  CalWkDayNo[5] = "2";
  CalEntry[5] = "7-30 - 9-00pm Fun and Bible.(FAB) 11-14 yr olds.";
// Saturday 1
  CalWkDayNo[6] = "3";
  CalEntry[6] = "12-00 noon<br />Induction of Ben Holmes at Holbrooks.";
// Week 2
// Sunday 2
  CalWkDayNo[7] = "4 Sunday Services";
  CalEntry[7] = "10-30am \& 6-00pm<br />Preacher: Pastor<br />pm service to include The Lord\'s Supper.";
// Monday 2
  CalWkDayNo[8] = "5";
  CalEntry[8] = "";
// Tuesday 2
  CalWkDayNo[9] = "6";
  CalEntry[9] = "";
// Wednesday 2
  CalWkDayNo[10] = "7";
  CalEntry[10] = "7-30pm Midweek Prayer \& Bible Study.";
// Thursday 2
  CalWkDayNo[11] = "8";
  CalEntry[11] = "10-00am Ladies Meeting Point at Hinckley<br />Books worth reading - group members.<br /><br />6-00pm Good News Club.";
// Friday 2
  CalWkDayNo[12] = "9";
  CalEntry[12] = "7-30 -9-00pm Fun and Bible (FAB) 11 -14 yr olds.";
// Saturday 2
  CalWkDayNo[13] = "10";
  CalEntry[13] = "";
// Week 3
// Sunday 3
  CalWkDayNo[14] = "11 Sunday Services";
  CalEntry[14] = "10-30am \& 6-00pm<br />Preacher: Neville Swain.";
// Monday 3
  CalWkDayNo[15] = "12";
  CalEntry[15] = "";
// Tuesday 3
  CalWkDayNo[16] = "13";
  CalEntry[16] = "";
// Wednesday 3
  CalWkDayNo[17] = "14";
  CalEntry[17] = "7-30pm Midweek Prayer \& Bible Study.";
// Thursday 3
  CalWkDayNo[18] = "15";
  CalEntry[18] = "1-45pm Young at Heart, speaker: Lucy Beale on \'The life of John Dagley\' a local Congregational Minister.<br /><br />6-00pm Good News Club";
// Friday 3
  CalWkDayNo[19] = "16";
  CalEntry[19] = "7-30-9-00pm Fun and Bible (FAB) 11 -14yr olds.";
// Saturday 3
  CalWkDayNo[20] = "17";
  CalEntry[20] = "";
// Week 4
// Sunday 4
  CalWkDayNo[21] = "18 Sunday Services";
  CalEntry[21] = "10-30am \& 6-00pm<br />Preacher: Peter Beale<br />pm service to include The Lord\'s Supper.";
// Monday 4
  CalWkDayNo[22] = "19";
  CalEntry[22] = "";
// Tuesday 4
  CalWkDayNo[23] = "20";
  CalEntry[23] = "";
// Wednesday 4
  CalWkDayNo[24] = "21";
  CalEntry[24] = "7-30pm Midweek Prayer \& Bible Study.";
// Thursday 4
  CalWkDayNo[25] = "22";
  CalEntry[25] = "6-00pm Good News Club BBQ with FAB<br /><br />No Men\'s Meeting in July or August..";
// Friday 4
  CalWkDayNo[26] = "23";
  CalEntry[26] = "No Fun and Bible";
// Saturday 4
  CalWkDayNo[27] = "24";
  CalEntry[27] = "";
// Week 5
// Sunday 5
  CalWkDayNo[28] = "25 Sunday Services";
  CalEntry[28] = "10-30am \& 6-00pm<br />Preacher: Paul Taylor.";
// Monday 5
  CalWkDayNo[29] = "26";
  CalEntry[29] = "";
// Tuesday 5
  CalWkDayNo[30] = "27";
  CalEntry[30] = "10-30am Ladies Bible study \& Fellowship at Jean Harrold\'s<br />1 Timothy 5";
// Wednesday 5
  CalWkDayNo[31] = "28";
  CalEntry[31] = "7-30pm Midweek Prayer \& Bible Study, including The Lord\'s Supper.";
// Thursday 5
  CalWkDayNo[32] = "29";
  CalEntry[32] = "No Good News Club";
// Friday 5
  CalWkDayNo[33] = "30";
  CalEntry[33] = "No Fun and Bible.";
// Saturday 5
  CalWkDayNo[34] = "31";
  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);
}

function ScrollToElement(theElement){

  var selectedPosX = 0;
  var selectedPosY = 0;
              
  while(theElement != null){
    selectedPosX += theElement.offsetLeft;
    selectedPosY += theElement.offsetTop;
    theElement = theElement.offsetParent;
  }
                        		      
 window.scrollTo(selectedPosX,selectedPosY);

}

//-->
