/*<P><!--This information displays in Internet Explorer when page is loaded as an HTML document-->


<HTML><HEAD><TITLE>JavaScript Debugging Assistant</TITLE></HEAD><BODY GCOLOR="ffffff">
This tool must be imported into the document of the page that contains the script that you wish to debug.  Place the following code into the &lt;HEAD&gt; section of your document:<P>
&lt;SCRIPT LANGUAGE="JavaScript" SRC="jda.js"&gt;&lt;/SCRIPT&gt;<P>Make sure that the "jda.js" file is also saved in the same directory as the web page that you are debugging.

<!--End instructional information-->
<!--
*/


////////////////////////////////////////////
/// JavaScript Debugging Assistant		////
/// version 1.0							////
/// 									////
/// Dates Created 11/20 - 12/1/2000		////
/// 									////
/// by Jebeze Alexander					////
/// e-mail: jebeze@webhammer.com		////
////////////////////////////////////////////




var errWin = ""
var errArray = new Array()
var errCounter = 0
var displayID


window.onerror = errWindow


if (navigator.appName == "Microsoft Internet Explorer") {
	sHeight = screen.height - 275
	sWidth = screen.width - 388
}
else if (navigator.appName == "Netscape") {
	sHeight = screen.availHeight - 240
	sWidth = screen.availWidth - 373
}
else {
	sHeight = 0
	sWidth = 0
}


function errWindow(msg, URL, linenum) {
	if (displayID) {
		clearTimeout(displayID)
	}
	errArray[errCounter] = URL + "::" + linenum + "::" + msg
	++errCounter
	displayID = setTimeout("displayErrors()",500)
	return true
 }
 
 

 
 
function displayErrors() {
	if (!errWin || errWin.closed) {
		errWin = window.open("","error","height=210,width=360,top=" + sHeight + ",left=" + sWidth + ",menubar=no, toolbars=no,status=no,location=no,scrollbars=yes,personalbar=no")
	}
	errCounter = 0
	writeToWin(0)
}
 

