$(document).ready(function() {
	
	if($('a#galleryLink').length > 0){
		$('a#galleryLink').click(function() {
			$('#tabs-4 > div.bodyCopy > div#photoGalleryScroller > div.items > abbr').each(function(index) {
				var alt = $(this).attr("alt");
				var src = $(this).attr("src");
				var title = $(this).attr("title");
				$(this).replaceWith('<img src="' + src + '" alt="' + alt + '" title="' + title + '"' + ' />');
				$("#photoGalleryScroller .items img").slimbox({}, function(el) {
					return [el.src, el.title];
				} );
			});	 
		});
	}

	if($('a#galleryLink')){
		$('a#patientGalleryLink').click(function() {
			$('#tabs-5 > div.bodyCopy > div#beforeAfterGalleryScroller > div.items > abbr').each(function(index) {
				var alt = $(this).attr("alt");
				var src = $(this).attr("src");
				var title = $(this).attr("title");
				$(this).replaceWith('<img src="' + src + '" alt="' + alt + '" title="' + title + '"' + ' />');
				$("#beforeAfterGalleryScroller .items img").slimbox({}, function(el) {
					return [el.src, el.title];
				} );		
			});	 
		});
	}	
	
	if($("#beforeAfterGalleryScroller").length > 0){
		$("#beforeAfterGalleryScroller").scrollable();
	}
	if($("#photoGalleryScroller").length > 0){
		$("#photoGalleryScroller").scrollable();
	}	
});

