/**
 * <p>Title: eventTools.js</p>
 * <p>Description: Collection of event management tools.</p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: Kreber Graphics, Inc.</p>
 * @author Charlie Reading
 */

// Includes
var eventtools_js = 1;
var includes = "";
if (includes != "")
{
	alert("eventTools.js: you must first include:\n" + includes);
}

// checkKeypress() return values
kKeypress_OK = 0;
kKeypress_Cancel = 1;
kKeypress_Process = 2;


//
// Check the keypress for OK/Cancel/Process
//
// e = event
//
// returns kKeypress_x value
//
function checkKeypress(e)
{
	var charCode = (bIE ? event.keyCode : e.keyCode);
	var kEscape = (bIE ? 27 : e.DOM_VK_ESCAPE);

	var keypress;
	switch (charCode)
	{
		case 3: 									// Macintosh "Enter" key
		case "\n".charCodeAt(0):	// Line-Feed (this cannot be '\n' -- it doesn't work)
		case "\r".charCodeAt(0):	// Return (this cannot be '\r' -- it doesn't work)
		{
			keypress = kKeypress_OK;
			break;
		}
		case kEscape:							// Escape
		{
			keypress = kKeypress_Cancel;
			break;
		}
		default:
		{
			keypress = kKeypress_Process;
			break;
		}
	}
	return keypress;
}
