// Javascript from Moodle modules

var undefined;
var KeyboardTable = {
	// name of namespace
	name: 'KeyboardTable',
	images: [],
	arrayId: [],
	callbackFunctions: [],
	pageLoad: false,
	VKLoad: false,
	PSLoad: false,
	isHandler: false,
	checkCount: 0,
	flashValid: true,
	pathImg: '',
	langLayout: 'Mask',
	currentLang: '',
	soundMode: 0,
	divIconsBlock: '',
	imgSwitchSound: '',
	divOver: '',
	divSymbolTable: '',
	divSound: '',
	playIE: '',
	play: '',
	divkeyboard: '',
	keyboardIE: '',
	keyboard: '',
	isSwitch: true,
	VKManager: {},
	PSManager: {},
	
	isIE: (window.ActiveXObject),
	isSafari: navigator.vendor && -1 != navigator.vendor.indexOf('Apple') ? true : false,
	isMacFirefox: navigator.platform && -1 != navigator.platform.indexOf('Mac') && navigator.userAgent && navigator.userAgent.indexOf('Firefox') ? true : false,
	isWinFirefox: navigator.platform && -1 != navigator.platform.indexOf('Win') && navigator.userAgent && navigator.userAgent.indexOf('Firefox') ? true : false,
	// flag for ending load page
	endLoad: false,
	listener: [],
	timeout: 5, // in seconds
	specSymbol: {
//                '8': 1,	// backspace
		'9': 1,	// tab
		'13': 1, // newline
                '16': 1,	// shift
                '17': 1, // ctrl
                '32': 1,	// space
		'33': 1,	// !
/*		
		'34': 1,	// '
		'35': 1,	// #
		'36': 1,	// $
		'37': 1,	// %
		'38': 1,	// &
		'39': 1,	// "
		'40': 1,	// (
*/
		'41': 1,	// )
		'42': 1,	// *
		'43': 1,	// +
		'44': 1,	// ,
		'45': 1,	// -
//		'46': 1,	// .
		'47': 1, // /
		'94': 1,	// ^
		'95': 1,	// _
		'124': 1	// |
        },
	
	// preload for image
	preLoadImgs: function(prefix) {
		this.pathImg = prefix;
		for (var i=0; i < this.images.length; i++) {
			var img = new Image();
			img.src = prefix + this.images[i];
		}
	},
	
	// handler event listener for different browsers: 'add' - add, 'remove' - delete
	handlerListener: function(type, element, eventType, funct, functName, obj, override) {
		var functAdd, len;
		var flag = false;
		if (obj) {
		        functAdd = function(event) {
				return funct.call(obj, event, obj);
			}
		} else {
			functAdd = funct;
		}
		if ('add' == type) {
			this.listener[this.listener.length] = {
				'function': functAdd,
				'functionName': functName,
				'element': element,
				'eventType': eventType,
				'obj': obj ? obj : false
			}
		} else {
			obj = obj ? obj : false;
			for(var i = 0, len = this.listener.length; i < len; i++) {
				if (this.listener[i]['element'] == element
				    && this.listener[i]['eventType'] == eventType
				    && this.listener[i]['obj'] == obj
				    && this.listener[i]['functionName'] == functName) {
					functAdd = this.listener[i]['function'];
					this.listener.splice(i, 1);
					break;
				}
			}
		}
                if (window.addEventListener) {
			if ('add' == type) {
				element.addEventListener(eventType, functAdd, override ? true : false);
			} else if ('remove' == type) {
				element.removeEventListener(eventType, functAdd, override ? true : false);
			}

//			return true;
                } else if (window.attachEvent) {
			if ('add' == type) {
	                        element.attachEvent("on" + eventType, functAdd);
			} else if ('remove' == type) {
	                        element.detachEvent("on" + eventType, functAdd);
			}
//			return true;
                } else {
			return false;
		}
	},

	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
		return false;
	},
	
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return false;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 	// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	],
	
	getPS: function(type) {
		if ('start' == type && 'undefined' == typeof this.PS) {
			this.PSManager.initializeExternalInterface(this.playIE);
			this.PS = new this.PlaySound(this, this.arrayId, this.callbackFunctions);
			this.PS.specSymbol = this.specSymbol;
			this.PSLoad = true;
			if (this.pageLoad && this.VKLoad) {
				this.pageHandler();
			}
		}
	},
	
	getVK: function(type) {
		if ('start' == type && 'undefined' == typeof this.VK) {
			this.VKManager.initializeExternalInterface(this.keyboardIE);
			this.VK = new this.VirtualKeyboard(this, "VK", this.arrayId, this.callbackFunctions);
			this.VKLoad = true;
			if (this.pageLoad && this.PSLoad) {
				this.pageHandler();
			}
		}
	},

	testFunction: function() {
		var a = 1;
		return true;
	},
	
	checkVersion: function(idCall, nameCall, idVersion, nameVersion) {
		var browser = this.searchString(this.dataBrowser) || 'An unknown browser';
		var version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| 'an unknown version';
		var OS = this.searchString(this.dataOS) || 'an unknown OS';
		if (!this.testFunction.call) {
			document.getElementById(idCall).innerHTML = 'Sorry, ' + nameCall + ' does not work in your browser ('
				+ browser + ' ' + version + ' for ' + OS + ').';
			this.flashValid = false;
			return false;
		} else {
			if ('Explorer' == browser && 7 == version && 'Windows' == OS) {
				if (-1 == navigator.userAgent.indexOf('Windows NT 6.0')) {
					document.getElementById(idCall).innerHTML = 'We discovered that Internet Explorer 7'
						+ ' running under Windows XP have problems in displaying Unicode Cree Syllabics fonts.'
						+ ' There is no solution for this problem at this time. Please use'
						+ ' <a href="http://www.getfirefox.com" target="_blank">Firefox</a>'
						+ ' or <a href="http://opera.com" target="_blank">Opera</a> instead of Internet Explorer 7.';
				}
				this.flashValid = false;
				return false;
			}
			var version, i;
			var plugin = (navigator.mimeTypes && navigator.mimeTypes['application/x-shockwave-flash'])
				? navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin : 0;
			if (plugin) {
				var words = navigator.plugins['Shockwave Flash'].description.split(' ');
				for (i = 0; i < words.length; ++i) {
					if (isNaN(parseInt(words[i])))
						continue;
					version = words[i];
				}
				if (!version) {
					this.flashValid = false;
					return false;
				}
//			} else if (navigator.mimeTypes) {
//				this.flashValid = false;
//				return false;
			} else {
				version = null;
			}
			if (version) {
				for (i=1; i < 8; i++) {
				        if (-1 != version.indexOf(' ' + i + ',') || 0 == version.indexOf(i + '.')) {
						document.getElementById(idVersion).innerHTML = 'Sorry, ' + nameVersion + ' is only for Flash Player 8 and higher. Current Flash version is '
							+ version + '. Please <a href="http://www.adobe.com/go/getflashplayer">update Flash Player</a>.';
						this.flashValid = false;
						return false;
					}
				}
			}
		return true;
		}
	},

	// function for copy object into other object
	clone: function(objectCopy, firstObject, currentObject) {
		var i, elem, j, id;
		if (typeof objectCopy != 'object') {
			return objectCopy;
		}
		if (null == objectCopy) {
			return objectCopy;
		}
		var elem = {};
		if (i == 'window' || (undefined != objectCopy[i] && objectCopy[i] == window)) {
			elem = window;
		} else if (i == 'document' || (undefined != objectCopy[i] && objectCopy[i] == document)) {
			elem = document;
		} else {
			for( i in objectCopy) {
				if (objectCopy[i] == window) {
					elem[i] = window;
				} else if (objectCopy[i] == document) {
					elem[i] = document;
				} else {
					if (i != 'parent' && firstObject != objectCopy[i]) {
						elem[i] = KT.clone(objectCopy[i], firstObject, currentObject);
					} else {
						elem[i] = currentObject;
					}
				}
			}
		}
		return elem;
	},
	
	// make random ids
	randomId: function() {
		var alpha = 'abcdefghijklmnopqrstuvwxyz';
		var i, a, b, aString, bString;
		aString = '';
		for (i = 0; i < 10; i++) {
			aString += alpha.substr(Math.round(Math.random() * (alpha.length - 1)), 1);
		}
		return this.name + aString;
	},
		
	
	// method for finding ids for definition textFieldId
	findIds: function(idDiv, fieldClassName) {
		var parentElement = document.getElementById(idDiv).parentElement || document.getElementById(idDiv).parentNode;
		if (undefined == parentElement.tagName || 'DIV' != parentElement.tagName) {
			while (undefined == parentElement.tagName || 'DIV' != parentElement.tagName) {
				if (undefined == parentElement.parentElement && undefined == parentElement.parentNode) {
					return false;
				}
				parentElement = parentElement.parentElement || parentElement.parentNode;
			}
		}
		if (undefined == parentElement.nextSibling) {
			return false;
		}
		var nextDivElement = parentElement.nextSibling;
		if (undefined == nextDivElement.tagName || 'DIV' != nextDivElement.tagName) {
			while (undefined == nextDivElement.tagName || 'DIV' != nextDivElement.tagName) {
				if (undefined == nextDivElement.nextSibling) {
					return false;
				}
				nextDivElement = nextDivElement.nextSibling;
			}
		}		
		var childrens = nextDivElement.childNodes;
		this.arrayId = [];
		for (var child = 0; child < childrens.length; child++) {
			if (undefined != childrens[child] && undefined != childrens[child].className
				&& fieldClassName == childrens[child].className) {
				var childrensChild = childrens[child].childNodes;
				for (var childChild = 0; childChild < childrensChild.length; childChild++) {
					if ('INPUT' == childrensChild[childChild].tagName || 'TEXTAREA' == childrensChild[childChild].tagName) {
						if (undefined == childrensChild[childChild].id || !childrensChild[childChild].id) {
							childrensChild[childChild].id = this.randomId();
						}
						var inArray = false;
						for (var i = 0; i < this.arrayId.length; i++) {
							if (this.arrayId[i] == childrensChild[childChild].id) {
								inArray = true;
								break;
							}
						}
						if (!inArray) {
							this.arrayId.push(childrensChild[childChild].id);
						}
					}
				}
			}
		}
	},
	
	ExternalInterfaceManager:  function(parent) {
		this.parent = parent;
		this.fakeMovies = [];
//		this.registerMovie = function(movieName) {
//			this.fakeMovies[this.fakeMovies.length] = movieName;
//		}
		this.initialize = function(movieId) {
			if (this.parent.isIE) {
				if (undefined != movieId) {
					window[movieId] = {};
//					window.attachEvent("onload", initializeExternalInterface);
				}
			}
		}
	
		this.initializeExternalInterface = function(movieName) {
//			for(var i = 0; i < this.fakeMovies.length; i++) {
//		var movieName = window.fakeMovies[i];
			var fakeMovie = window[movieName];
			var realMovie = document.getElementById(movieName);
			if (undefined == realMovie) {
				return false;
			}
			for(var method in fakeMovie) {
				realMovie[method] = function() {flashFunction = "&lt;invoke name=\"" + method.toString() + "\" returntype=\"javascript\"&gt;" + __flash__argumentsToXML(arguments, 0) + "&lt;/invoke&gt;";this.CallFunction(flashFunction);}
			}
			window[movieName] = realMovie;
		}
//}
	}
}

