/*
* Data structure for Supply Preacher records. Currently three fields are kept:
*  - name
*  - photo (null if not available)
*  - description. The constructor allows this to be specified as a
*    sequence of strings, that are concatentated with separating spaces.
*/
function Preacher (name, photo, desc)
{
this.name =  name
this.photo = photo
var d = desc

for (i = 3; i < arguments.length; ++i) {
d += " " + arguments[i]
}
this.desc = d
}

/*
* Array of supply preacher records. This is initialized on the first
* call to the showPreachers function.
*/
var preachers = new Array(0)

/*
* Display the list of available preachers, as a table. Column 1 contains the
* photo, or name if not available. olumn 2 contains the name and biography.
*/
function showPreachers()
{
if (preachers.length == 0)
initPreachers()
p = randomize(preachers)

document.write("<table>")
for (i = 0; i < p.length; ++i) {
document.write("<tr><td colspan='2'><hr></td></tr>")

document.write("<tr>")

document.write("<td align='middle'>")
if ((p[i].photo != null) && (p[i].photo.length > 0)) {
document.write("<img src='" + p[i].photo + "'"
+ " alt='" + p[i].name + "'"
+ " align='center' hspace='15'>")
}
else {
document.write("<em class='pspic'>"
+ p[i].name + "</em>")
}
document.write("</td>")

document.write("<td>")
document.write("<em class='psname'>" + p[i].name + ":</em> ")
document.write(p[i].desc)
document.write("</td>")

document.write("</tr>")
}
document.write("</table>")
}

/*
* Create an array with the same values the parameter array, but
* in a "random" permutation.
*
* The implementation makes a copy, and then swaps randomly-selected
* pairs of entries. As many swaps are done as there are elemented in the
* list. It can be proved that this produces a random permutation (assuming
* a perfect RNG). It has the advantage over some methods (e.g. selection)
* that it runs on O(N) time, worst case.
*/
function randomize (list)
{
var p = new Array(list.length)
for (i = 0; i < list.length; ++i)
p[i] = list[i]
for (i = 0; i < list.length; ++i) {
var n1 = Math.floor(Math.random() * list.length)
var n2 = Math.floor(Math.random() * list.length)

/* The checks on the list length are needed because the */
/* for Math.random() does not guarantee that the result */
/* is strictly less than 1.0 */
if ((n1 != n2) && (n1 < list.length) && (n2 < list.length)) {
var r = p[n1]
p[n1] = p[n2]
p[n2] = r
}
}

return p
}

