var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
lastSelection = null;

function menuMouseOver(obj) {
    try {
        if(document.all) {
            if(obj.className == "sidemenusel") {
				obj.runtimeStyle.backgroundImage = "url('images/btnbkgrnd.jpg')";
				obj.runtimeStyle.backgroundColor = "#F3D447";
				obj.runtimeStyle.fontWeight = "bold";
				obj.runtimeStyle.color = "#000000";
				obj.runtimeStyle.cursor = "hand";
            } else {
				obj.runtimeStyle.backgroundImage = "url('images/btnbkgrnd.jpg')";
				obj.runtimeStyle.backgroundColor = "#F3D447";
				obj.runtimeStyle.fontWeight = "bold";
				obj.runtimeStyle.color = "#000000";
				obj.runtimeStyle.cursor = "hand";
            }
        }
    } catch(e) {
        alert(e.message);
    }
}

function menuMouseOut(obj) {
    try {
        if(document.all) {
            if(obj.className == "sidemenusel") {
				obj.runtimeStyle.backgroundImage = "url('images/btnbkgrnd.jpg')";
				obj.runtimeStyle.backgroundColor = "#F3D447";
				obj.runtimeStyle.fontWeight = "bold";
				obj.runtimeStyle.fontFamily = "Arial,Helvetica,Verdana,Sans-Serif";
				obj.runtimeStyle.fontSize = "10pt";
				obj.runtimeStyle.color = "#ff0000";
				obj.runtimeStyle.border = "2px groove #808080";
				obj.runtimeStyle.textAlign = "center";
				obj.runtimeStyle.width = "100px";
				obj.runtimeStyle.cursor = "default";
            } else {
				obj.runtimeStyle.backgroundImage = "url('images/btnbkgrnd.jpg')";
				obj.runtimeStyle.backgroundColor = "#F3D447";
				obj.runtimeStyle.fontWeight = "normal";
				obj.runtimeStyle.fontFamily = "Arial,Helvetica,Verdana,Sans-Serif";
				obj.runtimeStyle.fontSize = "10pt";
				obj.runtimeStyle.color = "#000000";
				obj.runtimeStyle.border = "2px groove #808080";
				obj.runtimeStyle.textAlign = "center";
				obj.runtimeStyle.width = "100px";
				obj.runtimeStyle.cursor = "default";
            }
        }
    } catch(e) {
        alert(e.message);
    }
}

function doPageHeader(head) {

	var wrd = head.split(" ");
	for(var i = 0; i < wrd.length; i++) {
		if(i > 0) document.write("&nbsp;");
		document.write("<font class=container>" + wrd[i] +
			"<font class=titleText>" + wrd[i] + "</font>" +
			"</font>");
	}

}

function doSubTitleText(head) {

	var wrd = head.split(" ");
	for(var i = 0; i < wrd.length; i++) {
		if(i > 0) document.write("&nbsp;");
		document.write("<font class=titleShadow>" + wrd[i] +
			"<font class=title>" + wrd[i] + "</font>" +
			"</font>");
	}

}

function showImage(imName, imWidth, imHeight) {

	var winDlg = new Object();

	winDlg.width = imWidth + 40;
	winDlg.height = imHeight + 76;
	winDlg.name = (new Date()).getSeconds().toString();

	if (Nav4) {
		winDlg.left = window.screenX + ((window.outerWidth - winDlg.width) / 2);
		winDlg.top = window.screenY + ((window.outerHeight - winDlg.height) / 2);
		var attr = "screenX=" + winDlg.left + ",screenY=" + winDlg.top +
			",resizable=no,width=" + winDlg.width + ",height=" + winDlg.height;
	} else {
		winDlg.left = (screen.width - winDlg.width) / 2;
		winDlg.top = (screen.height - winDlg.height) / 2;
		var attr = "left=" + winDlg.left + ",top=" + winDlg.top + ",resizable=no," +
			"width=" + winDlg.width + ",height=" + winDlg.height;
	}

	winDlg = window.open("", winDlg.name, attr)
	winDlg.document.write("<form>");
	winDlg.document.write("<table width=100% cellpadding=2 cellspacing=2 border=0>");
	winDlg.document.write("<tr><td width=100% align=center>");
	winDlg.document.write("<img src=" + imName + " border=0>");
	winDlg.document.write("</td></tr>");
	winDlg.document.write("<tr><td align=center>");
	winDlg.document.write("<input type=button value=\"Close\" style=\"width:120pt; height: 20pt;\" onclick=\"window.close();\">");
	winDlg.document.write("</td></tr></table></form>");

	winDlg.focus()

}

