jQuery.noConflict();
jQuery(document).ready(function(){ 	
	jQuery("#contactForm").submit(function(){
		
		jQuery('#errorMessage').html('');
		// validate
		var error = '';
		if (jQuery('#fcontact_name').val() == ''){
			error = 'Please enter a valid name';	
		}
		else if (jQuery('#fcontact_email').val() == ''){
			error = 'Please enter a valid email address';
		} 
		else if (jQuery('#fcontact_comments').val() == ''){
			error = 'Please enter a comment so we can get back to you';
		}
		
		if (error != ''){
			jQuery('#errorMessage').html(error);
			return false;
		}
		
		jQuery('#loaderImage').css({'display': 'block'});
		var url = '/contact.php';
		
		try
		{
			jQuery.post(url,  
				{	name : jQuery('#fcontact_name').val(), email : jQuery('#fcontact_email').val(), 
					comments : jQuery('#fcontact_comments').val(), company : jQuery('#fcontact_company').val() }
				, function(data){
					//jQuery('#contact_thanks').html(data);
					jQuery('#contact_thanks').html('Thank you, we will contact you shortly.');
				}
			);
		}
		catch(error)
		{
			alert('Error: ' + error.message);
		}	
		
		return false;
	});
});

