// main.js - Created by Bradley J. Gibby q:)
// Version 1.0 - 20031003

// Dependencies:-
//	. browser.js - For browser dependent boolean variables

var currentRollover, prevRolloverImage;
var windowTypes = [
	"width=550,height=300,scrollbars=yes,resizable=no", 
	"width=850,height=400,scrollbars=yes,resizable=no", 
	"width=550,height=416,scrollbars=no,resizable=no", 
	"width=550,height=440,scrollbars=no,resizable=no", 
	"width=750,height=550,scrollbars=yes,resizable=yes", 
	"width=790,height=590,scrollbars=yes,resizable=yes,top=0,left=0",
	"width=225,height=200,scrollbars=no,resizable=no",
	"width=450,height=400,scrollbars=no,resizable=no",
	""
];

// Constants
var NODETAILS = 6;
var TOOLWINDOW = 4;
var RESOURCE = 5;
var COMMUNICATE = 5;

function swap(id, src) {
	currentRollover = id;
	var obj;
	
	if (isIE5up || isNav6up) {
		obj = getElement(id);
	} else if (isNav4) {
		obj = getElement(id, "image");
	}

	prevRolloverImage = obj.src;
	obj.src = src;
}

function swapRestore() {
	var obj;

	if (isIE5up || isNav6up) {
		obj = getElement(currentRollover);
	} else if (isNav4) {
		obj = getElement(currentRollover, "image");
	}

	obj.src = prevRolloverImage;
	currentRollover = null;
}

function getElement(id, type) {
	if (isIE5up || isNav6up) {
		return document.getElementById(id);
	} else if (isNav4) {
		if (type == "image") {
			return eval("document.images['" + id + "'];");
		} else if (type == "layer") {
			return eval("document.layers['" + id + "'];");
		}
	}
}

function showHide(id, state) {
	var argument, styleType;

	if (state == 1) {
		// Show Layer (VISIBILITY)
		if (isIE5up || isNav6up) {
			argument = "visible";
		} else if (isNav4) {
			argument = "show";
		}
		
		styleType = 0;
	} else if (state == 2) {
		// Hide Layer (VISIBILITY)
		if (isIE5up || isNav6up) {
			argument = "hidden";
		} else if (isNav4) {
			argument = "hide";
		}

		styleType = 0;
	} else if (state == 3) {
		// Show Layer (DISPLAY: BLOCK)
		argument = "block";
		styleType = 1;
	} else if (state == 4) {
		// Show Layer (DISPLAY: INLINE)
		argument = "inline";
		styleType = 1;
	} else if (state == 5) {
		// Hide Layer (DISPLAY: NONE)
		argument = "none";
		styleType = 1;
	}
	
	var obj = getElement(id, "layer");
	
	if (styleType) {
		// Layers DISPLAY style
		if (isIE5up || isNav6up) {
			obj.style.display = argument;
		} else if (isNav4) {
			// Not supported
		}
	} else {
		// Layers VISIBILITY style
		if (isIE5up || isNav6up) {
			obj.style.visibility = argument;
		} else if (isNav4) {
			obj.visibility = argument;
		}
	}
}

function setLayerPosition(id, rel, ieX, ieY, nsX, nsY) {
	var obj = getElement(id, "layer");
	var relObj = getElement(rel, "layer");
	
	var relObj_x = getPageOffsetLeft(relObj);
	var relObj_y = getPageOffsetTop(relObj);
	
	if (isIE5up || isNav6up) {
		obj.style.top = relObj_y + ieY;
		obj.style.left = relObj_x + ieX;
	} else if (isNav4) {
		obj.top = relObj_y + nsY;
		obj.left = relObj_x + nsX;
	}
}

function getPageOffsetLeft(el) {
	var x;
	
	if (isIE5up || isNav6up) {
		x = el.offsetLeft;
		if (el.offsetParent != null)
			x += getPageOffsetLeft(el.offsetParent);
	} else if (isNav4) {
		x = el.pageX;
	}
	
	return x;
}

function getPageOffsetTop(el) {
	var y;
	
	if (isIE5up || isNav6up) {
		y = el.offsetTop;
		if (el.offsetParent != null)
			y += getPageOffsetTop(el.offsetParent);
	} else if (isNav4) {
		y = el.pageY;
	}
	
	return y;
}

