divForPopUpImage = null;


var DeltaXAxle = 20;
var DeltaYAxle = 20;

function TracePositionOfCursor(e) {
    x1 = (document.all) ? window.event.clientX + truebody().scrollLeft : e.pageX;
    
    y1 = (document.all) ? window.event.clientY + truebody().scrollTop : e.pageY;
    
    
    
    if (divForPopUpImage != null && divForPopUpImage.style.display != "none") {
        divForPopUpImage.style.left = (x1 + DeltaXAxle) + "px";
        divForPopUpImage.style.top = (y1 + DeltaYAxle) + "px";
    }
}
function TracePositionOfCursorWithCorrection(e) {
var top=getOffsetTop();
    x = (document.all) ? window.event.clientX + truebody().scrollLeft : e.pageX;
    y = (document.all) ? window.event.clientY : e.pageY -top ;
    x1 = x;
    y1 = y;
    
    var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15
    var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
if(docwidth>1400&&x1>(docwidth-1400))
x1-=docwidth-1400;

    //alert(x + '|' + y + ' window=' + docwidth + '|' + docheight + ' top=' + top);
    /*if (docwidth - x1 < Pop_UpDivWidth){
    x1 = x1 - DeltaXAxle - Pop_UpDivWidth;
    } else {
    x1 += DeltaXAxle;
    }*/
    //alert(docwidth+"|"+docheight)
    if (Pop_UpDivWidth > 0) {
        if (x1+DeltaXAxle>Pop_UpDivWidth)
            x1 -= DeltaXAxle*2 + Pop_UpDivWidth ;
        else
            x1 += DeltaXAxle;
    }
    else
        x1 += DeltaXAxle;

    if (docheight - y1 < Pop_UpDivHeight) {
        y1 = docheight - Pop_UpDivHeight + top - 50;
    } else {
        y1 += DeltaYAxle + top;
    }



    if (y1 < 0) { y1 = y; }
    if (divForPopUpImage != null && divForPopUpImage.style.display != "none") {
        divForPopUpImage.style.left = x1 + "px";
        divForPopUpImage.style.top = y1 + "px";
    }
}
function ShowPopUpDiv(id, logofile, transparency, imgContainerID) {
    document.onmousemove = TracePositionOfCursor;
    var TransparencyValue = 90;
    if (transparency)
        TransparencyValue = transparency;
    var AbsoluteTransparencyValue = (TransparencyValue / 100);
    if (divForPopUpImage == null) {
        divForPopUpImage = document.getElementById(id);
    }
    var imgContainer = document.getElementById(imgContainerID);
    if (logofile) {
        if (imgContainer)
            imgContainer.innerHTML = '<img src="' + logofile + '" style="-moz-opacity: ' + AbsoluteTransparencyValue + ';filter: alpha(Opacity=' + TransparencyValue + ');">';
        else
            divForPopUpImage.innerHTML = '<img src="' + logofile + '" style="-moz-opacity: ' + AbsoluteTransparencyValue + ';filter: alpha(Opacity=' + TransparencyValue + ');">';
    }
    divForPopUpImage.style.position = "absolute";
    divForPopUpImage.style.display = "block";
    divForPopUpImage.style.visibility = "visible";

}
function truebody() {
    return (!window.opera && document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}
var Pop_UpDivHeight = 0, Pop_UpDivWidth = 0;

function ShowPopUpDivWithComment(id, logofile, transparency, imgDivID, commentDivID, comment, width, height) {


    var TransparencyValue = 90;
    if (transparency)
        TransparencyValue = transparency;
    var AbsoluteTransparencyValue = (TransparencyValue / 100);
    if (divForPopUpImage == null) {
        divForPopUpImage = document.getElementById(id);

    }

    if (logofile) {
        var imgDiv = document.getElementById(imgDivID);
        if (transparency!=100)
            imgDiv.innerHTML = '<img src="' + logofile + '" style="-moz-opacity: ' + AbsoluteTransparencyValue + ';filter: alpha(Opacity=' + TransparencyValue + ');">';
        else
            imgDiv.innerHTML = '<img src="' + logofile + '">';
        if (commentDivID) {
            var commentDiv = document.getElementById(commentDivID);
            if (comment)
                commentDiv.innerHTML = comment;
            else
                commentDiv.style.display = "none";
        }

    }
//    if (window.ActiveXObject && width == 0) {
//        x1 = window.event.clientX + truebody().scrollLeft;
//        y1 = window.event.clientY + truebody().scrollTop;
//        if (width > 0)
//            x1 -= DeltaXAxle + width + 50;
//        divForPopUpImage.style.left = (x1 + DeltaXAxle) + "px";
//        divForPopUpImage.style.top = (y1 + DeltaYAxle) + "px";
//    }
    if (height > 0) {
        document.onmousemove = TracePositionOfCursorWithMyCorrection;
        Pop_UpDivHeight = height;
        Pop_UpDivWidth = width;
    }
    else
        document.onmousemove = TracePositionOfCursor;

    divForPopUpImage.style.position = "absolute";
    divForPopUpImage.style.display = "block";
    divForPopUpImage.style.visibility = "visible";

}










function TracePositionOfCursorWithMyCorrection(e) {
var top=getOffsetTop();
//    x = (document.all) ? window.event.clientX + truebody().scrollLeft : e.pageX;
    y = (document.all) ? window.event.clientY : e.pageY -top ;
//    x1 = x;
//    y1 = y;
    
      x1 = (document.all) ? window.event.clientX + truebody().scrollLeft : e.pageX;
    
      y1 = (document.all) ? window.event.clientY + truebody().scrollTop : e.pageY;
    
     // alert("x="+ x1 + "  y="+y1);


    if (y1 < 0) { y1 = y; }
    if (divForPopUpImage != null && divForPopUpImage.style.display != "none") 
    {
      if(x1>800)
      {
        x1 = x1-550;
      }
      else
      x1 =x1 + 100;
        divForPopUpImage.style.left = x1 + "px";
       
        divForPopUpImage.style.top = (y1-250) + "px";
    }
}


















function HidePopUpDiv() {
    if (divForPopUpImage) {
        divForPopUpImage.style.display = "none";
        divForPopUpImage.style.left = "-500px";
        divForPopUpImage.style.top = "-500px";
        divForPopUpImage = null;
        document.onmousemove = null;
    }

}




function getOffsetTop(win) {
    if (!win)
        win = window;
    if (win.innerWidth)  // All browsers but IE
        return win.pageYOffset;
    else if (win.document.documentElement && win.document.documentElement.clientWidth)
        return win.document.documentElement.scrollTop;
    else if (win.document.body.clientWidth) // These are for IE4, IE5, and IE6 without a DOCTYPE
        return win.document.body.scrollTop;
}
