// JavaScript Document
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeimg(imgnum) {
//create an array containing the urls to the image files
resource = "images/gallery/"
urlid = new Array(9);
urlid[0] = resource + "johnguitar.jpg";
urlid[1] = resource + "christmasday.jpg";
urlid[2] = resource + "congregation.jpg";
urlid[3] = resource + "harvestflowers.jpg";
urlid[4] = resource + "ruth.jpg";
urlid[5] = resource + "shumensong.jpg";
urlid[6] = resource + "shumencong.jpg";
urlid[7] = resource + "shumenread.jpg";
urlid[8] = resource + "churchfront.jpg";
urlid[9] = resource + "marriage.jpg";

//create an array containing the captions and alt tags for the above image files
captionTxT = new Array(9);
captionTxT[0] = "Our Minister John Bown playing the guitar";
captionTxT[1] = "Christmas Day Advent Candle lighting";
captionTxT[2] = "The Congregation at a Parade Service";
captionTxT[3] = "Harvest Festival flower arrangement";
captionTxT[4] = "Ruth Bravo talking about the Mission to Seamen";
captionTxT[5] = "The congregation at the Shumen Methodist Church singing together";
captionTxT[6] = "The congregation at the Shumen Methodist Church";
captionTxT[7] = "A reading at the Shuman service";
captionTxT[8] = "Bromley Methodist Church building";
captionTxT[9] = "The Marriage of Jane Carter and Matthew Willock";

//assign the selected image to picture viewer with alt tag
getPicView = document.getElementById("picview");
getPicView.setAttribute("src",urlid[imgnum]);
getPicView.setAttribute("alt",captionTxT[imgnum]);

//replace caption on picture
getCaption = document.getElementById("caption");
oldTag = getCaption.getElementsByTagName("b").item(0);
txtCaption = document.createTextNode(captionTxT[imgnum]);
txtHolder = document.createElement("b");
txtHolder.appendChild(txtCaption);
getCaption.replaceChild(txtHolder,oldTag);

}//eofn



function moreChurches() {
	listofChurches = document.getElementById("bromleychurches");

	churches = new Array(6);
	churches[0] = "St John's";
	churches[1] = "St Joseph's";
	churches[2] = "St Mary's";
	churches[3] = "Bromley Religious Society of Friends";
	churches[4] = "Bromley Town Church";
	churches[5] = "Bromley Christian Centre";
	churches[6] = "Cornerstone Christian Centre";
	
	url = new Array(6);
	url[0] = "http://www.sjep.org/";
	url[1] = "http://stjosephsbromley.org.uk/";
	url[2] = "http://www.stmarys-bromley.org.uk/";
	url[3] = "";
	url[4] = "http://www.bromleytownchurch.com/";
	url[5] = "http://www.bcc-bromley.org.uk/";
	url[6] = "http://www.cornerstonecc.org.uk/";
	
	//Loop to add all churches
	lp = 0;
	for (lp=0;lp<=6;lp++) 
	{	
	newList = document.createElement("li");
	if (url[lp] != "") {
		newAtag = document.createElement("a");
		newAtag.setAttribute("href",url[lp]);
	}
	church = churches[lp];
	TextNode = document.createTextNode(church);
	if (url[lp] != "") {
		newAtag.appendChild(TextNode);
		newList.appendChild(newAtag);
	}
	else {
		newList.appendChild(TextNode);
	}
	listofChurches.appendChild(newList);
	}
	
	//Converts More Churches to Less Churches
	oldButton = document.getElementById("expand");
	newButtonContent =  document.createElement("a");
	newButtonContent.setAttribute("href","javascript:lessChurches();");
	collapseTxt = "Less Churches...";
	newButtonValue = document.createTextNode(collapseTxt);
	newButtonContent.appendChild(newButtonValue);
	newButton = document.createElement("li");
	newButton.setAttribute("id","expanded");
	newButton.appendChild(newButtonContent);
	listofChurches.removeChild(oldButton);
	listofChurches.appendChild(newButton);
}//eofn

function lessChurches() {
	
	//Converts Less Churches to More Churches
	listofChurches = document.getElementById("bromleychurches");
	oldButton = document.getElementById("expanded");
	newButtonContent =  document.createElement("a");
	newButtonContent.setAttribute("href","javascript:moreChurches();");
	collapseTxt = "More Churches...";
	newButtonValue = document.createTextNode(collapseTxt);
	newButtonContent.appendChild(newButtonValue);
	newButton = document.createElement("li");
	newButton.setAttribute("id","expand");
	newButton.appendChild(newButtonContent);
	
	listofChurches.removeChild(oldButton);
	
	//Loop to remove all the added churches
	lp = 0;
	for (lp=0;lp<=6;lp++)
	{
	lastNode = listofChurches.lastChild;
	listofChurches.removeChild(lastNode);
	}
	
	//Appends the More Churches button when all finished
	listofChurches.appendChild(newButton);
}//eofn

function johnimg(boolean) {
	if (boolean == 1) {
		getAlink = document.getElementById("johnpicparent");
		oldImg	= getAlink.getElementsByTagName("img").item(0);
		changePic = document.createElement("img");
		changePic.setAttribute("width","96");
		changePic.setAttribute("height","120");
		changePic.setAttribute("hspace","5");
		changePic.setAttribute("alt","Rev John Bown");
		changePic.setAttribute("align","left");
		changePic.setAttribute("src","images/johnpanto05.jpg");
		getAlink.replaceChild(changePic,oldImg);
	}
	else if (boolean == 0) {
		getAlink = document.getElementById("johnpicparent");
		oldImg	= getAlink.getElementsByTagName("img").item(0);
		changePic = document.createElement("img");
		changePic.setAttribute("width","96");
		changePic.setAttribute("height","120");
		changePic.setAttribute("hspace","5");
		changePic.setAttribute("alt","Rev John Bown");
		changePic.setAttribute("align","left");
		changePic.setAttribute("src","images/revjohnbown.jpg");
		getAlink.replaceChild(changePic,oldImg);	
	}
}//eofn

//-->
