var page = {
  posts_per_page: 12, // change this if you need
  posts : [],

  no: function() {
    return this.page? this.page : this.page =
      (pp = /\?(\d+)$/.exec(window.location.href)) != null? parseInt(pp[1]) : 1;
  },
  total: function() {
    if(e = arguments[0]) {
      this.posts.push(e);
      this.t = Math.ceil(this.posts.length/this.posts_per_page);
    }
    return this.t? this.t : 0;
  },
  prev_page: function() {
    return (pp = this.no()-1)? pp : null;
  },
  prev: function() { return this.goTo(this.prev_page()) },
  next_page: function() {
    return (pp = this.no()+1)<=this.total()? pp : null;
  },
  next: function() { return this.goTo(this.next_page()) },
  goTo: function(pp) {
    if(pp) window.location.href = '?'+pp;
    return false;
  },
  navigation: function() {
    document.write('<div id="page_navigation">'
    +(this.prev_page()? '<a id="prev" href="#" onclick="return page.prev()">&laquo; Previous page</a>' : '')
	+' ');
	for(var p=1; p<=page.total(); p++)
      if(p==page.no()) document.write('<strong>'+p+'</strong> ');
      else document.write('<a href="#" onclick="return page.goTo('+p+')">'+p+'</a> ');
	document.write(' '
	+(this.next_page()? '<a id="next" href="#" onclick="return page.next()">Next page &raquo;</a>' : '')
    +' ');
    document.write('</div>');
  }
}
function p(id) {
  var e = document.getElementById('post-'+id);
  if(page.no() && page.no() != page.total(e))
    e.style.display = 'none';
}