var _objImageXML = null;
var _bImageMousedOut = true;
var _objPositionImage = null;
var _sThumbnailImagePath = "";

function TP_OpenImage(ImageObject, ThumbnailPath)
{
    _bImageMousedOut = false;
    _objPositionImage = ImageObject;
    _sThumbnailImagePath = ThumbnailPath;
    _objImageXML = TP_CreateXMLRequest(ThumbnailPath, TP_ImageDownloading);
}

function TP_ImageDownloading()
{
    if (_objImageXML != null)
    {               
        if (_objImageXML.readyState == 4)    //COMPLETE
        {                           
            if (_objImageXML.status == 200)  //RETURNED OK
            {                                    
                if (!_bImageMousedOut)
                {     
                    var divImage = document.getElementById('_divThumbnailImage');

                    if (divImage == null)
                    {
                        divImage = document.createElement('DIV');
                        
                        divImage.id = '_divThumbnailImage';    
                        divImage.style.zIndex = 100000;
                        divImage.style.backgroundColor = "white";
                        divImage.style.borderStyle = "solid";
                        divImage.style.borderWidth = "1px";
                        divImage.style.position = "absolute";
                        divImage.style.display = "none";
                        
                        document.body.appendChild(divImage);
                    }

                    var imgThumbnail = new Image();

                    imgThumbnail.src = _sThumbnailImagePath;
                    divImage.style.width = imgThumbnail.width + "px";
                    divImage.style.height = imgThumbnail.height + "px";

                    divImage.innerHTML = "<img src=\"" + _sThumbnailImagePath + "\">";                        
                    TP_PositionDiv(divImage, _objPositionImage, false);
                }
            } 
            else    //ERROR 
            {                
                TP_CloseImage();
            }
        }            
    }
}

function TP_CloseImage()
{
    if (document.getElementById('_divThumbnailImage') != null) document.getElementById('_divThumbnailImage').style.display = "none";
    _bImageMousedOut = true;
}
