var sid = 0;
var hid = 0;
var showtd = true;
window.afterInitTable = function() {
$('.errorname span').mouseover(showErrorDescription).mouseout(function() { showtd = false; clearTimeout(sid); hid = setTimeout('hideErrorDescription()', 400); }).click(function() { showtd = false; });
};
//Показать/скрыть описание заявки
function showErrorDescription() {
    var id = this.id;
    showtd = true;
    sid = setTimeout('_showErrorDescription("' + id + '")', 500);
    clearTimeout(hid);
}
function hideErrorDescription() {
    $('.errordescription').hide();
}

function _showErrorDescription(tid) {
    if (!showtd) return;
    var id = getId(tid);

    var tdkey = '#errordescription_' + id;
    $('.errordescription').hide();

    var offset = $('#errorname_' + id).offset();
    var h = $('#errorname_' + id).height();
    var w = $(window).width() - 300;
    if (w < 300) w = 300;
    if (w > 400) w = 400;
    
    if ($(tdkey).length > 0) {
        $(tdkey).css('top', offset.top + h + 5).css('left', offset.left + 60).css('width', w);
        $(tdkey).fadeIn('fast');
    }
    else {
        $('body').append('<div id="errordescription_' + id + '" class="errordescription popupwrapper"><div class="popup"></div></div>');
        $(tdkey).css('top', offset.top + h + 5).css('left', offset.left + 40).css('width', w);
        $(tdkey).mouseover(function() { clearTimeout(hid); }).mouseout(function() { hid = setTimeout('hideErrorDescription()', 500); });
        $('.popup', $(tdkey)).load(base + 'eventlog.ivp/errordetails/' + id, { date: new Date().toString() }, function() { if (!showtd) return; $('.popup', $(tdkey)).bgiframe(); $(tdkey).show();});
    }
}