﻿var rows = null;
var i = 0;
var randomnumber = 0;
var switchDelay = 6000;
var length = 0;

$("#rotator.panel tr").ready(function () {
    $("#rotator.panel tr").each(function (index) {
        this.style.display = "none";

    });
});
$(document).ready(initialiseRows);

function initialiseRows() {

    if (rows == null) {
        rows = $("#rotator.panel tr");
        length = rows.length;
        randomnumber = Math.floor(Math.random() * (length / 2))
        i = randomnumber * 2;
    }

    if (i > length - 1) {
        i = 0;
    }

    rows.each(function (index) {
        if (index == i) {
            $(this).fadeIn(6000);
            //            this.style.display = "block";
        }
        else {
            $(this).fadeOut(3000);
            //this.style.display = "none";
        }
    });
    i = i + 1;
    setTimeout("initialiseRows()", switchDelay);
}

var rows2 = null;
var j = 0;
var randomnumber2 = 0;
var switchDelay2 = 7231;
var length2 = 0;

$("#shift tr").ready(function () {
    $("#shift tr").each(function (index2) {
        this.style.display = "none";
    });
});
$(document).ready(initialiseRows2);

function initialiseRows2() {

    if (rows2 == null) {
        rows2 = $("#shift tr");
        length2 = rows2.length;
        randomnumber2 = Math.floor(Math.random() * (length2 / 2))
        j = randomnumber2 * 2;
    }

    if (j > length2 - 1) {
        j = 0;
    }

    rows2.each(function (index2) {
        if (index2 == j) {
            // $(this).fadeIn(2000);
            this.style.display = "block";
        }
        else {
            //$(this).fadeOut("slow");
            this.style.display = "none";
        }
    });
    j = j + 1;
    setTimeout("initialiseRows2()", switchDelay2);
}



var num_entries;
var number_items;

function pageselectCallback(page_index, jq) {

    var items_per_page = number_items;
    var max_elem = Math.min((page_index + 1) * items_per_page, num_entries);
    var new_content = '';
    $('#Searchresult').empty();
    // Iterate through a selection of the content and build an HTML string
    for (var i = page_index * items_per_page; i < max_elem; i++) {
        new_content = jQuery('#articlePaginator div.result:eq(' + i + ')').clone();
        $('#Searchresult').append(new_content);
    }
    return false;
}

function initPagination(num_items) {
    // count entries inside the hidden content
    num_entries = jQuery('#articlePaginator div.result').length;
    number_items = num_items;
    // Create content inside pagination element
    $("#Pagination").pagination(num_entries, {
        callback: pageselectCallback,
        items_per_page: num_items // Show only ten items per page
    });
}

//function initPagination2() {
//    // count entries inside the hidden content
//    num_entries = jQuery('#fullarticlePaginator div.result').length;
//    // Create content inside pagination element
//    $("#Pagination2").pagination(num_entries, {
//        callback: pageselectCallback2,
//        items_per_page: 20 // Show only ten items per page
//    });
//}
//function pageselectCallback2(page_index, jq) {

//    var items_per_page = 20;
//    var max_elem = Math.min((page_index + 1) * items_per_page, num_entries);
//    var new_content = '';
//    $('#Searchresult2').empty();
//    // Iterate through a selection of the content and build an HTML string
//    for (var i = page_index * items_per_page; i < max_elem; i++) {
//        new_content = jQuery('#fullarticlePaginator div.result:eq(' + i + ')').clone();
//        $('#Searchresult2').append(new_content);
//    }
//    return false;
//}


