var cX = 0; 
var cY = 0; 
var rX = 0; 
var rY = 0;


function UpdateCursorPosition(e){ 
    cX = e.pageX; 
    cY = e.pageY;
}

function UpdateCursorPositionDocAll(e){ 
    cX = event.clientX; 
    cY = event.clientY;
}

if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d) {
    var x, y;
    var wHeight;
    var lHeight;
    var fHeight;
    var tmpvar;
  
    d.style.display = "block";
    d.style.position = "absolute";
  
    wHeight = document.body.clientHeight + document.body.scrollTop;
    lHeight = d.offsetHeight;

    if (document.all) { 
        y = cY + 10 + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
        x = cX + 10 + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    } else {
        y = cY + 10;
        x = cX + 10;
    }
  
    fHeight = y + lHeight;
    if (document.body) {
        if (x + d.clientWidth > document.body.clientWidth)
            x = document.body.clientWidth - d.clientWidth - 10;
    }
  
    if(fHeight > wHeight) {
        tmpvar = fHeight - wHeight;
        d.style.top = (y - tmpvar) +"px";
        d.style.left = x +"px";        
    } else {
        d.style.top = y +"px";
        d.style.left = x +"px";
    }  
}

function HideContent(d) {
    if(d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
    if(d.length < 1) { return; }
    var dd = document.getElementById(d);
    AssignPosition(dd);
    dd.style.display = "block";
}

function ReverseContentDisplay(d) {
    if(d.length < 1) { return; }
    var dd = document.getElementById(d);
    AssignPosition(dd);
    if(dd.style.display == "none") { dd.style.display = "block"; }
    else { dd.style.display = "none"; }
}
