/// Prevents the default action associated with the event.
/// return PreventDefaultAction(event);
function PreventDefaultAction(e)
{
	e = e || window.event;

	if (!(e)) return false

	if (e.preventDefault) e.preventDefault();
	else e.returnValue = false;
	
	return false;
}

/// Adds an event listener to the control.
/// AddEventListener(control, "click", MyEventHandler);
function AddEventListener(control, eventName, handler)
{
	if (!(control)) return;

	if (window.addEventListener) control.addEventListener(eventName, handler, false);
	else control.attachEvent("on" + eventName, handler);
}


// A class for determining a value of a pressed key in an event.
var KeyValidator = new Object();

KeyValidator.isNumericKey = function(key, allowDecimals, allowNegative)
	{
		return ((key >= 48) && (key <= 57)) // Classic numeric keys
		|| ((key >= 96) && (key <= 105)) // Numpad numeric keys
		|| (allowDecimals && ((key == 188) || (key == 190) || (key == 110) || (key == 78)))	// , . Numpad. OperaNumpad.
		|| (allowNegative && ((key == 189) || (key == 109) || (key == 45))) // - Numpad- OperaNumpad-
	}
KeyValidator.isMovementKey = function(key)
	{
		return ((key >= 33) && (key <= 40)) // Movement keys
	}
KeyValidator.isBackspaceKey = function(key)
	{
		return (key == 8); // Backspace
	}
KeyValidator.isTabKey = function(key)
	{
		return (key == 9); // Tabulator
	}
KeyValidator.isBackspaceOrDeleteKey = function(key)
	{
		return (key == 8) || (key == 46); // Backspace or delete
	}
KeyValidator.isSelOrCopyKey = function(key, ctrlPressed)
	{
		return (ctrlPressed && ((key == 65) || (key == 67))); // CTRL+A,C
	}
KeyValidator.isSelCopyPasteCutKey = function(key, ctrlPressed)
	{
		return (ctrlPressed && ((key == 65) || (key == 67) || (key == 86) ||(key == 88))); // CTRL+A,C,V,X
	}