function writeToWin(errArg) {
	
	var theError = errArray[errArg].split("::")
	var eURL = theError[0]
	var eLineNum = theError[1]
	var eMsg = theError[2]
	
	var errFound = false
	
	if (eLineNum == 0) {
		eLineNum += " (may have occured in an event handler)"
	}
	
	//errWin.document.open("text/html",replace)
	errWin.document.writeln("<HTML>")
	errWin.document.writeln("<HEAD>")
	errWin.document.writeln("<TITLE>JavaScript Debugging Assistant</TITLE>")
	errWin.document.writeln("</HEAD>")
	errWin.document.writeln("<BODY BGCOLOR='#ffffff' TOPMARGIN=8 STYLE='position:relative; top: -4; left: -2'>")
	errWin.document.writeln("<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=0 WIDTH='100%'>")
	errWin.document.writeln("<TR ALIGN=left>")
	errWin.document.writeln("<TD BGCOLOR=#D7A665>")
	errWin.document.writeln("<B><FONT FACE='Verdana, Arial, Helvetica' SIZE=2 COLOR=#583406 STYLE='font-size: 10px'>JavaScript Debugging Assistant</FONT></B>")
	errWin.document.writeln("</TD>")
	errWin.document.writeln("<TD ALIGN=center BGCOLOR=#583406>")
	errWin.document.writeln("<FONT FACE='Verdana, Arial, Helvetica' SIZE=1 COLOR=#d7a665 STYLE='font-size: 9px'>")
	errWin.document.write("<A HREF=\"javascript: opener.displayInfo('about')\" STYLE='text-decoration: none; color: #d7a665'>")
	errWin.document.write("about")
	errWin.document.writeln("</A>")
	errWin.document.writeln("<FONT COLOR=#d7a665 STYLE='font-size: 9px'>")
	errWin.document.writeln(" | ")
	errWin.document.writeln("</FONT>")
	errWin.document.write("<A HREF=\"javascript: opener.displayInfo('help')\" STYLE='text-decoration: none; color: #d7a665'>")
	errWin.document.write("help")
	errWin.document.writeln("</A>")
	errWin.document.writeln("</FONT>")
	errWin.document.writeln("</TD>")
	errWin.document.writeln("</TR>")
	errWin.document.writeln("</TABLE>")
	errWin.document.writeln("<FONT FACE='Verdana, Arial, Helvetica' SIZE=1 STYLE='font-size: 9px'>")
	errWin.document.writeln("<BR>")
	errWin.document.writeln("<B>")

	if (errArray.length == 1) {
		errWin.document.writeln("An error occured")
	}
	else {
		errWin.document.writeln("error " + (parseInt(errArg) + 1) + " of " + errArray.length)
	}
	
	errWin.document.writeln("</B>")
	errWin.document.writeln("<BR><BR>")
	errWin.document.writeln("<B>file: </B>")
	errWin.document.writeln(eURL)
	errWin.document.writeln("<BR>")
	errWin.document.writeln("<B>in the vicinity of line: </B>")
	errWin.document.writeln(eLineNum)
	errWin.document.writeln("<BR><BR>")
	errWin.document.writeln("<B>error message: </B>")
	errWin.document.writeln("<FONT COLOR=red>")
	errWin.document.writeln(eMsg)
	errWin.document.writeln("</FONT>")
	errWin.document.writeln("<P>")
	errWin.document.writeln("<B>description: </B>")
	for (i=1; i <= totalMsgs; ++i) {
		var item1 = eval("errMsg" + i + ".matchStringNS")
		var item2 = eval("errMsg" + i + ".matchStringIE")
		if ((item1 != "" & eMsg.indexOf(item1) >= 0) || (item2 != "" && eMsg.indexOf(item2) >= 0)) {
			errWin.document.writeln(eval("errMsg" + i + ".description"))
			errFound = true
			break
		}
	}
	if (!errFound) {
		errWin.document.writeln(errMsg0.description)
	}
	
	
	
	errWin.document.writeln("<CENTER>")
	errWin.document.writeln("<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH='100%'>")
	errWin.document.writeln("<TR>")

	if (errArg != 0) {
		errWin.document.writeln("<TD>")
		errWin.document.writeln("<BR>")
		errWin.document.writeln("<FONT FACE='Verdana, Arial, Helvetica' SIZE=1>")
		errWin.document.write("<A HREF=\"javascript: opener.writeToWin(" + (parseInt(errArg) - 1) + ")\" STYLE=\"text-decoration: none\">")
		errWin.document.write("&lt;--")
		errWin.document.write("Previous Error")
		errWin.document.writeln("</A>")
		errWin.document.writeln("</FONT>")
		errWin.document.writeln("</TD>")
	}
	
	
	if (errArg != (errArray.length - 1)) {
		errWin.document.writeln("<TD>")
		errWin.document.writeln("<BR>")
		errWin.document.writeln("<FONT FACE='Verdana, Arial, Helvetica' SIZE=1>")
		errWin.document.write("<A HREF=\"javascript: opener.writeToWin(" + ++errArg + ")\" STYLE=\"text-decoration: none\">")
		errWin.document.write("Next Error")
		errWin.document.write("--&gt;")
		errWin.document.writeln("</A>")
		errWin.document.writeln("</FONT>")
		errWin.document.writeln("</TD>")
	}
	
	errWin.document.writeln("</TR>")
	errWin.document.writeln("</TABLE>")
	errWin.document.writeln("<CENTER>")

	
	errWin.document.writeln("</FONT>")
	errWin.document.writeln("</BODY>")
	errWin.document.writeln("</HTML>")
	errWin.document.close()
	errWin.focus()
	
	//errArray = ""
	
}



function closeIt() {
	if (errWin && !errWin.closed) {
		errWin.close()
	}
}

if (window.onunload) {
	closeIt()
}


function onunload() {
	closeIt()
}



