function validateFindmore (which) {
    error=0; msg="";
    // Your Name
	if(!$("input#findmore_name").val()){error++; msg+="<strong>Nom en entier</strong><br />"; $("input#findmore_name").parent().addClass("error");}
	else{$("input#findmore_name").parent().removeClass("error"); findmore_name=$("input#findmore_name").val();}
	    	
	// Your Email
	if(!checkEmail($("input#findmore_email").val())){error++; msg+="<strong>Adresse de courriel</strong><br />"; $("input#findmore_email").parent().addClass("error");}
	else{$("input#findmore_email").parent().removeClass("error"); findmore_email=$("input#findmore_email").val();}
	
	// Daytime phone number
	if(!checkPhone($("input#findmore_tel").val())){error++; msg+="<strong>Téléphone de jour</strong><br />"; $("input#findmore_tel").parent().addClass("error");}
	else{$("input#findmore_tel").parent().removeClass("error"); findmore_tel=$("input#findmore_tel").val(); }
	
	// Subject
	if($("select#findmore_subject").val() == ''){error++; msg+="<strong>Sujet</strong><br />"; $("select#findmore_subject").parent().addClass("error");}
	else{$("select#findmore_subject").parent().removeClass("error"); findmore_subject=$("select#findmore_subject").val();}
	
	// Message
	findmore_message = $("textarea#findmore_message").val();
	
	if($("#msgErrorSidebar")){ $("#msgErrorSidebar").remove(); }
	if(error!=0){
		msg = "<strong>Attention</strong><br />Assurez-vous de remplir correctement les champs suivants avant d'envoyer :<br /><br />" + msg;
		$("#"+which).before("<div id='msgErrorSidebar'>" +msg+ "</div>");
	}else{
	    $("#"+which+" .submit").hide();
		$(".b_sending").show();
		theUrl = "/fr/mail/find-more.php?findmore_name="+ findmore_name +"&findmore_email="+ findmore_email +"&findmore_tel="+ findmore_tel +"&findmore_subject="+ findmore_subject +"&findmore_message="+ findmore_message;
		$.ajax({
			type: "GET",
			url: theUrl,
			success: function(resp){
                toggleFindmore('thanks');
			},
			error: function(req) {}
		});
    }
}

function toggleFindmore(state) {
    if(state == 'form') {
   	    $("#frm_findmore .submit").show();
		$(".b_sending").hide();
        $("#frm_findmore").show();
        $("div#findmore_thanks").remove();
    } else if (state == "thanks") {
	    var thanks  = '';
	    thanks += '<div id="findmore_thanks">\n';
	    thanks += '  <h3>Merci !</h3>\n';
		thanks += '  <p>Nous vous contacterons sous peu.</p>\n';
//		thanks += '  <p><a href="" onclick="javascript:toggleFindmore(\'form\'); return false;" class="b b_close">Fermer</a></p>\n';
		thanks += '</div>\n';
	    $("#frm_findmore", "#sidebar").before(thanks);
	    $("#frm_findmore").hide();
    }
}

