function pp_image_popup(image,width,height,title) {
    //jQuery.slimbox(image);
    //return;
	image_popup = window.open("","","height=" + height + ",width=" + width + ",toolbar=no,menubar=no,scrollbars=no,resizable=yes");
	var tmp = image_popup.document;
	tmp.write("<html><head><title>" + title + "</title>");
	tmp.write("<style type=\'text/css\' media=\'screen\'>");
	tmp.write("body{ margin: 0; padding: 0; }");
	tmp.write("p.centered { text-align: center; font-size: small; margin: 0; padding: 0; }");
	tmp.write("a img { border: 0; }");
	tmp.write("img.centered { display: block; margin-left: auto; margin-right: auto; padding: 0;}");
	tmp.write("</style>");
	tmp.write("</head><body>");
	tmp.write("<a href=\'javascript:self.close()\'>");
	tmp.write("<img class=\'centered\' src=\'" + image + "\' width=\'" + width + "\' height=\'" + height + "\' />");
	tmp.write("</a>");
	tmp.write("</body></html>");
	tmp.close();
	image_popup.focus();
	return false;
}

function pp_prepare_popups() {
    jQuery(".pp_ajax_cat a[href^='http://"+location.hostname+"/photos/'] > img:first-child[src]").parent().unbind("click").slimbox({
	}, function(el) {
        return [el.children[0].src.replace("/thumb_", "/"),
        	(el.title || el.children[0].alt) + '<br /><a href="' + encodeURI(el.children[0].src.replace("/thumb_", "/orig_")) + '">Show original</a>'];
    }, function(el) {
		return (this == el) || (jQuery(this).closest(slimbox2_options['selector'])[0] && (jQuery(this).closest(slimbox2_options['selector'])[0] == jQuery(el).closest(slimbox2_options['selector'])[0]));
	});
}

jQuery(document).ready(function($) {
    $('#primary').delegate('.pp_page_links a', 'click', function() {
        var container = $(this).closest('.pp_ajax_cat');
        $.get(this.href.substring(0, this.href.lastIndexOf('/')), function( data ) {
            var offset = $(document).scrollTop();
            container.fadeOut(200, function() {
                container.hide().html(data).fadeIn(200); 
                $(document).scrollTop(offset);
                pp_prepare_popups();
            });
        });
        return false;
    });

    $('#primary').delegate(".pp_ajax_cat a[href^='http://"+location.hostname+"/photos/'] > img:first-child[src]", 'click', function() {
        pp_prepare_popups();
        $(this).click();
        return false;
    });
});


