
onerror = errorHandler;
function errorHandler(errorMessage, url, line) {
//alert (errorMessage + "   " + line);
return false;
}

function HelpWindow(src) {
    win=window.open('/pan/helpTextServlet?helpText=' + src,'wnd','toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width=300,height=300,screenX=0,screenY=0,top=0,left=0');
    win.focus();
}

function PopUp(textKeyBody,textKeyTitle,width,height) {
   win=window.open('/pan/helpTextServlet?helpText='+textKeyBody+'&helpTextTitle='+textKeyTitle+'&helpTextWidth='+width+'&helpTextHeight='+height,'wnd','toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width='+width+',height='+height+',screenX=0,screenY=0,top=0,left=0');
   win.focus();
}

function CustomWindow(url, width, height) {
   win=window.open(url,'CustomWindow','toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width='+width+',height='+height+',screenX=0,screenY=0,top=0,left=0');
   win.focus();
}

function PopGe(id) {
    win=window.open('/pan/graphicalElementController?action=showGraphicalElement&graphicalElementId=' + id,'gewindow','toolbar=no,location=no,menu=no,scrollbars=no,directories=no,resizable=yes,width=300,height=300,screenX=0,screenY=0,top=0,left=0');
    win.focus();
}


originalColorArray = new Array();

function changeBg(tr) {
	if (isTrMarked(tr)) return;
	var children = tr.childNodes;
	tmpArray = new Array();
	if (tr.children) {
		for (var i=0;i < children.length; i++) {
			tmpArray[i] = tr.children[i].bgColor;
			tr.children[i].bgColor='cccccc';
		}
	}
	originalColorArray[tr.rowIndex] = tmpArray;
}

function resetBg(tr) {
	if (isTrMarked(tr)) return;
	tmpArray = originalColorArray[tr.rowIndex];
	var children = tr.childNodes;
	if (tr.children) {
		for (var i=0;i < children.length; i++) {
			tr.children[i].bgColor=tmpArray[i];
		}
	}
}

function isTrMarked(tr) {

	if (tr.children && tr.children[0].bgColor=='#437ca7') {
		return true;
	}
	return false;
}

function markTr(tr) {
	var children = tr.childNodes;
	var doStyle = true;
	if (isTrMarked(tr)) {
		unMarkTr(tr);
	} else {
		tmpArray = new Array();
		if (tr.children) {
			for (var i=0;i < children.length; i++) {
				tr.children[i].bgColor='437CA7';
				if (tr.children[i].style.color == "red") {
					tr.children[i].style.color="ffff00";
				} else {
					tr.children[i].style.color="ffffff";
				}
				if (tr.children[i].childNodes[0] != null && tr.children[i].childNodes[0].nodeName == "A") {
					tr.children[i].childNodes[0].style.color="ffffff";
				}
			}
		}
	}
}

function unMarkTr(tr) {
	var children = tr.childNodes;
	tmpArray = originalColorArray[tr.rowIndex];
	if (tr.children) {
		for (var i=0;i < children.length; i++) {
			tr.children[i].bgColor=tmpArray[i];
			if (tr.children[i].style.color == "#ffff00") {
				tr.children[i].style.color="red";
			} else {
				tr.children[i].style.color="000000";
			}
			if (tr.children[i].childNodes[0].nodeName == "A") {
				tr.children[i].childNodes[0].style.color="305E80";
			}
		}
	}
}


function getById(id) {
   return document.getElementById?document.getElementById(id):(document.all?document.all(id):null);
}

function hideDiv(id) {
   getById(id).style.visibility = "hidden";
   getById(id).style.display = "none";
}

function showDiv(id) {
   	getById(id).style.visibility = "visible";
   	getById(id).style.display = "inline";
}

function doNothing() {}

function getScroll() {
	if (document.all) {
		var ieBox = document.compatMode != "CSS1Compat";
		var cont = ieBox ? document.body : document.documentElement;
		return {x:cont.scrollLeft, y:cont.scrollTop};
	} else {
		return {x:window.pageXOffset, y:window.pageYOffset};
	}
}

function hidePopBox() {
	hideDiv('popBox');
	hideDiv('popBoxShadow');
}

var timeout;
function showPopBox(e,w,h,code) {
	var x = (window.event) ? window.event.x : e.pageX;
	var y = (window.event) ? window.event.y : e.pageY;
	if (document.all) {
		var scroll = getScroll();
		y = y + scroll.y;
	}
	getById('popBox').style.width = w;
	getById('popBox').style.height = h;
	getById('popBoxShadow').style.width = w;
	getById('popBoxShadow').style.height = h;
	getById('popBox').style.top = y+10;
	getById('popBox').style.left = x;
	getById('popBoxShadow').style.top = y+13;
	getById('popBoxShadow').style.left = x+3;
	getById('popBox').innerHTML = code;
	showDiv('popBox');
	showDiv('popBoxShadow');

	timeout = setTimeout("hideDiv('popBox');hideDiv('popBoxShadow');", 3000);
}

function replace(a,b,c) {
	while (a.indexOf(b)>-1) {
		pos = a.indexOf(b);
		a = '' + (a.substring(0, pos) + c + a.substring((pos + b.length), a.length));
	}
	return a;
}

function popBoxOut(){
    timeout = setTimeout("hideDiv('popBox');hideDiv('popBoxShadow');", 0);
}