function displayInfo(theInfo) {

	(theInfo == "about") ? theOther = "help" : theOther = "about"
	errWin.document.writeln("<HTML>")
	errWin.document.writeln("<HEAD>")
	errWin.document.writeln("<TITLE>JavaScript Debugging Assistant</TITLE>")
	errWin.document.writeln("</HEAD>")
	errWin.document.writeln("<BODY BGCOLOR='#ffffff' TOPMARGIN=8 STYLE='position:relative; top: -4; left: -2'>")
	errWin.document.writeln("<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=0 WIDTH='100%'>")
	errWin.document.writeln("<TR ALIGN=left>")
	errWin.document.writeln("<TD BGCOLOR=#D7A665>")
	errWin.document.writeln("<B><FONT FACE='Verdana, Arial, Helvetica' SIZE=2 COLOR=#583406 STYLE='font-size: 10px'>JavaScript Debugging Assistant</FONT></B>")
	errWin.document.writeln("</TD>")
	errWin.document.writeln("<TD ALIGN=center BGCOLOR=#583406>")
	errWin.document.writeln("<FONT FACE='Verdana, Arial, Helvetica' SIZE=1 COLOR=#d7a665 STYLE='font-size: 9px'>")
	errWin.document.write("<A HREF='javascript: opener.writeToWin(0)' STYLE='text-decoration: none; color: #d7a665'>")
	errWin.document.write("error")
	if (errArray.length > 1) {
		errWin.document.write("s")
	}
	errWin.document.writeln("</A>")
	errWin.document.writeln("<FONT COLOR=#d7a665 STYLE='font-size: 9px'>")
	errWin.document.writeln(" | ")
	errWin.document.writeln("</FONT>")
	errWin.document.write("<A HREF=\"javascript: opener.displayInfo('" + theOther + "')\" STYLE='text-decoration: none; color: #d7a665'>")
	errWin.document.write(theOther)
	errWin.document.writeln("</A>")
	errWin.document.writeln("</FONT>")
	errWin.document.writeln("</TD>")
	errWin.document.writeln("</TR>")
	errWin.document.writeln("</TABLE>")
	errWin.document.writeln("<FONT FACE='Verdana, Arial, Helvetica' SIZE=1 STYLE='font-size: 9px'>")
	errWin.document.writeln("<BR>")
	if (theInfo == "about") {
		errWin.document.writeln(aboutText)
	}
	else {
		errWin.document.writeln(helpText)
	}
	errWin.document.writeln("</FONT>")
	errWin.document.writeln("</BODY>")
	errWin.document.writeln("</HTML>")
	errWin.document.close()
	errWin.focus()

}


// READ ME info

var aboutText = "<B>About the JavaScript Debugging Assistant</B><P>Error messages are generated by the web browser whenever it encounters a syntax error in your script.  These error messages are educated guesses about the cause of the problem. They provide minimal feedback by way of a line number and a very curt description.  The web browser is often wrong in its estimation, and in either case the feedback that it provides is hardly informative.<P>The JavaScript Debugging Assistant (JDA) serves to aid in the debugging process.  It is only needed when you are writing and testing your scripts.  Once you have worked out the kinks in your script, you should remove the link to the JDA from your code. It helps you to make sense of the error messages that are generated by the web browser by elaborating on what these error messages mean and providing suggestions as to where to look in your script for potential errors.<P>The JDA will not \"debug\" your code for you - it will not step through your code line by line to locate specific syntax errors.  You will have to use your noggin to find these errors.  However, the JDA serves to ease some of the technical and informational obstacles in this process.  If you are familiar with the debugging process in Netscape or Internet Explorer, you may be wondering how the JDA is different from the \"JavaScript Console\" that is built into Netscape or the \"Script Debugger\" that is available to IE on the PC.  In some respects the JDA is not very different.  It is triggered in the same instances as these debugging utilities, however, the JDA differs in the following ways which make it a superior utility for debugging:<UL><LI><B>The JDA works cross-browser and cross-platform.</B>  Unlike the \"Script Debugger\" and the \"JavaScript Console\", you can use the JDA on both Netscape and Internet Explorer for both Mac and PC.<P><LI><B>The JDA pops-up instantly and conveniently when an error is encountered.</B> Unlike the \"JavaScript Console\" which requires you to type \"javascript:\" in the location box when you \"suspect\" that an error has occurred or like the \"Script Debugger\" which presents you with a confirmation dialog box each time an error is encountered, the JDA automatically opens a small sub-window that displays all of the information about that error.<P><LI><B>You know when your scripts are successful.</B> Because the JDA opens a sub window automatically when it encounters an error, you know when your scripts are running smoothly.<P><LI><B>The JDA is informative.</B> The JDA provides you with more information about what the problem could potentially be.<P><LI><B>The JDA organizes multiple error messages.</B> When there is more than one error in your script, the JDA makes it easy for you to view each of these messages.  Unlike the \"JavaScript Console\", it displays the error in the same order that they are encountered in your script. This is useful because the first error messages encountered are usually more accurate than the later messages.<P><LI><B>The JDA automatically clears the error history.</B> When using the \"JavaScript Console\" you have to do this often in order to accurately read the messages that are displayed.  This often adds several additional steps to the debugging process.<P><LI><B>The JDA is written entirely in JavaScript.</B> The JDA is a great example of JavaScript at work.  The code is open source.  You can open it up in a text editor and see how it works.  You can improve upon it, customize it, learn from it, or change it for your own uses.<P></UL><P>"



