function goTheme(loc) {
	window.navigate(loc);
}

function goThemeP(loc) {
	parent.navigate(loc);
}

var curRow= null;
var openValueID = "";
var openLableID = "";
function openSelectClientSuppliedDomain(valueID,lableID,recall,isClick) {
				if (isClick && document.all["select"].style.display == "block")
				{
					document.all["select"].style.display = "none";
					return;
				}
				openValueID = valueID;
				openLableID = lableID;
				if (valueID != "") {
					document.all[valueID].value = "";
				}

				document.all["select"].style.left = getOffsetLeft(lableID);
				document.all["select"].style.top = getOffsetTop(lableID)+16;
				document.all["select"].style.display = "block";
				/*try {
					document.all[lableID].focus();
				} catch(e){}*/
}

function closeSelect() {
				openValueID = "";
				openLableID = "";
				document.all["select"].style.height = 0;
				document.all["select"].style.display = "none";
}

function resetSelect() {
				//try {
					if (document.activeElement.id != openLableID || event.keyCode==27) { // 27: Esc, 13: Enter
						if (openValueID != "" && openLableID != "") {
							document.all[openValueID].value = "";
							document.all[openLableID].value = "";
						}
						closeSelect();
					}
				/*}
				catch(e) {
					if (openValueID != "" && openLableID != "") {
						document.all[openValueID].value = "";
						document.all[openLableID].value = "";
					}
					closeSelect();
				}*/
}

function showList(valueID,lableID) { // Show the select list
				var listHeight = document.frames.select.document.all["list"].offsetHeight;
				var availableHeight = document.body.offsetHeight-document.all["select"].offsetTop+document.body.scrollTop;

				if (listHeight < 288) {
					if (listHeight > availableHeight) {
						document.all["select"].style.height = availableHeight;
						document.frames.select.document.all['dropDown'].width-=15;
					}
					else
						document.all["select"].style.height = listHeight;
					document.all["select"].style.width = 162;
				}
				else {
					if (288 > availableHeight) {
						document.all["select"].style.height = availableHeight;
					}
					else
						document.all["select"].style.height = 288;
					document.all["select"].style.width = 177;
				}

				var listWidth = document.frames.select.document.all["list"].offsetWidth;
				var availableWidth = document.body.offsetWidth-document.all["select"].offsetLeft;

				if (listWidth > availableWidth) {
					document.frames.select.document.all['dropDown'].width = availableWidth-15;
					document.all["select"].style.width = availableWidth;
				}

				// Now select first row on list...
				highlight(document.frames.select.document.all['dropDown'].rows[0]);
				dropDownJustKeyNavigated= true;
}

function unhighlight() {
				//try {
					if (curRow) {
						curRow.style.backgroundColor= "#FFFBF0";
						curRow.style.color="#003366";
						curRow.style.fontWeight="normal";
					}
					curRow= null;
				//} catch(e){}
}
var dropDownJustKeyNavigated= false;

function mouseHighlight(row) {
//				try {
					if (!dropDownJustKeyNavigated) {
						highlight(row);
					}
					dropDownJustKeyNavigated= false;
//				} catch(e){}
}

function highlight(row) {
//				try {
					unhighlight();
					row.style.backgroundColor= "#456F8F";
					row.style.color="#FFFBF0";
					row.style.fontWeight="bold";
					
					// This litle trick ensures that the row is visible without it getting focus...
					var focusedElm= document.activeElement;
//					row.firstChild.focus();
//					focusedElm.focus();

					curRow= row;
//				} catch(e){}
}



function getOffsetLeft(eln) {
				var el = document.all[eln];
				var ol = el.offsetLeft;
				while ((el = el.offsetParent) != null) ol += el.offsetLeft;
				return ol;
}

function getOffsetRight(eln) {
				var el = document.all[eln];
				var ol = 0; //el.offsetLeft;
				//ol += Number(el.width);
				while ((el = el.offsetParent) != null) {
					if (typeof(el.offsetLeft) != 'undefined')
						ol += Number(el.offsetLeft);
					if (typeof(el.width) != 'undefined' && el.width != '100%')
						ol += Number(el.width);
				}
				return ol;
}

function getOffsetTop(eln) {
				var el = document.all[eln];
				var ot = el.offsetTop;
				if (el.offsetParent != null) {
					el = el.offsetParent;
					while(el.offsetParent != null) {
						ot += el.offsetTop;
						el = el.offsetParent;
					}
				}
				return ot;
}

function activate(id, node) {
	var leftx = getOffsetLeft(node);
	document.all["view1"].innerHTML = '<img src="' + nodes[id][0] + '" width="100" height="100">';
	var l = leftx - 300;
	var ofs = 0;
	if (l < 0) {
		ofs = l;
		l = 0;
	}
	if (id == 9 || id == 10)
		ofs += 40;

	document.all["view1"].style.left = l;
	document.all["view1"].style.top = getOffsetTop(node);
	document.all["view1"].style.zIndex = -1;
	document.all["view1"].style.display = "block";

	document.all["view2"].innerHTML = '<p>' + nodes[id][1] + '</p>';
	document.all["view2"].style.left = l + 105;
	document.all["view2"].style.top = getOffsetTop(node);
	document.all["view2"].style.width = 150 + ofs;
	document.all["view2"].style.zIndex = -1;
	document.all["view2"].style.display = "block";
	document.all["view2"].style.height = document.all["view2"].scrollHeight + 50;
	lastNode = node;
	closeSelect();
}

function activateT(id, node, force) {
	if (opacity > 80 || force) {
		closeSelect();
		var photoid = document.all['pid'+id].value;
		document.all[photoid].src = document.all['pv'+id].value;
		document.all['resume'].innerHTML = document.all[node + 'span'].innerHTML;
	}
}

function adjustViews() {
	if (typeof(lastNode) != "undefined") {
		var leftx = getOffsetLeft(lastNode);
		document.all["view1"].style.left = leftx - 300;
		document.all["view2"].style.left = leftx - 200;
	}
	if (openLableID != "")
		document.all["select"].style.left = getOffsetLeft(openLableID);
}

function activateH(id) {
	var right = getOffsetRight('d' + id) + 10;
	if (history[id][0] != "") {
		document.all["view1"].innerHTML = '<img src="images/' + history[id][0] + '" width="150" height="150">';
		document.all["view1"].style.left = right + descWidth + 10;
		document.all["view1"].style.top = getOffsetTop('d' + id);
		document.all["view1"].style.zIndex = 1;
		document.all["view1"].style.display = "block";
	}
	else
		document.all["view1"].style.display = "none";

	document.all["view2"].innerHTML = '<p>' + history[id][1] + '</p>';
	document.all["view2"].style.left = right;
	document.all["view2"].style.top = getOffsetTop('d' + id);
	document.all["view2"].style.width = descWidth;
	document.all["view2"].style.zIndex = 10;
	document.all["view2"].style.display = "block";
	document.all["view2"].style.height = document.all["view2"].scrollHeight + 50;

	if (lastHist > -1)
		document.all['d' + lastHist].bgColor = lastColor;

	lastColor = document.all['d' + id].bgColor;
	var c;
	if (lastColor == '#000000' || lastColor == '')
		c = '#F0F0F0';
	else
		c = '#FFD7B9';

	document.all['d' + id].bgColor = c;
	lastHist = id;
}

function adjustViewsH() {
	if (lastHist > -1) {
		var right = getOffsetRight('d' + lastHist) + 10;
		document.all["view1"].style.left = right + 160;
		document.all["view2"].style.left = right;
	}
}


