/*
blog
Copyright (C) May 2009, Andrea Russo

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

function getPos (obj)
{
    var output = new Object();
    var mytop=0, myleft=0;
    while( obj) {
        mytop+= obj.offsetTop;
        myleft+= obj.offsetLeft;
        obj= obj.offsetParent;
    }
    output.left = myleft;
    output.top = mytop;
    return output;
}

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

function hide_blog_news_in_excess()
{
    var portlet =
        document.getElementById('column-collective-portletpage-toprow-portlet-contenuto-pagina-principale');
    var blog_links =
        document.getElements('#column-collective-portletpage-toprow-portlet-tec-blog a');
    var portlet_bottom_pos = getPos(portlet).top + portlet.scrollHeight-80; //for ClimateScience&Policy banner

    // alert('portlet_bottom_pos: ' + portlet_bottom_pos);

    for (i=0; i < blog_links.length; i++)
    {
        var link = blog_links[i];
        var link_bottom_pos = getPos(link).top + link.scrollHeight;
        
        if (link_bottom_pos > portlet_bottom_pos)
        {
            link.setStyle('visibility', 'hidden');
            link.parentNode.setStyle('visibility', 'hidden');
            // alert('link_bottom_pos: ' + link_bottom_pos);
        }
    }
}
