$(document).ready(function()
{
	// Toggle of form to retrieve investor code
	$('#get_investor_code').bind('click', function()
	{
		$('#get_investor_code span').toggle();
		$('#get_investor_code_content').toggle('slow');
		$('#get_investor_code_content div.error').css('display', 'none');
	});
	
	// Get Investor Code
	$('#get_investor_code_form').bind('submit', function(event)
	{
		event.preventDefault();
		if($.trim($('#email').val()) == '')
		{
			alert('Please enter your email address');
			$('#email').focus();
			return false;
		}
		
		// Make AJAX request to get code
		$.post('/investors/get_code/', { email: $('#email').val() },
		function(data)
		{
			if(data.result == 'false')
			{
				$('#get_investor_code_content div.error strong').after(' ' + data.message);
				$('#get_investor_code_content div.error').slideDown();
			}
			
			if(data.result == 'true')
			{
				$('#get_investor_code_content').hide();
				$('#get_investor_code_content').html('<div class="success"><strong>Success: </strong> Your investor code is <strong>'+ data.message +'</strong>.<br><br>Please record your Investor Code in a safe place and enter it into the above text field to continue.</div>');
				$('#get_investor_code_content').slideDown();
			}
		}, 'json');
	});
});


function get_investor_code($email)
{
	
}
