thanks MorningZ, but no luck here. on refresh safari ignores positioning and messes up image resizing.
l. // create gallery images $(document).ready(function() { var max_width = 310; var max_height = 310; var selector = 'img.medium'; $(selector).each(function() { var width = $(this).width(); var height = $(this).height(); if (height > width) { var ratio = (width / height); var new_height = max_height; var new_width = (new_height * ratio); var position = Math.floor((max_width - new_width)/2); $(this) .css("width",new_width + "px") .css("height",new_height + "px") .css("position","relative") .css("left",position + "px"); } else { var ratio = (height / width); var new_width = max_width; var new_height = (new_width * ratio); var position = Math.floor((max_height - new_height)/2); $(this) .css("width",new_width + "px") .css("height",new_height + "px") .css("position","relative") .css("top",position + "px"); } }); // create thumb images var max_width = 100; var max_height = 100; var selector = 'img.thumb'; $(selector).each(function() { var width = $(this).width(); var height = $(this).height(); if (height > width) { var ratio = (width / height); var new_height = max_height; var new_width = (new_height * ratio); var position = Math.floor((max_width - new_width)/2); $(this) .css("width",new_width + "px") .css("height",new_height + "px") .css("position","relative") .css("left",position + "px"); } else { var ratio = (height / width); var new_width = max_width; var new_height = (new_width * ratio); var position = Math.floor((max_height - new_height)/2); $(this) .css("width",new_width + "px") .css("height",new_height + "px") .css("position","relative") .css("top",position + "px"); } }); // create gallery var tabContainers = $('div.tabs > div.gallery > div'); $('div.tabs span.tabNavigation a').click(function () { tabContainers.hide('slow').filter(this.hash).toggle('slow'); $('div.tabs span.tabNavigation a').removeClass('selected'); $(this).addClass('selected'); return false; }).filter(':first').click(); });