/**
 * light version of overlib
 *
 * @author Mateusz Czaja
 * @date 2007.12.06
 */
function OverlibLight()
{
    var wmtt = null;
    var overDiv = null;
    var width = 350;
    var divVisible = 0;
    var gShowOnTop = 0;
    var xOffset = 0;
    var yOffset = 0;
    var gTimer;


    function sstt(id, showOnTop, mousePosition)
    {
        xOffset = 0;
        yOffset = 0;
        if(showOnTop != "undefined") {
            gShowOnTop = showOnTop;
        } else {
            gShowOnTop = 0;
        }
        if(mousePosition != "undefined") {
            gMousePosition = mousePosition;
        } else {
            gMousePosition = null;
        }
        overDiv = (document.getElementById('overDiv') ? document.getElementById('overDiv') : createDiv('overDiv'));
        if (wmtt == null && (typeof id) == "string"){
            try {
                wmtt=document.getElementById(id);
            } catch(f){
                return;
            }
        } else {
            if((typeof id)=="object") {
                wmtt=id;
            }
        }
        //var html = '<table cellspacing="0" cellpadding="0" border="0" width="'+width+'"><tr><td>';
        //var html = '<table cellspacing="0" cellpadding="0" border="0" width="'+width+'" class="tooltip" style="width:'+width+'"><tr><td>';
        //var html = '<div class="tooltipActive" style="width:'+width+'">';
        var html = '<div class="'+wmtt.className+'">';
        try {
            html += wmtt.innerHTML;
        } catch(f){
            return;
        }
        //html += '</td></tr></table>';
        html += '</div>';
        overDiv.innerHTML      = html;
        //overDiv.style.border   = 'solid 1px #005e34'
        overDiv.style.width    = 'auto';
        overDiv.style.display  = 'block';
        overDiv.style.zIndex   = 100;
        //overDiv.style.fontSize = '10px'
        if(gTimer){
                clearTimeout(gTimer);
        }
        try {
            gTimer=setTimeout("oll.showContent()", 50);
        } catch (ff) {
        //
        }
        listenMouse();
    }
    this.sstt = sstt


    function hstt()
    {
        if(overDiv) {
            wmtt = null;
            overDiv.style.display = 'none';
            overDiv.style.visibility = 'hidden';
            if(gTimer){
                clearTimeout(gTimer);
            }
            try {
                gTimer=setTimeout("oll.hideContent()", 50);
            } catch(f) {}
            deleteListener();
        }
        divVisible = 0;
    }
    this.hstt=hstt


    function hideContent()
    {
        try {
            overDiv.innerHTML = '';
        } catch (ff) {
            //
        }
    }
    this.hideContent = hideContent


    function moveTooltip(e)
    {
        var x, y;
        var topOff = 0;
        var leftOff = 0;
        if (e.pageX) {
            x = e.pageX;
            y = e.pageY;
            topOff = window.pageYOffset;
            leftOff = e.screenX;
        } else {
            x = e.clientX;
            y = e.clientY;
            if (document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
                x += document.documentElement.scrollLeft;
                topOff = document.documentElement.scrollTop;
                y += topOff;
            } else if (document.body) { // all other Explorers
                x += document.body.scrollLeft;
                topOff = document.body.scrollTop;
                y += topOff;
            }
        }

        if(gMousePosition == "top") {
            x=x-10;
            y=y-10;
        } else {
            x=x+10;
            y=y+10;
        }
        browserWidth = getWidth()
        browserHeight = getHeight()
        var dHeight = getOverHeight();
        if(!dHeight) {
            dHeight = 100;
        }

        if(x+width>browserWidth-20) {
            x=browserWidth-width-20;
        }

        if(gMousePosition == "top") {
            y=y-dHeight;
            if(y<topOff){
                y=topOff+20;
            }
        } else {
            if(y+dHeight>browserHeight+topOff){
                y=topOff+browserHeight-dHeight-20;
            }
        }

        if(gShowOnTop == 1){
            if( y> topOff){
                y = topOff +20;
            }
        }

        x += xOffset;
        y += yOffset;

        overDiv.style.left=x+'px';
        overDiv.style.top=y+'px';
    }


    function showContent()
    {
        try {
        if(divVisible==0){
            divVisible=1;
            overDiv.style.display = 'block';
            overDiv.style.visibility = 'visible';
        }
        } catch (ff) {
        return;
        }
    }
    this.showContent = showContent


    function getWidth()
    {
        var myWidth = 0;
        if( typeof( window.innerWidth ) == 'number' ) {//Non-IE
            myWidth = window.innerWidth;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {//IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            myWidth = document.body.clientWidth;//IE 4 compatible
        }
        return myWidth;
    }


    function getOverHeight()
    {
        var myHeight = 0;
        try {
            myHeight = parseInt( document.defaultView.getComputedStyle(overDiv,"").height );
        } catch(ff) {
                try {
                        var dim = overDiv.getClientRects();
                        myHeight = dim[0].bottom - dim[0].top;
                } catch (fe) {
                        myHeight = 50;
                }
        }
        return myHeight;
    }


    function getHeight()
    {
        var myHeight = 0;
        if( typeof( window.innerHeight ) == 'number' ) {//Non-IE
            myHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {//IE 6+ in 'standards compliant mode'
            myHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            myHeight = document.body.clientHeight;//IE 4 compatible
        }
        return myHeight;
    }


    function listenMouse()//IE safe
    {
        try{
            document.body.addEventListener("mousemove", moveTooltip, false);
        } catch(e){
            try{
                document.body.onmousemove = function() { moveTooltip(event); };
            } catch (g){
                try {
                    window.attachEvent("onMouseMove", moveTooltip);
                } catch(f){
                    // nothing to do
                }
            }
        }
    }


    function deleteListener()
    {
        try{
            document.body.removeEventListener("mousemove",moveTooltip,false);
        } catch(e){
            try{
                document.body.onmousemove=function() { };
            } catch (g){
                try{
                    window.detachEvent("onMouseMove",moveTooltip);
                } catch(f){}
            }
        }
    }


    function createDiv(id, zValue)
    {
        id = (id || 'overDiv'), zValue = (zValue || 1000);
        var body                 = document.getElementsByTagName("BODY")[0];
        var divContainer = document.createElement("DIV");
        divContainer.id    = id;
        body.appendChild(divContainer);
        objRef = divContainer.style;
        objRef.position = 'absolute';
        objRef.display = 'none';
        objRef.visibility = 'hidden';
        objRef.zIndex = zValue;
        return divContainer;
    }

}//OverlibLight
var oll= new OverlibLight();
