function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function verify()
{
	// Verify checkboxes
	if (!$('notifications_check1').checked && !$('notifications_check2').checked)
	{
		$('notifications_message').innerHTML = 'Error: <span class="red">Please choose at least one type of notification to receive.</span>';
		$('notifications_message').setStyles({
			'opacity': 0,
			'margin-left': $('notifications_check1').getPosition($('notifications')).x
		});
		$('notifications_message').removeClass('hidden');
		$('notifications_message').fade('in');
	}
	
	// If okay, move on
	else
	{
		// Verify email
		if ($('notifications_email').value == '' || !isValidEmail($('notifications_email').value))
		{
			$('notifications_message').innerHTML = 'Error: <span class="red">Valid email required.</span>';
			$('notifications_message').setStyles({
				'opacity': 0,
				'margin-left': $('notifications_email').getPosition($('notifications')).x
			});
			$('notifications_message').removeClass('hidden');
			$('notifications_message').fade('in');
		}
		
		// If verified, submit form
		else
		{
			$('notifications_message').innerHTML = 'Submitting...';
			$('notifications_message').setStyles({
				'opacity': 0,
				'margin-left': $('notifications_email').getPosition($('notifications')).x
			});
			$('notifications_message').removeClass('hidden');
			$('notifications_message').fade('in');
			document.notifications.submit();
		}
	}
}