// short namespace
var KT = KeyboardTable;
KT.name = 'KT';
	
function flashCalls(val) {
//	alert("flash calls and says: "+val);
}

window.onerror = function( ) { return true; }
;
function addKeyboardTable(currentLayout, chooseType, nameSpace) {
	var str;
	var date = new Date();
/*	var eim = new ExternalInterfaceManager();
	eim.registerMovie(nameSpace.keyboardIE);
	eim.registerMovie(nameSpace.playIE);
*/
	nameSpace.VKManager = new nameSpace.ExternalInterfaceManager(nameSpace);
	nameSpace.VKManager.initialize(nameSpace.keyboardIE);
	nameSpace.PSManager = new nameSpace.ExternalInterfaceManager(nameSpace);
	nameSpace.PSManager.initialize(nameSpace.playIE);
	str = '<div style="margin: 0pt; font-size: 10px;" id="' + nameSpace.divOver + '">\
						<div style="white-space: nowrap; padding-top: 4px;" id="' + nameSpace.name + 'divSwitch">Switch to: <a style="display: inline;" href="javascript://" id="' + nameSpace.name + 'ctswitch"';
	str += ('charTable' == chooseType) ? ' style="display: none;"' : '';
	str += ' onclick="' + nameSpace.name + '.chooseMethod(\'charTable\');this.style.display=\'none\';document.getElementById(\'' + nameSpace.name + 'kbswitch\').style.display=\'inline\';">Table</a><a href="javascript://" id="' + nameSpace.name + 'kbswitch"';
	str += ('keyboard' == chooseType) ? ' style="display: none;"' : '';
	str += ' onclick="' + nameSpace.name + '.chooseMethod(\'keyboard\');this.style.display=\'none\';document.getElementById(\'' + nameSpace.name + 'ctswitch\').style.display=\'inline\';">Keyboard</a></div><br />\
</div>\
<div class="object" id="' + nameSpace.divkeyboard + '">\
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="' + nameSpace.keyboardIE + '" align="top" height="197" width="575">\
<param name="allowScriptAccess" value="sameDomain">\
<param name="wmode" value="transparent">\
<param name="movie" id="' + nameSpace.keyboardIE + 'Movie" value="' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/keyboard/keyboard.swf?lang=mask_cree&amp;keyboardname=' + nameSpace.name + '.VK&amp;path=' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/keyboard/&amp;current=' + currentLayout + '&amp;soundMode=' + nameSpace.soundMode +  '&amp;time=' + date.getTime() + '">\
<param name="quality" value="high"><param name="bgcolor" value="#fbf6dE">\
<embed id="' + nameSpace.keyboard + '" src="' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/keyboard/keyboard.swf?lang=mask_cree&amp;keyboardname=' + nameSpace.name + '.VK&amp;path=' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/keyboard/&amp;current=' + currentLayout + '&amp;soundMode=' + nameSpace.soundMode + '&amp;time=' + date.getTime() + '" quality="high" bgcolor="#fbf6dE" name="keyboard" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" style="overflow: hidden; width: 575px; height: 197px;" align="top" height="197" width="575">\
</object>\
</div>\
\
						<div style="text-align: center;">\
						<div id="' + nameSpace.divIconsBlock + '" class="IconsM" style="display: none;">\
							<a href="javascript://" title="Syllabic/Roman Orthography"><img src="' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/img/adult/chartable/convert.gif" alt="Syllabic/Roman Orthography" onclick="' + nameSpace.name + '.PS.switchFocus();" height="36" width="36"></a><a href="javascript://" title="Sound On" onclick="' + nameSpace.name + '.PS.switchSound(); "><img id="' + nameSpace.imgSwitchSound + '" src="' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/img/adult/chartable/';
	str += (2 != nameSpace.soundMode) ? 'sound-off' : 'sound-on';
	str += '.gif" alt="Sound Off" height="36" width="36"></a>\
						</div><br />\
						<div>\
						<div style="display: none;" class="SymbolTable" id="' + nameSpace.divSymbolTable + '">\
					<table class="SymbolTable">\
							<tbody><tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(82, 0);"><a href="javascript://"><span>ᐊ</span><br>a</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(86, 0);"><a href="javascript://"><span>ᐁ</span><br>e</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(70, 0);"><a href="javascript://"><span>ᐃ</span><br>i</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(82, 1);"><a href="javascript://"><span>ᐅ</span><br>o</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(70, 1);"><a href="javascript://"><span class="ExtrasH">ᐦ</span><br>h</a></td>\
								<td class="Extras" onmousedown="' + nameSpace.name + '.PS.typeSymbol(222, 0);"><a href="javascript://"><span>ᐧ</span><br>w</a></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(81, 0);"><a href="javascript://"><span>ᐸ</span><br>pa</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(90, 0);"><a href="javascript://"><span>ᐯ</span><br>pe</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(65, 0);"><a href="javascript://"><span>ᐱ</span><br>pi</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(81, 1);"><a href="javascript://"><span>ᐳ</span><br>po</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(65, 1);"><a href="javascript://"><span>ᑊ</span><br>p</a></td>\
								<td class="Extras" onmousedown="' + nameSpace.name + '.PS.typeSymbol(222, 1);"><a href="javascript://"><span>ᐤ</span><br>ow</a></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(69, 0);"><a href="javascript://"><span>ᑕ</span><br>ta</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(67, 0);"><a href="javascript://"><span>ᑌ</span><br>te</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(68, 0);"><a href="javascript://"><span>ᑎ</span><br>ti</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(69, 1);"><a href="javascript://"><span>ᑐ</span><br>to</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(68, 1);"><a href="javascript://"><span>ᐟ</span><br>t</a></td>\
								<td class="Empty"></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(85, 0);"><a href="javascript://"><span>ᑲ</span><br>ka</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(77, 0);"><a href="javascript://"><span>ᑫ</span><br>ke</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(74, 0);"><a href="javascript://"><span>ᑭ</span><br>ki</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(85, 1);"><a href="javascript://"><span>ᑯ</span><br>ko</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(74, 1);"><a href="javascript://"><span>ᐠ</span><br>k</a></td>\
								<td class="Empty"></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(87, 0);"><a href="javascript://"><span>ᒐ</span><br>cha</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(88, 0);"><a href="javascript://"><span>ᒉ</span><br>che</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(83, 0);"><a href="javascript://"><span>ᒋ</span><br>chi</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(87, 1);"><a href="javascript://"><span>ᒍ</span><br>cho</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(83, 1);"><a href="javascript://"><span>ᐨ</span><br>ch</a></td>\
								<td class="Empty"></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(89, 0);"><a href="javascript://"><span>ᒪ</span><br>ma</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(78, 0);"><a href="javascript://"><span>ᒣ</span><br>me</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(72, 0);"><a href="javascript://"><span>ᒥ</span><br>mi</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(89, 1);"><a href="javascript://"><span>ᒧ</span><br>mo</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(72, 1);"><a href="javascript://"><span>ᒼ</span><br>m</a></td>\
								<td class="Empty"></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(73, 0);"><a href="javascript://"><span>ᓇ</span><br>na</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(188, 0);"><a href="javascript://"><span>ᓀ</span><br>ne</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(75, 0);"><a href="javascript://"><span>ᓂ</span><br>ni</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(73, 1);"><a href="javascript://"><span>ᓄ</span><br>no</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(75, 1);"><a href="javascript://"><span>ᐣ</span><br>n</a></td>\
								<td class="Empty"></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(79, 0);"><a href="javascript://"><span>ᓴ</span><br>sa</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(190, 0);"><a href="javascript://"><span>ᓭ</span><br>se</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(76, 0);"><a href="javascript://"><span>ᓯ</span><br>si</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(79, 1);"><a href="javascript://"><span>ᓱ</span><br>so</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(76, 1);"><a href="javascript://"><span>ᐢ</span><br>s</a></td>\
								<td class="Empty"></td>\
							</tr>\
							<tr>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(84, 0);"><a href="javascript://"><span>ᔭ</span><br>ya</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(66, 0);"><a href="javascript://"><span>ᔦ</span><br>ye</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(71, 0);"><a href="javascript://"><span>ᔨ</span><br>yi</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(84, 1);"><a href="javascript://"><span>ᔪ</span><br>yo</a></td>\
								<td onmousedown="' + nameSpace.name + '.PS.typeSymbol(71, 1);"><a href="javascript://"><span>ᕀ</span><br>y</a></td>\
								<td class="Empty"></td>\
							</tr>\
						</tbody></table>\
					</div></div><br>\
<div id="' + nameSpace.divSound + '">\
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="' + nameSpace.playIE + '" height="1" width="1">\
<param name="allowScriptAccess" value="sameDomain">\
<param name="movie" id="' + nameSpace.playIE + 'Movie" value="' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/syllabics/syllabicsound.swf?lang=mask_cree&amp;soundname=' + nameSpace.name + '.PS&amp;path=' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/keyboard/&amp;current=' + currentLayout + '&amp;time=' + date.getTime() + '"><param name="quality" value="high">\
<embed id="' + nameSpace.play + '" src="' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/syllabics/syllabicsound.swf?lang=mask_cree&amp;soundname=' + nameSpace.name + '.PS&amp;path=' + nameSpace.root + '/filter/creeinputdevice/keyboardtable/keyboard/&amp;current=' + currentLayout + '&amp;time=' + date.getTime() + '" quality="high" name="play" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="1" width="1">\
</object>\
</div>\
						</div>';
	document.write(str);
//	eim.initialize();
	var idNone;
	idNone = ('charTable' == chooseType) ? nameSpace.name + 'ctswitch' : nameSpace.name + 'kbswitch';
	document.getElementById(idNone).style.display = 'none';
	if (!nameSpace.isSwitch) {
		document.getElementById(nameSpace.name + 'divSwitch').style.display = 'none';
	}
/*	
	var form = document.getElementById(idNone).parentNode;
	while (undefined == form.tagName || 'FORM' != form.tagName) {
		form = form.parentNode;
	}
	
	form[nameSpace.keyboardIE].javaCalls = function(val){
		var string1 = "<invoke name=\"javaCalls\" returntype=\"javascript\"><arguments><string>"+val+"</string></arguments></invoke>";
		form[nameSpace.keyboardIE].CallFunction(string1);
	}
	
	form[nameSpace.playIE].javaCalls = function(val){
		var string1 = "<invoke name=\"javaCalls\" returntype=\"javascript\"><arguments><string>"+val+"</string></arguments></invoke>";
		form[nameSpace.playIE].CallFunction(string1);
	}
*/	
};
if ("undefined" == typeof KeyboardTable.keyLayout) {
	KeyboardTable.keyLayout = {};
}
KeyboardTable.keyLayout['mask_cree'] = {
	'0': { // no control keys
                '32': ' ',
                '48': '0',
		'49': '1',
		'50': '2',
		'51': '3',
                '52': '4',
                '53': '5',
                '54': '6',
                '55': '7',
                '56': '8',
                '57': '9',
                '58': '',
//	        '59': ';',
                '60': '',
                '61': '=',
                '62': '',
                '63': '',
                '64': '',
                '65': 'ᐱ',
                '66': 'ᔦ',
                '67': 'ᑌ',
                '68': 'ᑎ',
                '69': 'ᑕ',
                '70': 'ᐃ',
                '71': 'ᔨ',
                '72': 'ᒥ',
                '73': 'ᓇ',
		'74': 'ᑭ',
                '75': 'ᓂ',
                '76': 'ᓯ',
                '77': 'ᑫ',
                '78': 'ᒣ',
                '79': 'ᓴ',
                '80': '',
                '81': 'ᐸ',
                '82': 'ᐊ',
                '83': 'ᒋ',
                '84': 'ᔭ',
                '85': 'ᑲ',
                '86': 'ᐁ',
                '87': 'ᒐ',
                '88': 'ᒉ',
                '89': 'ᒪ',
                '90': 'ᐯ',
                '109': '-',
                '188': 'ᓀ',
                '190': 'ᓭ',
/*		'191': '/',
                '219': '[',
                '220': '\\',
                '221': ']',
*/
                '222': 'ᐧ'
	},

	'1': { // shift
		'32': ' ',
                '48': ')',
		'49': '!',
		'50': '@',
		'51': '#',
                '52': '$',
                '53': '%',
                '54': '^',
                '55': '&',
                '56': '*',
                '57': '(',
                '58': '',
                '59': '',
                '60': '',
                '61': '+',
                '62': '',
                '63': '',
                '64': '',
                '65': 'ᑊ',
                '68': 'ᐟ',
                '69': 'ᑐ',
                '70': 'ᐦ',
                '71': 'ᕀ',
                '72': 'ᒼ',
                '73': 'ᓄ',
		'74': 'ᐠ',
                '75': 'ᐣ',
                '76': 'ᐢ',
                '79': 'ᓱ',
                '81': 'ᐳ',
                '82': 'ᐅ',
                '83': 'ᐨ',
                '84': 'ᔪ',
                '85': 'ᑯ',
                '87': 'ᒍ',
                '89': 'ᒧ',
                '109': '_',
		'123': '',
		'125': '',
                '187': '+',
                '189': '_',
	        '191': '?',
                '219': '{',
//              '220': '|',
                '221': '}',
                '222': 'ᐤ'
	},
	
	2: {}
}
if ("undefined" == typeof KeyboardTable.overKeyLayout) {
	KeyboardTable.overKeyLayout = {};
}
KeyboardTable.overKeyLayout['mask_cree'] = new Array();
KeyboardTable.overKeyLayout['mask_cree'][65] = 'A',
KeyboardTable.overKeyLayout['mask_cree'][69] = 'E';
KeyboardTable.overKeyLayout['mask_cree'][73] = 'I';
KeyboardTable.overKeyLayout['mask_cree'][79] = 'O';
KeyboardTable.overKeyLayout['mask_cree'][84] = 'T';;
if ("undefined" == typeof KeyboardTable.keyLayout) {
	KeyboardTable.keyLayout = {};
}
KeyboardTable.keyLayout['latin'] = {
	'0': { // no control keys
                '32': ' ',
		'45': '-',
                '48': '0',
		'49': '1',
		'50': '2',
		'51': '3',
                '52': '4',
                '53': '5',
                '54': '6',
                '55': '7',
                '56': '8',
                '57': '9',
                '58': '',
                '59': ';',
                '60': '',
                '61': '=',
                '62': '',
                '63': '',
                '64': '',
                '65': 'a',
                '66': 'b',
                '67': 'c',
                '68': 'd',
                '69': 'e',
                '70': 'f',
                '71': 'g',
                '72': 'h',
                '73': 'i',
		'74': 'j',
                '75': 'k',
                '76': 'l',
                '77': 'm',
                '78': 'n',
                '79': 'o',
                '80': 'p',
                '81': 'q',
                '82': 'r',
                '83': 's',
                '84': 't',
                '85': 'u',
                '86': 'v',
                '87': 'w',
                '88': 'x',
                '89': 'y',
                '90': 'z',
                '109': '-',
		'187': '=',
                '188': ',',
		'189': '-',
                '190': '.',
                '191': '/',
		'192': '~',
//              '219': '[',
                '220': '\\',
//              '221': ']',
		'222': "'"
	},          

	'1': { // shift
                '32': ' ',
		'33': '!',
/*		'35': '#',
		'36': '$',
		'37': '%',
		'38': '&',
		'40': '(',
*/
		'41': ')',
		'42': '*',
		'45': '_',
                '48': ')',
		'49': '!',
		'50': '@',
		'51': '#',
                '52': '$',
                '53': '%',
                '54': '^',
                '55': '&',
                '56': '*',
                '57': '(',
                '58': '',
                '59': ':',
                '60': '',
                '61': '+',
                '62': '',
                '63': '',
                '64': '',
                '65': 'A',
                '66': 'B',
                '67': 'C',
                '68': 'D',
                '69': 'E',
                '70': 'F',
                '71': 'G',
                '72': 'H',
                '73': 'I',
		'74': 'J',
                '75': 'K',
                '76': 'L',
                '77': 'M',
                '78': 'N',
                '79': 'O',
                '80': 'P',
                '81': 'Q',
                '82': 'R',
                '83': 'S',
                '84': 'T',
                '85': 'U',
                '86': 'V',
                '87': 'W',
                '88': 'X',
                '89': 'Y',
                '90': 'Z',
                '109': '_',
                '187': '+',
                '188': '<',
                '189': '_',
                '190': '>',
                '191': '?',
		'192': '',
                '219': '{',
                '220': '',
                '221': '}',
                '222': '"'
	},
	
	2: {}
};
KeyboardTable.VirtualKeyboard = function(parent, name, textFieldId, functionEvent) {
	this.name = name;
	this.parent = parent;
	this.specSymbol = this.parent.specSymbol;
	this.focused = false;
	this.movie = this.parent.isIE || this.parent.isSafari ? document.getElementById(this.parent.keyboardIE) : document.getElementById(this.parent.keyboard);
	if (undefined != this.movie) {
		this.movieWidth = this.movie.width || this.movie.clientWidth;
		this.movieHeight = this.movie.height || this.movie.clientHeight;
	} else {
		this.movieWidth = 1;
		this.movieHeight = 1;
	}
	this.movie.style.width = '1px';
	this.movie.style.height = '1px';
	this.currentCASh = 0;
	this.currentLayout = 'mask_cree';
	this.focusedField = null;
	this.keyboardLayout = this.parent.keyboardLayout;
	this.keyLayout = this.parent.keyLayout;
	this.keyLayoutLatin = this.parent.keyLayout['latin'];
	this.textFieldId = textFieldId;
	this.callback = functionEvent ? functionEvent : Array();
//	if (!this.parent.flashValid || (!this.checkVersion() && this.parent.flashValid)) {
	if (!this.parent.flashValid || !this.checkVersion()) {
		this.movie = null;
		this.movieWidth = '0px';
		this.movieHeight = '0px';
	}
	if (!this.parent.isSafari) {
		this.parent.findIds(this.parent.divOver, this.parent.fieldClassName);
		this.textFieldId = this.parent.arrayId;
		this.handlerKeyListeners('add');
	}
}


