﻿var NumberPerPage = 8;
var ListContainerId;    //example the ID in <div id "Articles_list"> ...</div>
                        //which represents the parent tag of items which will be paged

var HTMLTagPaged;       //example the ITEMs which will be page such as <div.media-content/>
                        //and are children of the parent tag.
                                      
function pageselectCallback(page_index, jq){
    // Get number of elements per pagionation page from form
    var items_per_page = + NumberPerPage;
    var total_num_of_elements = jQuery('#' +ListContainerId+ ' ' + HTMLTagPaged ).length;
    var max_elem = Math.min((page_index + 1) * items_per_page, total_num_of_elements);
    var new_content='';
    // Iterate through a selection of the content and build an HTML string
    $('#Searchresult').empty();
    for (var i = page_index * items_per_page; i < max_elem; i++) {
        $('#Searchresult').append(jQuery('#' + ListContainerId + ' ' + HTMLTagPaged + ':eq(' + i + ')').clone());
    }
    // Prevent click event propagation
    return false;
}

//add initPagination function
function _intPagination() {
// count entries inside the hidden content
    var num_entries = jQuery('#' + ListContainerId + ' ' + HTMLTagPaged).length;
   $("#Pagination").pagination(num_entries, {
   callback: pageselectCallback,
   items_per_page: NumberPerPage  // Show only one item per page
 });
}

//add initPagination function
function initPagination() {
    //defaults
    ListContainerId = "Articles_list";
    HTMLTagPaged = "div.media-content";
    _intPagination();
}

function initPaging(iNumberPerPage, ContainerID, htmlTagPaged) {
    NumberPerPage = iNumberPerPage;
    HTMLTagPaged = htmlTagPaged;
    ListContainerId = ContainerID;
    _intPagination();
}

//$(document).ready(function(){
//    $('a.spectrum_of_care img').click(function(){
//    $('#BrightcoveShowMe').hide();
//    });

//    $('#cboxContent #cboxClose').click(function(){
//    $('#BrightcoveShowMe').show();
//    });
//    
//});
// When document is ready, initialize pagination
//$(document).ready(function(){
//   initPagination();
//});

//PAGINATE