var helpText = "<B>Help for the JavaScript Debugging Assistant</B><P>There is no help information available yet.</P>"











//Error Message database






var errMsg0 = new Object()
errMsg0.title = ""
errMsg0.matchStringNS = ""
errMsg0.matchStringIE = ""
errMsg0.description = "There is no description in the database for this error message."






var errMsg1 = new Object()
errMsg1.title = "[something] is not defined or Object Expected"
errMsg1.matchStringNS = "is not defined"
errMsg1.matchStringIE = "Object expected"
errMsg1.description = "This error is triggered whenever JavaScript believes it has encountered an error in the name, use, or definition of a variable, function, or object.  Unfortunately, JavaScript is sometimes confused when it displays this error - the problem may be related to imbalanced curly braces or parentheses in any statement above this line number.<P>Here are some scenarios that may trigger this message.<P>If the item is a variable: you have tried to read a variable that you have not declared, you forgot to enclose a string in quotes and JavaScript thinks its a variable, you misspelled the name of a previously declared variable or are using the incorrect case to reference it, or tried to use a local variable in another function. <P>If the item is an object or function, perhaps you have misspelled it or are using the wrong case to access it, or you have tried to access an object that does not exist in the DOM for that browser."




var errMsg2 = new Object()
errMsg2.title = "[something] is not a function"
errMsg2.matchStringNS = "is not a function"
errMsg2.matchStringIE = ""
errMsg2.description = "This error is triggered whenever JavaScript is confused about the name or definition of a function or method.  Perhaps you have mismatched the case of letters in a function or a method call or are using a method that is not available to an object (this happens when you are trying to close a window that has already been closed). Sometimes this error also appears when other problems exist in the script above the function named in the error message, and this function is the last one in a script."




var errMsg3 = new Object()
errMsg3.title = "Missing { before function body"
errMsg3.matchStringNS = "missing { before function body"
errMsg3.matchStringIE = "Expected '{'"
errMsg3.description = "This error is triggered when JavaScript believes that a closing brace is missing at the start of a function or at the start of any conditional statements within that function."



var errMsg4 = new Object()
errMsg4.title = "Missing } after function body"
errMsg4.matchStringNS = "missing } after function body"
errMsg4.matchStringIE = "Expected '}'"
errMsg4.description = "This error is triggered when JavaScript believes that a closing brace is missing at the end of a function or at the end of any conditional statements within that function."




var errMsg5 = new Object()
errMsg5.title = "[something] is not a number"
errMsg5.matchStringNS = "is not a number"
errMsg5.matchStringIE = ""
errMsg5.description = "This error is triggered when a variable is being used in a statement and that variable is a string, a null value, an undefined value, or has never been declared.  If you are not sure of the data type of a variable destined for a math operation, you can use the parseInt() or parseFloat() functions to convert strings to numbers."




