/*
 * SimpleModal Confirm Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2009 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: confirm.js 212 2009-09-03 05:33:44Z emartin24 $
 *
 */

$(document).ready(function () {
	$('input.confirm, a.confirm').bind("click",function (e) {
		e.preventDefault();
		if ($('#email').val()=='') {
			alert("Please enter an email address");
			return false;
		}
		if (!($('#terms-1').attr('checked'))) {
			alert("Please accept the terms of service");
			return false;
		}
		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		 $.getJSON("data/confirm.php?email=" + $('#email').val() ,
        function(data){
        	confirm(data.message, data.button, function () {
			
		});
         });
        
	
	});
});

function confirm(message, button, callback) {
	$('#confirm').modal({
		closeHTML:"<a href='#' title='Close' class='modal-close'>x</a>",
		position: ["20%",],
		overlayId:'confirm-overlay',
		containerId:'confirm-container', 
		onShow: function (dialog) {
			$('.message', dialog.data[0]).append(message);
			$('.yes', dialog.data[0]).append(button);
			// if the user clicks "yes"
			
		}
	});
}