function sbGalleryAttachLinkControls (randName,fcName) {
	$('#'+randName+' a').unbind('click');
	$('#'+randName+' a').click(function(){
		var theWidth = $('#'+randName+'').width();
		var theHeight = $('#'+randName+'').height();
		var theTop = $('#'+randName+'').position().top;
		var theLeft = $('#'+randName+'').position().left;
		$('#'+randName+'').append('<div class="sb_gallery_preloader_overlay" style="width:'+theWidth+'px;height:'+theHeight+'px;top:'+theTop+'px;left:'+theLeft+'px;"><div class="sb_gallery_preloader"></div></div>');
		var fcNameQuoted = (fcName+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1");
		var theRegEx = new RegExp('^([^;]*);' + fcNameQuoted + ':([^;&]*);?(&.*)?$','ig');
		var theUrl = '';
		if ($(this).attr('href').match(theRegEx)) {
			theUrl = $(this).attr('href').replace(theRegEx, "$1;"+fcName+":\$2%26exec=true%26r="+Math.random()+"$3");
		} else {
			theUrl = $(this).attr('href').replace(/^([^&]*)(&rewriteurls.*$)?/ig,'$1;'+fcName+":exec=true%26r="+Math.random()+"$2");
		}
		$.getJSON(theUrl,function(response){
			var theHtml = response.data;
			if (typeof(sbUrlRewriter) != 'undefined') {
				theHtml = sbUrlRewriter.rewrite(theHtml);
			}
			$('#'+randName+'').html(theHtml);
			sbGalleryAttachLinkControls(randName,fcName);
			$('#'+randName+' a.sb_lightbox').not('.sb_widget_direct_control').lightbox();
		});
		return false;
	});
}