//= Copyright 2002, Peter A. Curran. All rights reserved.







var names =     ["office",          "secretary",      "website"]
var mailnames = ["office",          "office",	  "web"]
var maildmns  = ["haltonpres.org",  "haltonpres.org", "haltonpres.org"]


var churches = new Array(0)
var committees = new Array(0)
var curChurch = "appleby"
var execlist = ""






function Church (name, phone, fax, mail, domain, web, map, region)
{
this.name = name
this.phone = phone
this.fax = fax
this.mail = mail
this.domain = domain
this.web = web
this.map = map + "map.htm"
this.region = region
}


function Committee (key, name, chair, mail)
{
this.key = key
this.name = name
this.chair = chair
this.mail = mail
}





function joinargs (args, strt, sep)
{
if ((arguments.length < 1) || (strt == undefined))
strt = 0
if ((arguments.length < 2) || (sep == undefined))
sep = " "
var result = ""
if (args.length > strt)
result = args[strt]
for (k = strt+1; k < args.length; ++k)
result += sep + args[k]
return result
}







function strtail (str, leng)
{
var result = str + ""
while (result.length < leng)
result = "0" + result
if (result.length > leng)
result = result.substr(result.length - leng)
return result
}



function mailaddr (name)
{
var i
for (i = 0; i < names.length; ++i)
if (names[i] == name)
break
if (i >= names.length)
i = 0
return mailnames[i] + "@" + maildmns[i]
}




function mailtext (text)
{

return text
}

function makeSend (name, text)
{
var result = "<a href='mailto:" + mailaddr(name) + "'>"
+ mailtext(text) + "</a>"
return result
}



function Send (name, text)
{
document.write(makeSend(name, text))
}

function makeMailLink (name, domain, text)
{
return "<a href='mailto:" + name
+ '@' + domain + "'>"
+ mailtext(text) + "</a>"
}

function churchMail(church, text)
{
var data = getChurchData(church)
if ((arguments.length < 2) || (text == undefined) || (text.length == 0))
text = data.name
if ((text == "X") && (data.mail.length > 0))
text = data.mail + "@" + data.domain
if (text == "X")
text = ""
var result = makeMailLink(data.mail, data.domain, text)
return result
}

function churchPhone(church)
{
var data = getChurchData(church)
return makePhoneNo("905" + data.phone)
}

function churchWeb(church)
{
var data = getChurchData(church)
var result = data.web
if (result == undefined)
result = ""
return result
}



function maillink (name, domain, text)
{
document.write(makeMailLink(name, domain, text))
}








function makePhoneNo (area, exch, nmbr, ext)
{
if (exch == undefined) {
var str = "" + area
area = "905"
exch = ""
nmbr = ""
var i = str.indexOf("X")
if (i >= 0) {
ext = str.substr(i+1)
str = str.substr(0, i)
}
nmbr = strtail(str, 4)
exch = str.substr(0, str.length - 4)
}
else if (nmbr == undefined) {
nmbr = exch
exch = area
area = "905"
}
ext = ""
if (exch.length > 3) {
area = exch.substr(0, 3)
exch = exch.substr(3)
}


exch = strtail(exch, 3)
area = strtail(area, 3)
nmbr = strtail(nmbr, 4)

var result = "(" + area + ") " + exch + "-" + nmbr
if (ext.length > 0)
result += " Ext. " + ext

return result
}


function phoneNo (area, exch, nmbr, ext)
{
document.write(makePhoneNo(area, exch, nmbr, ext))
}





function econtact(name, mail, domain, web)
{
var result = ""
if (arguments.length == 1) {
var data = getChurchData(name)
mail = data.mail
domain = data.domain
web = data.web
}

if ((name.length > 0) && (mail.length > 0) && (domain.length > 0)) {
result = "E-Mail:&nbsp;" + makeMailLink(mail, domain, mail + "&#64;" + domain)
}
if (web.length > 0) {
if (result.length > 0)
result += "<br>"
result += "Web:&nbsp;" + "<a href='http://" + web + "' target='_blank'>"
+ web + "</a>"

}

if (result.length > 0)
document.write(result)
}




