﻿/**********************************************************
this file will detect images with descriptions. it will then
create the icon for hover description.
***********************************************************/

function ImageDescription(imageObj, descriptionObj)
{
    this._img = imageObj;
    this._icon = null;
    this._descriptionHTML = descriptionObj.value;
}

ImageDescription.prototype.build = function()
{
    this._icon = document.createElement("img");
    this._icon.style.position = "absolute";
    this._icon.style.width = "10px";
    this._icon.style.height = "10px";
    this.position();
}

ImageDescription.prototype.position = function()
{
    var x = GetAbsoluteLeft(this._img);
    var y = GetAbsoluteTop(this._img);
    x += this._img.offsetWidth - 10;
    y += this._img.offsetHeight - 10;
    this._icon.style.top = y.toString() + "px";
    this._icon.style.left = x.toString() + "px";
}

function InitializeImageDescriptions()
{
    // parse all images.
    for(var i = 0; i < document.images.length; i++)
    {
        //alert(document.images[i].src);
    }
}

window.onload = InitializeImageDescriptions;


function GetAbsoluteX(obj)
{
    var i = obj.offsetLeft;
    while (obj.offsetParent!=null)
    {
        obj = obj.offsetParent;
        i+=obj.offestLeft;
    }
    return i;
}
function GetAbsoluteY(obj)
{
    var i = obj.offsetTop;
    while (obj.offsetParent!=null)
    {
        obj = obj.offsetParent;
        i+=obj.offestTop;
    }
    return i;
}



