var vkb = null;
function ToggleKeyboard()
{
	var intKBStatus = document.getElementById('kb_status');
	switch(intKBStatus.value)
	{
		case "1":
			intKBStatus.value = "2";
			ShowKB();
			break;
		case "2":
			intKBStatus.value = "1";
			vkb.Show(false);
			vkb = null;
			break;
	}

}

function ShowKB()
{
var lang = document.getElementById('langCode').value;
if (vkb)
{
	vkb.Show(false);
}
$('#keyboardPlaceHolder').html('');
vkb =
    new VKeyboard("keyboardPlaceHolder",   // container's id, mandatory
                  keyb_callback,// reference to callback function, mandatory
                                // (this & following parameters are optional)
                  false,         // create the arrow keys or not?
                  false,         // create up and down arrow keys?
                  false,        // reserved
                  false,         // create the numpad or not?
                  "",           // font name ("" == system default)
                  "14px",       // font size in px
                  "#000",       // font color
                  "#F00",       // font color for the dead keys
                  "#FFF",       // keyboard base background color
                  "#FFF",       // keys' background color
                  "#DDD",       // background color of switched/selected item
                  "#777",       // border color
                  "#CCC",       // border/font color of "inactive" key
                                // (key with no value/disabled)
                  "#FFF",       // background color of "inactive" key
                                // (key with no value/disabled)
                  "#F77",       // border color of language selector's cell
                  true,         // show key flash on click? (false by default)
                  "#CC3300",    // font color during flash
                  "#FF9966",    // key background color during flash
                  "#CC3300",    // key border color during flash
                  false,        // embed VKeyboard into the page?
                  true,         // use 1-pixel gap between the keys?
                  lang);
				  
	vkb.Show(true);
}

function keyb_callback(ch)
{
	// Let's bind vkeyboard to the <TEXTAREA>

	// with id="textfield":
	
	var name_1 = "searchInput"+name;
    var text = document.getElementById(name_1 ), val = text.value;
		
    switch(ch)
    {
        case "BackSpace":
        var min=(val.charCodeAt(val.length - 1) == 10) ? 2 : 1;
        text.value = val.substr(0, val.length - min);
		querySuggestions(1); nav(1);
        break;

       case "Enter":
           document.getElementById('sendForm').submit();
           break;

       default:
           text.value += ch;
		   querySuggestions(1); nav(1);
    }
	
}