function showPage(urlname, mwidth, mheight, isScroll) {
	if (Nav4) {
		var leftpnt = window.screenX + ((window.outerWidth - mwidth) / 2);
		var toppnt = window.screenY + ((window.outerHeight - mheight) / 2);
		var attr = "screenX=" + leftpnt + ",screenY=" + toppnt + ",resizable=no,height=" + 
			mheight + ",width=" + mwidth + ",scrollbars=" + isScroll;
	} else {
		var leftpnt = ((screen.width - mwidth) / 2);
		var toppnt = ((screen.height - mheight) / 2);
		var attr = "left=" + leftpnt + ",top=" + toppnt + ",resizable=no,height=" + 
			mheight + ",width=" + mwidth + ",scrollbars=" + isScroll;
	}
	var dlg = window.open(urlname, (new Date()).getSeconds().toString(), attr);
}

function setHeaders() {
	var d = document.getElementById("spnData");
	var h = document.getElementById("spnHeader");
	h.scrollLeft = d.scrollLeft;
}

function select(element) {

	var e, r, c, theEvent, browser;

	try {
		if(!Nav4) {
			if(window.event) {
				theEvent = window.event;
			} else if(arguments.callee.caller) {
				theEvent = arguments.callee.caller.arguments[0];
			}

			if(theEvent) {
				if(theEvent.srcElement) {
					e = theEvent.srcElement;
				} else if(theEvent.currentTarget) {
					e = theEvent.currentTarget;
				} else if(theEvent.target) {
					e = theEvent.target;
				}
			}
		} else {
			theEvent = element;
			e = element.target;
		}

		if(e.tagName == "TR") {
			r = e;
		} else {
			r = findRow(e);
		}

		if((r != null) && (r.id != "")) {
			if(lastSelection != null) {
				deselectRowOrCell(lastSelection);
			}
			lastDefColour = r.style.backgroundColor;
			selectRowOrCell(r);
			lastSelection = r;
			rowid = r.id;
		}
	} catch(e) {
		alert(e.message);
	}

}

function cancelSelect() {

	var theElement = null;
	var theEvent = null;
	var e = null;
	var r = null;

	if(window.event) {
		theEvent = window.event;
	} else if(arguments.callee.caller) {
		theEvent = arguments.callee.caller.arguments[0];
	}

	if(theEvent != null) {
		if(theEvent.srcElement) {
			e = theEvent.srcElement;
		} else if(theEvent.currentTarget) {
			e = theEvent.currentTarget;
		} else if(theEvent.target) {
			e = theEvent.target;
		}
	}

	if(e != null) {
		if (e.tagName != "BODY") return;
		if (lastSelection != null) {
   			deselectRowOrCell(lastSelection);
    		lastSelection = null;
  		}
  	}
}

document.onclick = cancelSelect;

function findRow(e) {

	var p;

	if(e.tagNAme == "TR") {
		return e;
	} else {
		p = e.parentNode;
		while((p.tagName != "TABLE") && (p.tagName != "BODY") && (p.tagName != "TR")) {
			p = p.parentNode;
		}
		if(p.tagName == "TR") {
			return p;
		} else {
			return null;
		}
	}
}

function findCell(e) {
	if (e.tagName == "TD") {
    	return e;
  	} else if (e.tagName == "BODY") {
    	return null;
  	} else {
    	return findCell(e.parentNode);
  	}
}

function deselectRowOrCell(r) {
  	var browser;

  	if(navigator.appName.indexOf("Microsoft Internet Explorer") >= 0) { browser = "IE"; }
	else { browser = "NS"; }

  	if(browser == "IE") {
  		r.runtimeStyle.backgroundColor = lastDefColour;
  		r.runtimeStyle.color = "";
  	} else {
  		r.style.backgroundColor = lastDefColour;
  		r.style.color = "";
  	}
}

function selectRowOrCell(r) {

  	var foreColour = "#000000";
	var backColour = "#BDBFFF";
	var e, r, browser;

 	if(navigator.appName.indexOf("Microsoft Internet Explorer") >= 0) { browser = "IE"; }
	else { browser = "NS"; }

  	if(browser == "IE") {
  		r.runtimeStyle.backgroundColor = backColour;
  		r.runtimeStyle.color = foreColour;
  	} else {
  		r.style.backgroundColor = backColour;
  		r.style.color = foreColour;
  	}

}

function nothingSelected() {
  	return (lastSelection == null);
}

function rowSelected() {
  	var c;
  	if(lastSelection == null) return false;
  	c = lastSelection;
  	return (c.tagName == "TR");
}

function cellSelected() {
  	var c;
  	if (lastSelection == null) return false;
	c = lastSelection;
	return (c.tagName == "TD");
}

function whatIsSelected() {
  	if(lastSelection == null)
    	return "Table";
  	if(lastSelection.tagName == "TD")
    	return "Cell";
  	if(lastSelection.tagName == "TR")
    	return "Row";
}
