J(function($){
	/* set global variable for boxy window */
	var contactBoxy = null;
	/* what to do when click on contact us link */
	$('#btnEnvoyer').click(function(){
		var boxy_content;
		boxy_content += "<div style=\"height:180px;width:370px;\"><form id=\"formEnvoyerAmi\">";
		boxy_content += "<label for=\"email\" style=\"width:150px;display:block;float:left;\">Adresse e-mail :</label>";
		boxy_content += "<input name=\"email\" id=\"email\" type=\"text\" value=\"\" size=30 maxlength=40 /><br /><br />";
		boxy_content += "<input name=\"url\" id=\"url\" type=\"hidden\" value=\""+ urlActuel +"\" size=30 maxlength=40 />";
		boxy_content += "<label for=\"message\" style=\"width:150px;display:block;float:left;\">Message d'accompagnement :</label>";
		boxy_content += "<textarea name=\"message\" id=\"message\" style='width:200px;height:100px;'></textarea>";
		boxy_content += "<table style=\"width:370px;height:50px;vertical-align:bottom;\"><tr>";
		boxy_content += "<td style=\"width:260px;text-align:right;font-size:10px;padding-right:10px;\">&nbsp;</td>";
		boxy_content += "<td style=\"text-align:left;\" ><input type=\"submit\" name=\"submit\" value=\"Envoyer >>\" /></div></td>";
		boxy_content += "</tr></table>";
		boxy_content += "</form></div>";
		contactBoxy = new Boxy(boxy_content, {
			title: "Envoyer",
			draggable: false,
			modal: true,
			behaviours: function(c) {
				c.find('#formEnvoyerAmi').submit(function() {
					Boxy.get(this).setContent("<div style='height:50px;width:315px;'>Envoi...</div>");
					// on appelle la page php en lui passant des arguments en POST
					$.post("./envoyer-ami.php", { message: c.find("textarea[name='message']").val(),email: c.find("input[name='email']").val(),url: c.find("input[name='url']").val()},
					function(data){
						//on récupére ce qui a été afficher sur la page php
						contactBoxy.setContent(data);
					});
					return false;
				});
			}
		});
		return false;
	});
});
