// -------------------------------------------------------------------
// JavaScript Image Popup - By Code Project, available at: http://www.codeproject.com/KB/scripting/Javascript_Image_PopUp.aspx
// -------------------------------------------------------------------


function getElementLeft(elm) 
{
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) 
{
    var y = 0;

    //set x to elm’s offsetTop
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}



function popupLarge(obj, img_location, img_alt_text, img_pos)
{
    var img = document.createElement("img");
    img.src=img_location;
    var imgpopupbox=document.getElementById("imgpopupbox");
    var imgpopupinner=document.getElementById("imgpopupinner");
    imgpopupbox.style.visibility='visible';
	var height = (img.height / 2);
	height = height.toFixed();
    img.alt=img_alt_text;
    imgpopupinner.innerHTML='';
    imgpopupinner.appendChild(img);
    imgpopupbox.style.left=(getElementLeft(obj)-175-img_pos) +'px';
    imgpopupbox.style.top=(getElementTop(obj)-height) + 'px';
}

function popupOut()
{
    var imgpopupbox=document.getElementById("imgpopupbox");
    imgpopupbox.style.visibility='hidden';
}


