String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

$(document).ready(function() {
	//photogallery2
	$('.pg_thumbnail a').fancybox({
		'titlePosition' : 'inside',
		'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-inside">(' + (currentIndex + 1) + ' / ' + currentArray.length + ')' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
	});
});

function fixCaption()
{
    $(".image").each(function(index, e) {
        var w = $(".image_img img", e).width();
        $(e).width(w);
    });
}

$(window).load(function() {
    fixCaption();
});
