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