/*global JMT Ext $ BackgroundLoad*/
if (!JMT){
	var JMT = {};
}
JMT.keyHandler = function(){
	// public functions
	return { 
		// e is event object passed from function invocation 		
		EnterKeyPressed : function (e,callback,params){
			//literal character code
			var characterCode; 
			
			if (!e) {
				e = window.event;
			}
			// character code is contained in IE's keyCode property
			if (e.keyCode) {
				characterCode = e.keyCode;
			}
			// if which property of event object is supported (NN4)
			else if (e.which) {
				characterCode = e.which;
			}
			//ext method
			else if (e.getKey) {
				characterCode = e.getKey();
			}
		
			// if generated character code is equal to ascii 13 (ie. enter key)
			if(characterCode && characterCode === 13){ 
				if (e.preventDefault) {
					e.preventDefault(); // stop the browser default behavior
				}
				if (typeof callback === 'function') {
					var parameters = Array.prototype.slice.apply(arguments,[2]);
					callback.apply(null,parameters);
				}			
				return false;
			}
			else{
				return true;
			}

		}
	};
}();

