function changePage(page, type) {

    gPage = page;
    
    $.post(
            'ajax/getPortfolioPage.php',
            {
                page: page,
                type: type
            },
            onPost
    );   
}

function onPost(html) {

    $('#folio_list').html(html);

    printPages();

    $(function() {
        $('.light').bind('click', lightbox);
        $('.tip_link').each(init);
    });
}

function printPages() {

    out = 'pages';

    for (i=1; i <= gPagesCount; i++) {
        if (i == gPage) {
            out += '&nbsp;&nbsp;&nbsp;<span>' + i + '</span>';
        } else {
            out += '&nbsp;&nbsp;&nbsp;<a href="javascript: changePage(' + i + ', ' + gType + ');">' + i + '</a>';
        }
    }
    
    $('#page_block').html(out);
}