/*
 * SimpleModal Contact Form
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2007 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: contact.js 113 2008-03-15 15:36:21Z emartin24 $
 *
 */
$(document).ready(function () {
	$('.viewMapLink, viewMapForm input:eq(0)').click(function (e) {
		e.preventDefault();
		// load the contact form using ajax
		$.get('view-map.php?id=' + $(this).text().substr(15), function(data){
			// create a modal dialog with the data
			$(data).modal({
				close: false,
				overlayId: 'view-map-overlay',
				containerId: 'view-map-container',
				onOpen: viewMap.open,
				onShow: viewMap.show,
				onClose: viewMap.close
			});
		});
	});
});

var viewMap = {
	message: null,
	open: function (dialog) {
		// add padding to the buttons in firefox/mozilla
		var title = $('#view-map-container .view-map-title').html();
		$('#view-map-container .view-map-title').html('Loading...');
		dialog.overlay.fadeIn(200, function () {
			dialog.container.fadeIn(200, function () {
				dialog.data.fadeIn(200, function () {
					$('#view-map-container .view-map-content').animate({
						height: 400
					}, function () {
						$('#view-map-container .view-map-title').html(title);
						 $('#view-map-container iframe').fadeIn(200, function () {
						});
					});
				});
			});
		});
	},
	close: function (dialog) {
		$('#view-map-container iframe').fadeOut(200);
		$('#view-map-container iframe').css({'display': 'none'});
		$('#view-map-container .view-map-title').html('Goodbye...');
		$('#view-map-container .view-map-content').animate({
			height: 40
		}, function () {
			dialog.data.fadeOut(200, function () {
				dialog.container.fadeOut(200, function () {
					dialog.overlay.fadeOut(200, function () {
						$.modal.close();
					});
				});
			});
		});
	}
};
