window.addEvent('load', function () {
	$$('#contentMain img').each(function (el) {
		if (el.getParent().getTag() != 'a'){
			oLink = new Element('a').setProperties({
				//'href'  : el.src.replace(new RegExp(/\/iWidth(.*)/),""),
				'href'  : '#',
				'rel'   : 'lightbox[]',
				'title' : el.title,
				'onclick' : 'return false;'
			}).addEvent('click', function() {
				var oOverlay = new Element('div').setProperties({
					'id': 'transOverlay'
				}).setStyles({
					'height': window.getScrollHeight(),
					'width': '100%',
					'position': 'absolute',
					'top': 0,
					'right': 0,
					'bottom': 0,
					'left': 0,
					'background': '#000000',
					'z-index': 100
				}).setOpacity(0.8).inject(document.body);
				var oFullImageHolder = new Element('div').setProperties({
					'id': 'fullImageHolder'
				}).setStyles({
					'height': window.getScrollHeight(),
					'width': '100%',
					'position': 'absolute',
					'top': 100,
					'right': 0,
					'bottom': 0,
					'left': 0,
					'text-align': 'center',
					'z-index': 101
				}).addEvent('click', function() {
					$('transOverlay').remove();
					$('fullImageHolder').remove();
				}).inject(document.body);
				var oFullImage = new Element('img').setProperties({
					'src': el.src.replace(new RegExp(/\/iWidth(.*)/),""),
					'alt': el.title
				}).setStyles({
					'margin': window.getScrollTop() + 100 + 'px 0 0 0',
					'border': '10px solid #ffffff'
				}).inject(oFullImageHolder);
				return false;
			}).injectBefore(el);
			el.injectInside(oLink);
		} else {
			el.getParent().setProperties({
				'href': '#',
				'onclick' : 'return false;'
			}).addEvent('click', function() {
				var oOverlay = new Element('div').setProperties({
					'id': 'transOverlay'
				}).setStyles({
					'height': window.getScrollHeight(),
					'width': '100%',
					'position': 'absolute',
					'top': 0,
					'right': 0,
					'bottom': 0,
					'left': 0,
					'background': '#000000',
					'z-index': 100
				}).setOpacity(0.8).inject(document.body);
				var oFullImageHolder = new Element('div').setProperties({
					'id': 'fullImageHolder'
				}).setStyles({
					'height': window.getScrollHeight(),
					'width': '100%',
					'position': 'absolute',
					'top': 100,
					'right': 0,
					'bottom': 0,
					'left': 0,
					'text-align': 'center',
					'z-index': 101
				}).addEvent('click', function() {
					$('transOverlay').remove();
					$('fullImageHolder').remove();
				}).inject(document.body);
				var oFullImage = new Element('img').setProperties({
					'src': el.src.replace(new RegExp(/\/iWidth(.*)/),""),
					'alt': el.title
				}).setStyles({
					'margin': window.getScrollTop() + 100 + 'px 0 0 0',
					'border': '10px solid #ffffff'
				}).inject(oFullImageHolder);
				return false;
			});
		}
	});
});