$(function(){		 
	$('ul#services').innerfade({
		animationtype:'fade',
		speed: 3000,
		timeout: 6000,
		type: 'sequence'
	});
	
	function populateElement(selector, defvalue) {
		$(selector).each(function() {
			if($.trim(this.value) == "") {
				this.value = defvalue;
			}
		});	  
		$(selector).focus(function() {
			if(this.value == defvalue) {
				this.value = "";
			}
		});		
		$(selector).blur(function() {
			if($.trim(this.value) == "") {
				this.value = defvalue;
			}
		});
	 }
	 
	 populateElement('#name', 'Entrez votre nom');
	 populateElement('#company', 'Entrez votre nom de lentreprise');
	 populateElement('#phone', 'Entrez votre numero de telephone');
	 populateElement('#altphone', 'Entrez votre numero alternatif');
	 populateElement('#email', 'Entrez votre courriel');
	 populateElement('#comments', 'Saisissez votre message ici...');
	
	$('#contact_form').submit(function(){	
		var action = $(this).attr('action');
		
		$("#error").slideUp(750,function() {
		$('#error').hide();
		
 		$('#submit').attr('disabled','disabled');
		
			$.post(action, { 
				name: $('#name').val(),
				company: $('#company').val(),			
				phone: $('#phone').val(),
				altphone: $('#altphone').val(),
				email: $('#email').val(),
				comments: $('#comments').val()
			},
				function(data){	
					document.getElementById('error').innerHTML = data;
					$('#error').slideDown('slow');
					$('#contact_form #submit').attr('disabled',''); 
					if(data.match('success') != null){$('#contact_form').slideUp('slow');}								
				}
			);		
		});	
		return false; 	
	});
});