/*
* Entries of Pulpit Supply Preachers
*/
function initPreachers()
{
preachers = new Array(
new Preacher("Russell Martin", "Images/RMartin.jpg",
"A Licensed Lay Preacher, Russell is a member of",
"Maple Grove United Church in Oakville.",
"Russell completed his Ph.D. in Religion,",
"University of Toronto in 2003.",
"He is a biblical scholar, with emphasis on",
"the early history of Christianity.",
"<p>Before taking up his religion studies,",
"Russell studied mathematics, and worked as a",
"computer software developer.",
"<p>To contact Russell, please phone",
makePhoneNo(469, 3103) + " or",
makeMailLink("rmartin377", "cogeco.ca", "e-mail here") + "."),

new Preacher("Dianne Allum", null,
"A Licensed Lay Preacher since 1991.",
"Dianne served as Lay Assistant at",
"Lowville United Church from 1990 to 200l,",
"responsible for pastoral care to the sick and",
"elderly as well as Mt. Nemo Nursing Home,",
"and officiated at several funerals.",
"<p>Dianne graduated from the Ontario Bible College,",
"(now Tyndale University and Seminary), in 1986,",
"and has taken courses at McMaster University.",
"She has preached at many of the churches",
"in the Presbytery.",
"<p>To contact Dianne, please phone",
makePhoneNo(878, 7180) + " or",
makeMailLink("dianneallum", "yahoo.ca", "e-mail here") + "."),

new Preacher("Rev. David Walker", "Images/DavidWalker.jpg",
"David retired from St. John's United Church,",
"Oakville in 2005.",
"David's experience includes 30 years in",
"United Church congregations in city, suburban",
"and rural locations.",
"He has done supply work in several congregations",
"within Halton Presbytery and recently completed",
"a short-term supply ministry at Trinity United",
"Church in Oakville.",
"<p>David has facilitated grief groups,",
"various world religion discussion groups",
"and information sessions on senior life concerns",
"as a function of pastoral care and adult education.",
"<p>To contact David, please phone",
makePhoneNo(905, 637, 8527) + " or ",
makeMailLink("dwalker29", "cogeco.ca", "e-mail here") + "."),

/***** Apparently has a new job
new Preacher("Edward Bellsmith", null,
"Edward has had five years experience preaching",
"in the United Church of Canada, and several years",
"preaching experience prior to that.",
"He is a student minister completing his M. Div. at",
"Emmanuel, and is scheduled to become ordained in",
"April 2007.",
"He is currently serving at the Community Outreach",
"Coordinator for the United Churches in Milton.",
"<p>To contact Edward, please",
makeMailLink("edwardbellsmith", "stpaulsmilton.org",
"e-mail here") + "."),
****/

new Preacher("Judith Robinson", "Images/JRobinson.jpg",
"Judith Robinson takes a creative approach to",
"preaching.",
"Her Divinity studies at Emmanuel College,",
"in the 1970’s, gave her a passion for social justice.",
"Her plays, books, journalistic articles, sermons",
"and lesson plans embody a spirit of empowerment for",
"those whose voices have not been effectively heard.",
"<p>She has been a freelance writer for",
"The Globe &amp; Mail, CBC Radio, Education Forum,",
"The United Church Observer and Mandate Magazine.",
"Samples of her written work appear on her web site at",
"<a href='http://www.judithirobinson.com' target='_blank'>www.judithirobinson.com</a>.",

"<p>To contact Judith, please phone",
makePhoneNo(905, 336, 1844) + " or",
makeMailLink("jrobinson32", "cogeco.ca", "e-mail here") + "."),

/***** Does not respond to e-mails
new Preacher("Sue Cowan", null,
"Sue has provided pulpit supply in churches",
"throughout Dufferin-Peel Presbytery for the past",
"decade in a lay capacity.",
"She recently completed her Lay Certificate in",
"Theology from Emmanuel College (May 2006) and has",
"also been approved by Toronto Conference as a",
"Lay Pastoral Minister in Training (LPMiT).",
"<p>Sue has a background that includes 25 years in",
"the business world, and a lifetime in the",
"United Church ~~~ with experience as a member of a",
"praise band, C.G.I.T. leader, choir member,",
"Sunday School Superintendent/teacher, Trustee,",
"Worship Ministry, etc.  Her gifts of preaching and",
"music help her to shape the weekly worship",
"experience into an uplifting time for all who attend.",
"<p>Sue recently covered a 2 month sabbatical for",
"St. John's UC in Georgetown. providing Sunday",
"leadership, pastoral care and sitting on various",
"committees/boards as the congregation's minister.",
"Sue looks forward to the opportunity for",
"learning/growth that she experiences every time she",
"shares in the worship life of a congregation.",
"<p>To contact Sue, please phone",
makePhoneNo(905, 873, 3171) + " or",
makeMailLink("cowanpsem", "aol.com",
"e-mail here") + "."),
*****/

new Preacher("Rev. Robert W. Johnson", null,
"Robert has served as an Intentional",
"Interim Minister in 13 interim pastorates",
"in both the Presbyterian Church and",
"the United Church of Canada.",
"He is a contributor in the congregational handbook",
"for Interim Ministry: <i>Temporary Shepherds<\/i>,",
"and in the handbook <i>Tools for Clergy<\/i>.",
"He has been active member of the Interim Ministry",
"Network, and has seved as a faculty member",
"for training interim ministers.",
"He did graduate studies with <i>LIOS<\/i>",
"(Leadership Institute of Seattle), in leading",
"and consulting.",
"He has supplied churches in the Hamilton Presbytery",
"with both the Presbyterian Church",
"and the United Church.",
"<p>To contact Robert, please phone",
makePhoneNo(905, 575, 9301) + " or",
makeMailLink("robert.johnson", "sympatico.ca", "e-mail here") + "."),

new Preacher("Rev. George Addison", "Images/GeorgeAddison.jpg",
"George is now retired, after serving as",
"Senior Chaplain in the department of Campus Ministries",
"at Brock University.",
"He has also served a number of pastoral charges,",
"and served for 16 years as a correctional chaplain,",
"including five years at Toronto's Don Jail.",
"<p>George is particularly interested in justice",
"and peace issues, especially in relation to",
"religious faith.",
"He is involved in teaching and promoting",
"restorative justice, and is active in the",
"Niagara Coalition for Peace.",
"He has taught a number of courses at Brock,",
"both in Continuing Education and as a part-time",
"faculty member of Brock's Faculty of Education.",
"<p>To contact George, please phone",
makePhoneNo(905, 934, 7293) + " or",
makeMailLink("gaddison", "brocku", "e-mail here") + ".")
)
}

