$(document).ready(function() {
	$('img.fancybox').each(function(){
		var $this = $(this); 
		var regImgGroupExists = new RegExp(/imgGrp\:([^ ]+)/);
		var matches = false;
		var imgGrp = "";
		if(matches = $this.attr('class').match(regImgGroupExists)){
			imgGrp = matches[1];
		}
		$this.wrap('<a class="fancybox" rel="'+imgGrp+'" title="' + $this.attr('alt') + '" href="' + $this.attr('src') + '"></a>');
		$this.removeClass("fancybox");
	});
});
