/*
Extension developed by Elena V. Galtseva
*/

var isID=0;
var isALL=0;
var isLayers=0;
var isDHTML=0;

if (document.layers){isLayers=1; isDHTML=1;}

else {
        if (document.all){isALL=1; isDHTML=1;}
        else {
                if (document.getElementById){isID=1; isDHTML=1;}
        }
}

function findDOM(objectID,withStyle,d){
        var x;
        if(!d) d=document;

        if (withStyle==1){
                if (isID){x=document.getElementById(objectID).style; return x;}
                else {
                        if (isALL){x=document.all[objectID].style; return x;}
                        else {
                                if (isLayers){x=document.layers[objectID]; return x;}
                        }
                }
        }
        else {
                if (isID){x=document.getElementById(objectID); return x;}
                else {
                        if (isALL){x=document.all[objectID]; return x;}
                        else {
                                if (isLayers){x=document.layers[objectID]; return x;}
                        }
                }
        }

}


function findLivePageWidth(){
        var w;
        if (window.innerWidth != null){
                w=window.innerWidth;
                return w;

        }
        if (document.body.clientWidth != null){
                w=document.body.clientWidth;
                return w;
        }
        return (null);
}
/*
// Get named object's computed width

function findObjWidth1(objectID) {
        if (isDHTML) {
                if (isALL) {elemWidth=eval(objectID + ".offsetWidth");}
                else if (isID) {
                        dom=findDOM(objectID,0);
                        elemWidth= parseInt(document.defaultView.getComputedStyle(dom, "").getPropertyValue("width"));
                }
                else if (isLayers) {elemWidth=document.layers[objectID].clip.width;}
                else {elemWidth=null;}
                //alert ("isLayers=" +isLayers +"; isALL=" + isALL + "; isID=" + isID + "; elemWidth=" +elemWidth);
                return elemWidth;
        }
}

function findObjWidth(objectID) {
        var dom=findDOM(objectID,0);
        elemWidth=2;

        if (dom.offsetWidth) {elemWidth=dom.offsetWidth;}
        else {
                if (dom.clip.width) {
                        elemWidth=document.layers[objectID].clip.width;
                }
        }
        //alert ("2: " +"isLayers=" +isLayers +"; isALL=" + isALL + "; isID=" + isID + "; elemWidth=" +elemWidth);
        return elemWidth;
}
*/

function showTooltip(objectID, evt,tipContent, width ){
        if (isDHTML){

                var backcolor = "#ffff99";          //N4
                var bordercolor = "#000000";        //N4
                var textcolor = "#000000";          //N4

                var livePageWidth=findLivePageWidth();

                elemWidth=2;

                dom=findDOM(objectID,0);
                domStyle=findDOM(objectID,1);
                state=domStyle.visibility;

                if (isLayers){
                        dom.document.write('<table width="10" border="0" cellspacing="1" cellpadding="1"><tr bgcolor="'+bordercolor+'"><td><table width="'+width+'" border="0" cellspacing="0" cellpadding="5"><tr bgcolor="'+backcolor+'"><td nowrap><font style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px; color: '+textcolor+'">&nbsp;'+unescape(tipContent)+'&nbsp;</font></td></tr></table><td></tr></table>');                                dom.document.close();
                        elemWidth=dom.clip.width;
                }

                else {
                        if (isALL){
                                dom.innerHTML='<table class="TableMake" cellspacing="1" cellpadding="1"><tr><td class="TdMake">&nbsp;'+unescape(tipContent)+'&nbsp;</td></tr></table>';
                                elemWidth=dom.offsetWidth;
                        }
                        else {
                                if (isID){

                                        var newText;
                                        var oTable=document.createElement("table");
                                        var oTr=document.createElement("tr");
                                        var oTd=document.createElement("td");
                                        
					livePageWidth = livePageWidth - 20;
					oTable.className="TableMake";
                                        oTr.className="TdMake";

                                        insetText=unescape(tipContent);
                                        newText=document.createTextNode(insetText);

                                        tableElem = dom.getElementsByTagName("table");
                                        for (var i = 0; i < tableElem.length; i++) {
                                                dom.removeChild(tableElem[i]);
                                        }

                                        document.getElementById(objectID).appendChild(oTable);
                                        oTable.appendChild(oTr);
                                        oTr.appendChild(oTd);
                                        oTd.appendChild(newText);
                                        elemWidth=oTable.offsetWidth;
                                }
                        }
                }

		// Mozilla
		if (evt.pageY) {
		    topVal  = evt.pageY + 20;
		    leftVal = evt.pageX + 20;
		}
		// IE
		else if (evt.y) {
		    topVal  = evt.y + document.body.scrollTop + 20;
		    leftVal = evt.x + document.body.scrollLeft + 20;
		}

                if (leftVal < 2) {
		    leftVal = 2;
		}
                else if ((leftVal + elemWidth) > livePageWidth) {
		    leftVal = livePageWidth - elemWidth;
                }

                domStyle.top=topVal;
                domStyle.left=leftVal;
                domStyle.visibility="visible";
        }
}


function hideTooltip(objectID)
{
        if (isDHTML){
                findDOM(objectID,1).visibility="hidden";
                findDOM(objectID,1).left = 1;
                findDOM(objectID,1).top = 1;

                return false;
        }

        else return true;
}

