$extend( TASTE, {

	initEnquiry: function()
	{
		
		$( 'form_contact' ).addEvent( 'submit', function(e) {
			
			e.stop();
			
			// Define data
			var data = {
			    assignedMemberIncId: $( 'form_contact_topic' ).value,
				contactName: $( 'form_contact_contactName' ).value,
				topic: $( 'form_contact_topic' ).value,
				emailAddress: $( 'form_contact_emailAddress' ).value,
				phoneNumber: $( 'form_contact_phoneNumber' ).value,
				message: $( 'form_contact_message' ).value
			};
			
			switch( data.topic )
			{
				case '2018': data.topic = 'Foveaux Street Store'; break;
				case '1976': data.topic = 'Sussex Lane Store'; break;
				case '1978': data.topic = 'Market Street Store'; break;
				case '1980': data.topic = 'World Square Store'; break;
				case '1981': data.topic = 'Sydney University Store'; break;
				case '1980': data.topic = 'Functions'; break;
				case '1980': data.topic = 'Catering'; break;
				case '1980': data.topic = 'Other'; break;
			}
			
			// Check values
   			if ( data.contactName == 'Full name' || !data.contactName )
   				data.contactName = '';
			
			// Send name string as summary
			data.name = data.contactName + ' - ' + data.emailAddress;
			
			
			// Validate fields
			if ( !TASTE.FormTools.validateFields( data, {
					'contactName': 'Please enter your name before trying to send the form.'
				}))
				return;
				
			if ( !TASTE.FormTools.validateFields( data, {
					'phoneNumber': 'Please enter your phone number before trying to send the form.'
				}))
				return;
			
			if ( !/^[\w\-]+(\.[\w\-]+)*@[\w\-]+\.([\w\-]+\.)*[a-z]{2,}$/i.test( data.emailAddress ) )
			{
				alert( 'That is not a valid email address, please try again.' );
				$( 'form_contact_emailAddress' ).focus();
				return;
			}
			
			
			$( 'form_contact_submit' ).set( 'value', 'sending...' ).set( 'disabled', true );
				
			
			Aurora.callAPI({
				
				key: 'create enquiry',
				data: data,
				
				onComplete: function( rtnData ) {
					
					$( 'form_contact_submit' ).set( 'value', 'Submit' ).set( 'disabled', false );
					
					if ( rtnData.success )
					{
						$( 'form_contact_success' ).show();
						$( 'form_contact' ).hide();
						
						$( 'form_contact_contactName' ).set( 'value', '' ).fireEvent( 'blur' );
						$( 'form_contact_emailAddress' ).set( 'value', '' ).fireEvent( 'blur' );
						$( 'form_contact_phoneNumber' ).set( 'value', '' ).fireEvent( 'blur' );
						$( 'form_contact_topic' ).set( 'value', '' ).fireEvent( 'blur' );
						$( 'form_contact_message' ).set( 'value', '' ).fireEvent( 'blur' );
					}
					else
					{
						alert( "Sorry, there was an error sending your message. Please reload the page and try again.\n\nIf you continue to get this message, please get in contact with us." );
						return;
					}
					
				}
				
			});
			
		});
	
	}

});

window.addEvent( 'domready', function() {

	TASTE._initHooks = [ TASTE.initEnquiry() ];

});