KeyboardTable.VirtualKeyboard.prototype = {
// methods for correct page work
	// correct values

	checkVersion: function() {
		var version, i;
		version = this.movie.GetVariable('$version');
		for (i=1; i < 8; i++) {
		        if (-1 != version.indexOf(' ' + i + ',') || 0 == version.indexOf(i + '.')) {
				document.getElementById(this.parent.divkeyboard).innerHTML = 'Sorry, Virtual Keyboard is only for Flash Player 8 and higher. Current Flash version is '
					+ version + '. Please <a href="http://www.adobe.com/go/getflashplayer">update Flash Player</a>.';
				this.parent.flashValid = false;
				return false;
			}
		}

		if (this.parent.isSafari && -1 != version.indexOf('MAC 9,0') && parseInt(version.substr(8, 2)) < 28) {
//			var divkeyboardContent = document.getElementById("divkeyboard").innerHTML;
/*			document.getElementById("divkeyboard").innerHTML = '<br/>You have a version of Flash Player that may cause a crash of Safari.'
				+ ' Current Flash version is ' + version
				+ '. Please <a href="http://www.adobe.com/go/getflashplayer">update Flash Player</a>.';
*/
			this.sendValue('frame', 2, '_checkVersion');
			this.parent.flashValid = false;
			return false;
		}
	return true;
	},

	handlerKeyListeners: function(type, lang) {
		var fLen, i, j;
		fLen = this.textFieldId.length;
		var eLen = this.callback.length;
		for (i = 0; i < fLen; i++) {
			// get pressed down key (JS event handler)
			this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), 'keydown', this.keyDown, this.parent.name + '.VK.keyDown', this, false);

			// get up key (JS event handler)
			this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), 'keyup', this.keyUp, this.parent.name + '.VK.keyUp', this, false);

			// false keyPress only for Opera - other browser not invoke
			this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), 'keypress', this.keyPress, this.parent.name + '.VK.keyPress', this, false);
			
			for (j = 0; j < eLen; j++) {
				if ('field' == this.callback[j]['elementType']) {
					this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), this.callback[j]['eventType'], this.callback[j]['function'], this.callback[j]['functionName'], this.callback[j]['functionObject'], false);
				}
			}
		}
		for (j = 0; j < eLen; j++) {
			if ('input' == this.callback[j]['elementType']) {
				this.parent.handlerListener(type, this.movie, this.callback[j]['eventType'], this.callback[j]['function'], this.callback[j]['functionName'], this.callback[j]['functionObject'], false);
			}
		}
		if ('undefined' != lang) {
			this.loadPage(type, lang);
		} else {
			this.loadPage(type, this.keyboardLayout);
		}
		return true;
	},
	
	removeKeyListeners: function() {
		var fLen, i;
		fLen = this.textFieldId.length;
		for (i = 0; i < fLen; i++) {
			// get pressed down key (JS event handler)
			this.parent.removeListener(document.getElementById(this.textFieldId[i]), 'keydown', this.keyDown, this, false);

			// get up key (JS event handler)
			this.parent.removeListener(document.getElementById(this.textFieldId[i]), 'keyup', this.keyUp, this, false);

			// false keyPress only for Opera - other browser not invoke
			this.parent.removeListener(document.getElementById(this.textFieldId[i]), 'keypress', this.keyPress, this, false);
		}
		this.parent.unLoadPage(this.saveFocus, this.fixBlur, this);
		return true;
	},
	
	init: function(keyboardLayout) {
		this.currentLayout = (keyboardLayout) ? keyboardLayout : this.currentLayout;
		this.parent.init();
		this.keyLayout = this.parent.keyLayout;
	},

	// save last selected field
	saveFocus: function(e) {
		if (!e) e = event;
		this.parent.saveFocus(e);
		this.focusedField = this.parent.focusedField;
		this.focused = this.parent.focused;
		return true;
	},

	// save last selected field
	fixBlur: function(e) {
		this.parent.fixBlur(e);
		this.focused = this.parent.focused;
		return true;
	},

	// set onfocus handlers for all document forms.
	loadPage: function(type, keyboardLayout) {
		if ('remove' != type) {
			this.init(keyboardLayout);
		}
		this.parent.handlerLoadPage(type, this.saveFocus, this.parent.name + '.VK.saveFocus', this.fixBlur, this.parent.name + '.VK.fixBlur', this);
	},

    // methods for exchanging data with flash
	// change language into flash keyboard
	switchLanguage: function() {
		if (undefined != this.movie) {
			this.movie.switchLanguage();
		} else {
			var currentLang = (this.currentLayout == 'latin') ? this.parent.keyboardLayout : 'latin';
			this.getLanguage(currentLang);
		}
	},

	// send and change language into flash keyboard
	sendLanguage: function(lang) {
		this.sendValue('CFG.currentLayout', lang, '');
		if (undefined != this.movie) {
			this.movie.switchLanguage();
		} else {
			this.currentLayout = lang == 'latin' ? this.parent.keyboardLayout : 'latin';
		}
	},

	// function take and sets language from flash
        getLanguage: function(lang) {
		if (this.currentLayout != lang) {
			this.currentLayout = lang;
		}
		return true;
	},
	
	getSound: function(soundMode) {
	},

	// function send value to flash
        sendValue: function(name, value, src) {
		if (undefined != this.movie) {
			this.movie.getValue(name, value);
		}
	},

	// function take and sets value from flash
	getValue: function(name, value) {
		eval('this.' + name + ' = ' + value);
		return true;
	},

	// function send keys code to flash
	sendCode: function(code, frame) {
		if (undefined != this.movie) {
			this.movie.getCode(code, frame);
		}
	},

	// methods for keys
	// output key by keyCode
	typeSymbol: function(src, keyCode, FcurrentCASh) {
		if (keyCode < 48 && this.specSymbol[keyCode] == undefined) {
			return true;
		}
		if ((FcurrentCASh & 1 && keyCode == 17 && !(FcurrentCASh & 4)) || (FcurrentCASh & 2 && keyCode == 16 && !(FcurrentCASh & 4))) {
			this.currentCASh = 0;
			this.sendValue("CFG.currentCASh", 0, src + '_typeSymbol');
			this.switchLanguage();
			return false;
		}
		var setFocus = false;
		switch (keyCode) {
			case 8:
				if (this.focusedField) {
				    if (this.parent.isIE) {
//					if (!focused) setFocus = true;
					this.focusedField.focus();
//						if (setFocus) setCursorPosition(this.focusedField, this.focusedField.value.length, this.focusedField.value.length);
					return true;
				    }
				    // delete parent if insertAtCursor into VK
				    this.parent.deleteAtCursor(this.focusedField);
				}
				break;
			case 9:
				return true;
				break;
			case 13:
				if (undefined != this.focusedField) {
					this.parent.insertAtCursor(this.focusedField, "\n");
				}
				return false;
				break;
			case 1:
			case 2:
			case 3:
			case 4:
			case 16:	// shift
			        if (!(FcurrentCASh & 1)) {
				        this.currentCASh  = FcurrentCASh + 1;
				        this.sendValue("CFG.currentCASh", this.currentCASh, src + '_typeSymbol');
			        }
				return true;
				break;
			case 17:	// ctrl
				if (!(FcurrentCASh & 2)) {
				        this.currentCASh = FcurrentCASh + 2;
				        this.sendValue("CFG.currentCASh", this.currentCASh, src + '_typeSymbol');
				}
				return true;
				break;
			case 18:	// alt
			        if (!(FcurrentCASh & 4)) {
				        this.currentCASh = FcurrentCASh + 4;
				        this.sendValue("CFG.currentCASh", this.currentCASh, src + '_typeSymbol');
				}
				return true;
				break;
			case 116:   // F5
				location.href = document.URL;
				return false;
				break;
/*			case 67:    // c
			        if (this.currentCASh & 2) {
				        if (undefined == this.parent.isIE) {
						return true;
					}
					if (this.focusedField) {
						// delete parent if insertAtCursor into VK
						this.parent.clipboardCopy(this.focusedField);
					}
					break;
				}
*/
			case 86:    // v
			        if (this.currentCASh & 2) {
					if (undefined == this.parent.isIE) {
						return true;
					}
					if (this.focusedField) {
						// delete parent if insertAtCursor into VK
						this.parent.clipboardPaste(this.focusedField);
					}
					break;
                                }
			default:
				if (undefined != this.focusedField && undefined != this.keyLayout[this.currentLayout][this.currentCASh][keyCode]) {
					if (!this.parent.focused) {
						this.parent.focusedField.focus();
					}
					// delete parent if insertAtCursor into VK
					this.parent.insertAtCursor(this.focusedField, this.keyLayout[this.currentLayout][this.currentCASh][keyCode]);
					for (var j = 0; j < this.callback.length; j++) {
						if ('typeSymbol' == this.callback[j]['elementType']) {
							this.callback[j]['function'].call(this.callback[j]['functionObject']);
						}
					}
					return false;
				} else {
					return true;
				}
		}
		return false;
	},

	// get pressed down key (JS event handler)
	keyDown: function(e) {
		if (!e) e = event;
		var code = e.which ? e.which : e.keyCode;
		if (e.shiftKey && e.ctrlKey) {
			this.switchLanguage();
			return false;
		}

		if (e.shiftKey && code != 16) { // shift
		        if (!(this.currentCASh & 1)) {
			        this.currentCASh ++;
				this.sendValue("CFG.currentCASh", this.currentCASh, 'down');
			}
		}

		if (e.ctrlKey && code != 17) { // ctrl
		    if (!(this.currentCASh & 2)) {
			    this.currentCASh += 2;
			    this.sendValue("CFG.currentCASh", this.currentCASh, 'down');
		    }
		}

		if (e.altKey && code != 18) { // alt
			if (!(this.currentCASh & 4)) {
				this.currentCASh += 4;
				this.sendValue("CFG.currentCASh", this.currentCASh, 'down');
			}
		}
		this.sendCode(code, 3);
		var ret = this.typeSymbol('js', code, this.currentCASh);
		if (false === ret && !this.parent.isIE) {
			e.preventDefault();
		}
		return ret;
	},

        // get up key (JS event handler)
	keyUp: function(e) {
		if (!e) e = event;
		var code = e.which ? e.which : e.keyCode;
		if (!e.shiftKey && this.currentCASh & 1) { // shift
			this.currentCASh --;
			this.sendValue("CFG.currentCASh", this.currentCASh, 'up');
			return true;
		}

		if (!e.ctrlKey && this.currentCASh & 2) { // ctrl
			this.currentCASh -= 2;
			this.sendValue("CFG.currentCASh", this.currentCASh, 'up');
			return true;
		}

		if (!e.altKey && this.currentCASh & 4) { // alt
			this.currentCASh -= 4;
			this.sendValue("CFG.currentCASh", this.currentCASh, 'up');
			return true;
		}
		this.sendCode(code, 1);
		if ((code > 47 && (undefined != this.keyLayout[this.currentLayout][this.currentCASh][code] || 0 == this.currentCASh)) || undefined != this.specSymbol[code]) {
			return false;
		} else {
		    return true;
		}
	},
	
	// false keyPress only for Opera - other browser not invoke
	keyPress: function(e) {
		if (!e) e = event;
		var code = e.which ? e.which : e.keyCode;
		if (e.shiftKey && e.ctrlKey) {
			return false;
		}
		if (code > 96 && code < 123) code -= 32;
		if (9 == code) {
			if (!this.parent.isIE) this.focusedField.parentNode.blur();
			this.focusedField.parentNode.focus();
			if (!this.parent.isIE) {
				e.preventDefault();
			}
			return false;
		} else if ((code > 47 && (undefined != this.keyLayout[this.currentLayout][this.currentCASh][code] || 0 == this.currentCASh) && !(this.parent.isSafari && code < 63236 && code > 63231)) || undefined != this.specSymbol[code]) {
			if (!this.parent.isIE) {
				e.preventDefault();
			}
			return false;
		} else if (code < 256 || (this.parent.isSafari && code < 63236 && code > 63231)) {
		        return true;
		} else {
			code = e.which ? e.which : e.keyCode;
			if (!this.parent.isIE) {
				e.preventDefault();
			}
			return false;
		}
	}
};
if ("undefined" == typeof KeyboardTable.keyLayoutSound) {
	KeyboardTable.keyLayoutSound = {};
}
KeyboardTable.keyLayoutSound['mask_cree'] = {};
KeyboardTable.keyLayoutSound['mask_cree']['latin'] = {
	'0': { // no control keys
                '65': 'pi',
                '66': 'ye',
                '67': 'te',
                '68': 'ti',
                '69': 'ta',
                '70': 'i',
                '71': 'yi',
                '72': 'mi',
                '73': 'na',
		'74': 'ki',
                '75': 'ni',
                '76': 'si',
                '77': 'ke',
                '78': 'me',
                '79': 'sa',
                '81': 'pa',
                '82': 'a',
                '83': 'chi',
                '84': 'ya',
                '85': 'ka',
                '86': 'e',
                '87': 'cha',
                '88': 'che',
                '89': 'ma',
                '90': 'pe',
                '188': 'ne',
                '190': 'se',
		'222': 'w'
	},          

	'1': { // shift
                '65': 'p',
                '68': 't',
                '69': 'to',
                '70': 'h',
                '71': 'y',
                '72': 'm',
                '73': 'no',
		'74': 'k',
                '75': 'n',
                '76': 's',
                '79': 'so',
                '81': 'po',
                '82': 'o',
                '83': 'ch',
                '84': 'yo',
                '85': 'ko',
                '87': 'cho',
                '89': 'mo',
                '222': 'w'
	}
};
KeyboardTable.PlaySound = function(parent, textFieldId, functionEvent) {
	this.parent = parent;
	this.currentLayout = this.parent.keyboardLayout;
	this.keyLayout = this.parent.keyLayout;
	this.isSound = (2 == this.parent.soundMode) ? 1 : 0;
	this.movie = this.parent.isIE || this.parent.isSafari ? document.getElementById(this.parent.playIE) : document.getElementById(this.parent.play);
	this.soundImg =  document.getElementById(this.parent.imgSwitchSound);
	this.currentCASh = 0;
	this.callback = functionEvent ? functionEvent : Array();
	this.textFieldId = textFieldId;
	if (!this.parent.flashValid || !this.checkVersion()) {
		this.movie = null;
	}
}

