// Braham Ketcham bbk@willinet.net

var bgcolor = "#FFFFFF";
var bordercolor = "#000000";
var textcolor = "#000000";
var boxwidth = "180";
var borderwidth = "1";
var boxover = false;
var linkover = false;
var boxopen = false;
var lastbox = " ";
var delay = 250;
var ns = (document.layers)? true:false
var ie = (document.all)? true:false
highVer = ((ns) || (ie))? true:false
var h = new Array;
var picNum = 0;
var xres = 0;
var yres = 0;
var xoff = 0;
var yoff = (ns)? 0:4
if (ns) delay = 500;
var clover = false;

function showbox(theBox,xco,yco) {
	linkover = true;
	makeTable(theBox);
	if ((boxopen == false) || (theBox != lastbox)) { 
		if (ns) {
			xoff = 4;
			yoff = -(parseInt((yco - 162) / 19));
		}
		if (ie) {
			xoff = 2;
		}
		xres = xco + xoff;
		yres = yco + yoff;
		drawbox(xres,yres);
	}
	lastbox = theBox;
}

function closebox() {
	if ((boxover == false) && (linkover == false)) {
		if ((ns) || (ie)) {
			if (ns) { themenu.visibility = "hide"; }
			else { themenu.visibility = "hidden"; }
			boxopen = false;
		}
	}
}

function boxon() {
	boxover = true;
	drawbox(xres,yres);
}

function makeTable(theBox) {
	var liston = false;
	tableHTML = "<table width="+boxwidth+" border="+borderwidth+" bordercolor=\""+bordercolor+"\" cellspacing=0 cellpadding=5><tr bgcolor=\""+bgcolor+"\"><td><font size=\"1\" face=\"Arial,Verdana,Geneva,sans-serif\" color=\""+textcolor+"\">";
	for(var i=0; i<theBox[2]; i++) {
		if (theBox[1][i] == "line-break") {
			tableHTML = tableHTML+"<hr noshade size=\"1\" color=\""+bordercolor+"\">";
		}
		else if (theBox[1][i] == "nolink") {
			tableHTML = tableHTML+"<strong>"+theBox[0][i]+"</strong><br>";
		}
		else if (theBox[1][i] == "startlist") {
			tableHTML = tableHTML+"<strong>"+theBox[0][i]+"</strong><br>";
			liston = true;
		}
		else if (theBox[1][i] == "endlist") {
			liston = false;
		}
		else if (liston) {
			tableHTML = tableHTML+"&nbsp;&nbsp;&nbsp;&nbsp;<a href=\""+theBox[1][i]+"\">"+theBox[0][i]+"</a><br>";
		}
		else { tableHTML = tableHTML+"<a href=\""+theBox[1][i]+"\">"+theBox[0][i]+"</a><br>"; }

	}
	tableHTML = tableHTML+"</font></td></tr></table>";
	if (ns) {
		var nslayer = themenu.document;
		nslayer.write(tableHTML);
		nslayer.close();
	}
	else if (ie) document.all["menuBox"].innerHTML = tableHTML;
}

function drawbox(xco,yco) {
	themenu.left = xco;
	themenu.top = yco;
	if ( (ns) || (ie) ) {
		if (ns) themenu.visibility = "show";
		else if (ie) themenu.visibility = "visible";
	}
	boxopen = true;
}

function linkhide() {
	linkover = false;
	setTimeout("closebox(); clean();", delay);
}

function boxhide() {
	boxover = false;
	setTimeout("closebox(); clean();", delay);
}

function load(onOff, onOver, imgName, descImg) {
  if (highVer) {
    h[picNum] = new Array(4);
    h[picNum][0] = new Image();
    h[picNum][0].src = onOff;
    h[picNum][1] = new Image();
    h[picNum][1].src = onOver;
    h[picNum][2] = imgName;
    h[picNum][3] = new Image();
    h[picNum][3].src = descImg;
   picNum++;
  }
}
function ccel(cellName) {
celn = new String(cellName.id);
if (celn.match("tmCell0_0") == null) tmCell0_0.bgColor="#FFFFFF";
if (celn.match("tmCell1_0") == null) tmCell1_0.bgColor="#FFFFFF";
if (celn.match("tmCell2_0") == null) tmCell2_0.bgColor="#FFFFFF";
if (celn.match("tmCell3_0") == null) tmCell3_0.bgColor="#FFFFFF";

cellName.bgColor = "#DDF7BC";
clover = true;
}

function change(imgName) {
 if (highVer) {
  for (var c = 1; c < picNum; c++) {
    if (h[c][2] == imgName) {
      if (document.images[imgName].src != null) {
          document.images[imgName].src = h[c][1].src;
          document.images[h[0][2]].src = h[c][3].src;
      }
    }
    else { document.images[h[c][2]].src = h[c][0].src; }
  }
 }
}

function clcel() {

tmCell0_0.bgColor="#FFFFFF";
tmCell1_0.bgColor="#FFFFFF";
tmCell2_0.bgColor="#FFFFFF";
}

function clean() {
  if ((ie) && (boxover == false) && (linkover == false) && (clover == false)) {

clcel();
/*
    for (var c = 1; c < picNum; c++) {
      if (h[c][2] != null) {
        if (document.images[h[c][2]].src != h[c][0].src) {
           document.images[h[c][2]].src = h[c][0].src;
        }
      }
    }
    if (document.images[h[0][2]].src != h[0][0].src ) {
	document.images[h[0][2]].src = h[0][0].src;
    }
*/
  }
}