var errMsg6 = new Object()
errMsg6.title = "[something] has no property named"
errMsg6.matchStringNS = "has no property named"
errMsg6.matchStringIE = ""
errMsg6.description = "This error is triggered when you have incorrectly attempted to reference a property of a JavaScript object using dot syntax.  Here are some typical errors: you have incorrectly spelled the object or property, you're trying to retrieve a property that doesn't exist for that object, or you have forgotten to include [] brackets for an object that can have more than one instance (e.g. images[], forms[], elements[], links[], etc.)."




var errMsg7 = new Object()
errMsg7.title = "[something] has no property indexed by [i]"
errMsg7.matchStringNS = "has no property indexed by"
errMsg7.matchStringIE = ""
errMsg7.description = "This error typically appears when you have appended a set of [] brackets to an object that only has one instance within a page."





var errMsg8 = new Object()
errMsg8.title = "[something] can't be set by assignment"
errMsg8.matchStringNS = "can't be set by assignment"
errMsg8.matchStringIE = ""
errMsg8.description = "This error message is typically triggered when you are trying to change the value of a property that is read-only (e.g. \"navigator.appName\")."





var errMsg9 = new Object()
errMsg9.title = "Test for equality (==) mistyped as assignment (=)?"
errMsg9.matchStringNS = "test for equality (==) mistyped as assignment (=)?"
errMsg9.matchStringIE = ""
errMsg9.description = "Remember that a single = sign is used to assign a value to a variable.  A double == sign is used to compare to values in a condition."




var errMsg10 = new Object()
errMsg10.title = "Function does not always return a value"
errMsg10.matchStringNS = "function does not always return a value"
errMsg10.matchStringIE = ""
errMsg10.description = "Using the \"return\" keyword as the final statement, a function can return a value that can be used on the right side of an assignment operator. You can use a set of conditional statements to have the function return different values based on different criteria.  JavaScript checks the organization of the function, if you are missing a return value, this error message is triggered."





var errMsg11 = new Object()
errMsg11.title = "Access disallowed from scripts at URL to documents at URL"
errMsg11.matchStringNS = "access disallowed from scripts at"
errMsg11.matchStringIE = ""
errMsg11.description = "JavaScript has some restrictions on how frames and windows can communicate. This error is triggered when a script in one frame or window tries to access a property or similar information about the content of another frame whose protocol, server, or host is different.<P>If the two sites have the same domain (for example, webhammer.com) but different server names or protocols, you can, however, set the document.domain properties of documents so that they recognize each other as equals."





var errMsg12 = new Object()
errMsg12.title = "Too many JavaScript errors"
errMsg12.matchStringNS = "too many JavaScript errors"
errMsg12.matchStringIE = ""
errMsg12.description = "This error sometimes appears up when an error occurs inside a for or while loop and generates more error messages (or windows) than Navigator allows."




var errMsg13 = new Object()
errMsg13.title = "missing ( before formal parameters, missing ( before condition, or Expected '(' "
errMsg13.matchStringNS = "missing ( before"
errMsg13.matchStringIE = "Expected '('"
errMsg13.description = "This error is triggered whenever JavaScript believes that you have forgotten the left parenthesis in a function declaration or conditional statement."



var errMsg14 = new Object()
errMsg14.title = "missing ) before after parameters, missing ) after condition, Expected ')' "
errMsg14.matchStringNS = "missing ) after"
errMsg14.matchStringIE = "Expected ')'"
errMsg14.description = "This error is triggered whenever JavaScript believes that you have forgotten the right parenthesis in a function declaration or conditional statement. Sometimes this error also occurs when a a single or double quote appears within a string that is inside a condition or function.  Remove the quote if possible or precede it with a \ character to turn off its meaning in this instance."



var errMsg15 = new Object()
errMsg15.title = "Unterminated string literal"
errMsg15.matchStringNS = "unterminated string literal"
errMsg15.matchStringIE = ""
errMsg15.description = "This error is triggered when a string is not correctly surrounded by quotes. This type of error is most common when concatenating values and when nesting quotes within an event handler.  An errant enter/return keystroke in the middle of a string will trigger this error as well."