KeyboardTable.PlaySound.prototype = {
// methods for correct page work
	// check flash player version
	checkVersion: function() {
		var version, i;
		version = this.movie.GetVariable('$version');
		for (i=1; i < 8; i++) {
		        if (-1 != version.indexOf(' ' + i + ',') || 0 == version.indexOf(i + '.')) {
				document.getElementById(this.parent.divIconsBlock).innerHTML = 'Sorry, Syllabic Table is only for Flash Player 8 and higher. Current Flash version is '
					+ version + '. Please <a href="http://www.adobe.com/go/getflashplayer">update Flash Player</a>.';
				this.parent.flashValid = false;
				return false;
			}
		}
	return true;
	},

	// switch sound mode - on/off	
	switchSound: function() {
		if (this.parent.flashValid) {
			if (this.isSound & 1) {
				this.isSound = 0;
				this.soundImg.src = this.parent.pathImg + "chartable/sound-off.gif";
				this.soundImg.alt = 'Sound Off';
				if (2 == this.parent.soundMode) {
					this.parent.soundMode = 0;
					if (undefined != this.parent.VK.movie) {
						this.parent.VK.movie.switchSound();
					}
				}
			} else {
				this.isSound = 1;
				this.soundImg.src = this.parent.pathImg + "chartable/sound-on.gif";
				this.soundImg.alt = 'Sound On';
				if (2 != this.parent.soundMode) {
					var oldSound = this.parent.soundMode ;
					this.parent.soundMode = 2;
					if (undefined != this.parent.VK.movie) {
						this.parent.VK.movie.switchSound();
						if (0 == oldSound) {
							this.parent.VK.movie.switchSound();
						}
					}
				}				
				this.parent.soundMode = 2;
			}
		}
	},
	
	playSound: function(code, currectCASh) {
		if (this.parent.flashValid && this.isSound) {
			this.movie.playSound(code, currectCASh);
		}
	}
	
};
	KT.chooseType = 'keyboard';
	
	KT.init = function() {
		if (undefined != this.overKeyLayout && undefined != this.overKeyLayout[this.keyboardLayout] && this.overKeyLayout[this.keyboardLayout].length) {
			for (var i = 0; i < this.overKeyLayout[this.keyboardLayout].length; i++) {
				if (undefined != this.overKeyLayout[this.keyboardLayout][i]) {
					this.keyLayout['latin'][1][i] = this.overKeyLayout[this.keyboardLayout][i];
				}
			}
		}
	}
	
	KT.onLoadHandler = function() {
		this.pageLoad = true;
		if (this.flashValid) {
			this.checkVersion('content', 'Online Converter', this.divkeyboard, 'Virtual Keyboard');
		}
		if (this.flashValid) {
			if (this.VKLoad && this.PSLoad) {
				this.pageHandler();
			}
		} else {
			if (undefined == this.VK) {
				this.VK = new this.VirtualKeyboard(this, "VK", this.arrayId);
			}
			this.VKLoad = true;
			this.pageHandler();
			this.PS = new this.PlaySound(this, this.arrayId);
			this.PSLoad = true;
		}
	}

	
	// save last selected field
	KT.saveFocus = function(e) {
		if (!e) e = event;
		var code = e.which ? e.which : e.keyCode;
		var element = (e.srcElement) ? e.srcElement : e.target;
		this.focusedField = element;
		this.focused = true;
	}
	
	// save last selected field
	KT.fixBlur = function(e) {
		if (!e) e = event;
		var code = e.which ? e.which : e.keyCode;
		var element = (e.srcElement) ? e.srcElement : e.target;
		this.focused = false;
	}

	KT.insertAtCursor = function(textField, textValue) {
		var setFocus = false;
		//IE support
		if (document.selection) {
			var sel;
			if (!this.focused) setFocus = true;
			textField.focus();
			if (setFocus) this.setCursorPosition(textField, textField.value.length, textField.value.length);
			sel = document.selection.createRange();
			sel.text = textValue;
			sel.collapse(false);
			sel.select();
//			textField.click();
		//MOZILLA/NETSCAPE support
		} else if (textField.selectionStart || textField.selectionStart == '0') {
			var startPos = textField.selectionStart;
			var endPos = textField.selectionEnd;
			textField.value = textField.value.substring(0, startPos)
				+ textValue
				+ textField.value.substring(endPos, textField.value.length);
			textField.selectionStart = textField.selectionEnd = startPos + textValue.length;
		} else {
			textField.value += textValue;
		}
	}
	
		// delete form cursor
	KT.deleteAtCursor = function(textField) {
		//IE support
//		var setFocus = false;
//		if (document.selection) {
////			var sel;
////			if (!focused) setFocus = true;
//			textField.onfocus = deleteInIE;
////			textField.addEventListener("focus", deteteInIE, false);
//			textField.focus();
//		}
//		//MOZILLA/NETSCAPE support
//		else
//
		if (textField.selectionStart || textField.selectionStart == '0') {
			var startPos = textField.selectionStart;
			var endPos = textField.selectionEnd;
			if (startPos == endPos) startPos--;
			textField.value = textField.value.substring(0, startPos)
				+ textField.value.substring(endPos, textField.value.length);
			textField.selectionStart = textField.selectionEnd = startPos;
		} else {
			textField.value = textField.value.substring(0, textField.value.length - 1);
		}
	}
	
	KT.setCursorPosition = function(textField, start, end) {
	        if (textField.setSelectionRange) {
	                textField.setSelectionRange(start, end);
	        } else if (textField.createTextRange) {
	                range = textField.createTextRange();
	                range.collapse(true);
	                range.moveEnd('character', end);
	                range.moveStart('character', start);
	                range.select();
	        }
	}
	
	// copy to clipboard
	KT.clipboardCopy = function(textField) {
	        if (document.selection) {
			if (!this.isIE) {
				this.focusedField.blur();
			}
			textField.focus();
                        this.setCursorPosition(textField, 0, textField.value.length);
//               } else {
//	    // may be for MOZILLA
//                   if (textField.selectionStart || textField.selectionStart == '0') {
//                        textField.selectionStart = o;
//                        textField.selectionEnd = textField.length - 1;
//                }
//
		}
		if (window.clipboardData) {
		        window.clipboardData.clearData();
		        window.clipboardData.setData("Text", textField.value);
//             	} else {
//			// may be for MOZILLA
//			if(window.Components) {
//				var clip, trans, str;
//			        //  ,      ,     
//			        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
//			       //   
//			       (str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString)).data = textField.value;
//			       //   
//			       if(!(clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard))) return;
//			       //  ()
//			       if(!(trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable))) return;
//			       trans.addDataFlavor('text/unicode');
//			       //     ,       ;-)
//			       trans.setTransferData("text/unicode",str,text.length*2);
//			       //    
//			       clip.setData(trans,null,Components.interfaces.nsIClipboard.kGlobalClipboard);
//			}
//
		}
	}

	// paste from clipboard
	KT.clipboardPaste = function(textField) {
		if (window.clipboardData) {
		        var text = window.clipboardData.getData("Text");
		        this.insertAtCursor(textField, text);
		}
	}
	// set onfocus handlers for elements with id in KT.arrayId
	KT.handlerLoadPage = function(type, saveFocus, saveFocusName, fixBlur, fixBlurName, obj) {
		var fLen, i;
		fLen = this.arrayId.length;
		for (i = 0; i < fLen; i++) {
			this.handlerListener(type, document.getElementById(this.arrayId[i]), 'focus', saveFocus, saveFocusName, obj, false);
			this.handlerListener(type, document.getElementById(this.arrayId[i]), 'blur', fixBlur, fixBlurName, obj, false);
		}
		this.endLoad = true;
		
	}

