// JavaScript Document
window.addEvent('domready', function(){
	
	
	/**   NEWSLETTER **/
	$('email').addEvent('click', function()
						{
						this.erase('value');	
							
						});
	$('formNewsletter').addEvent('submit', function(e) {
		//Prevents the default submit event from loading a new page.
		e.stop();
		//Empty the log and show the spinning indicator.
		//var log = $('log_res').empty().addClass('ajax-loading');
		//Set the options of the form's Request handler. 
		//("this" refers to the $('myForm') element).
		this.set('send', {onComplete: function(response) { 
			//log.removeClass('ajax-loading');
			//log.set('html', response);
			if (response=="oui")
			{
				myAlert.alert("<h3>Succès :</h3><p>Votre email a bien &eacute;t&eacute; enregistr&eacute;.</p>");
				$('email').set('value','votre email...');
			}
			if (response=="non")myAlert.alert("<h3>Erreur :</h3><p>V&eacute;rifiez votre email et essayer &agrave; nouveau, si l'erreur persiste contactez nous &agrave; l'aide de notre formulaire.</p>")
			
			if (response=="deja")myAlert.alert("<h3>Erreur :</h3><p>Vous &ecirc;tes d&eacute;j&agrave; inscrit &agrave; notre newsletter.</p>")
			
		}});
		//Send the form.
		this.send();
	});
	
	
	/* RAPPEL IMMMEDIAT **/
	$('telimmediat').addEvent('click', function()
						{
						this.erase('value');	
							
						});
	$('formRappel').addEvent('submit', function(e) {
		//Prevents the default submit event from loading a new page.
		e.stop();
		//Empty the log and show the spinning indicator.
		//var log = $('log_res').empty().addClass('ajax-loading');
		//Set the options of the form's Request handler. 
		//("this" refers to the $('myForm') element).
		this.set('send', {onComplete: function(response) { 
			//log.removeClass('ajax-loading');
			//log.set('html', response);
			if (response=="oui")
			{
				myAlert.alert("<h3>Succès :</h3><p>Votre t&eacute;l&eacute;phone nous est bien parvenu, nous allons rapidement vous contactez.</p>");
				$('telimmediat').set('value','votre numero de tel...');
			}
			if (response=="non")myAlert.alert("<h3>Erreur :</h3><p>V&eacute;rifiez votre num&eacute;ro de t&eacute;l&eacute;phone et essayer &agrave; nouveau, si l'erreur persiste contactez nous &agrave; l'aide de notre formulaire.</p>")
		}});
		//Send the form.
		this.send();
	});
	
	
	
	var myAlert = new Roar({
			position: 'lowerLeft'
		})
	
	
	
});
