/** * Fonction d'ouverture du choix de la langue (top) */ function toggleLang(name) { var o = $(name); if (o.visible()) { o.hide(); } else { o.show(); } } // fin de toggleLang /** * Fonction de confirmation de l'âge */ function ageConfirm(state) { if (state == 1) { $('light').hide(); $('fade').hide(); } else { $('light').hide(); $('min_light').show(); } var url = '_action.php?a=age_confirm&state=' + state; new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { //container.update(transport.responseText); } }); } // fin de ageConfirm /** * Fonction d'ouverture de popup Apero */ function displayPopup(url) { var a = new Display.DivForm( { onFinish: function() { var container = $("container-popup"); container.update('Loading ...'); new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { container.update(transport.responseText); if ($('box-friend')) { addRecipeFriend(); } } }); } }).open(); } // fin de displayPopup function closePopup() { new Display.DivForm().close(); } function submitRecipeInvitation(share) { var data = { lastname:{ need:true, message: "You must fill your lastname" }, firstname:{ need:true, message: "You must fill your firstname" }, email:{ need:true, type:"email", message: "You must fill a valid email" }, id_grape:{ need:true, message: "You must specify the grape variety" }, date:{ need:true, message: "You must fill the date" }, location:{ need:true, message: "You must fill the location" } }; if (!share) { for (var i=1; i <= $('nb').value; i++) { data["friend_lastname" + i] = { need: true, message: "You must specify the lastname of your guest n°" + i }; data["friend_firstname" + i] = { need: true, message: "You must specify the firstname of your guest n°" + i }; data["friend_email" + i] = { need: true, message: "You must specify a valid email for your guest n°" + i }; } } var form = new Page.Form("form_starter_invitation"); var result = form.verif(data, { message: "Please verify the form" }); // on soumet si la verification de formulaire n'a pas échoué if (result) { if (!share) { startWait(); // soumission du formulaire en ajax $('form_starter_invitation').request({ onComplete: function(transport){ stopWait(); new Display.Message("Your message has been well sent", {cssClass: "form-info",speed:0.3}); closePopup(); } }); } else { shareRecipe(share); } } } function shareRecipe(type) { var share; var url = "http://www.vindefrance-cepages.org/idees-apero-recettes.php?id=" + $('id_grape').value; var msg = "I invite you: " + $('id_grape').options[$('id_grape').selectedIndex].text + " on " + $('date').value if ($('hour').value) { msg += " at " + $('hour').value + ":" + $('min').value; } if ($('location').value) { msg += ", " + $('location').value; } msg += " www.vindefrance.org"; msg = encodeURIComponent(msg); switch (type) { case "facebook": share = "http://www.facebook.com/sharer.php?u=" + url + "&t=" + msg; break; case "twitter": share = "http://twitter.com/home?status=" + msg + " > " + url; break; } window.open(share); } function addRecipeFriend() { $('nb').value = parseInt($('nb').value) + 1; var o = $('box-friend').innerHTML; o = o.replace(/\{i\}/g, $('nb').value); var div = document.createElement('div'); div.update(o); $('container-friend').appendChild(div); } /** * Declenchements lors d'actions qui demande du temps */ var w = null; function startWait() { w = new Display.Wait({cache:true, ajaxImg: 'img/ajax-loader.gif'}); } // fin de startWait function stopWait() { w.close(); } // fin de stopWait Event.observe(window, 'load', function() { // mise en cache de l'image de loading var img = new Element('img', { src: 'img/ajax-loader.gif' } ); img.hide(); $('conteneur').insert({bottom: img }); if ($('pro-content')) { $('pro-content').select('input[type="text"], textarea').each( function(el) { if (el.alt) { Event.observe(el, 'focus', fieldChange); Event.observe(el, 'blur', fieldChange); fieldInit(el); } } ); Event.observe('form-edit', 'submit', function(event) { $('pro-content').select('input[type="text"], textarea').each( function(el) { if (el.alt) { if (el.value == el.alt) el.value = ""; } } ); window.scrollTo(0,0); startWait(); } ); } }); function fieldChange(event) { fieldInit(this); } function fieldInit(el) { if (el.value == el.alt) { el.value = ""; el.style.color = null; } else if (el.value == "") { el.value = el.alt; el.style.color = "#ccc"; } }