// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
uri.file = uri.page;
if (uri.ext != '') uri.file += '.' + uri.ext;
if (uri.file == '') uri.page = 'index';
uri.args = location.search.substr(1).split("?");
return uri;
}

var uri = new Object();
getURL(uri);
                  


// JavaScript Document - Banner rotator

var rI = {
  addImg:function() {
    rI.imgList.push(arguments[0]);
    rI.altList.push(arguments[1]);
  },
  showImg:function() {
    var j=parseInt(Math.random()*rI.imgList.length);
    j=(isNaN(j))?0:j;
    newImg=document.createElement("img");
    newImg.src=rI.imgList[j];
    newImg.alt=rI.altList[j];
    obj=document.getElementById("randomImage");
    obj.appendChild(newImg);
  },
  addEvent: function(obj,evt, fn) {
    if (obj.addEventListener) {obj.addEventListener(evt, fn, false);
    } else if (obj.attachEvent) {obj.attachEvent('on'+evt, fn);
    } else {obj['on'+evt]=fn;}
  },
  imgList:[],
  altList:[]
}


//take into account whether site is being viewed on filesystem or via web server
//
var prefix = '/'	//change this depending on site location

if(typeof(uri.domain) !='undefined') prefix='/'; //on webserver so set refrence to absolute

rI.addImg(prefix+'siteresources/ui/header1.jpg','Allan Wilson Centre');
rI.addImg(prefix+'siteresources/ui/header2.jpg','Allan Wilson Centre');
rI.addImg(prefix+'siteresources/ui/header3.jpg','Allan Wilson Centre');
rI.addEvent(window,'load',rI.showImg);