function getWindowYOffset() {
	if ( window.pageYOffset || window.pageYOffset == 0 )
		return window.pageYOffset;
	
	if ( document.body.scrollTop || document.body.scrollTop == 0 )
		return document.body.scrollTop;
}

function getWindowXOffset() {
	if ( window.pageXOffset || window.pageXOffset == 0 )
		return window.pageXOffset;
	
	if ( document.body.scrollLeft || document.body.scrollLeft == 0 )
		return document.body.scrollLeft;
}

function openWindow(url, windowType) {
	window.open(url, "", windowTypes[windowType]);
}

function drawGL() {
	document.write("<div id=\"glossaryLayer\" style=\"position: absolute; top: 10px; left: 150px; width: 497px; height: 240px; visibility: hidden;\">");

	document.write("<table  border=\"0\" cellspacing=\"0\" cellpadding=\"20\" background=\"" + SITE_PREFIX + "/gh/glossary/images/background.jpg\">");
	document.write("<tr>");
	document.write("<td width=\"497\" height=\"540\" align=\"center\" valign=\"top\">");
	
	document.write("<table width=\"497\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("<tr>");
	document.write("<td width=\"497\">");
	document.write("<table width=\"497\" height=\"104\"  border=\"0\" cellpadding=\"0\" cellspacing=\"3\" bgcolor=\"FFFFFF\">");
	document.write("<tr>");
	document.write("<td align=\"left\" valign=\"bottom\" bgcolor=\"#FFFFFF\"><img src=\"" + SITE_PREFIX + "/gh/glossary/images/glossary.jpg\" width=\"74\" height=\"22\"><br></td>");
	document.write("<td align=\"right\" valign=\"top\" bgcolor=\"#FFFFFF\"><a href=\"javascript:closeGlossary();\"><img src=\"" + SITE_PREFIX + "/gh/glossary/images/cross.jpg\" width=\"16\" height=\"16\" border=\"0\"></a></td>");
	document.write("</tr>");
	document.write("<tr align=\"center\">");
	document.write("<td colspan=\"2\" bgcolor=\"#FFFFFF\"><p><b><a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/a.htm\" target=\"glossary\">A</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/b.htm\" target=\"glossary\">B<a/> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/c.htm\" target=\"glossary\">C</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/d.htm\" target=\"glossary\">D</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/e.htm\" target=\"glossary\">E</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/f.htm\" target=\"glossary\">F</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/g.htm\" target=\"glossary\">G</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/h.htm\" target=\"glossary\">H</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/i.htm\" target=\"glossary\">I<a/> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/j.htm\" target=\"glossary\">J</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/k.htm\" target=\"glossary\">K</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/l.htm\" target=\"glossary\">L</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/m.htm\" target=\"glossary\">M</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/n.htm\" target=\"glossary\">N</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/o.htm\" target=\"glossary\">O</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/p.htm\" target=\"glossary\">P</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/q.htm\" target=\"glossary\">Q</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/r.htm\" target=\"glossary\">R</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/s.htm\" target=\"glossary\">S</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/t.htm\" target=\"glossary\">T</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/u.htm\" target=\"glossary\">U</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/v.htm\" target=\"glossary\">V</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/w.htm\" target=\"glossary\">W</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/x.htm\" target=\"glossary\">X</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/y.htm\" target=\"glossary\">Y</a> <a class=\"GLOSSARY\" href=\"" + SITE_PREFIX + "/gh/glossary/z.htm\" target=\"glossary\">Z</a><br><img src=\"" + SITE_PREFIX + "/gh/glossary/images/wave_line.jpg\" height=\"26\"></b></p></td>");
	document.write("</tr>");
	document.write("</table>");

	document.write("<table width=\"497\" height=\"400\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
	document.write("<tr>");
	document.write("<td width=\"497\" height=\"389\" align=\"center\" valign=\"top\" bgcolor=\"#FFFFFF\"><iframe name=\"glossary\" id=\"glossary\" height=\"399\" width=\"497\" frameborder=0 scrolling=yes src=\"" + SITE_PREFIX + "/gh/glossary/a.htm\"></iframe></td>");
	document.write("</tr>");
	document.write("</table>");

	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
	
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
	
	document.write("</div>");
}

function getClientWidth() {
	if (isIE) {
		return document.body.clientWidth;
	} else {
		return window.innerWidth;
	}
}

function getClientHeight() {
	if (isIE) {
		return document.body.clientHeight;
	} else {
		return window.innerHeight;
	}
}


