function Popup(Adresse_de_la_page,Nom_de_la_fenetre) {
	window.open(Adresse_de_la_page,Nom_de_la_fenetre,'height=420,width=504,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no');
}

function postForm(the_form) {
	var urlz = 'dynamic/api.php';
	var inputz = jQuery('form#'+the_form).serialize();
	//alert(inputz);
	jQuery.post(urlz, inputz,function(data, textStatus){
    	alert(data);
    	var index;
    	index = data.indexOf('Erreur');
    	
    	if((textStatus == 'success') && (index == -1)) {
			jQuery('form#'+the_form)[0].reset();
		}
  	});
}

jQuery(function(){
		jQuery.noConflict();
				
		// Bind scroll
		jQuery('.scroll').jScrollPane({dragMinHeight:9,dragMaxHeight:9,scrollbarMargin:10});
		
		// Bind footer link
		jQuery('a#plegal').click(function(e){
			e.preventDefault();
			Popup('mentions-legales.html','legal');
		});
		
		jQuery('a#pcontact').click(function(e){
			e.preventDefault();
			Popup('contact.html','contact');
		});
		
		// Clear input on first click
		jQuery('input#url, input#email, input#cp').one('focus', function(){ jQuery(this).val(''); });
		
		// Form submit trigger
		jQuery('input#submitpar').click(function(){
			postForm('particulier');
		});
		
		// Form submit trigger
		jQuery('input#submitpro').click(function(){
			postForm('pro');
		});
		
		// Form submit trigger
		jQuery('input#submitpresse').click(function(){
			postForm('presse_f');
		});
		
		// Form submit trigger
		jQuery('input#submitzpar').click(function(){
			postForm('zparticulier');
		});
		
		// Form submit trigger
		jQuery('input#submitzpro').click(function(){
			postForm('zpro');
		});
});
