/*
 * 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 39 2007-10-26 20:46:32Z emartin24 $
 *
 */

function showModal() {
		// load the contact form using ajax
		$.get("/postit_ptn/survey.jsp", function(data){
			// create a modal dialog with the data
			$(data).modal({
				close: false,
				overlayId: 'contactModalOverlay',
				containerId: 'contactModalContainer',
				iframeId: 'contactModalIframe',
				onOpen: contact.open,
				onShow: contact.show,
				onClose: contact.close
			});
		});
}

$(document).ready(function () {
                showModal();
});

var contact = {
	message: null,
	open: function (dialog) {
		dialog.overlay.fadeIn(200, function () {
			dialog.container.fadeIn(200, function () {
				dialog.content.fadeIn(200, function () {
					$('#contactModalContainer #name').focus();
				});
				// resize the textarea for safari
				if ($.browser.safari) {
					$('#contactModalContainer textarea').attr({
						cols: '37',
						rows: '8'
					});
				}
			});
		});
	},
	close: function (dialog) {
		dialog.content.fadeOut(200, function () {
			dialog.container.fadeOut(200, function () {
				dialog.overlay.fadeOut(200, function () {
					$.modal.remove(dialog);
				});
			});
		});
	},
	error: function (xhr) {
		alert(xhr.statusText);
	},
	showError: function () {
		$('#contactModalContainer .message').html($('<div class="error"></div>').append(contact.message)).fadeIn(200);
	}
};