function displayStf (state) {
	if(state=="form"){
		if($("#stf").is("div")){
			if($("#stf").css("display")=="none"){
				$("#stf_thanks").hide(); $("#stf_form").show();
				$("#stf").show();
				$(".b_send","#li_stf_buttons").show();
        		$(".b_sending","#li_stf_buttons").hide();
			} else {
			    $("#stf").hide();
			}
		}else{
			var stf="";				
			stf += '<div id="stf">\n';
			stf += '	<div id="stf_thanks" style="display:none;">\n';
			stf += '		<h3>Merci !</h3>\n';
			stf += '		<p>Votre courriel a bien &eacute;t&eacute; envoy&eacute;</p>\n';
			stf += '		<p class="clearfix"><a href="javascript:displayStf(\'remove\');" class="b b_close">Fermer</a></p>\n';
			stf += '	</div>\n';
			stf += '	<div id="stf_form">\n';
			stf += '		<h3>Partager cette page avec un ami ou un coll&egrave;gue.</h3>\n';
			stf += '		<form id="frm_stf">\n';
			stf += '			<fieldset>\n';
			stf += '				<ol>\n';
			stf += '					<li id="li_stf_name"><label for="stf_name">Votre nom</label><input type="text" id="stf_name" name="stf_name" class="mandatory" maxlength="200" /></li>\n';
			stf += '					<li id="li_stf_email"><label for="stf_email">Votre courriel</label><input type="text" id="stf_email" name="stf_email" class="mandatory" maxlength="200" /></li>\n';
			stf += '					<li id="li_stf_friendsname"><label for="stf_friendsname">Nom du destinataire</label><input type="text" id="stf_friendsname" name="stf_friendsname" class="mandatory" maxlength="200" /></li>\n';
			stf += '					<li id="li_stf_friendsemail"><label for="stf_friendsemail">Courriel du destinataire</label><input type="text" id="stf_friendsemail" name="stf_friendsemail" class="mandatory" maxlength="200" /></li>\n';
			stf += '					<li id="li_stf_comments"><label for="stf_comments">Commentaires<span> (optionnel)</span></label><textarea id="stf_comments" name="stf_comments"></textarea></li>\n';
			stf += '					<li id="li_stf_buttons">\n';
			stf += '						<a href="javascript:validateStf(\'frm_stf\');" class="b b_send">Envoyer</a>\n';
			stf += '						<span class="b b_sending" style="display:none;">Transmission...</span>\n';
			stf += '						<a href="javascript:displayStf(\'hide\');" class="b b_cancel">Annuler</a>\n';
			stf += '					</li>\n';
			stf += '				</ol>\n';
			stf += '			</fieldset>\n';
			stf += '		</form>\n';
			stf += '	</div>\n';
			stf += '</div>\n';
			
			$("#subheader").after(stf);
			$("#stf").show();
			$("#stf #stf_name").focus();
		}
	}else if (state == "thanks"){
	}else{
		$("#stf").hide();
	}
}


function validateStf(which){		
	error=0; msg="";
	
	// Your Name
	if(!$("input#stf_name").val()){ error++; msg+="<strong>Votre nom<strong><br />"; $("input#stf_name").parent().addClass("error"); }
	else{ $("input#stf_name").parent().removeClass("error"); stf_name=$("input#stf_name").val(); }
	
	// Your Email
	if(!checkEmail($("input#stf_email").val())){ error++; msg+="<strong>Votre courriel</strong><br />"; $("input#stf_email").parent().addClass("error"); }
	else{ $("input#stf_email").parent().removeClass("error"); stf_email=$("input#stf_email").val(); }
	
	// Friends Name
	if(!$("input#stf_friendsname").val()){ error++; msg+="<strong>Nom du destinataire</strong><br />"; $("input#stf_friendsname").parent().addClass("error"); }
	else{ $("input#stf_friendsname").parent().removeClass("error"); stf_friendsname=$("input#stf_friendsname").val(); }
	
	// Friends Email
	if(!checkEmail($("input#stf_friendsemail").val())){ error++; msg+="<strong>Courriel du destinataire</strong><br />"; $("input#stf_friendsemail").parent().addClass("error"); }
	else{ $("input#stf_friendsemail").parent().removeClass("error"); stf_friendsemail=$("input#stf_friendsemail").val(); }
	
	// Comments
	stf_comments=$("textarea#stf_comments").val();
	
	if(error!=0){
		msg="<strong>Attention</strong><br />Assurez-vous de remplir correctement les champs suivants avant d'envoyer :<br /><br />" + msg;
		if($("#msgErrorTop")){ $("#msgErrorTop").remove(); }
		$("#"+which).before("<div id='msgErrorTop'>" +msg+ "</div>");
	}else{
		$(".b_send","#li_stf_buttons").hide();
		$(".b_sending","#li_stf_buttons").show();
		theUrl = "/fr/mail/send-to-a-friend.php?stf_name="+ stf_name +"&stf_email="+ stf_email +"&stf_friendsname="+ stf_friendsname +"&stf_friendsemail="+ stf_friendsemail +"&stf_comments="+ escape(stf_comments) +"&stf_path="+ location.href;
		$.ajax({
			type: "GET",
			url: theUrl,
			success: function(resp){ $("#stf_thanks").show(); $("#stf_form").hide();},
			error: function(req) { }
		});
	}
}