﻿if (!window.Keyboard)
    window.Keyboard = {};


Keyboard.Handler = function() {
    this.InputControl = null;
}

jQuery(document).ready(function($) {
    $(".KeyboardInput").each(function() {
        var current = this;
        this.onfocus = function(event) {
            keyboardHandler.Select(current);
            var control = $(".KeyboardInput")
            var left = control.position().left + control.width() / 2;
            var top = control.position().top + control.height();
            Tip('If you need input help please select <a onclick="keyboardHandler.Show(\'keyboardControl\');" href="#" >Keyboard</a> control', BALLOON, true, FOLLOWMOUSE, false, FIX, [current, 0, 5]);
        }
    });
});


Keyboard.CreateDelegate = function(instance, method) {
    return function() {
        return method.apply(instance, arguments);
    }
}
Keyboard.Handler.prototype =
{
    CloseToolTip: function() {
        UnTip();
    },

    Show: function(divBlock) {
        w = 800;
        h = 350;
        this.CloseToolTip();
        divHandler.DisplayFloatingDiv(divBlock, w, h);
    },
    Close: function() {
        divHandler.HiddenFloatingDiv();
    },
    Select: function(sender) {
        this.InputControl = sender;
    },

    SetText: function(isOk, newText) {
        this.Close();
        if (!this.InputControl || !newText) return;
        if (isOk) {
            this.InputControl.value = newText;
        }
    },
    GetCurrentText: function() {
        if (this.InputControl)
            return this.InputControl.value;
        return '';
    }
}

var keyboardHandler = null;
if (!keyboardHandler) {
    keyboardHandler = new Keyboard.Handler();
}

