var PS = {};
PS.sign_up = function(event_id, forward) {
	$.getJSON(
		'/index.php', 
		{ACT: 37, form: 'sign_up', member_id: 0, entry_id: event_id}, 
		function(json) {
			if (json.success) {
				var openEvent = function() {
						if (!forward) {
							location.reload(true);
						}
						else {
							location = $('#button_' + event_id).attr('href');
							
							if ($('#button_' + event_id).hasClass('view-event')) {
								location.reload();
							}
						}
					};
				$("#register-login").dialog({ hide: 'slide' });
				$("#not-started-yet").dialog('option', 'buttons', { "Ok" : function() {$("#not-started-yet").dialog('close')} });
					
					$("#not-started-yet").dialog('option', 'title', 'Sign up successfull');
					var title = $('#button_' + event_id).attr('title');
					$("#not-started-yet").html('You are now signed up to '+title+'. Press OK to continue.');
					$('#not-started-yet').bind('dialogclose', openEvent);
					
					if ($('#button_' + event_id).hasClass('before-fifteen') || !$('#button_' + event_id).hasClass('enter')) {
						$('#not-started-yet').dialog("open");
					} else {
						openEvent();
					}
				
				$("#not-started-yet").dialog('option', 'buttons', { "Ok" : function() {$("#not-started-yet").dialog('close')} });
				$("#not-started-yet").dialog('option', 'title', 'Sign up successfull');
				var title = $('#button_' + event_id).attr('title');
				$("#not-started-yet").html('You are now signed up to '+title+'. Press OK to continue.');
				$('#not-started-yet').bind('dialogclose', openEvent);
				
				if ($('#button_' + event_id).hasClass('before-fifteen') || !$('#button_' + event_id).hasClass('enter')) {
					$('#not-started-yet').dialog("open");
				} else {
					openEvent();
				}
			}
			else {
				location = url;
			}
		}
	);
		
};
