function getPageCoords(element) 
{ // thanks to 'Martin Honnen' for this function 
    var coords = {x: 0, y: 0};
    
    if( typeof( element.offsetParent ) != 'undefined' ) 
    {
        while (element) 
        {
            coords.x += element.offsetLeft; 
            coords.y += element.offsetTop; 
            element = element.offsetParent;
        } 
    } 
    else 
    {
        coords.x = element.x; 
        coords.y = element.y;
    }
    return coords; 
}

function getObj(id)
{
    return document.getElementById(id);
}

function posizionaObjFromObj(idObjDaLeggere,idObjDaPos,piuX,piuY)
{
    var coordMenu = getPageCoords(getObj(idObjDaLeggere));
    getObj(idObjDaPos).style.position='absolute';
    getObj(idObjDaPos).style.top=coordMenu.y+piuY+"px";
    getObj(idObjDaPos).style.left=coordMenu.x+piuX+"px";
}

function reloadPiuLingua(lang)
{
    var loc = document.location.href;
    //alert(loc);
    if(loc.indexOf("lang=") != -1)
    {
        if(lang == "en")
        {
          loc = loc.replace("lang=it","lang="+lang);
        }
        else
        {
          loc = loc.replace("lang=en","lang="+lang);
        }
    }
    else
    {
        if(loc.indexOf(".jsp") != -1)
          loc = loc + "&lang=" + lang;
        else
          loc = loc + "index.jsp?lang=" + lang;
    }

    document.location.href = loc;
}