var errMsg16 = new Object()
errMsg16.title = "Missing ; before statement"
errMsg16.matchStringNS = "missing ; before statement"
errMsg16.matchStringIE = "Expected ';'"
errMsg16.description = "This error is usually triggered when you have placed an enter, return keystroke within a statement (or comment), or when you have placed a spacebar or tab keystroke in an inappropriate part of a statement (i.e. within a method or property address).<P>This error <B>can also be triggered</B> by syntax errors within an event handler.  Check the code of your event handlers for missing/extra parentheses or quotes.  Remember that single quotes should be used around strings within an event handler."




var errMsg17 = new Object()
errMsg17.title = "Not an object"
errMsg17.matchStringNS = "has no properties"
errMsg17.matchStringIE = "is not an object"
errMsg17.description = "This error is triggered when you have misspelled an object or array name, tried to access an object that is not in the Document Object Model, or tried to access an object or array that has not been created yet in your script."




var errMsg18 = new Object()
errMsg18.title = "Object doesn't support this property or method "
errMsg18.matchStringNS = ""
errMsg18.matchStringIE = "Object doesn't support this property or method"
errMsg18.description = "This error is triggered when you try to use a method that is not available to an object (e.g. when you try to close a window that has already been closed)."




var errMsg19 = new Object()
errMsg19.title = "Syntax error"
errMsg19.matchStringNS = "syntax error"
errMsg19.matchStringIE = "Syntax error"
errMsg19.description = "This error is often triggered when you have forgotten to surround a string in quotes. Check strings, concatenated values, and nested quotes within an event handler. It can, of course, also be triggered when any sort of syntax error has occurred."




var errMsg20 = new Object()
errMsg20.title = "Missing ; after for-loop condition"
errMsg20.matchStringNS = "missing ; after for-loop condition"
errMsg20.matchStringIE = ""
errMsg20.description = "You have forgotten or mistyped a semicolon within the parentheses of a for loop condition."






var errMsg21 = new Object()
errMsg21.title = "Invalid increment operand"
errMsg21.matchStringNS = "invalid increment operand"
errMsg21.matchStringIE = ""
errMsg21.description = "You have provided an invalid symbol or variable name as the third argument of the for loop condition."



var errMsg22 = new Object()
errMsg22.title = "[something] is undefined"
errMsg22.matchStringNS = ""
errMsg22.matchStringIE = "is undefined"
errMsg22.description = "This error is triggered when you attempt to access the value of a variable, object, or property that has not been created and/or has not been assigned a value."





var errMsg23 = new Object()
errMsg23.title = "Type mismatch"
errMsg23.matchStringNS = ""
errMsg23.matchStringIE = "Type mismatch"
errMsg23.description = "This error is triggered when you perform a mathematical operation using a value that is not a number.  This can be the case when a property has been mispelled; contains a string, true/false value, or other non-numerical value; or, is not a part of the DOM of this browser. Or, when a variable contains a non-numerical value; has not been declared; or, is mispelled."



var totalMsgs = 23


/*
var errMsg = new Object()
errMsg.title = "Lengthy JavaScript still running. Continue?"
errMsg.matchStringNS = "lengthy javascript still running. continue?"
errMsg5.matchStringIE = ""
errMsg.description = "Although not a genuine error message (it appears in a JavaScript confirm dialog box), this alert dialog box provides a safeguard against inadvertent infinite loops and intentional ones triggered by JavaScript tricksters. Instead of permanently locking up the browser, Navigator Üafter processing a large number of rapidly executing script cycles Üasks the user whether the scripts should continue. "Syntax error" JavaScript is best at detecting true syntax errors and showing you the location of the problem. Even if the line counter is off, the chance that the error dialog box accurately shows the problem-causing code fragment and pointer is still good. The errors you've seen here aren't the only error messages that you will encounter in your scripts. Other error messages are pretty smart (for example, a message alerting you that you have only one equal sign when you meant to use two for a conditional test on the equality of two values). The real headaches occur when the error message and your code don't seem to mesh.</P>

-->
<P>
</BODY>
</HTML>
*/


