// Convert document.lastModified to 'dd mmmm yyyy'
function modDate(z) {
x = new Date(z);
x = x.toLocaleString();
y = x.indexOf(":");
x = x.slice(0,y - 3);
document.write(x)
}

function modDateI(z) {
x = new Date(z);
x = x.toLocaleString();
y = x.indexOf(":");
x = x.slice(0,y - 3);
return(x)
}


// Page Footer
// d = date last modified
// l = level ie folders below root where root = 0

function footer(d,l) {

if (l = 0) { i = "" }
else if (l = 1) { i = "../" }
else if (l = 2) { i = "../../" }

document.write("<span class=l3rdf>[<a href='" + i + "index.html'>St. John's Front Page</a>]<br>[<a href='javascript:history.go(-1)'>Return to Previous Page</a>]</span>")
document.write("<span class=m3rdf>[<a href='" + i + "siteinfo.html'>Disclaimer</a>] [<a href='" + i + "siteinfo.html'>Copyright Notice</a>] [<a href='" + i + "siteinfo.html'>Privacy Statement</a>] [<a href='" + i + "siteinfo.html'>Acknowledgements</a>] [<a href='" + i + "siteinfo.html'>Credits</a>] [<a href='" + i + "sitemap.html'>Sitemap</a>]</span>")
document.write("<span class=r3rdf>[<a href='#top'>Top of Page</a>]<br>[" + modDateI(d) + "]</span><br class=all>")

}


// Open External links in a new tab works in everything except ie
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("class") == "ext")
     anchor.target = "_newtab";
   else if (anchor.getAttribute("href") &&
       anchor.getAttribute("class") == "f1 ext")
     anchor.target = "_newtab";
   else if (anchor.getAttribute("href") &&
       anchor.getAttribute("class") == "mnu ext")
     anchor.target = "_newtab";
 }
}
window.onload = externalLinks;


// Countdown Timer (z=Name of Event(ie 'Christmas'), y=Date of Event(ie 'December 25, 2006'))
function cDown(z,y) {
var urodz = new Date(y);
var now = new Date();
var ile = urodz.getTime() - now.getTime();
var dni = Math.floor(ile / (1000 * 60 * 60 * 24));
if (dni > 1)
document.write("Only " + dni + " days until " + z)
else if (dni == 1)
document.write("Only two days until " + z)
else if (dni == 0)
document.write("Only one day until " + z)
else if (dni == -1)
document.write("Today is " + z);
else
document.write(z + " is here");
}

// cDown('The Opening Ceremony','July 28, 2012')


// Long document.LastModified
function NmodDate(z) {
lastmod = document.lastModified; // get date
modarray=lastmod.split("/"); // split it
lastmod = modarray[1]+"/"+modarray[0]+"/"+modarray[2]; // convert it to International format
lastmoddate = Date.parse(lastmod); // convert it back to a date
if(lastmoddate == 0){ // check it
document.writeln(" "); // oops, lost it
}
else {
document.writeln(lastmod); // show it
}
}


// Image Protector
function piclik(x)
	{
	document.getElementById(x).style.display='none';
	alert('All Photos Are Copyright St James Church\nIf you would like copies please contact us\n\nPlease reload this page to view the photo again.');
	this.src = 'images/bex.gif';
	}