if ("undefined" != typeof KeyboardTable.PlaySound) {
		KeyboardTable.PlaySound.prototype.typeSymbol = function(keyCode, currentCASh) {
			this.playSound(keyCode, currentCASh);
			var setFocus = false;
			var symbol;
			switch (keyCode) {
				case 8:
					if (this.parent.focusedField) {
					    if (this.parent.isIE) {
						this.parent.focusedField.focus();
						return true;
					    }
					    this.parent.deleteAtCursor(this.focusedField);
					}
					break;
				case 9:
					return true;
					break;
				case 13:
					if (undefined != this.parent.focusedField) {
						this.parent.insertAtCursor(this.parent.focusedField, "\n");
					}
					return false;
					break;
				case 116:   // F5
					location.href = document.URL;
					return false;
					break;
				case 86:    // v
				        if (this.currentCASh & 2) {
						if (undefined == this.parent.isIE) {
							return true;
						}
						if (this.parent.focusedField) {
							this.parent.clipboardPaste(this.parent.focusedField);
						}
						break;
	                                }
				default:
					if (undefined != this.parent.focusedField && undefined != this.parent.keyLayout[this.currentLayout][currentCASh][keyCode]) {
						if (!this.parent.focused) {
							this.parent.focusedField.focus();
						}
						this.parent.insertAtCursor(this.parent.focusedField, this.keyLayout[this.currentLayout][currentCASh][keyCode]);
//						if (this.parent.isMacFirefox) {
//							this.parent.focusedField.blur();
//						}
//						this.parent.focusedField.focus();
						for (var j = 0; j < this.callback.length; j++) {
							if ('typeSymbol' == this.callback[j]['elementType']) {
								this.callback[j]['function'].call(this.callback[j]['functionObject']);
							}
						}
						return false;
					} else {
						return true;
					}
				}
			return false;
		}
		

		// method for switch keyLayout for char table
		KeyboardTable.PlaySound.prototype.switchLanguage = function(lang, type) {
			if (this.currentLayout != lang || type) {
				this.currentLayout = lang;
				if (this.currentLayout != 'latin') {
					var divElement = document.getElementById(this.parent.divSymbolTable);
					divElement.className = divElement.className.replace('Red', '');
					var childs = divElement.childNodes;
					for (var i = 0; i < childs.length; i++) {
						if (1 == childs[i].nodeType && 'TABLE' == childs[i].tagName) {
							childs[i].className = childs[i].className.replace('Red', '');
							break;
						}
					}
				} else {
					var divElement = document.getElementById(this.parent.divSymbolTable);
					if (-1 == divElement.className.indexOf('Red')) {
						divElement.className += 'Red';
					}
					var childs = divElement.childNodes;
					for (var i = 0; i < childs.length; i++) {
						if (1 == childs[i].nodeType && 'TABLE' == childs[i].tagName) {
							if (-1 == childs[i].className.indexOf('Red')) {
								childs[i].className += 'Red';
							}
							break;
						}
					}
//					document.getElementById(this.parent.divSymbolTable).style.color = '#FF0000';
				}
/*				if (document.styleSheets) {
					var styleSheet = document.styleSheets[0];
					var styleRules = styleSheet.cssRules ? styleSheet.cssRules : styleSheet.rules;
					if (this.currentLayout == 'latin') {
						for (var i = 0; i < styleRules.length; i ++) {
							if ('.symboltable td a' == styleRules[i].selectorText.toLowerCase() || '.symboltable2 td a' == styleRules[i].selectorText.toLowerCase()) {
								styleRules[i].style.color = 'red'//'#922B00';
								//styleRules[i].style.fontSize = '2em';
							} else if ('.symboltable td a span' == styleRules[i].selectorText.toLowerCase() || '.symboltable2 td a span' == styleRules[i].selectorText.toLowerCase()) {
								styleRules[i].style.color = '#6D553E';
								//styleRules[i].style.fontSize = '12px';
							}
						}
					} else {
						for (var i = 0; i < styleRules.length; i ++) {
							if ('.symboltable td a' == styleRules[i].selectorText.toLowerCase() || '.symboltable2 td a' == styleRules[i].selectorText.toLowerCase()) {
								styleRules[i].style.color = '#6D553E';
								//styleRules[i].style.fontSize = '12px';
							} else if ('.symboltable td a span' == styleRules[i].selectorText.toLowerCase() || '.symboltable2 td a span' == styleRules[i].selectorText.toLowerCase()) {
								styleRules[i].style.color = '#922B00';
								//styleRules[i].style.fontSize = '2em';
							}
						}
					}
				}
*/
			}
		}

			// get pressed down key (JS event handler)
		KeyboardTable.PlaySound.prototype.keyDown = function(e) {
			if (!e) e = event;
			var code = e.which ? e.which : e.keyCode;
			if (e.shiftKey && e.ctrlKey) {
				this.switchFocus();
				return false;
			}

			if (e.shiftKey && code != 16) { // shift
			        if (!(this.currentCASh & 1)) {
				        this.currentCASh ++;
				}
			}

			if (e.ctrlKey && code != 17) { // ctrl
				if (!(this.currentCASh & 2)) {
				    this.currentCASh += 2;
				}
			}

			if (e.altKey && code != 18) { // alt
				if (!(this.currentCASh & 4)) {
					this.currentCASh += 4;
				}
			}
			var ret = this.typeSymbol(code, this.currentCASh);
			if (false === ret && !this.parent.isIE) {
				e.preventDefault();
			}
			return ret;
		},

        // get up key (JS event handler)
		KeyboardTable.PlaySound.prototype.keyUp = function(e) {
			if (!e) e = event;
			var code = e.which ? e.which : e.keyCode;
			if (!e.shiftKey && this.currentCASh & 1) { // shift
				this.currentCASh --;
				return true;
			}

			if (!e.ctrlKey && this.currentCASh & 2) { // ctrl
				this.currentCASh -= 2;
				return true;
			}

			if (!e.altKey && this.currentCASh & 4) { // alt
				this.currentCASh -= 4;
				return true;
			}
			if ((code > 47 && (undefined != this.keyLayout[this.currentLayout][this.currentCASh][code] || 0 == this.currentCASh)) || undefined != this.specSymbol[code]) {
				return false;
			} else {
			    return true;
			}
		},
	
	// false keyPress only for Opera - other browser not invoke
		KeyboardTable.PlaySound.prototype.keyPress = function(e) {
			if (!e) e = event;
			var code = e.which ? e.which : e.keyCode;
			if (e.shiftKey && e.ctrlKey) {
			    return false;
			}
			if (code > 96 && code < 123) code -= 32;
			if (9 == code) {
				if (!this.parent.isIE && this.focusedField.parentNode) {
					this.focusedField.parentNode.blur();
				}
				this.focusedField.parentNode.focus();
				if (!this.parent.isIE) {
					e.preventDefault();
				}
				return false;
			} else if ((code > 47 && (undefined != this.keyLayout[this.currentLayout][this.currentCASh][code] || 0 == this.currentCASh) && !(this.parent.isSafari && code < 63236 && code > 63231)) || undefined != this.specSymbol[code]) {
				if (!this.parent.isIE) {
					e.preventDefault();
				}
				return false;
						// arrows codes into Safari
			} else if (code < 256 || (this.parent.isSafari && code < 63236 && code > 63231)) {
			        return true;
			} else {
				if (!this.parent.isIE) {
					e.preventDefault();
				}
				return false;
			}
		}


		KeyboardTable.PlaySound.prototype.handlerKeyListeners = function(type) {
			var fLen, i, j;
			fLen = this.textFieldId.length;
			var eLen = this.callback.length;
			for (i = 0; i < fLen; i++) {
				if ('latin' != this.currentLayout || ('latin' == this.currentLayout && 'remove' == type)) {
					// get pressed down key (JS event handler)
					this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), 'keydown', this.keyDown, this.parent.name + '.PS.keyDown', this, false);

					// get up key (JS event handler)
					this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), 'keyup', this.keyUp, this.parent.name + '.PS.keyUp', this, false);

					// false keyPress only for Opera - other browser not invoke
					this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), 'keypress', this.keyPress, this.parent.name + '.PS.keyPress', this, false);
				}
				for (j = 0; j < eLen; j++) {
					if ('field' == this.callback[j]['elementType']) {
						this.parent.handlerListener(type, document.getElementById(this.textFieldId[i]), this.callback[j]['eventType'], this.callback[j]['function'], this.callback[j]['functionName'], this.callback[j]['functionObject'], false);
					}
				}
			}
			for (j = 0; j < eLen; j++) {
				if ('input' == this.callback[j]['elementType']) {
					this.parent.handlerListener(type, document.getElementById(this.parent.divSymbolTable), this.callback[j]['eventType'], this.callback[j]['function'], this.callback[j]['functionName'], this.callback[j]['functionObject'], false);
				}
			}
			return true;
		}
	}

	// switcher between charTable and keyboard
	KeyboardTable.chooseMethod = function(type, from) {
		if (!this.PSLoad || !this.VKLoad) {
			if (undefined != from) {
				setTimeout(this.name + '.chooseMethod("' + type + '", "' + from + '")', 10);
			} else {
				setTimeout(this.name + '.chooseMethod("' + type + '")', 10);
			}
			return false;
		}
		var element;
		if ('keyboard' == type) {
			// hide charTable - flash is hidden
			element = document.getElementById(this.divSymbolTable);
			element.style.display = 'none';
			element = document.getElementById(this.divIconsBlock);
			element.style.display = 'none';
			if ('load' == from) {
				if (!this.flashValid || ('load' == from && !this.VK.checkVersion())) {
					this.VK.movie = null;
				} else {
					// show keyboard - normal size
					this.VK.movie.style.width = this.VK.movieWidth + 'px';
					this.VK.movie.style.height = this.VK.movieHeight + 'px';
				}
			}
			if (type != this.chooseType || 'nothing' == from) {
				// change latin
				this.keyLayout['latin'] = this.VK.keyLayoutLatin;
				if ('nothing' != from) {
					this.currentLang = ('load' == from) ? this.currentViewLayout : this.PS.currentLayout;
					// remove handlers for keys and focus events
					this.handlerLoadPage('remove', this.saveFocus, this.name + '.saveFocus', this.fixBlur, this.name + '.fixBlur', this);
					this.PS.handlerKeyListeners('remove');
				}
				this.VK.movie = this.isIE || this.isSafari ? document.getElementById(this.keyboardIE) : document.getElementById(this.keyboard);
				if (!this.flashValid || ('load' == from && !this.VK.checkVersion())) {
					this.VK.movie = null;
				} else {
					// show keyboard - normal size
					this.VK.movie.style.width = this.VK.movieWidth + 'px';
					this.VK.movie.style.height = this.VK.movieHeight + 'px';
				}
				this.VK.movie.style.visibility = "visible";
				if ('none' == document.getElementById(this.divkeyboard).style.display) {
					// show keyboard if use display (this.VK.movie is NULL - flash is not valid)
					document.getElementById(this.divkeyboard).style.display = 'block';
				}
				// add handlers for keys and focus events
				this.VK.handlerKeyListeners('add');
				if ('nothing' != from) {
					this.VK.sendLanguage(-1 == this.currentLang.indexOf('cree') ? this.keyboardLayout : 'latin');
				}
			}
		} else if ('charTable' == type && (type != this.chooseType || 'nothing' == from)) {
			// change latin
			this.PS.keyLayout['latin'] = this.keyLayoutSound[this.keyboardLayout]['latin'];
			if ('nothing' != from) {
				this.currentLang = ('load' == from) ? this.currentViewLayout : this.VK.currentLayout;
				// remove handlers for keys and focus events
				this.VK.handlerKeyListeners('remove');
			}
			// hide keyboard - no size if this.Vk.movie is not NULL, use display other
			if (undefined == this.VK.movie) {
				element = document.getElementById(this.divkeyboard);
				element.style.display = 'none';
			} else {
				this.VK.movie.style.width = '1px';
				this.VK.movie.style.height = '1px';
			}
//			this.VK.movie = null;
			// show charTable - flash is visible
			element = document.getElementById(this.divSymbolTable);
			element.style.display = 'inline';
//			element.style.display = 'block';
			element = document.getElementById(this.divIconsBlock);
			element.style.display = 'block';
			// add handlers for keys and focus events
			this.handlerLoadPage('add', this.saveFocus, this.name + '.saveFocus', this.fixBlur, this.name + '.fixBlur', this);
			if ('latin' != this.currentLang) {
				this.PS.handlerKeyListeners('add');
			}
			if ('nothing' != from) {
				this.PS.switchLanguage(this.currentLang, 1);
			}
		}
		this.chooseType = type;
	
		if (undefined != this.arrayId[0]) {
			document.getElementById(this.arrayId[0]).focus();
		}
		return true;
	}
