/* ===========================================================================
 *
 * JQuery Quick Pagination
 * Version 1.0.1
 * Quick and dirty pagination for pretty much any set of elements on the page.
 *
 * Author: Mark Perkins
 * Author email: mark@allmarkedup.com
 * For full documentation and more go to http://projects.allmarkedup.com/jquery_quick_paginate/
 *
 * ---------------------------------------------------------------------------
 *
 * LICENCE:
 *
 * Released under a MIT Licence. See licence.txt that should have been supplied with this file,
 * or visit http://projects.allmarkedup.com/jquery_quick_paginate/licence.txt
 *
 * ---------------------------------------------------------------------------
 * 
 * EXAMPLES OF USE:
 *
 * jQuery('.news_item').quickpaginate(); // would paginate all items on the page with the class of 'news_item'
 * 
 * jQuery('div#quick_slideshow img').quickpaginate(); // would paginate all img elements within the div with an id of 'quick_slideshow'
 *
 * // Paginate everything with the class of "news_item",
 * // 5 per 'page' and without the page counter.
 * jQuery('.news_item').quickpaginate( { perpage: 5, showcounter: false } ); 
 *
 * // Paginate all img elements and the element with the id of "info",
 * // with the prev/next/counter element appended to the element with the id of "pager_here"
 * jQuery('img, #info').quickpaginate({ pager : $("#pager_here") });
 *
 */

jQuery.fn.quickpaginate=function(b){b=jQuery.extend({perpage:6,pager:null,showcounter:true,prev:"qp_next",next:"qp_prev",pagenumber:"qp_pagenumber",totalnumber:"qp_totalnumber",counter:"qp_counter"},b);var j;var h;var k=false;var d=true;var g=jQuery(this);var c;var f;var l=function(){g.show();h=g.size();if(g.size()>b.perpage){g.filter(":gt("+(b.perpage-1)+")").hide();j=b.perpage;a()}};var i=function(){if(!k){var m=j+b.perpage;g.hide(0);g.slice(j,m).fadeIn(400);j=m;if(j>=h){k=true;c.addClass("qp_disabled")}if(b.showcounter){b.pager.find("."+b.pagenumber).text(j/b.perpage)}f.removeClass("qp_disabled");d=false}};var e=function(){if(!d){var m=j-b.perpage;g.hide(0);g.slice((m-b.perpage),m).fadeIn(400);j=m;if(j==b.perpage){d=true;f.addClass("qp_disabled")}if(b.showcounter){b.pager.find("."+b.pagenumber).text(j/b.perpage)}c.removeClass("qp_disabled");k=false}};var a=function(){if(b.pager===null){b.pager=jQuery('<div class="qc_pager"></div>');g.eq(g.size()-1).after(b.pager)}var n=$('<a class="'+b.prev+'" href="#">&laquo; Zur&uuml;ck</a><a class="'+b.next+'" href="#">Vor &raquo;</a>');jQuery(b.pager).append(n);if(b.showcounter){var m='<span class="'+b.counter+'">Seite : <span class="'+b.pagenumber+'"></span>&nbsp;von <span class="'+b.totalnumber+'"></span></span>';b.pager.find("."+b.prev).before(m);b.pager.find("."+b.pagenumber).text(1);b.pager.find("."+b.totalnumber).text(Math.ceil(h/b.perpage))}c=b.pager.find("."+b.next);f=b.pager.find("."+b.prev);f.addClass("qp_disabled");c.click(function(){i();return false});f.click(function(){e();return false})};l()};

