var theImages = new Array()

//Random-loading images
theImages[0] = ['images/main_images/amigos.jpg','portfolio/branding/amigos/index.htm']
theImages[1] = ['images/main_images/guardian2.jpg','portfolio/advertising/guardian/index.htm']
theImages[2] = ['images/main_images/agr.jpg','portfolio/magazines/agr/index.htm']
theImages[3] = ['images/main_images/bbc.jpg','portfolio/advertising/bbc/index.htm']
theImages[4] = ['images/main_images/swm.jpg','portfolio/literature/swm/index.htm']
theImages[5] = ['images/main_images/guardian3.jpg','portfolio/literature/guardian/index.htm']
theImages[6] = ['images/main_images/agr2.jpg','portfolio/magazines/agr/index.htm']
theImages[7] = ['images/main_images/guardian.jpg','portfolio/branding/guardian/index.htm']
theImages[8] = ['images/main_images/year10.jpg','portfolio/literature/year10/index.htm']

var p = theImages.length;

var preBuffer = new Array()
for (var i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i][0]
}
var whichImage = Math.floor(Math.random()*p);

onload=function showImage(){

document.mypic.src=theImages[whichImage][0]

document.mypic.onclick=function(){
window.location=theImages[whichImage][1]
}

document.getElementById("mylink").setAttribute("href",theImages[whichImage][1])

}
