// Setup this var so it's globally available
var hiddenMaps = {};
// Set the tabberOptions so our functions are called appropriately
var tabberOptions = { onLoad:tabberMapInit, onTabDisplay:tabberMapCheck };

function tabberMapInit() {
	
	// Construct an array of tabbed maps to use later
	jQuery.each(jQuery('.tabbertab .map'), function(i, val) {
		hiddenMaps[i] = (jQuery(val).attr('id'));
	} );
	
	tabberMapCheck();
	
}

function tabberMapCheck() {
	
	jQuery.each(hiddenMaps, function(i, val) {
		// If this map is visible, call the checkResize function and re-center the map
		if (jQuery('#' + val).parents('.tabbertab').css('display') == 'block') {
			mapobj = val.replace(/-/, '');
			posobj = mapobj.replace(/map/, 'pos');
			if (typeof(window[mapobj]) != 'undefined') {
				window[mapobj].checkResize();
				window[mapobj].setCenter(window[posobj], 13);
			}
			delete hiddenMaps[i];
		}
	});
	
}

jQuery(document).ready(function(){
	
	// Enable thickbox on all gallery images
	tb_init('div.gallery dl.gallery-item a');
	
});
