navHover = function() {
	var lis = document.getElementById("navmenu-v").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);

// JavaScript Unicode Keyboard Handler (version 2.0 - Jan 2006)
//
// Copyright (c) 2003-2008 Jawish Hameed (http://jawish.org/)
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Details and updates: http://jawish.org/blog/


function juk_HandleKeyPress( evt )
{
	// cross browser workaround for accessing events
    var evt 	= ( evt ) ? evt : window.event;
	
	// cross browser workaround for accessing target element
	var elem 	= ( evt.target ) ? evt.target : evt.srcElement;
	
	// cross browser workaround for getting the pressed key
	var keycode = ( evt.which ) ? evt.which : evt.keyCode;
	
	var english_ascii = "hSnrbLkwvmfdtlgNsDzTypjcXHKJRxBMYZWGQVaAiIuUeEoOqF,;?";
	var dhivehi_unicode = [ '\u0780','\u0781','\u0782','\u0783','\u0784','\u0785','\u0786',
							'\u0787','\u0788','\u0789','\u078A','\u078B','\u078C','\u078D',
							'\u078E','\u078F','\u0790','\u0791','\u0792','\u0793','\u0794',
							'\u0795','\u0796','\u0797','\u0798','\u0799','\u079A','\u079B',
							'\u079C','\u079D','\u079E','\u079F','\u07A0','\u07A1','\u07A2',
							'\u07A3','\u07A4','\u07A5','\u07A6','\u07A7','\u07A8','\u07A9',
							'\u07AA','\u07AB','\u07AC','\u07AD','\u07AE','\u07AF','\u07B0',
							'\uFDF2','\u060C','\u061B','\u061F' ]
	
	// get the position of the character from the english list
	var pos = english_ascii.indexOf( String.fromCharCode( keycode ) );
	
	// if character is to be switched for dhivehi equivalent
	if ( pos != -1 && evt.ctrlKey == false )
	{
		
		// update the text
		if ( document.selection )
		{
			// for ie
		    sel = document.selection.createRange();
		    sel.text = dhivehi_unicode[ pos ];
			
		} else {
			// for mozilla
			var selstart = elem.selectionStart;
			elem.value = elem.value.substring( 0, selstart ) + dhivehi_unicode[ pos ] + elem.value.substring( elem.selectionEnd );
		}
		
		// IE specific cancellation of pressed key
		if ( navigator.appName == "Microsoft Internet Explorer") {	
			evt.keyCode = 0;
		}
		
		// set the caret
		selstart = selstart+1;
		elem.setSelectionRange( selstart, selstart );
		
		// stop the normal processing of the entered key
		return false;
		
	} else {
		
		if ( keycode == 32 || keycode == 10 || keycode == 13 )
		{
			/*
			var selstart = elem.selectionStart + 1;
			elem.setSelectionRange( selstart, selstart );
			*/
		
		document.getElementById('msg').innerText = "a" + String.fromCharCode(keycode).length + "a";
		// set the caret
		var selstart = elem.selectionStart+1;
		elem.value = elem.value.substring( 0, selstart ) + String.fromCharCode(keycode) + elem.value.substring( elem.selectionEnd );
		
		// set the caret
		selstart = selstart+1;
		elem.setSelectionRange( selstart, selstart );

		return false;
		}
	}
}