function phones (phone, fax)
{
if (arguments.length == 1) {
fax = ""
var data = getChurchData(phone)
if (data.name.length > 1) {
phone = data.phone
fax = data.fax
}
}
if (phone.length > 0)
phoneNo(phone)
if (fax.length > 0) {
document.write("<br>Fax: ")
phoneNo(fax)
}
}







function makeMapLink (name, title, base)
{
var data = getChurchData(name)
if ((arguments.length < 2) || (title == undefined) || (title.length <= 0))
title = data.name

title = title.replace(/ Milton/, "")
title = title.replace(/ Oakville/, "")
title += " United Church"
if (data.region.length > 0)
title += ", " + data.region
if ((arguments.length < 3) || (base == undefined))
base = ""
else
base += "/"
result = "<a href='" + base + "Maps/" + data.map + "'>" + title + "</a>"
return result
}

function mapLink (name, title, base)
{
document.write(makeMapLink(name, title, base))
}





function getChurchData (church)
{
result = new Church("", 0, 0, "", "", "", "")
if (churches.length == 0)
initChurchData()
name = curChurch
if ((arguments.length > 0) && (church != undefined))
name = church
curChurch = name
for (i = 0; i < churches.length; ++i) {
if (name == churches[i].name) {
result = churches[i]
break
}
}
if (i >= churches.length) {
for (j = 0; j < altNames.length; j += 2) {
if (name == altNames[j]) {
result = getChurchData(altNames[j+1])
break
}
}
if (j >= altNames.length)
document.write("No church data found: " + name)
}
return result
}

/*
* The following list provides alternate names for some churches.
* These are used in getChurchData() to find names that are not
* in the list. The intent is to provide easier-to-type names that
* can be used without looking up the exact name in the database,
* or to cover for common mistakes.
* Names can be added as they seem convenient.
* Each entry is a pair of names, the alternate name and the real name.
*/
altNames = ["St. Stephen's", "St. Stephen's-on-the-Hill",
"Munns", "Munn's",
"Walton", "Walton Memorial"]















