jQuery - more elegant way to write the script
<p>I have following script: </p>

<ul>
<li>it is creating tabs based on number of visible 'li'</li>
<li>please note this is only the part of the script - I'm looking for shorthans - smart ideas to write that etc..</li>
</ul>

<p>Can you suggest any shorthand for this? Or more elegant way to write that? Any suggestion much appreciated. </p>

<pre><code>    var CoundNumberOfDivs = $('#portfolio-items li:visible').length;

    if( CoundNumberOfDivs &lt;= 4 ) { 
        $('.pagination li a').hide(); 
        return false;
    }
    else if( CoundNumberOfDivs &lt;= 8 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(2)').show(); 

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show();
    }
    else if( CoundNumberOfDivs &lt;= 12 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(3)').show(); 

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show();
    }
    else if( CoundNumberOfDivs &lt;= 16 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(4)').show();

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show(); 
    }
    else if( CoundNumberOfDivs &lt;= 20 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(5)').show();

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show(); 
    }

    else if( CoundNumberOfDivs &lt;= 24 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(6)').show();

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show(); 
    }

    else if( CoundNumberOfDivs &lt;= 28 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(7)').show();

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show(); 
    }

    else if( CoundNumberOfDivs &lt;= 32 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(8)').show();

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show(); 
    }

    else if( CoundNumberOfDivs &lt;= 36 ) { 
        $('.pagination li a').hide();
        $('.pagination li a:lt(9)').show();

        $('#portfolio-items li').hide();
        $('#portfolio-items li:lt(4)').show(); 
    }
</code></pre>
