var pageCount = Math.ceil(itemCount / perPage);

function showPrev() {
   hideCurrent();
   page -= 1;
   showCurrent();
}

function showNext() {
   hideCurrent();
   page += 1;
   showCurrent();
}

function hideCurrent() {
   for (i = ((page - 1) * perPage) + 1; i <= (page * perPage); i++) {
      try {
         document.getElementById("entry"+i).style.display = "none";
      } catch (e) {}
   }
}

function showCurrent() {
   var pagString = "";
   if (page != 1) {
      pagString += "<a href='javascript:showPrev()'>&laquo; Prev</a>";
   } 


pagString+="&nbsp;&nbsp;&nbsp;Page&nbsp;"+page+"&nbsp;of&nbsp;"+pageCount+"&nbsp;&nbsp;&nbsp;";

   if (page != pageCount) {
      pagString += "<a href='javascript:showNext()'>Next &raquo;</a>";
   }

   document.getElementById("pagination").innerHTML = pagString;

   for (i = ((page - 1) * perPage) + 1; i <= (page * perPage); i++) {
      try {
         document.getElementById("entry"+i).style.display = "block";
      } catch (e) {}
   }
   try {
    var growerDiv = document.getElementById("grower");
    var growerInnerDiv = document.getElementById("grower-inner");
    cHeight = document.documentElement.clientHeight;
    containerHeight = Math.max(810,document.getElementById('container').offsetHeight);
    
if (containerHeight > cHeight) {
      if (growerInnerDiv.offsetHeight >= cHeight - 350) { //Inner Container is larger than minimum
        growerDiv.style.height = Math.max(growerInnerDiv.offsetHeight+25,(cHeight - 350)) + "px";
      } else {
        growerDiv.style.height = (cHeight - 350) + "px";
      }
    } else {
      growerDiv.style.height = Math.max(growerInnerDiv.offsetHeight+25,(containerHeight - 350)) + "px";
    }
    growerMinHeight = growerDiv.offsetHeight;
   } catch(e) {}
}

showCurrent();