;
<!-- this is my script if needed -->
function ExternalInterfaceManager() {
	this.registerMovie = function(movieName) {
	if(!window.fakeMovies) window.fakeMovies = new Array();
	window.fakeMovies[window.fakeMovies.length] = movieName;
}
	this.initialize = function() {
		if(document.all) {
			if(window.fakeMovies) {
				for(var i=0;i<window.fakeMovies.length;i++) {
					window[window.fakeMovies[i]] = new Object();
				}
				window.attachEvent("onload", initializeExternalInterface);
			}
		}
	}
}

function initializeExternalInterface() {
	for(var i = 0; i < window.fakeMovies.length; i++) {
		var movieName = window.fakeMovies[i];
		var fakeMovie = window[movieName];
		var realMovie = document.getElementById(movieName);

		for(var method in fakeMovie) {
			realMovie[method] = function() {flashFunction = "&lt;invoke name=\"" + method.toString() + "\" returntype=\"javascript\"&gt;" + __flash__argumentsToXML(arguments, 0) + "&lt;/invoke&gt;";this.CallFunction(flashFunction);}
		}

		window[movieName] = realMovie;
	}
}

// KT.arrayId = "KT.arrayId.concat(['input_1']); // array of target fields

KT.root = "http://learn.creedictionary.com";
KT.divIconsBlock = "KT128389231513";
KT.imgSwitchSound = "KT128389231514";
KT.divSymbolTable = "KT128389231515";
KT.divSound = "KT128389231516";
KT.playIE = "KT128389231517";
KT.play = "KT128389231518";
KT.divkeyboard = "KT128389231519";
KT.keyboardIE = "KT128389231520";
KT.keyboard = "KT128389231521";
KT.divOver = "KT128389231522";
KT.fieldClassName = "answer";
KT.soundMode = 2;
// KT.methodView = "keyboard";//"charTable";
KT.methodView = "keyboard";
KT.keyboardLayout = "mask_cree";
KT.currentViewLayout = "mask_cree";//"latin"
KT.langLayout = "Mask";
KT.preLoadImgs("http://learn.creedictionary.com/filter/creeinputdevice/keyboardtable/img/adult/");
KT.handlerListener("add", window, "load", KT.onLoadHandler, "KT.onLoadHandler", KT);
window.KT128389231520 = {};
window.KT128389231517 = {};KT.images = KT.images.concat(['chartable/sound-off.gif', 'chartable/sound-on.gif']);

