var Q_tooltip = {
/*
Browser: MSIE8, Firefox3, Safari3, Opera9
DTD: Strict XHTML 1.0
Created: 2008-08-17
Last Updated: 2009-03-01
*/
     arry : new Array()
    ,usr_agnt : navigator.userAgent.toLowerCase()
    ,gap_x : 30
    ,gap_y : 30
    ,background_color : 'white'
    ,font : '12px arial'
    ,padding : '10px'
    ,border : '0px solid silver'
    ,attach : function(objct,type,fnctn) {
        if(objct.addEventListener) { objct.addEventListener(type,fnctn,false); return true; } //Mozilla
        else if(objct.attachEvent) { var rtrn = objct.attachEvent('on'+type,fnctn); return rtrn; } //MSIE
        else objct.onclick = fnctn;
    }
    ,scrlld : function() {
        var arry = new Array(2);
        if(document.body.scrollLeft)                 arry[0] = document.body.scrollLeft;
        else if(document.documentElement.scrollLeft) arry[0] = document.documentElement.scrollLeft;
        if(document.body.scrollTop)                  arry[1] = document.body.scrollTop;
        else if(document.documentElement.scrollTop)  arry[1] = document.documentElement.scrollTop;
        return arry;
    }
    ,create : function() {
        var ghost    = this;
        this.objct   = null;
        this.img     = null;
        this.dscrptn = null;
        this.wdth    = null;
        this.hght    = null;
        this.dvsn    = null;
        this.mouseover = function(e) {
            var evntX = e.clientX;
            var evntY = e.clientY;
            var scrlld_x = 0;
            var scrlld_y = 0;
            var arry = Q_tooltip.scrlld();
            if(typeof(arry[0])!='undefined') scrlld_x += arry[0];
            if(typeof(arry[1])!='undefined') scrlld_y += arry[1];
            var clntW = (document.compatMode=='BackCompat')?(document.body.clientWidth ):(document.documentElement.clientWidth );
            var clntH = (document.compatMode=='BackCompat')?(document.body.clientHeight):(document.documentElement.clientHeight);
            var dvsnW = ghost.dvsn.offsetWidth;
            var dvsnH = ghost.dvsn.offsetHeight;
            if(evntX+dvsnW>clntW)
                 ghost.dvsn.style.left = scrlld_x+clntW-(dvsnW+Q_tooltip.gap_x)+'px';
            else ghost.dvsn.style.left = scrlld_x+evntX-Q_tooltip.gap_x +'px';
            if(evntY-dvsnH-Q_tooltip.gap_y<0) 
                 ghost.dvsn.style.top = scrlld_y+evntY+Q_tooltip.gap_y+'px';
            else ghost.dvsn.style.top = scrlld_y+evntY-dvsnH-Q_tooltip.gap_y+'px';
            ghost.dvsn.style.visibility = 'visible';
        };
        this.mouseout = function(e) { 
            ghost.dvsn.style.visibility = 'hidden';
        };
        this.attch = function() {
            ghost.dvsn = document.createElement('div');
            if(ghost.wdth) ghost.dvsn.style.width  = ghost.wdth+'px';
            if(ghost.hght) ghost.dvsn.style.height = ghost.hght+'px';
            ghost.dvsn.style.zIndex = 1000;
            ghost.dvsn.style.visibility = 'hidden';
            ghost.dvsn.style.position = 'absolute';
            ghost.dvsn.style.left     = '0px';
            ghost.dvsn.style.top      = '0px';
            ghost.dvsn.style.backgroundColor = Q_tooltip.background_color;
            ghost.dvsn.style.font            = Q_tooltip.font;
            ghost.dvsn.style.padding         = Q_tooltip.padding;
            ghost.dvsn.style.border          = Q_tooltip.border;
            if(ghost.img) {
                img = document.createElement('img');
                img.setAttribute('src',ghost.img);
                if(Q_tooltip.usr_agnt.indexOf('msie')!=-1) img.style.styleFloat = 'left';
                else img.style.cssFloat = 'left';
                ghost.dvsn.appendChild(img);
            }
            if(ghost.dscrptn) {
                if(ghost.img) {
                    img.style.marginRight  = '5px';
                    img.style.marginBottom = '5px';
                }
                dscrptn = document.createTextNode(ghost.dscrptn);
                ghost.dvsn.appendChild(dscrptn);
            }
            document.getElementsByTagName('body')[0].appendChild(ghost.dvsn);
            Q_tooltip.attach(ghost.objct,'mouseover',ghost.mouseover);
            Q_tooltip.attach(ghost.objct,'mouseout' ,ghost.mouseout);
        };
    }
    ,start: function() {
        for(i=0;i<Q_tooltip.arry.length;i++) {
            window.setTimeout("Q_tooltip.arry["+i+"].attch();",1);
        }
    }
    ,bind: function() {
        Q_tooltip.attach(window,'load',Q_tooltip.start);
    }
    //idntty,img,dscrptn,wdth,hght
    ,add : function() {
        var ghost = new Q_tooltip.create();
        ghost.objct = document.getElementById(arguments[0]);
        if(arguments[1]) ghost.img     = arguments[1];
        if(arguments[2]) ghost.dscrptn = arguments[2];
        if(arguments[3]) ghost.wdth    = arguments[3];
        if(arguments[4]) ghost.hght    = arguments[4];
        Q_tooltip.arry.push(ghost);
    }
};
Q_tooltip.bind();

// customizing
//Q_tooltip.gap_x = 30;
//Q_tooltip.gap_y = 30;
//Q_tooltip.background_color = 'white';
//Q_tooltip.font    = '12px arial';
//Q_tooltip.padding = '10px';
//Q_tooltip.border  = '1px solid silver';

