//GLOBAL CONSTANTS
var vbCrLf = "\r\n";
var debugWindow;
var debugCount = 0;
var strHtml;
var strHead = new Array();
var strItem = new Array();

strHtml = "<HTML><HEAD><TITLE>Trace Output</TITLE><LINK rel='STYLESHEET' href='/style/trace.css' type='text/css'></HEAD><BODY marginwidth=0 marginheight=0 scroll=yes>";
strHead[0] = "<TABLE width=100% cellpadding=5 cellspacing=0 border=0 bgcolor=navy><TR><TD><FONT color=white><B>Trace Output</B><BR>";
strHead[1] = "</FONT></TD></TR></TABLE>";
strItem[0] = "<TABLE width=100% cellpadding=5 cellspacing=0 border=0><TR><TD valign=top>";
strItem[1] = "</TD><TD width=100% >";
strItem[2] = "</TD></TR></TABLE>";

//GLOBAL FUNCTIONS

function Trace(str) {
	if (!debugWindow) {
		debugWindow = window.open("","debugWin","toolbar=no,resizable=yes,scrollbars=yes,top=0,left=0,width=200,height=400");
		debugWindow.document.write(strHtml);
	}		
	if (debugCount++==0) {
		if (!document.getElementById) debugWindow.document.write(strItem[1]);
		debugWindow.document.write(strHead[0] + TraceDate() + strHead[1]);
	}
	debugWindow.document.write(strItem[0] + debugCount + "." + strItem[1] + str + strItem[2]);
	debugWindow.scrollTo(0, 65536);
	debugWindow.focus();
}

function TraceDump(str) {
	if (!debugWindow) {
		debugWindow = window.open("","debugWin","toolbar=no,resizable=yes,scrollbars=yes,top=0,left=0,width=200,height=400");
		debugWindow.document.write(strHtml);
	}		
	if (debugCount++==0) {
		if (!document.getElementById) debugWindow.document.write(strItem[1]);
		debugWindow.document.write(strHead[0] + TraceDate() + strHead[1]);
	}
	str = str.replace(/</g, "&lt;");
	str = str.replace(/>/g, "&gt;");
	debugWindow.document.write(strItem[0] + debugCount + "." + strItem[1] + str + strItem[2]);
	debugWindow.scrollTo(0, 65536);
}

function TraceDate() {
	var strDate = new Date().toString();
	strDate = strDate.replace(/GMT-[0-9]* \([A-Za-z ]*\)/, "");
	strDate = strDate.replace(/ [A-Z][SD]T/, "");
	return strDate;
}

function ShowImage(strURL, strTitle, strAlt) {
	if (strURL!="") {
		var intHeight = 200;
		var intWidth = 200;
		var intTop;
		var intLeft;
		var ImageViewer;
		var strImageViewerProperties;

		intTop = window.screen.height;
		intLeft = window.screen.width;
		strImageViewerProperties = "channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=yes,toolbar=no,top="+intTop+",left="+intLeft+",height="+intHeight+",width="+intWidth;

		ImageViewer = window.open("/picture.asp?url="+strURL+"&title="+strTitle+"&alt="+strAlt, "ImageViewer", strImageViewerProperties);
		intTop = (window.screen.availHeight - intHeight)/2;
		intLeft = (window.screen.availWidth - intWidth)/2;

		ImageViewer.resizeTo(intWidth, intHeight);
		ImageViewer.moveTo(intLeft, intTop);
	}
}

function stripAlpha(str) {
	return parseInt(str.replace(/[a-z]*/gi, ""));
}


function IsSelected(strA, strB) {
	var strFunctionOutput;

	if (strA==strB) {
		strFunctionOutput = " selected";
	} else {
		strFunctionOutput = "";
	}

	return strFunctionOutput;
}


function GetTrigger(evt) {
	var objEvent;

	if (!evt) {
		objEvent = event.srcElement;
	} else {
		objEvent = evt.target;
		if (objEvent.nodeType && objEvent.nodeType==3) {
			objEvent = objEvent.parentNode;
		}
	}

	return objEvent;
}
