jQuery( window ).load( function()
{    
    var projectsCount = jQuery( "#top-projects li" ).length;
    var rowsCount = ( projectsCount % 3 == 0 ) ? ( parseInt( projectsCount / 3 ) ) : ( parseInt( projectsCount / 3 ) + 1 );
    for ( i = 1; i <= rowsCount; i++ )
    {
        maxHeight = 0;
        jQuery( "li:lt(" + ( i * 3 )+ ")" + ( ( (  ( i - 1 ) * 3 - 1 ) > 0 ) ? ( ":gt(" + (  ( i - 1 ) * 3 - 1 ) + ")" ) : ( "" ) )  + " div.main-image", jQuery( "#top-projects" ) ).each( function( index ){
            if( maxHeight < jQuery( this ).height() )
            {
                maxHeight = jQuery( this ).height();
            }
        });
        
        jQuery( "li:lt(" + ( i * 3 )+ ")" + ( ( (  ( i - 1 ) * 3 - 1 ) > 0 ) ? ( ":gt(" + (  ( i - 1 ) * 3 - 1 ) + ")" ) : ( "" ) ) + " div.main-image", jQuery( "#top-projects" ) ).css( "height", maxHeight + "px" );
        
        maxHeight = 0;
        jQuery( "li:lt(" + ( i * 3 )+ ")" + ( ( (  ( i - 1 ) * 3 - 1 ) > 0 ) ? ( ":gt(" + (  ( i - 1 ) * 3 - 1 ) + ")" ) : ( "" ) ), jQuery( "#top-projects" ) ).each( function( index )
        {
            if( maxHeight < jQuery( this ).outerHeight( true ) )
            {
                maxHeight = jQuery( this ).outerHeight( true );
            }
        });
        
        jQuery( "li:lt(" + ( i * 3 )+ ")" + ( ( (  ( i - 1 ) * 3 - 1 ) > 0 ) ? ( ":gt(" + (  ( i - 1 ) * 3 - 1 ) + ")" ) : ( "" ) ), jQuery( "#top-projects" ) ).css( "height", maxHeight + "px" );
    }
    
    jQuery( "div.vertical-align" ).VerticalAlign();
    
});