function initChurchData ()
{
churches = new Array (

new Church("Appleby", "6372942", "6370799",
"office", "applebychurch.ca", "www.applebychurch.ca",
"appleby", "Burlington"),
new Church("East Plains", "6345562", "6345563",
"office", "eastplainsunitedchurch.com",
"eastplainsunitedchurch.com",
"eastplains", "Burlington"),
new Church("Nelson", "3359394", "",
"lowville-nelsonum", "rogers.com", "www.nelsonunited.ca",
"nelson", "Burlington"),
new Church("Port Nelson", "6375631", "6370471",
"office", "portnelsonunitedchurch.com",
"www.portnelsonunitedchurch.com",
"portnels", "Burlington"),
new Church("St. James", "6896223", "6890650",
"stjames", "stjameswaterdown.ca", "www.stjameswaterdown.ca",
"stjames", "Waterdown"),
new Church("St. Stephen", "3367413", "3367412",
"ststephn", "bserv.com", "www.ststephenunited.ca",
"ststepbutl", "Burlington"),
new Church("Tansley", "3350090", "",
"tansley", "on.aibn.com", "www.tansleychurch.com",
"tansley", "Burlington"),
new Church("Wellington Square", "6341849", "6344237",
"wsquare", "bellnet.ca", "www.wsquare.ca",
"wellington", "Burlington"),
new Church("West Plains", "5294871", "5299707",
"info", "westplains.ca", "www.westplains.ca",
"westplain", "Burlington"),

new Church("Carlisle", "6898630", "",
"minister", "carlisleuc.ca", "www.carlisleuc.ca",
"carlisle", ""),
new Church("Kilbride", "", "", "", "", "", "kilbride", ""),
new Church("Freelton", "6593380", "", "", "", "", "freelton", ""),
new Church("Strabane", "", "", "", "", "", "strabane", ""),

new Church("Hillcrest", "8784872", "8780982",
"office", "hbuc.ca", "www.hbuc.ca",
"hillcrest", "Milton"),
new Church("Bethel", "8784872", "8780982",
"office", "hbuc.ca", "www.hbuc.ca",
"bethel", "Milton"),
new Church("Lowville", "3350911", "3354134",
"lowville-nelsonum", "rogers.com", "www.lowvilleunited.ca",
"lowville", "Burlington"),
new Church("St. Paul's Milton", "8788895", "8786400",
"info", "stpaulsmilton.org", "www.stpaulsmilton.org",
"stpaulmil", "Milton"),

new Church("Applewood", "2774162", "2773041",
"valerie", "applewoodunited.ca", "www.applewoodunited.ca",
"applewood", "Mississauga"),
new Church("Britannia", "", "", "", "", "", ""),
new Church("Cawthra Park", "2787376", "2787376",
"office", "cawthraparkuc.org", "www.cawthraparkuc.org",
"cawthra", "Mississauga"),
new Church("Christ Church", "8229834", "8229871",
"office", "christchurch-ucc.com", "www.christchurch-ucc.com",
"chrchur", "Mississauga"),
new Church("Cooksville", "2772338", "2774471",
"cuc.church", "bellnet.ca", "",
"cooksville", "Mississauga"),
new Church("Eden", "8245578", "8245580",
"office", "edenunitedchurch.com", "www.edenunitedchurch.com",
"eden", "Mississauga"),
new Church("Erindale", "2773656", "2773657",
"churchoffice", "erindaleunited.org", "www.erindaleunited.org",
"erindale", "Mississauga"),
new Church("Erin Mills", "8209466", "8207087",
"office", "emuc.ca", "www.emuc.ca",
"erinmills", "Mississauga"),
new Church("First", "2783714", "2785686",
"info", "firstportcredit.com", "www.firstportcredit.com",
"first", "Mississauga"),
new Church("Mississauga Chinese", "2739336", "2735278",
"chinhungcheung", "yahoo.com", "",
"misschi", "Mississauga"),
new Church("St. Stephen's-on-the-Hill", "2789245", "2789772",
"office", "ststephensuc.ca", "www.ststephensuc.ca",
"ststeponh", "Mississauga"),
new Church("Sheridan", "8229001", "8229001",
"sheridan", "sheridanunited.ca", "www.sheridanunited.ca",
"sheridan", "Mississauga"),
new Church("Streetsville", "8261542", "8261816",
"info", "streetsvilleunited.ca", "www.streetsvilleunited.ca",
"streetsville", "Mississauga"),
new Church("Westminster", "2739505", "2735278",
"westminsteruc", "bellnet.ca",
"www.westminsterunitedchurch.ca",
"westmin", "Mississauga"),

new Church("Glen Abbey", "8255292", "8259526",
"info", "glenabbeyunitedchurch.com",
"www.glenabbeyunitedchurch.com",
"glenabbey", "Oakville"),
new Church("Maple Grove", "8455721", "8424159",
"mguc", "cogeco.net", "www.maplegroveunitedchurch.org",
"maplmap", "Oakville"),
new Church("Munn's", "2578434", "2578434",
"office", "munnsunited.com", "www.munnsunited.com",
"munns", "Oakville"),
new Church("Palermo", "8270530", "",
"welcome", "palermounited.ca", "www.palermounited.ca",
"palermo", "Oakville"),
new Church("St. John's", "8450551", "8450651",
"info", "stjohnsunited.ca", "www.stjohnsunited.ca",
"stjohn", "Oakville"),
new Church("St. Paul's Oakville", "8453427", "8453428",
"spunited", "bellnet.ca", "www.stpaulsoakville.com",
"stpaul", "Oakville"),
new Church("Trinity", "8453152", "",
"info", "trinityunited.com", "www.trinityunited.com",
"trinity", "Oakville"),
new Church("Walton Memorial", "8271643", "8256465",
"waltonmemorial", "cogeco.ca", "www.waltonmemorial.com",
"walton", "Oakville")
)
}




