function Editor_AjaxConnector(page, params, contentHandler, errorHandler) { var request = typeof(XMLHttpRequest) != "undefined" ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); var url = page + "?" + params.join("&"); request.open("GET", url, true); request.onreadystatechange = function() { if (request.readyState == 4) { var code = request.status; if (code != 200) { //errorHandler(code, page); //return; } // end if contentHandler(request.responseText); } // end if } // end function request.send(null); } // end function function editor_ajaxError(code, message) { alert("Probleme de communication avec le serveur : " + code + " - " + message); } // end function /* test le formulaire d'ajout ---------------------------------------------*/ function checkFormContact(_target, _lang, _contact){ var data = {lang:_lang, contact:_contact, type_contact: $(_target).hasClass('catalogue') ? 'catalogue' : 'normal'}; var check = true; // on vérifie tous les champs de texte $(_target).find("input").each(function(){ if($(this).attr("rel") == "check"){ if($(this).val() == "" || $(this).val() == $(this).attr("alt")) { check = false; } } // end if if($(this).attr("type") == 'text' && $(this).attr("id").toLowerCase().search('mail') > -1 && !isEmail(this)){ check = false; } // end if if($(this).attr("type") != "submit" && $(this).attr("type") != "button") data[$(this).attr("id")] = $(this).val() != $(this).attr("alt") ? $(this).val() : ""; }); // end each // on vérifie tous les textarea $(_target).find("textarea").each(function(){ if($(this).attr("rel") == "check"){ if($(this).val() == "") { check = false; } } // end if data[$(this).attr("id")] = $(this).val(); }); // each if(check){ $.ajax({ type: "POST", data: data, url: domain+"sys/php/sendContactMail.php", success: function(data){ console.log(data) if(data == "ok"){ if($(_target).data('type') == 'normal') { new AlertWindow("Votre e-mail a été envoyé. Merci de nous avoir contacté."); } else { new AlertWindow("Merci d'avoir rempli ce formulaire d'informations. Vous pouvez dès maintenant télécharger nos catalogues."); } $(_target).find("input").each(function(){ if($(this).attr("type") != "submit") $(this).val(""); }); $(_target).find("textarea").each(function(){ $(this).val(""); }); if($(_target).hasClass('catalogue')) { $.cookie('catalogue', 'ok', { path : '/' }); $('#catalogue-contact .form').stop().animate({'opacity': 0}, 500); $('#catalogue-contact').stop().animate({'opacity': 0}, 500, function() { $('#catalogue-contact').remove(); } ); } }else{ new AlertWindow("Votre e-mail n'a pas pu être envoyé. Nous vous prions de recommencer ultérieurement."); } // end if } // end success }); // end ajax }else{ new AlertWindow("Veuillez remplir tous les champs."); } // end if return false; } // end function checkFormContact /* Renseigne la valeur d'un champ du formulaire par sa valeur par défaut quand il perd le focus ou le vide quand il prend le focus s'il avait la valeur par défaut ---------------------------------------------*/ function setFieldValue(_target, _data){ if(_data == ""){ if($(_target).val() == $(_target).attr("alt")){ $(_target).val(""); $(_target).removeClass("field-inactive"); } // end if }else{ if($(_target).val() == ""){ $(_target).val($(_target).attr("alt")); $(_target).addClass("field-inactive"); } // end if } // end if } // end function setFieldValue /* vérifie la syntaxe de l'e-mail ---------------------------------------------*/ function isEmail(_target){ var verif = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); var value = true; if(verif.exec($(_target).val()) == null){ value = false; } //end if return value; } // end function isEmail /* change la lang ---------------------------------------------*/ function change_lang(lang) { document.cookie = 'lang=' + lang + '; expires=' + new Date() + '; path=/'; location.reload(); } /* ---------------------------------------------- Class Diaporama Créé Par Julien Cousseau pour Egami Creation Modifiée le 20 octobre 2014 Elle permet de zoomer les photos et de les passer en mode diaporama -----------------------------------------------*/ var Diaporama = function(_target, _galery){ var $current = $(_target).attr('src') !== undefined ? _target : $(_target).find('img').eq(0); var $this = this; var $mask; var $container; var $photo; var $title; var $galery = _galery; // objet HTML qui contient toutes les photos du diapo var $max_percent_size = 85; // taille maximale en pourcentage par rapport à la taille de la fenêtre /* création du masque noir et du container ----------------------------------------------*/ $this.init = function(){ // création du mask $mask = $('
'); $mask.click($this.close); $('body').append($mask); // création du container de la photo $container = $(''); $container.css("display", "none"); $container.css("opacity", 0); $('body').append($container); // création de l'objet img $photo = $('