window.onresize = ResizeTables;
window.onload = new Function("Initialize();");
var caption_text_img;
var caption_knot_img;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
function WindowHeight()
{
	var result = (window.innerHeight) ? window.innerHeight : (document.height) ? document.height : document.body.clientHeight;
	return (result);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
function ResizeTables()
{
	var client_height = WindowHeight();
	window.status = client_height + ", " + screen.height;
	document.sizer_img.height = client_height - 5;
	return true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
function WriteSizerImage()
{
	var img_tag = "<img name=\"sizer_img\" border=\"0\" src=\"/images/spacer.gif\" width=\"1\" height=\""+ WindowHeight() +"\">";
	document.write(img_tag);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
function Initialize()
{
	// so that the script can be included in the header before these images have been created
	caption_text_img = document.images["caption_text"];
	caption_knot_img = document.images["caption_knot"];
	if (caption_text_img) caption_text_img.base_src = caption_text_img.src;
	if (caption_knot_img) caption_knot_img.base_src =  caption_knot_img.src;

	if ((typeof InitializeContent) == "function") InitializeContent();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
function msover( animage )
{
	// lots of accounting-for-netscape bullshit here
	if (!(animage.base_src)) animage.base_src = animage.src;
	if (!(animage.over_src)) animage.over_src = animage.src.replace(/1./g,".");
	animage.src = animage.over_src;
	if (caption_text_img) caption_text_img.src = "/images/captions/"+animage.name + "_caption.gif";
	if (caption_knot_img) caption_knot_img.src = "/images/captions/"+animage.name + "_knot.gif";
	if (animage.friendlyname) window.status = animage.friendlyname;
	else window.status = animage.name.replace(/_/g," ");
	return true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
function msout( animage )
{
	// lots of accounting-for-netscape bullshit here
	if (animage.base_src) animage.src = animage.base_src;	
	if (caption_text_img) caption_text_img.src = caption_text_img.base_src;
	if (caption_knot_img) caption_knot_img.src = caption_knot_img.base_src;
	window.status = "";
	return true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
function link_msovers( alink, imagename )
{
	/* this function rewrites the link mouseovers  as necessary to account for fucking netscape's
		lack of mouseover events for the image object */
	var animage = document.images[imagename];
	if (!animage.onmouseover)
	{
		alink.onmouseover = new Function("return msover(document.images[\""+imagename+"\"])");
		alink.onmouseout = new Function("return msout(document.images[\""+imagename+"\"])");
		return msover(document.images[imagename]);
	}
	else
	{
		alink.onmouseover = null;
		return true;
	}
}

//----------------------------------------------------------
function GetObjectByName( object_name )
{
  var an_obj = (document.all) ? document.all[object_name] : ( (document.layers) ? document.layers[object_name] : ((document.getElementById) ? document.getElementById(object_name) : null));
  return an_obj;
}
