/**
 * @author Timo 13.2.2006
 */
Log.eventTool={
		_A_BREAK_KEYS:new Array(13),
		ctrlKey:'ctrlKey',
		shiftKey:'shiftKey',
		altKey:'altKey',
		/**
		 * DANISH KEYBOARD by Helge Willum Larsen
		 http://js-world.com/syntax/key_codes.php
		 
		 This document is written by Helge Willum Larsen
		 It contains a list of all "onkeypress", "onkeydown" and "onkeyup" KeyCodes in JavaScript,
		 that can be typed with a DANISH KEYBOARD !!!
		 Other keyboards probably have other KeyCodes.
		 
		 The first section is tested with the Microsoft Internet Explore 5.0 and the Netscape
		 Communicator 4.51. At this time, Netscape didn't support "onkeydown" and "onkeyup".
		 
		 I strongly recommend that you use the "onkeypress" function.
		 It has the greatest browser-compatibility.
		 Otherwise, you can maybe use some of the codes in the bottom of the page:
		 
		 KeyCodes (ALL keyboards):	onkeypress		Tested with Internet Explore 5.0
		 By: Helge Willum Larsen					and Netscape Communicator 4.51
		 on a DANISH keyboard
		 
		 SUPPORTS MULTIPLE KEYPRESSES:
		 [A] = [a]
		 [Shift] + [A] = [A]
		 [CapsLock] + [A] = [A]
		 [Shift] + [CapsLock] + [A] = [a]
		 
		 ALL KEYS THAT CREATES THE SAME OUTPUT, HAVE THE SAME KEYCODES !
		 
		 [NumPad 1] is the same as [1] (if NumLock)
		 [NumPad +] is the same as [+]
		 
		 DOES NOT SUPPORT ARROW-KEYS, DELETE, INSERT, SHIFT, ALT, CTRL, TAB, ESC...........!
		 But it supports [Return / Enter] and [Backspace]
		 
		 */
		iKey_Return_Enter : 13 , 
		/*
		 iKey_" : 34 , 
		 iKey_# : 35 , 
		 iKey_$ : 36 , 
		 iKey_% : 37 , 
		 iKey_& : 38 ,
		 iKey_singleQuot : 39 ,
		 
		 iKey_( : 40 , 
		 iKey_) : 41 ,
		 */
		/*
		 iKey_exclamation : 33 , 
		 iKey_BackSpace : 8 , 
		 iKey_multiply : 42 , 
		 iKey_plus : 43 , 
		 iKey_comma : 44 , 
		 iKey_minus : 45 , 
		 iKey_point : 46 , 
		 iKey_devide : 47 , 
		 iKey_0 : 48 , 
		 iKey_1 : 49 , 
		 iKey_2 : 50 , 
		 iKey_3 : 51 , 
		 iKey_4 : 52 , 
		 iKey_5 : 53 , 
		 iKey_6 : 54 , 
		 iKey_7 : 55 , 
		 iKey_8 : 56 , 
		 iKey_9 : 57 , 
		 iKey_colon : 58 , 
		 iKey_semicolon : 59 , 
		 iKey_lt : 60 , 
		 iKey_equals : 61 , 
		 iKey_gt : 62 , */
		 iKey_question : 63 , 
     /*
		 iKey_at : 64 , 
		 iKey_A : 65 , 
		 iKey_B : 66 , 
		 iKey_C : 67 , 
		 iKey_D : 68 , 
		 iKey_E : 69 , 
		 iKey_F : 70 , 
		 iKey_G : 71 , 
		 iKey_H : 72 , 
		 iKey_I : 73 , 
		 iKey_J : 74 , 
		 iKey_K : 75 , 
		 iKey_L : 76 , 
		 iKey_M : 77 , 
		 iKey_N : 78 , 
		 iKey_O : 79 , 
		 iKey_P : 80 , 
		 iKey_Q : 81 , 
		 iKey_R : 82 , 
		 iKey_S : 83 , 
		 iKey_T : 84 , 
		 iKey_U : 85 , 
		 iKey_V : 86 , 
		 iKey_W : 87 , 
		 iKey_X : 88 , 
		 iKey_Y : 89 , 
		 iKey_Z : 90 , 
		 iKey_ : 91 , 
		 iKey_backslash : 92 , 
		 iKey_ : 93 , 
		 iKey_circonflex : 94 , 
		 iKey_ : 95 , 
		 //iKey_` : 96 , 
		  iKey_a : 97 , 
		  iKey_b : 98 , 
		  iKey_c : 99 , 
		  iKey_d : 100 , 
		  iKey_e : 101 , 
		  iKey_f : 102 , 
		  iKey_g : 103 , 
		  iKey_h : 104 , 
		  iKey_i : 105 , 
		  iKey_j : 106 , 
		  iKey_k : 107 , 
		  iKey_l : 108 , 
		  iKey_m : 109 , 
		  iKey_n : 110 , 
		  iKey_o : 111 , 
		  iKey_p : 112 , 
		  iKey_q : 113 , 
		  iKey_r : 114 , 
		  iKey_s : 115 , 
		  iKey_t : 116 , 
		  iKey_u : 117 , 
		  iKey_v : 118 , 
		  iKey_w : 119 , 
		  iKey_x : 120 , 
		  iKey_y : 121 , 
		  iKey_z : 122 , 
		  */
		/*
		 iKey_{ : 123 , 
		 iKey_| : 124 , 
		 iKey_} : 125 , 
		 iKey_~ : 126 , 
		 iKey_£ : 163 , 
		 iKey_¤ : 164 , 
		 iKey_§ : 167 , 
		 iKey_¨ : 168 , 
		 //iKey_´ : 180 , 
		  iKey_half : 189 , 
		  iKey_Å : 197 , 
		  iKey_Æ : 198 , 
		  iKey_Ø : 216 , 
		  iKey_å : 229 , 
		  iKey_æ : 230 , 
		  iKey_ø : 248 , 
		  */
		/*
		 KeyCodes (DANISH keyboard):	onkeydown / onkeyup	Tested with Internet Explore 5.0)
		 By: Helge Willum Larsen
		 
		 DOES NOT SUPPORT MULTIPLE KEYPRESSES !
		 
		 ALL KEYS HAVE THEIR OWN, INDIVIDUAL KEYCODE !
		 
		 [NumPad 1] is NOT the same as [1]
		 [NumPad +] is NOT the same as [+]
		 
		 Button:			keyCode:	NumLock:	CapsLock:	ScrollLock:
		 
		 iKey_BackSpace : 8 , 
		 iKey_Tab : 9 , 
		 iKey_NumPad5 : 12 , 
		 iKey_Return_Enter : 13 , 
     */
		 iKey_Shift : 16 ,
		 iKey_Ctrl : 17 , 
		 iKey_Alt : 18 , 
		 iKey_Pause_Break : 19 , 
		 iKey_CapsLock : 20 ,  
     /*
		 iKey_Esc : 27 , 
		 iKey_Space : 32 , 
		 iKey_PageUp : 33 , 
		 iKey_PageDown : 34 , 
		 iKey_End : 35 , 
		 iKey_Home : 36 , 
		 iKey_LeftArrow : 37 , 
		 iKey_UpArrow : 38 , 
		 iKey_RightArrow : 39 , 
		 iKey_DownArrow : 40 , 
		 iKey_PrintScreen_SysRq : 44 , 
		 iKey_Insert : 45 , 
		 iKey_Delete : 46 , 
		 iKey_0 : 48 , 
		 iKey_1 : 49 , 
		 iKey_2 : 50 , 
		 iKey_3 : 51 , 
		 iKey_4 : 52 , 
		 iKey_5 : 53 , 
		 iKey_6 : 54 , 
		 iKey_7 : 55 , 
		 iKey_8 : 56 , 
		 iKey_9 : 57 , 
		 iKey_A : 65 , 
		 iKey_B : 66 , 
		 iKey_C : 67 , 
		 iKey_D : 68 , 
		 iKey_E : 69 , 
		 iKey_F : 70 , 
		 iKey_G : 71 , 
		 iKey_H : 72 , 
		 iKey_I : 73 , 
		 iKey_J : 74 , 
		 iKey_K : 75 , 
		 iKey_L : 76 , 
		 iKey_M : 77 , 
		 iKey_N : 78 , 
		 iKey_O : 79 , 
		 iKey_P : 80 , 
		 iKey_Q : 81 , 
		 iKey_R : 82 , 
		 iKey_S : 83 , 
		 iKey_T : 84 , 
		 iKey_U : 85 , 
		 iKey_V : 86 , 
		 iKey_W : 87 , 
		 iKey_X : 88 , 
		 iKey_Y : 89 , 
		 iKey_Z : 90 , 
		 iKey_TurnOff_special : 94 , 
		 iKey_Sleep_special : 95 , 
		 iKey_NumPad0 : 96 , 
		 iKey_NumPad1 : 97 , 
		 iKey_NumPad2 : 98 , 
		 iKey_NumPad3 : 99 , 
		 iKey_NumPad4 : 100 , 
		 iKey_NumPad5 : 101 , 
		 iKey_NumPad6 : 102 , 
		 iKey_NumPad7 : 103 , 
		 iKey_NumPad8 : 104 , 
		 iKey_NumPad9 : 105 , 
		 iKey_NumPad_multiply : 106 , 
		 iKey_NumPad_plus : 107 , 
		 iKey_NumPad_minus : 109 , 
		 iKey_NumPad_comma : 110 , 
		 iKey_NumPad_devide : 111 , 
		 iKey_F1 : 112 , 
		 iKey_F2 : 113 , 
		 iKey_F3 : 114 , 
		 iKey_F4 : 115 , 
		 iKey_F5 : 116 , 
		 iKey_F6 : 117 , 
		 iKey_F7 : 118 , 
		 iKey_F8 : 119 , 
		 iKey_F9 : 120 , 
		 iKey_F10 : 121 , 
		 iKey_F11 : 122 , 
		 iKey_F12 : 123 , 
		 iKey_NumLock : 144 , 
		 iKey_ScrollLock : 145 , 
		 iKey_plus_nextto0 : 187 , 
		 iKey_comma2 : 188 , 
		 iKey_minus_nextto_point : 189 , 
		 iKey_point2 : 190 ,
		 iKey_lt_nexttoZ : 226 ,
		 */
		/* 
		 iKey_Æ : 192 , 
		 iKey_´_nextto_plus : 219 , 
		 iKey_half_nextto1 : 220 , 
		 iKey_Å : 221 , 
		 iKey_Ø : 222 ,  
		 */
		
		iKey_WakeUp_special : 255 
}//Log.eventTool

