/*
CSS Browser Selector v0.3.2
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
window.onload = css_browser_selector;


// 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
}
}


// Front Page Random Image Selector
function frandim(x)
{
var ynum = 6;
var whichY = Math.floor(Math.random()*ynum);
var yar=new Array(ynum)
yar[0]="04";
yar[1]="05";
yar[2]="06";
yar[3]="07";
yar[4]="08";
yar[5]="09";

var picnum = 11;
var whichImg= Math.floor(Math.random()*picnum);
var img=new Array(picnum)
img[0]="01.jpg";
img[1]="02.jpg";
img[2]="03.jpg";
img[3]="04.jpg";
img[4]="05.jpg";
img[5]="06.jpg";
img[6]="07.jpg";
img[7]="08.jpg";
img[8]="09.jpg";
img[9]="10.jpg";
img[10]="11.jpg";
img[11]="12.jpg";

document.write("<img class=iac src='galleries/images/" + yar[whichY] + img[whichImg] + "' width=240 height=159 />");
}


// Thumbnail Block Random Image Selector
// x = image height
// y = number of images
function randimz(x,y)
{
var ynum = 6;
var whichY = Math.floor(Math.random()*ynum);
var yar=new Array(ynum)
yar[0]="04";
yar[1]="05";
yar[2]="06";
yar[3]="07";
yar[4]="08";
yar[5]="09";

var picnum = 11;
var Img01= Math.floor(Math.random()*picnum);
var img=new Array(picnum)
img[0]="01s.jpg";
img[1]="02s.jpg";
img[2]="03s.jpg";
img[3]="04s.jpg";
img[4]="05s.jpg";
img[5]="06s.jpg";
img[6]="07s.jpg";
img[7]="08s.jpg";
img[8]="09s.jpg";
img[9]="10s.jpg";
img[10]="11s.jpg";
img[11]="12s.jpg";
if (y > 0) {
	document.write("<img src='galleries/images/" + yar[whichY] + img[Img01] + "' height=" + x + " alt='Events At St Johns' />");
y = y - 1;
randimz (x,y);
}
}


// YPF Image Selector
function ypfimg(x)
{
var picnum = 10;
var whichImg= Math.floor(Math.random()*picnum);
var img=new Array(picnum);
img[0]="ypf.jpg";
img[1]="ypf01.jpg";
img[2]="ypf02.jpg";
img[3]="ypf03.jpg";
img[4]="ypf04.jpg";
img[5]="ypf05.jpg";
img[6]="ypf06.jpg";
img[7]="ypf07.jpg";
img[8]="ypf08.jpg";
img[9]="ypf09.jpg";
img[10]="ypf10.jpg";
document.images[3].src = "images/" + img[whichImg];
}


// onClick pop-ups (add new ones to the end of the array and call them by index number)
function jAlert(z) {
tArray = new Array("He Already Knows What You Want To Ask.","Jesus Has Changed Your Life.\r\rSave Changes ?","The Spirit Has Moved.\r\rClick OK To Follow.","Thanks Robin");
alert(tArray[z])
}


// Roundel or Web Logo for padding (roundel is square) (logo width=6 x height but never over 470)
function logopadd(x) 
{
	if (x <= 1) {
	return;
	}
	else if (x <= 45) {
	document.write("<img src='images/roundel.jpg' height=" + x + " width=" + x + " alt='St Johns E15' class=ial><img src='images/roundel.jpg' height=" + x + " width=" + x + " alt='Of Stratford' class=iar><img src='images/webaddy.jpg' height=" + x + " width=" + (x * 6) + " alt='Gods Love At The Centre' class=iac><hr>");
	}
	else if (x <= 53) {
	document.write("<img src='images/roundel.jpg' height=" + x + " width=" + x + " alt='St Johns E15' class=ial><img src='images/webaddy.jpg' height=" + x + " width=" + (x * 6) + " alt='Gods Love At The Centre of Stratford' class=iar><br class=all><hr>");
	}
	else if (x <= 62) {
	document.write("<img src='images/webaddy.jpg' height=" + x + " width=" + (x * 6) + " alt='Gods Love At The Centre of Stratford' class=iac><hr>");
	}
	else if (x <= 375) {
	document.write("<img src='images/roundel.jpg' height=" + x + " width=" + x + " alt='Gods Love At The Centre of Stratford' class=iac><hr>");
	}
}


// Gallery Image Swap
function swap(x) {
	for (var p=0; p<13; p++){
		pic="p"+p;
		document.getElementById(pic).style.display='none';
		}
		document.getElementById(x).style.display='block';
	}



// Image Protector
function piclik(x)
	{
	document.getElementById(x).style.display='none';
	this.src = 'images/bex.gif';
	}

