function attachShadowbox() {
	$$('div.attach_shadowbox img').each(function(image) {
		if (!image.hasClassName('page_link')) {
			var imageObj = new Image();
			imageObj.onload = function() {

				if (this.width > 50 && this.height > 50) {
					var a = document.createElement('a');
					a.setAttribute('href', image.src);
					a.setAttribute('alt', image.alt);
					a.setAttribute('rel', 'shadowbox[content]');
					Element.insert(image, {
						before : a
					});
					Element.remove(image);
					a.appendChild(image);
				}
			};
			imageObj.src = image.src;
		}
	});
}

document.observe('dom:loaded', function(){

	if (attachShadowbox !== undefined) {
		attachShadowbox();
	}

});

Event.observe(window, 'load', function(){
	Shadowbox.init();
});

