Joshua Sexton's Scientific Root Words
// window onClick opener code to direct definition to an explanatory website
function newwindow(url)
{
// save the parent url
var parent_url = document.location.href;
// gets the base href
var base_ref = document.getElementsByTagName('base')[0].href;
var win = window.open(url);
win.blur();
document.getElementsByTagName('base')[0].focus();
return;
}
// display the definition box
function defbox(thedefinition, theimage, thecaption, thesource)
{
// change these if the images don't fit
var max_width = 250;
var max_height = 200;
var image_box_width = max_width;
var image_box_height = max_height;
var imageurl = "./images/" + theimage;
imagewidth = document.getElementById("image1").width;
imageheight = document.getElementById("image1").height;
// swapped in image url
document.getElementById("image1").src = imageurl;
// create a mew image element
var swapimage = document.createElement("img");
swapimage.setAttribute('src', imageurl);
// wait for swapped in image to load
swapimage.onload = function()
{
imagewidth = swapimage.naturalWidth;
imageheight = swapimage.naturalHeight;
// build text and image box
var stuff1 = document.getElementById("info1");
box_info = "
"
box_info += thedefinition + ""
// scale image to make it fit within max_width and max_height
var width_ratio = imagewidth/max_width;
var height_ratio = imageheight/max_height;
if (width_ratio >= height_ratio)
{
image_box_width = imagewidth/width_ratio;
box_info += "