/* FACUP Fixtures BLOCK PAGINATION */
var facupFixtures_ulObject = $('#mod-faCup-fixturesbox-elements-show');
var facupFixtures_previous_page = 0;
var facupFixtures_list_position = 0;
var facupFixtures_elementWidth = 0;
function handlefacupFixturesPaginationClick(page_index, jq) {
var news = $('#mod-faCup-fixturesbox-elements-hide li');
var items_per_page = 6;
var max_elem = Math.min((page_index + 1) * items_per_page, news.length);
var newcontent = '';
var allElements = '';
var counter = 1;
for (var i = page_index * items_per_page; i < max_elem; i++) {
newcontent += '
' + $(news).eq(i).html() + '';
}
allElements = '';
for (var i = 0; i < news.length; i++) {
allElements += '- ' + $(news).eq(i).html() + '
';
counter++;
if (counter == 7) {
allElements += '
';
counter = 1;
}
}
allElements += '
';
$(facupFixtures_ulObject).empty().html(allElements);
facupFixtures_elementWidth = parseInt($('#mod-faCup-fixturesbox-elements-show ul').css('width'));
$(facupFixtures_ulObject).css('width', '' + (news.length * facupFixtures_elementWidth) + 'px')
if (facupFixtures_previous_page < page_index) {
facupFixtures_list_position = page_index * facupFixtures_elementWidth;
$(facupFixtures_ulObject).animate({ left: '-' + facupFixtures_list_position + 'px' }, 250);
} else if (facupFixtures_previous_page > page_index) {
facupFixtures_list_position = page_index * facupFixtures_elementWidth;
$(facupFixtures_ulObject).animate({ left: '-' + facupFixtures_list_position + 'px' }, 250);
} else {
$(facupFixtures_ulObject).css('left', '0');
}
facupFixtures_previous_page = page_index;
var actualPage = $('#cp-facupfixtures-paginator span[class="current"]').text();
var factor = news.length / items_per_page;
var factorParsed = parseInt(factor);
if (factorParsed < factor) {
var allPages = factorParsed + 1;
} else {
var allPages = factor;
}
$('#cp-facupfixtures-paginator .pagination a,#cp-facupfixtures-paginator .pagination span').hide();
$('#cp-facupfixtures-paginator .pagination .prev').show();
$('#cp-facupfixtures-paginator .pagination .next').before('' + actualPage + ' of ' + allPages + '');
$('#cp-facupfixtures-paginator .pagination .next').show();
return false;
}
$(document).ready(function () {
initfacupFixturesPagination();
});
function initfacupFixturesPagination() {
//$("#mod-faCup-Fixturesbox-elements-show").hide();
var news_total = $('#mod-faCup-fixturesbox-elements-hide li').length;
if ($("#cp-facupfixtures-paginator").length) {
$("#cp-facupfixtures-paginator").pagination(news_total, {
items_per_page: 6,
num_display_entries: 10,
load_first_page: true,
callback: handlefacupFixturesPaginationClick
});
}
if (news_total < 7) {
$('#cp-facupfixtures-paginator').remove();
};
}