function getComData (key)
{
var result = new Committee("", "", "", "")
if (committees.length == 0)
initCommitteeData()
var i
for (i = 0; i < committees.length; ++i) {
if (key == committees[i].key) {
result = committees[i]
break
}
}
if (i >= committees.length) {
document.write("No committee data found: " + key)
}
return result
}


function makeComName(key)
{
var com = getComData(key)
return com.name
}


function comName (key)
{
document.write(makeComName(key))
}


function makeComChair(key)
{
var com = getComData(key)
return com.chair
}


function comChair (key)
{
var chair = makeComChair(key)
document.write(chair)
}


function comChair (key)
{
document.write(makeComChair(key))
}



function makeComMail(key, text)
{
var com = getComData(key)
if ((arguments.length < 2) || (text.length <= 0))
text = com.chair
var result = makeMailLink(com.mail, "haltonpres.org", text)
return result
}



function comMail(key, text)
{
if (arguments.length < 2)
text = ""
document.write(makeComMail(key, text))
}

function getExecList (text)
{
document.write("<a href='mailto:" + execlist + "'>" + text + "</a>")
}








function initCommitteeData ()
{
committees = new Array (

new Committee("chair", "Chair", "Kathy Toivanen", "hpchair"),
new Committee("chair2", "Chair", "Rev. John Hogman", "hpchair2"),
new Committee("past", "Past Chair", "Peter Curran", "hppastchair"),
new Committee("secretary", "Secretary", "Marian Ferguson", "office"),
new Committee("treasurer", "Treasurer", "John Hurst", "hptreasurer"),
new Committee("nominating", "Nominating", "Peter Curran", "hpnominating"),
new Committee("candidacy", "Candidacy and Vocations", "Rev. Sarah Fanning", "hpcandidacy"),
new Committee("candidacy2", "Candidacy and Vocations", "Harold Devenne", "hpcandidacy2"),
new Committee("education", "Education and Students", "Harold Devenne", "hpeducation"),
new Committee("education2", "Education and Students", "Rev. Dale Skinner", "hpeducation2"),
new Committee("faithformation", "Faith Formation and Outreach", "Rev. Dr. Neville Smith", "hpfaithformation"),
new Committee("faithformation2", "Faith Formation and Outreach", "Rev. Allison Playfair", "hpfaithformation2"),
new Committee("finance", "Finance and Property", "Peter Hancock", "hpfinance"),
new Committee("regen", "Regeneration Task Force", "Rev. Dr. Orville James", "hpregen"),
new Committee("oversight", "Pastoral Charge Oversight", "Rev. John Tapscott", "hpoversight"),
new Committee("oversight2", "Pastoral Charge Oversight", "Rev. Blair Corcoran", "hpoversight2"),
new Committee("prelations", "Pastoral Relations", "Rev. Diane Blanchard", "prelations"),
new Committee("prelations2", "Pastoral Relations", "Rev. Barbara Morrison", "prelations2"),
new Committee("stewardship", "Stewardship", "Bill West", "hpstewardship"),
new Committee("strategy", "Strategic Mission Development", "John Fargey", "hpsmdc"),
new Committee("hucec", "Halton United Church Extension Council", "Sandy Skinner", "hphucec"),
new Committee("ucw", "United Church Women", "Mary Jane Ward", "hpucw"),
new Committee("web", "Web Master", "Peter Curran", "haltonp"),
new Committee("mdo", "Mission Development Officer", "Rev. Peter Hoyle", "hpmdo"),
new Committee("friend", "Persistent Friend", "Rev. Lorna MacQueen", "hpfriend")
)








var dups = ["nominating", "web",
"candidacy", "candidacy2"]


for (var i = 0; i < committees.length; ++i) {
var j
for (j = 0; j < dups.length; ++j)
if (dups[j] == committees[i].key)
break

if (j >= dups.length) {
if (execlist.length > 0)
execlist += ","
execlist += committees[i].mail + "@haltonpres.org"
}
}
}

