$(document).ready(function () {
	
	$("a.event_register").click(function () {
		var id = $(this).attr('href');
		$.post("http://www.amplifytrading.com/ajax/log_to_event/" + id, {}, function (result) {
			if (result == 'ok') {
				//user is logged in and we have signed him for the selected event
				$.fumodal({	
					width:300,
					height:150,
					style:true,
					content: '<div style="font-size: 12px; text-align: center; margin-top: 25px;">You have been successfully signed for the selected event.</div>',
					title:'<b>Alert</b>'
				});				
			} else {
				if (result == 'not_logged') {
					//user is not logged in, offer a form to fill in
					$.fumodal({	
						width:500,
						height:485,
						style:true,
						url: 'http://www.amplifytrading.com/ajax/form_to_event/' + id,
						title:'<b>Register for a Workshop</b>'
					});				
				} else {
					if (result == 'logged_already') {
						//user with the same details is already logged in for this event
						$.fumodal({	
							width:300,
							height:150,
							style:true,
							content: '<div style="font-size: 12px; text-align: center; margin-top: 25px;">You are already logged for this event.</div>',
							title:'<b>Alert</b>'
						});										
					}
				}
			}
		});
		return false;
	});
	
});