d.write('<div id="bottom">');
if (ie){
	when = d.lastModified.split(" "); date = when[0].split("/"); time = when[1]; 
	d.write('<p><br />Last modified: '+date[1]+"/"+date[0]+"/"+date[2]+" "+time+'</p>');
}

var specificImage=''
setPage();

//preload next arrow
nextArrow = new Image(); nextArrow.src = "/next_arrow.gif";
function getRandomOf(howmany){
	rnd = Math.random();
	rnd = rnd*(howmany);
	return Math.round(rnd)
}

function randomBanner() {
	rnd = Math.random();
	howmany = eval(whichBanners+".length-1")
	rnd = rnd*(howmany);
	which = Math.round(rnd)

/*	if (specificImage!='') {
        which = specificImage;
    }*/
}
//banners = "all";
function advanceBanner(){
	which++;
	if (which>=howmany+1){
		which=0;
    }
}

function changeBanner(how) {
	if(how==1){
		randomBanner();
	} else {
		advanceBanner();
	}
	d.getElementById('top').style.backgroundImage = 'url(/images/banners/'+eval(whichBanners+'['+which+']')+')';
	d.getElementById('bannerImg').setAttribute('alt', eval(whichBanners+'Alt['+which+']'));
	d.getElementById('bannerImg').setAttribute('title', eval(whichBanners+'Alt['+which+']'));
}

//random banner image
randomBanner();

d.write('<style type="text/css">#top{background-image:url(/images/banners/'+eval(whichBanners+'['+which+']')+')}</style>');

//setting alt text on banner img
d.getElementById('bannerImg').setAttribute('alt', eval(whichBanners+'Alt['+which+']'));
d.getElementById('bannerImg').setAttribute('title', eval(whichBanners+'Alt['+which+']'));
d.write('<a class="newWin" href="http://validator.w3.org/check/referer"><img src="/images/weeicons/valid_xhtml.gif" alt="Valid XHTML 1.0" title="Validate the XHTML of this document" style="border:0; width:80px;height:15px" /></a>&nbsp;<a class="newWin" href="http://jigsaw.w3.org/css-validator/validator?uri='+document.location.href+'"><img style="border:0;width:80px;height:15px" src="/images/weeicons/valid_css.gif" alt="Valid CSS" title="Validate the CSS of this document" /></a>&nbsp;<a href="/rss/" title="RSS feed from this site"><img src="/images/weeicons/rss2.png" style="width:68px;height:15px;border:0" /></a>&nbsp;<a class="newWin" href="http://www.getfirefox.com"><img src="/images/weeicons/firefox.gif" alt="Firefox" title="Get Firefox today" style="border:0; width:80px;height:15px" /></a>&nbsp;<a class="newWin" href="http://browsehappy.com/" title="Browse Happy: Switch to a safer browser today!"><img src="/images/weeicons/browsehappy.gif" style="width:80px;height:15px;border:0" /></a>&nbsp;<a class="newWin" id="libDems" href="http://www.libdems.org.uk/" title="Vote Liberal Democrat in 2005"><img src="/images/weeicons/libdems4.png" style="width:80px;height:15px;border:0" /></a>');

d.write('</div>');
d.write('<div id="nextArrow" onmouseover="show(\'nextArrow\')" onmouseout="hide(\'nextArrow\')"><a href="javascript:changeBanner(0)"><img src="/next_arrow.gif" width="13" height="13" alt="click here to change image" title="click here to change image" style="width:13px;height:13px;border:0" /></a></div>');


// add onclicks to newWin class 
if(document.getElementsByTagName){
	// create an array of objects of each link in the document 
	var pageLinks = document.getElementsByTagName("a");
	// loop through each of these links (anchor tags) 	
	for (var i=0; i < pageLinks.length; i++) {	
		// if the link has a class of "newWin"...	
		if (pageLinks[i].getAttribute("class") == "newWin") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, lnk (see extras.js) 	
			pageLinks[i].onclick = function() {	
			lnk(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		// if link goes to friends gallery
		if(pageLinks[i].href.indexOf('?g=')!=-1){
			if(pageLinks[i].className != "friends") { // add "friends" class if not already there
				pageLinks[i].className = (pageLinks[i].className == "") ? "friends" : pageLinks[i].className+" friends";
			}
			
			// add img node
			var thumb = document.createElement('img');
			picId = pageLinks[i].href.split('?g=')[1];
			path_to_icon = "/images/friends/"+picId+".jpg";
			image_alt_text = pageLinks[i].innerHTML;
			thumb.setAttribute('src', path_to_icon);
			thumb.setAttribute('alt', image_alt_text);
			
			// append new image
			pageLinks[i].appendChild(thumb);	
		}
	} 
}
