//thanks to http://www.codeproject.com/KB/scripting/Javascript_Image_PopUp.aspx

function Large(obj, imgsrc)
{

    var imgbox=document.getElementById("imgbox");

    var img = document.createElement("img");
    img.src=imgsrc;
    if(img.addEventListener){
        //img.addEventListener('mouseout',Out,false);
        img.addEventListener('click',Out,false);
    } else {
        //img.attachEvent('onmouseout',Out);
        img.attachEvent('click',Out);
    }             
    imgbox.innerHTML='';
    imgbox.appendChild(img);
    imgbox.style.left= 160 +'px';
    imgbox.style.position = 'absolute';

    //resize
    var width = img.style.width;
    var height = img.style.height;
    //alert(height);
    img.style.width= 850;
    img.style.height= 850*height/width;
    //alert(img.style.height);


    //alert(getY(obj));
    //position on current scroll, as long as not below windows.screen.height
    var doc = document.documentElement, body = document.body;
    var yscroll = (doc && doc.scrollTop  || body && body.scrollTop  || 0);
    imgbox.style.top = Math.min(Math.max(0,window.screen.height - img.style.height), yscroll)+'px';

    imgbox.style.visibility='visible';
}

function Out()
{
    document.getElementById("imgbox").style.visibility='hidden';
    document.getElementById("imgbox").innerHTML = '';
}

function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}


