$(document).ready(function(){
	$('#map').flash(
		{ src: 'flash/TassieMap-Homepage-2.swf',
		  width: 550,
		  height: 480 },
		{ version: 8 }
	);
	
	////////////////////////////////////////////////////////////////////////
	// AJAX Contact Form Handler
	/////////////////////////////////////////////////////////////////////////
    $('#submit').click(function () {
		
		$("#coordcontact").validate({
			
			submitHandler: function(form) {
         
			//Get the data from all the fields
			var recipient = $('input[name=recipient]');
			var name = $('input[name=name]');
			var address = $('input[name=address]');
			var city = $('input[name=city]');
			var postcode = $('input[name=postcode]');
			var phone = $('input[name=phone]');
			var email = $('input[name=email]');
			var enquirytype = $('input[name=enquirytype]');
			var enquiry = $('textarea[name=enquiry]');
	
			//organize the data properly
			var data = 
			'recipient=' + recipient.val() +
			'&name=' + name.val() +
			'&address=' + address.val() +
			'&city=' + city.val() +
			'&postcode=' + postcode.val() + 
			'&phone=' + phone.val() + 
			'&email=' + email.val() +
			'&enquirytype=' + enquirytype.val() + 
			'&enquiry=' + encodeURIComponent(enquiry.val());
			 
			//disabled all the text fields
			$('.text').attr('disabled','true');
			 
			//start the ajax
			$.ajax({
				//this is the php file that processes the data and send mail
				url: "inc/process.php",
				 
				//GET method is used
				type: "GET",
	 
				//pass the data        
				data: data,
				 
				//Do not cache the page
				cache: false,
				 
				//success
				success: function (html) {             
					//if process.php returned 1/true (send mail success)
					if (html==1) {
						//hide the form
						$('.form').fadeOut('slow');
						 
						//show the success message
						$('.done').fadeIn('slow');
						 
					//if process.php returned 0/false (send mail failed)
					} else alert(html);
				}      
			});
			
        	return false;
			
			} // end submitHandler
			
		}); // end validate function
    }); 
	/////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////
	
	
	
});

