﻿﻿jQuery.fn.toolTipInit = function () {
    return this.each(function () {
        $('<div id="cwToolTip"/>').appendTo(this);

        $(document).bind('keyup', 'esc', function (event) {
            hideTip();
            return true; //Continue with other escape stuff if any
        });
    });
};

function hideTip() {

    $('#cwToolTip').hide();

}

function showTip() {
    $('.close', $('#cwToolTip')).click(function () { hideTip(); });
    $('#cwToolTip').show();
    if(!$('#cwToolTip').find('a [href]').length) {
        window.setTimeout(hideTip, 6000);
    }
}
function statusBarShow(dummy){return true;}
function statusBarSetComplete(statusText, tooltip, success, tooltipPosition) {
    if (success === undefined)
        success = true;
    if (tooltip)
        $('#cwToolTip').html('<div title="Close" class="close closeicon"></div>' + tooltip);
    if (success) 
        $('#cwToolTip').removeClass('axerror');
    else 
        $('#cwToolTip').addClass('axerror');

    if (tooltip) {
        if (tooltipPosition === undefined)
            tooltipPosition = 'default';
    
        var topPos = (document.documentElement.clientHeight / 2) + document.documentElement.scrollTop - 50;
        var leftPos = (document.documentElement.clientWidth / 2) + document.documentElement.scrollLeft - 160;
        $('#cwToolTip').css('position', 'absolute');
        $('#cwToolTip').css('top', topPos + 'px');
        $('#cwToolTip').css('left', leftPos + 'px');
        showTip();
    }
}
