(function(b){
    function e(f,h,m){
        var q=m.relative?f.position().top:f.offset().top,o=m.relative?f.position().left:f.offset().left,v=m.position[0];
        q-=h.outerHeight()-m.offset[0];
        o+=f.outerWidth()+m.offset[1];
        var y=h.outerHeight()+f.outerHeight();
        if(v=="center")q+=y/2;
        if(v=="bottom")q+=y;
        v=m.position[1];
        f=h.outerWidth()+f.outerWidth();
        if(v=="center")o-=f/2;
        if(v=="left")o-=f;
        return{
            top:q,
            left:o
        }
    }
    function k(f,h){
    var m=this,q=f.add(m),o,v=0,y=0,C=f.attr("title"),H=c[h.effect],M,N=f.is(":input"),P=N&&f.is(":checkbox, :radio, select, :button, :submit"),
    G=f.attr("type"),l=h.events[G]||h.events[N?P?"widget":"input":"def"];
    if(!H)throw'Nonexistent effect "'+h.effect+'"';
    l=l.split(/,\s*/);
    if(l.length!=2)throw"Tooltip: bad events configuration for "+G;
    f.bind(l[0],function(W){
        clearTimeout(v);
        if(h.predelay)y=setTimeout(function(){
            m.show(W)
            },h.predelay);else m.show(W)
            }).bind(l[1],function(W){
        clearTimeout(y);
        if(h.delay)v=setTimeout(function(){
            m.hide(W)
            },h.delay);else m.hide(W)
            });
    if(C&&h.cancelDefault){
        f.removeAttr("title");
        f.data("title",C)
        }
        b.extend(m,{
        show:function(W){
            if(!o){
                if(C)o=
                    b(h.layout).addClass(h.tipClass).appendTo(document.body).hide().append(C);
                else if(h.tip)o=b(h.tip).eq(0);
                else{
                    o=f.next();
                    o.length||(o=f.parent().next())
                    }
                    if(!o.length)throw"Cannot find tooltip for "+f;
            }
            if(m.isShown())return m;
            o.stop(true,true);
            var Z=e(f,o,h);
            W=W||b.Event();
            W.type="onBeforeShow";
            q.trigger(W,[Z]);
            if(W.isDefaultPrevented())return m;
            Z=e(f,o,h);
            o.css({
                position:"absolute",
                top:Z.top,
                left:Z.left
                });
            M=true;
            H[0].call(m,function(){
                W.type="onShow";
                M="full";
                q.trigger(W)
                });
            Z=h.events.tooltip.split(/,\s*/);
            o.bind(Z[0],function(){
                clearTimeout(v);
                clearTimeout(y)
                });
            Z[1]&&!f.is("input:not(:checkbox, :radio), textarea")&&o.bind(Z[1],function(ia){
                ia.relatedTarget!=f[0]&&f.trigger(l[1].split(" ")[0])
                });
            return m
            },
        hide:function(W){
            if(!o||!m.isShown())return m;
            W=W||b.Event();
            W.type="onBeforeHide";
            q.trigger(W);
            if(!W.isDefaultPrevented()){
                M=false;
                c[h.effect][1].call(m,function(){
                    W.type="onHide";
                    M=false;
                    q.trigger(W)
                    });
                return m
                }
            },
    isShown:function(W){
        return W?M=="full":M
        },
    getConf:function(){
        return h
        },
    getTip:function(){
        return o
        },
    getTrigger:function(){
        return f
        }
    });
b.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(W,Z){
    b.isFunction(h[Z])&&b(m).bind(Z,h[Z]);
    m[Z]=function(ia){
        b(m).bind(Z,ia);
        return m
        }
    })
}
b.tools=b.tools||{
    version:"1.2.3"
};

b.tools.tooltip={
    conf:{
        effect:"toggle",
        fadeOutSpeed:"fast",
        predelay:0,
        delay:30,
        opacity:1,
        tip:0,
        position:["top","center"],
        offset:[0,0],
        relative:false,
        cancelDefault:true,
        events:{
            def:"mouseenter,mouseleave",
            input:"focus,blur",
            widget:"focus mouseenter,blur mouseleave",
            tooltip:"mouseenter,mouseleave"
        },
        layout:"<div/>",
        tipClass:"tooltip"
    },
    addEffect:function(f,h,m){
        c[f]=[h,m]
        }
    };

var c={
    toggle:[function(f){
        var h=this.getConf(),m=this.getTip();
        h=h.opacity;
        h<1&&m.css({
            opacity:h
        });
        m.show();
        f.call()
        },function(f){
        this.getTip().hide();
        f.call()
        }],
    fade:[function(f){
        var h=this.getConf();
        this.getTip().fadeTo(h.fadeInSpeed,h.opacity,f)
        },function(f){
        this.getTip().fadeOut(this.getConf().fadeOutSpeed,f)
        }]
    };

b.fn.tooltip=function(f){
    var h=this.data("tooltip");
    if(h)return h;
    f=b.extend(true,{},b.tools.tooltip.conf,f);
    if(typeof f.position=="string")f.position=f.position.split(/,?\s/);
    this.each(function(){
        h=new k(b(this),f);
        b(this).data("tooltip",h)
        });
    return f.api?h:this
    }
})(jQuery);


var hintTooltip={
    init:function(){
        $.browser.msie&&parseInt($.browser.version)<=6?$(".hintB").tooltip({
            api:true,
            relative:true,
            position:"bottom right",
            offset:[-21,-21],
            predelay:100,
            delay:500,
            events:{
                def:"mouseover, mouseout"
            },
            onShow:function(){
                this.getTip().bgIframe()
                }
            }):$(".hintB").tooltip({
        relative:true,
        position:"bottom right",
        offset:[-21,-21],
        predelay:100,
        delay:500,
        events:{
            def:"mouseover, mouseout"
        }
    });
$tooltipContainers=$("div.hint1[id^='hint-']").each(function(){
    var b=$(this),e=b.html();
    b.html(['<div class="hint1-message fixpng"><div class="hint1-qmark fixpng"></div><div class="hint1-content fixpng">',
        e,'</div><div style="clear: both;"></div></div>'].join(""))
    })
}
};

$(document).ready(function(){
    hintTooltip.init();
    $.browser.msie&&parseInt($.browser.version)<=6&&hintTooltipPngFix.init()
});
