﻿function tooltip(objId, msg, position, topen, tclose) {
    callAfter(function(){
        var tid = $(objId);
        if (tid.length < 1) {
            return false;
        }
        var tCss = {
	        width:'150px',
	        height:'77px',
	        background:'url(Template/images/tooltip.png) no-repeat',
	        zIndex:'9999',
	        position:'absolute',
	        fontSize:'10px',
	        fontFamily:'Arial',
	        color:'#ffffff'	        
        }
        var mtp = $('<div>').html(msg).css('margin','33px 10px 10px 20px');
        var tp = $('<div>').addClass('tooltip').css(tCss).css({left:(tid.offset().left + tid.width() - position.left), top:(tid.offset().top + tid.height() - position.top), display:'none'}).append(mtp);
        $('body').append(tp);
        tp.fadeIn(500, function(){
            $(this).animate({color:'#ff0000'},250, function(){
                $(this).animate({color:'#ffffff'},250, function(){
                    $(this).animate({color:'#ff0000'},250, function(){
                        $(this).animate({color:'#ffffff'},250)
                    ;})
                ;})
            ;});
            callAfter(function(){
                $('.tooltip').fadeOut(500, function() {
                    $(this).remove();
                });
            }, tclose);
        });
    }, topen);
}
function tooltip_remove() {
    $('.tooltip').remove();
}
function callAfter(callFunc, wait) {
    if (typeof(callFunc) == 'function') {
        var tmr = setTimeout(function(){
            callFunc();
            clearTimeout(tmr);
        }, wait);
    }
}