KT.pageHandler = function() {
	this.isHandler = true;
	var method = this.methodView;
	var currentLangLayout;
	if (this.isSafari) {
		this.findIds(this.divOver, this.fieldClassName);
		this.VK.textFieldId = this.arrayId;
		this.VK.handlerKeyListeners('add');
	}
	if (this.PS.textFieldId != this.arrayId) {
		this.PS.textFieldId = this.arrayId;
	}
	if (this.VK.textFieldId != this.arrayId) {
		this.VK.textFieldId = this.arrayId;
	}
	this.chooseMethod(method, 'load');
	// make current layout
	if ('keyboard' == method) {
		currentLangLayout = ('latin' == this.currentViewLayout) ? this.keyboardLayout : 'latin';
		this.VK.sendLanguage(currentLangLayout);
	} else if ('charTable' == method) {
		currentLangLayout = ('latin' != this.currentViewLayout) ? this.keyboardLayout : 'latin';
		this.PS.switchLanguage(currentLangLayout);
	}
	this.VK.getSound = function(soundMode) {
		this.parent.soundMode = soundMode;
		if (this.parent.PS) {
			if ((2 != soundMode && this.parent.PS.isSound & 1)
				|| (2 == soundMode && !this.parent.PS.isSound)) {
				this.parent.PS.switchSound();
			}
		}
	}
}

KeyboardTable.PlaySound.prototype.switchFocus = function() {
	// it is stud
	var lang;
	lang = (-1 ==  this.currentLayout.indexOf('cree')) ? this.parent.keyboardLayout : 'latin';
	this.switchLanguage(lang);
	if ('latin' == lang) {
		// remove handlers for keys and focus events
		this.handlerKeyListeners('remove');
	} else {
		// add handlers for keys and focus events
		this.handlerKeyListeners('add');
	}
}
;