Log.eventTool.getEvent=function(eVent){
	if(eVent==null){eVent=window.event;}
	//if(!eVent){eVent=window.event;}
	return eVent; 
}//getEvent

/**
 * try to cancel all bubbling and further processing
 * @author unknown
 */
Log.eventTool.stopEvent=function(eVent){
	try{
		if(window.event){
			window.event.returnValue=false;
			window.event.cancelBubble=true;
		}//if (window.event
	}catch(e_rror){/*Log.showExeption( e_rror, 'Log.eventTool.stopEvent');*/}
	void(0);
	return false;
}//stopEvent
/**
 * cursor - focus position
 * @author unknown
 */
Log.eventTool.eventPx=function(eVent){
	var i_x=0;
	var i_y=0;
	eVent=Log.eventTool.getEvent(eVent);
	if (eVent.pageX || eVent.pageY){
		i_x=eVent.pageX;
		i_y=eVent.pageY;
	}else if (eVent.clientX || eVent.clientY){
		i_x=eVent.clientX + document.body.scrollLeft;
		i_y=eVent.clientY + document.body.scrollTop;
	}
	return new Xy(i_x,i_y);
}//eventPx
/**
 */
Log.eventTool.isKey=function(eVent, i_keyCode){
	eVent=Log.eventTool.getEvent(eVent);
	//eval('i_keyCode=this.'+s_keyName);
	if(eVent.keyCode==i_keyCode){return true;}
	return false;
}//isKey

