var rn = 0;
var allpics = 158;
var borderpics = 66;
var restpicsstart = 101;
function rnGen(){
  rn = Math.ceil(Math.random()*allpics);
  if (rn>borderpics && rn<restpicsstart){
    rnGen();
  }
}
rnGen();	
var imgsrc = '<img src=http://library.wellcome.ac.uk/images/random/' + rn + '_random.jpg border=0>';
//var imgsrc = 'http://www.wellcome.ac.uk/en/devlib/images/random/' + rn + '_random.jpg';
//document.write('<!--#include exe="http://www.wellcome.ac.uk/cgi-bin/include/mysize.pl" -->');
//document.write("<SCR" + "IPT LANGUAGE='JavaScript' SRC='http://www.wellcome.ac.uk/en/devlib/images/" + rn + ".js' TYPE='text/javascript'><\/SCR" + "IPT>");
var hintsrc = '<img src=http://library.wellcome.ac.uk/images/random/' + rn + '_random.gif border=0>';
if (rn<=borderpics){
  document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr bgcolor="#7078bd"  width="1" height="1"><td colspan="5" height="1"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="1" height="1" border="0"></td></tr>');
  document.write('<tr><td rowspan="3" bgcolor="#7078bd"  width="1" height="1"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="1" height="1" border="0"></td><td colspan="3" height="10"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="1" height="10" border="0"></td>');
  document.write('<td rowspan="3" bgcolor="#7078bd"  width="1" height="1"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="1" height="1" border="0"></td></tr>');
  document.write('<tr><td width="10" height="10"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="10" height="1" border="0"></td><td width="10" height="10" align="center">');
}
//
if(!document.layers)document.write('<a href="javascript:;" onmouseover="showhint()" onmouseout="hidehint()" onfocus="if(this.blur)this.blur();" style="cursor:nw-resize">');
document.write(imgsrc);
if(!document.layers)document.write('</a>');
//
if (rn<=borderpics){
  document.write('</a></td><td width="10" height="10"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="10" height="1" border="0"></td></tr>');
  document.write('<tr><td colspan="3" height="10"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="1" height="10" border="0"></td></tr>');
  document.write('<tr bgcolor="#7078bd"  width="1" height="1"><td colspan="5"><img src="http://library.wellcome.ac.uk/images/spacer.gif"  width="1" height="1" border="0"></td></tr></table>');
}
//
//
if(!document.layers)document.write('<div id="c" style="position:absolute; left:41px; top:-348px; width: 200px; visibility: visible; z-index: 677;">' + hintsrc + '</div>');
////////////////////////////////////////////////////////
function nsmouse(evnt){
  xpos = evnt.pageX;
  ypos = evnt.pageY;
}
//if(document.layers || (document.getElementById && !document.all)) {
if(document.getElementById && !document.all) {
window.captureEvents(Event.MOUSEMOVE);
window.onmousemove = nsmouse;
}
////////////////////////////////////////////////////////
var idc = "c";
////////////////////////////////////////////////////////
if(document.getElementById) { 
    pCaption = document.getElementById(idc);
} else if (document.all) {
    pCaption = document.all[idc];
} else if (document.layers) {
    pCaption = document.layers[idc];
}
////////////////////////////////////////////////////////
function showhint() {
  if (pCaption.style) {
     if(document.getElementById && !document.all) { 
       pCaption.style.top = ypos + "px";
       pCaption.style.left = xpos + "px";
     } else if (document.all) {
       pCaption.style.top = event.clientY + document.body.scrollTop + "px";
       pCaption.style.left = event.clientX + document.body.scrollLeft + "px"; 
     }
  } else {
    pCaption.top = ypos;
    pCaption.left = xpos;
  }
}
////////////////////////////////////////////////////////
function hidehint() {
  if (pCaption.style) {
    pCaption.style.top = -400 + "px";
  } else {
    pCaption.top = -400;
  }
}
////////////////////////////////////////////////////////
