var delay=10000 //set delay in miliseconds
var curindex=0

var randomimages=new Array()

randomimages[0]=["http://www.philipcox.info/media/right/bird01.jpg","http://www.philipcox.info/works-for-sale.php"];
randomimages[1]=["http://www.philipcox.info/media/right/jesterhead.jpg","http://www.philipcox.info/works-for-sale.php"];
randomimages[2]=["http://www.philipcox.info/media/right/fishbox02b.jpg","http://www.philipcox.info/works-for-sale.php"];
randomimages[3]=["http://www.philipcox.info/media/right/fishbox10a.jpg","http://www.philipcox.info/works-for-sale.php"];

var preload=new Array()

for (n=0;n<randomimages.length;n++)
{
preload[n]=new Image()
preload[n].src=randomimages[n]
}

var First=Math.floor(Math.random()*(randomimages.length));
var LnkURL=randomimages[First][1];

document.write('<img onclick="Link();" name="defaultimage" src="'+randomimages[First][0]+'">')

function Link(){
if (LnkURL){
window.location=LnkURL;
}

}
function rotateimage()
{

if (curindex==(tempindex=Math.floor(Math.random()*(randomimages.length)))){
curindex=curindex==0? 1 : curindex-1
}
else
curindex=tempindex
LnkURL=randomimages[curindex][1];
document.images.defaultimage.src=randomimages[curindex][0];
}

setInterval("rotateimage()",delay)
