function showBusy(){ 	$('.form_busy').show('slow');	$('.form_added').hide('slow');	}
function showAdded(){	$('.form_added').show('slow'); }
function processForm(html){	
	$('.form_errors').hide('slow');		
	window.setTimeout( function(){			 	
				$('.form_busy').hide('slow');				
				if(parseFloat(html)){			 								
						showAdded();
			 	}else{
			 		$('.form_errors').html(html).show('slow');
			 	}			 	
	}, 2000);
}


jQuery(document).ready(function(){
	$('.form_busy').hide();
	$('.form_added').hide();
	$('.form_errors').hide();
	
	// $.CONTACT
	$('#standard_form_contact').submit(function(eve){
		eve.preventDefault();		
		$.ajax({
			url: "/contact/trimitere",
			type: "POST",
			dataType: "html",
			data: $('#standard_form_contact').serialize(),
			beforeSend: function(){
				showBusy();
			},	
		  	success: function(html) {		  		
		    	processForm(html);
		    	if(parseFloat(html)){
		    		$('#standard_form_contact').hide('slow');
		    	}
		 	}
		});

	});	
	
	
	
	// $.CONTACT
	$('#standard_form_contact_properties').submit(function(eve){
		eve.preventDefault();		
		$.ajax({
			url: "/contact/trimitere_properties",
			type: "POST",
			dataType: "html",
			data: $('#standard_form_contact_properties').serialize(),
			beforeSend: function(){
				showBusy();
			},	
		  	success: function(html) {		  		
		    	processForm(html);
		    	if(parseFloat(html)){
		    		$('#standard_form_contact_properties').hide('slow');
		    	}
		 	}
		});

	});	
	
});