$(document).ready(function() {
	var service = '12ALLJSONWebServices.php';
	var proxy12ALL = host + j_basepath + 'proxy12All.php';
	var domainName = 'groupe3.com';
	var listId = '103';

	$('#inscNewsLetterForm').submit(function(){
		if(!tmt_validateForm(this)){
			return false;
		}	
		var zNom = $('#nom').val();
		var zPrenom = $('#prenom').val();
		var zMail = $('#mail').val();
		$('#inscNewsLetterForm').hide('slow',function(){
			$("#m2").show('slow');			
		});					
		// on envoie chez 12ALL aussi
		$.post(proxy12ALL, { service: service, task: 'add', email: zMail, listid: listId, name: zNom + ' ' + zPrenom},function(data){
			data = eval('(' + data + ')');
			if(data === true){
				$('#m2').hide('slow',function(){
					$("#m3").show('slow');			
				});					
				
				if (typeof(iTimeoutID) != 'undefined') {
					clearTimeout(iTimeoutID);
				}
				iTimeoutID = setTimeout(function(){
					$("#m3").hide('slow',function(){
						$('#inscNewsLetterForm').show('slow');
						$('#inscNewsLetterForm').find('input[@type=text]').each(function(){
							$(this).val('');
						});
						$('#desinscNewsLetterForm').show('slow');
					});				
				}, 3000, 'JavaScript');
			}
		});

		return false;
	});
	$('#desinscNewsLetterForm').submit(function(){
		if(!tmt_validateForm(this)){
			return false;
		}		
		var zMail = $("#dmail").val();
		$('#desinscNewsLetterForm').hide('slow',function(){
			$("#m2").show('slow');			
		});					
		// on envoie chez 12ALL aussi
		$.post(proxy12ALL, { service: service, task: 'remove', email: zMail, listid: listId, name: ''},function(data){
			data = eval('(' + data + ')');
			if(data === true){
				$('#m2').hide('slow',function(){
					$("#m1").show('slow');			
				});					
				
				if (typeof(iTimeoutID) != 'undefined') {
					clearTimeout(iTimeoutID);
				}
				iTimeoutID = setTimeout(function(){
					$("#m1").hide('slow',function(){
						$('#desinscNewsLetterForm').show('slow');
						$('#desinscNewsLetterForm').find('input[@type=text]').each(function(){
							$(this).val('');
						});
						$('#desinscNewsLetterForm').show('slow');
					});				
				}, 3000, 'JavaScript');
			}
		});
		return false;
	});
	
});

