function initializeFooterButtons() {
	$('.modalFooterEdit').click(function (e) {
		e.preventDefault();
		// load the footer edit form using ajax
		var rnd=new Date().getTime();
		$.get("ax_get_footm.php?rnd="+rnd, function(data){
			// create a modal dialog with the data
			$(data).modal({
				closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
				position: ["15%",],
				overlayId: 'footm-overlay',
				containerId: 'footm-container',
				onOpen: footm.open,
				onShow: footm.show,
				onClose: footm.close
			});
		});
	});

	// preload images
	var img = ['cancel.png', 'form_bottom.gif', 'form_top.gif', 'loading.gif', 'send.png'];
	$(img).each(function () {
		var i = new Image();
		i.src = 'http://www.goldmedalbooster.org/images/modalpopup/' + this;
	});
	
	return false;
}

var footm = {
	message: null,
	open: function (dialog) {
		// add padding to the buttons in firefox/mozilla
		if ($.browser.mozilla) {
			$('#footm-container .footm-button').css({
				'padding-bottom': '2px'
			});
		}
		// input field font size
		if ($.browser.safari) {
			$('#footm-container .footm-input').css({
				'font-size': '.9em'
			});
		}

		// dynamically determine height
		var h = 360;
		if ($('#footm-subject').length) {
			h += 26;
		}
		if ($('#footm-cc').length) {
			h += 22;
		}

		var title = $('#footm-container .footm-title').html();
		$('#footm-container .footm-title').html('Loading...');
		dialog.overlay.fadeIn(100, function () {
			dialog.container.fadeIn(100, function () {
				dialog.data.fadeIn(100, function () {
					$('#footm-container .footm-content').animate({
						height: h
					}, function () {
						$('#footm-container .footm-title').html(title);
						$('#footm-container form').fadeIn(100, function () {
							$('#footm-container #footm-name').focus();

							$('#footm-container .footm-cc').click(function () {
								var cc = $('#footm-container #footm-cc');
								cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked');
							});

							// fix png's for IE 6
							if ($.browser.msie && $.browser.version < 7) {
								$('#footm-container .footm-button').each(function () {
									if ($(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+$/i)) {
										var src = RegExp.$1;
										$(this).css({
											backgroundImage: 'none',
											filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' +  src + '", sizingMethod="crop")'
										});
									}
								});
							}
						});
					});
				});
			});
		});
	},
	show: function (dialog) {
		$('#footm-container .footm-send').click(function (e) {
			e.preventDefault();
			// validate form
			if (footm.validate()) {
				var msg = $('#footm-container .footm-message');
				msg.fadeOut(function () {
					msg.removeClass('footm-error').empty();
				});
				$('#footm-container .footm-title').html('Sending...');
				$('#footm-container form').fadeOut(200);
				$('#footm-container .footm-content').animate({
					height: '100px'
				}, function () {
					$('#footm-container .footm-loading').fadeIn(200, function () {
						$.ajax({
							url: 'ax_sv_footm.php',
							data: $('#footm-container form').serialize() + '&action=send',
							type: 'post',
							cache: false,
							dataType: 'html',
							success: function (data) {
								$('#footm-container .footm-loading').fadeOut(200, function () {
									$('#footm-container .footm-title').html('Editing Footer Done');
									msg.html(data).fadeIn(200);
								});
							},
							error: footm.error
						});
					});
				});				
			}
			else {
				if ($('#footm-container .footm-message:visible').length > 0) {
					var msg = $('#footm-container .footm-message div');
					msg.fadeOut(100, function () {
						msg.empty();
						footm.showError();
						msg.fadeIn(100);
					});
				}
				else {
					$('#footm-container .footm-message').animate({
						height: '30px'
					}, footm.showError);
				}
				
			}
		});
	},
	close: function (dialog) {
		$('#footm-container .footm-message').fadeOut();
		$('#footm-container .footm-title').html('Closing...');
		$('#footm-container form').fadeOut(100);
		$('#footm-container .footm-content').animate({
			height: 60
		}, function () {
			dialog.data.fadeOut(100, function () {
				dialog.container.fadeOut(100, function () {
					dialog.overlay.fadeOut(100, function () {
						$.modal.close();
					});
				});
			});
		});
	},
	error: function (xhr) {
		alert(xhr.statusText);
	},
	validate: function () {
		footm.message = '';

		if (footm.message.length > 0) {
			return false;
		}
		else {
			return true;
		}
	},
	showError: function () {
		$('#footm-container .footm-message')
			.html($('<div class="footm-error"></div>').append(footm.message))
			.fadeIn(100);
	}
};

runWhenReady[runWhenReady.length] = 'initializeFooterButtons';