Log.eventTool.evokeEvent=function(e_lement,s_onEvent,event){// don't replace with 'eVent'
	try{
		event=Log.eventTool.getEvent(event);
		if(e_lement!=null&&s_onEvent!=null&&s_onEvent!=''){
			var s_eval='';
			eval('s_eval=e_lement.'+s_onEvent+'+"";');
			s_eval=Log.charTool.pile(s_eval, '{', '}');
			s_eval=s_eval.replace('this','e_lement');
			eval(s_eval);
		}//if(s_onEvent
	}catch(e_rror){Log.showExeption( e_rror, 'Log.eventTool.evokeEvent');}
	Log.eventTool.stopEvent(event);
}//evokeEvent

/** not in use
 Log.eventTool.getKeyName=function(eVent){
 eVent=Log.eventTool.getEvent(eVent);
 if(eVent.ctrlKey){return Log.eventTool.ctrlKey;}
 else if(eVent.shiftKey){return Log.eventTool.shiftKey;}
 else if(eVent.altKey){return Log.eventTool.altKey;}
 return null;
 }//getKeyName
 */
/**
 not in use
 Log.eventTool.getTarget=function(eVent){
 eVent=Log.eventTool.getEvent(eVent);
 var e_target;	
 if (eVent.target) e_target=eVent.target;
 else if (eVent.srcElement) e_target=eVent.srcElement;
 if (e_target.nodeType==3) e_target=e_target.parentNode;// defeat Safari bug
 return e_target;
 }//getTarget
 */
/*
 You may also use this sort of function to disable certain keys, by adding a void(0) in the function as shown.
 This essentially tells the page to cancel the last event, e.g. the pressing of that certain key. 
 In the example below, the key that is disabled is the enter key. 
 
 document.onkeydown = checkKeycode
 function checkKeycode(e){
 var keycode;
 if (window.event) keycode = window.event.keyCode;
 else if (e) keycode = e.which;
 if(keycode == 13){
 void(0);
 }
 }
 */
/*
 Log.eventTool.isEnterKey=function(eVent){
 var i_keyCode=eVent.keyCode;
 var i_wend=this._A_BREAK_KEYS.length;
 var i_while=0;
 while(i_while<i_wend){
 if(i_keyCode==this._A_BREAK_KEYS[i_while]){return true;}
 i_while=i_while+1;
 }//while(i_while<i_wend
 return false;
 }//isEnterKey
 */
