// ==== Expressions régulieres ==== var modele = /^[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,5}$/i; var modeleMail = /^[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,5}$/i; var detect = navigator.userAgent.toLowerCase(); var ie=0; if (checkIt('msie')) ie=1; var galerieGlobal=""; var photosGalerie=new Array(); var urlorigine=""; var edito=""; // ==== Création de l'objet XmlHttp ==== function getNewXMLHTTP() { try { return window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { //window.location='../index.php'; } } function loadpage(url,lancer_fonction) { xmlload = getNewXMLHTTP(); xmlload.onreadystatechange = lancer_fonction; xmlload.open("GET", url, true); xmlload.send(null); return false; } // ==== Affichage de l'écran ==== function loadpanel() { try { if ((xmlload.readyState == 4)&&(xmlload.status == 200)) { ic = xmlload.responseText; removeJS = document.getElementById('dynJS'); if (removeJS) removeJS.parentNode.removeChild(removeJS); var BaliseScript=document.createElement('script'); BaliseScript.setAttribute('type','text/javascript'); BaliseScript.setAttribute('id','dynJS'); BaliseScript.text = trimScript(xmlload.responseText); document.body.appendChild(BaliseScript); } } catch (e) { } } // ==== Requête asynchrone simple ==== function valid(url,lancer_fonction) { xmlload = getNewXMLHTTP(); xmlload.onreadystatechange = lancer_fonction; xmlload.open("GET", url, true); xmlload.send(null); return false; } // ==== Identification après validation du formulaire ==== function senddatas(url,idform,lancer_fonction) { xmlhttp = getNewXMLHTTP(); xmlhttp.onreadystatechange = lancer_fonction; datas=formData2QueryString(idform); xmlhttp.open("POST", url, true); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); xmlhttp.setRequestHeader("Content-length", datas.length); xmlhttp.setRequestHeader("Cache-Control", "no-cache"); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(datas); return false; } // ==== Concaténation des données de formulaire en chaîne URL ==== function formData2QueryString(docForm) { var formElem; var strSubmit = ''; var strLastElemName = ''; for (i = 0; i < docForm.elements.length; i++) { formElem = docForm.elements[i]; switch (formElem.type) { case 'text': case 'textarea': case 'select-one': case 'hidden': case 'password': strSubmit += formElem.name + '=' + encodeURIComponent(trim(formElem.value)) + '&' break; case 'select-multiple': var selectBox = formElem; for (var j=0; j1) galerieGlobal= setInterval("changePhoto()",5000); } function changePhoto() { largeur= $(window).width(); hauteur= $(window).height(); calcul=hauteur*66/100; calcul2=calcul+8; $('.bloc_photo').eq(2).fadeTo('slow',0.3, function() { $('.bloc_photo').animate({"margin-left":"-="+calcul2+"px"}, 'slow', function() { $('.bloc_photo').eq(0).css({"margin-left":-(calcul2*5/2)}); $('.bloc_photo').eq(1).css({"margin-left":-(calcul2*3/2)}); $('.bloc_photo').eq(2).css({"margin-left":-(calcul2/2)}); $('.bloc_photo').eq(3).css({"margin-left":(calcul2/2)}); $('.bloc_photo').eq(4).css({"margin-left":(calcul2*3/2)}); }); $('.bloc_photo').eq(2).fadeTo('slow',1); lb= $('#barre').width(); ct= (lb*idPhoto)/maxPhoto; $('#track').animate({"margin-left":ct}, 'slow'); }); idx=idPhoto+3; if (idx>=maxPhoto) idx-=maxPhoto; $('.bloc_photo').first().remove(); $('#bloc_image').append('
'); $('.bloc_photo').eq(4).css({"width":calcul}); $('.bloc_photo').eq(4).css("background-image","url('"+photosGalerie[idx]+"')"); $('.bloc_photo').eq(4).fadeTo('10',.3); idPhoto++; if (idPhoto>=maxPhoto) idPhoto=0; if (typeof texteGalerie!="undefined") $('#pop_texte').html(texteGalerie[idPhoto]); urlshare= "http://alexandrevauthier.com/partage-"+edito+".html/"+urlorigine+"/"+photosGalerie[idPhoto].replace(/\//g,"--")+"/"; } function gotoPhoto() { clearInterval(galerieGlobal); galerieGlobal=""; $('.btpause').attr('src','img/flp2.png'); dec= $(window).width()/100; largeur= $("#barre").width(); posX-=dec; pourcent= parseInt(100*posX/largeur); newPhoto=parseInt(maxPhoto*pourcent/100); posTrack= (largeur+dec)*(newPhoto/maxPhoto); $('#track').animate({"margin-left":posTrack}, 'slow'); //$('#bloc_collection').html(newPhoto+'=parseInt('+pourcent+'/'+maxPhoto+');' ); if (idPhoto!=newPhoto) viewPhotoId(newPhoto); } changementEnCours=0; function viewPhotoId(newPhoto) { largeur= $(window).width(); hauteur= $(window).height(); calcul=hauteur*66/100; calcul2=calcul+8; dif=idPhoto-newPhoto; if (dif<0) dif=-dif; if (changementEnCours==0) { changementEnCours=1; $('.bloc_photo').eq(2).fadeTo('slow',0.3, function() { if (idPhoto>newPhoto) { /* on défile vers la gauche */ for(i=0;i'); } urlshare= "http://alexandrevauthier.com/partage-"+edito+".html/"+urlorigine+"/"+photosGalerie[newPhoto].replace(/\//g,"--")+"/"; $('.bloc_photo').animate({"margin-left":"+="+(calcul2*dif)+"px"}, 'slow', function() { changementEnCours=0; }); setTimeout("for(i=0;i=maxPhoto) idx-=maxPhoto; $('#bloc_image').append('
'); } urlshare= "http://alexandrevauthier.com/partage-"+edito+".html/"+urlorigine+"/"+photosGalerie[newPhoto].replace(/\//g,"--")+"/"; $('.bloc_photo').animate({"margin-left":"-="+(calcul2*dif)+"px"}, 'slow', function() { changementEnCours=0; }); setTimeout("for(i=0;i=maxPhoto) nextPhoto=0; viewPhotoId(nextPhoto); //gostop(); } function goprev() { clearInterval(galerieGlobal); galerieGlobal=""; $('.btpause').attr('src','img/flp2.png'); prevPhoto=idPhoto-1; if (prevPhoto<0) prevPhoto=maxPhoto-1; viewPhotoId(prevPhoto); //gostop(); } function changePhotoRev() { } function retract() { $('#bloc_header').animate({"top":"-74px",opacity:0}, 'slow'); $('#bloc_collection').animate({"left":"-300px",opacity:0}, 'slow'); $('#bloc_pop').animate({"bottom":"-74px"}, 'slow'); $('#bloc_footer').animate({"bottom":"-74px",opacity:0}, 'slow'); $('.mejs-controls').animate({"bottom":"-74px",opacity:0}, 'slow'); if (viewpop!=2) $('.bloc_pop').fadeOut("slow"); $('#bloc_presse').animate({"left":"-300px",opacity:0}, 'slow'); } function expand() { $('#bloc_header').animate({"top":"0",opacity:1}, 'slow'); $('#bloc_collection').animate({"left":"24px",opacity:1}, 'slow'); $('#bloc_pop').animate({"bottom":"14%",opacity:1}, 'slow'); $('#bloc_footer').animate({"bottom":"0",opacity:1}, 'slow'); $('.mejs-controls').animate({"bottom":"55px",opacity:1}, 'slow'); $('#bloc_presse').animate({"left":"24px",opacity:1}, 'slow'); if (viewpop==1) $('.bloc_pop').fadeIn("slow"); } KEY_DOWN = 40; KEY_UP = 38; KEY_LEFT = 37; KEY_RIGHT = 39; KEY_END = 35; KEY_BEGIN = 36; KEY_BACK_TAB = 8; KEY_TAB = 9; KEY_SH_TAB = 16; KEY_ENTER = 13; KEY_ESC = 27; KEY_SPACE = 32; KEY_DEL = 46; function applyKey (_event_){ // --- Retrieve event object from current web explorer var winObj = checkEventObj(_event_); var intKeyCode = winObj.keyCode; var intAltKey = winObj.altKey; var intCtrlKey = winObj.ctrlKey; // 1° --- Access with [ALT/CTRL+Key] if (intAltKey || intCtrlKey) { /*if ( intKeyCode == KEY_RIGHT || intKeyCode == KEY_LEFT ){ // --- Display Message //alert("Hello with ALT/CTRL !"); // 3° --- Map the keyCode in another keyCode not used winObj.keyCode = intKeyCode = REMAP_KEY_T; winObj.returnValue = false; return false; }*/ } // 2 ° --- Access without [ALT/CTRL+Key] else { if ( intKeyCode == KEY_RIGHT || intKeyCode == KEY_LEFT ){ /*// --- Display Message alert("Hello !"); // 3° --- Map the keyCode in another keyCode not used winObj.keyCode = intKeyCode = REMAP_KEY_T; winObj.returnValue = false; return false;*/ } if ( intKeyCode == KEY_LEFT ){ goprev(); } if ( intKeyCode == KEY_RIGHT ){ gonext(); } } } function checkEventObj ( _event_ ){ // --- IE explorer if ( window.event ) return window.event; // --- Netscape and other explorers else return _event_; } document.onkeydown = applyKey; var timer; var down = true; function showpv(num) { $('.photovideo').hide(); $('#photovideo_'+num).show(); } function hidepv() { $('.photovideo').hide(); } var menuchange=0; function deploie(elm) { if ((menuvisible!=elm)&&(menuchange==0)){ menuchange=1; $("#bloc_menu ul ul").slideUp('slow'); $('#smenu'+elm).slideDown('slow',function() { menuchange=0; }); menuvisible=elm; } } function zoomprod() { $('#fondproduit').css({"background":"#efeeec url('/media/media/produits/chemise-fullscreen.jpg') no-repeat center center","backgroundSize":"auto 100%"}); $('#fondproduit').fadeIn(0); tofs(); } function hidezoomprod() { $('#fondproduit').fadeOut(0); fromfs(); } function affiche_panier(num,qte) { valid('commander.php?id_produit='+num+'&quantite='+qte+'&code=',gotoPanier); } function reload_panier() { if ((xmlload.readyState == 4) && (xmlload.status == 200)) { valid('panier.php?popin=1',recharge_panier); } } function charge_panier() { if ((xmlload.readyState == 4) && (xmlload.status == 200)) { reponse=xmlload.responseText.toString(); //document.getElementById("contenu_popin").innerHTML=reponse; //affiche_popin(); } } function recharge_panier() { if ((xmlload.readyState == 4) && (xmlload.status == 200)) { /*reponse=xmlload.responseText.toString(); $("#contenu_popin").fadeOut('slow',function() { document.getElementById("contenu_popin").innerHTML=reponse; $('#contenu_popin').fadeIn('slow'); setTimeout("$('#bloc_listepanier').jScrollPane();",10); } ); */ } } function produit_panier(htmlrep) { document.getElementById("contenu_popin").innerHTML="
"+htmlrep+"
"; if (document.getElementById('popin').style.display!="block") { document.getElementById("popin").style.backgroundImage=""; document.getElementById('popin').style.height="1px"; document.getElementById('popin').style.marginTop="1px"; document.getElementById('popin').style.display="block"; $("#popin").animate({ height: "+=685px", marginTop: "-=350px", opacity: 1 }, 'slow',function() {} ); $('#voile').fadeTo('slow',0.25); setTimeout("$('#bloc_listepanier').jScrollPane();",50); } } function affiche_popin() { if (document.getElementById('popin').style.display!="block") { document.getElementById("popin").style.backgroundImage=""; document.getElementById('popin').style.height="1px"; document.getElementById('popin').style.marginTop="1px"; document.getElementById('popin').style.display="block"; $("#popin").animate({ height: "+=445px", marginTop: "-=230px", opacity: 1 }, 'slow',function() {} ); $('#voile').fadeTo('slow',0.25); setTimeout("$('#bloc_listepanier').jScrollPane();",50); } } function close_popin() { document.getElementById("contenu_popin").innerHTML=""; h=$("#popin").height(); m=h/2; $("#popin").animate({ height: "-="+h+"px", marginTop: "+="+m+"px", opacity: 1 }, 'slow',function() { document.getElementById('popin').style.display="none"; } ); $('#voile').fadeTo('slow',0,function() { document.getElementById("voile").style.display="none"; }); } function pinbookmarks() { var e=document.createElement('script'); e.setAttribute('type','text/javascript'); e.setAttribute('charset','UTF-8'); e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r=' + Math.random()*99999999); document.body.appendChild(e); } var modefull=0; function tofs() { if (modefull==0) { modefull=1; var docElm = document.documentElement; if (docElm.requestFullscreen) { docElm.requestFullscreen(); } else if (docElm.mozRequestFullScreen) { docElm.mozRequestFullScreen(); } else if (docElm.webkitRequestFullScreen) { docElm.webkitRequestFullScreen(); } } else { modefull=0; if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } } setTimeout("readapt();",500); } vtxt=0; function toggleTxt() { if (vtxt==0) { hauteur= $(window).height(); $('#detail_produit').animate({"height":hauteur-385}, 'slow', function() { $('#detail_produit').jScrollPane();vtxt=1; } ); document.getElementById("scrtxt").src="img/moins2.png"; } else { $('#detail_produit').animate({"height":"135px"}, 'slow', function() { $('#detail_produit').jScrollPane();vtxt=0; } ); document.getElementById("scrtxt").src="img/plus2.png"; } } function informeDelai(num) { valid('loadpage.php?id_page='+num,result_informeDelai); } function result_informeDelai() { if ((xmlload.readyState == 4) && (xmlload.status == 200)) { formDelai=xmlload.responseText.toString(); $('#contenu_popin').css('background','#fff'); $('#contenu_popin').html(formDelai); reg=new RegExp("<.[^>]*>", "gi" ); truc =$('#titre_produit').html()+$('#caract_produit').html(); $('#produit').val(strip_tags(truc.replace(/(\t| )/g,'').replace(/()/g,''))); affiche_popin(); } } function showcgv(num) { valid('loadpage.php?id_page='+num,result_showcgv); } function result_showcgv() { if ((xmlload.readyState == 4) && (xmlload.status == 200)) { pageCgv=xmlload.responseText.toString(); $('#contenu_popin').css({'background':'#000',"height":"445px"}); $('#contenu_popin').html(pageCgv); affiche_popin(); $('#popin').css({'background':'#000',"border":"1px solid #fff"}); setTimeout("$('#contenu_popin').jScrollPane();",450); } } // ==== Retire les espaces en début et fin de chaine ==== function trim(chaine) { return chaine.replace(/(^\s*)|(\s*$)/g,''); } function gotoPanier() { if ((xmlload.readyState == 4)&&(xmlload.status == 200)) { window.location.href="page-mon-panier.html"; } } function gotoCommande() { if ((xmlload.readyState == 4)&&(xmlload.status == 200)) { window.location.href="page-mes-commandes.html"; } } function gotoWish() { if ((xmlload.readyState == 4)&&(xmlload.status == 200)) { var rg=/devez/g; rep=xmlload.responseText.toString(); if (rg.test(rep)) { alert(xmlload.responseText); window.location.href="page-mon-compte.html"; } else window.location.href="page-ma-wishlist.html"; } } function gotoCompte() { var rg=/succ/g; var rg2=/Déconnexion/g; if ((xmlhttp.readyState == 4)&&(xmlhttp.status == 200)) { document.getElementById('msg').style.display="none"; rep=xmlhttp.responseText.toString(); if (rg.test(rep)||rg2.test(rep)) window.location.reload(); else { document.getElementById('msg').style.display="block"; document.getElementById('msg').innerHTML=xmlhttp.responseText; } } } function recup_pass() { if ((xmlhttp.readyState == 4)&&(xmlhttp.status == 200)) { document.getElementById('msg').style.display="block"; document.getElementById('msg').innerHTML=xmlhttp.responseText; } } function supprim(num) { valid("supprimer.php?id_produit="+num,gotoPanier); } function supprim2(num) { valid("supprimer.php?id_produit="+num,gotoCommande); } function supprimwish(num) { valid("supprimer.php?wish=1&id_produit="+num,gotoWishList); } function gotoWishList() { if ((xmlload.readyState == 4)&&(xmlload.status == 200)) { window.location.href="page-ma-wishlist.html"; } } function changeetat(elm,coche) { if (document.getElementById(elm).value=="OUI") { document.getElementById(elm).value="NON"; coche.src="img/selectnon.png"; } else { document.getElementById(elm).value="OUI"; coche.src="img/selectoui.png"; } } function switchetat(elm,coche1,coche2,val) { if (document.getElementById(elm).value==val) return false; if (document.getElementById(elm).value=="OUI") { document.getElementById(elm).value="NON"; document.getElementById(coche1).src="img/selectnon.png"; document.getElementById(coche2).src="img/selectoui.png"; } else { document.getElementById(elm).value="OUI"; document.getElementById(coche1).src="img/selectoui.png"; document.getElementById(coche2).src="img/selectnon.png"; } } function copieinfos() { document.getElementById("l_id_civilite").value= document.getElementById("f_id_civilite").value; document.getElementById("l_nom").value= document.getElementById("f_nom").value; document.getElementById("l_prenom").value= document.getElementById("f_prenom").value; document.getElementById("l_adresse1").value= document.getElementById("f_adresse1").value; document.getElementById("l_adresse2").value= document.getElementById("f_adresse2").value; document.getElementById("l_code_postal").value= document.getElementById("f_code_postal").value; document.getElementById("l_ville").value= document.getElementById("f_ville").value; document.getElementById("l_id_pays").value= document.getElementById("f_id_pays").value; document.getElementById("l_telephone").value= document.getElementById("f_telephone").value; document.getElementById("l_portable").value= document.getElementById("f_portable").value; } function modifie(num,pas) { valid("modifier.php?id_produit="+num+"&pas="+pas,gotoPanier); } function modifiePopin(num,pas) { valid("modifier.php?id_produit="+num+"&pas="+pas,reload_panier); } function rien() { } function re(elm) { idElm= document.getElementById(elm); idElm.style.display="none"; while(idElm.hasChildNodes()==true){ var enfant=idElm.firstChild; idElm.removeChild(enfant); } var parent= idElm.parentNode; parent.removeChild(idElm); } function sdphoto() { document.sendphoto.submit(); document.getElementById('btload').style.display="none"; document.getElementById('btloader').style.display="block"; } function retry_photo() { document.getElementById('btloader').style.display="none"; document.getElementById('btload').style.display="block"; document.getElementById('_loadimage').src="blank.html"; } function majPhoto(num,chemin) { document.annonce.id_photo.value=num; document.getElementById('prev_photo').src= chemin; document.getElementById('consignPhoto').innerHTML="Cliquez ici pour modifier la photo."; } function setModeCreate() { $('#liste_boutons1').slideUp('slow'); $('#part_confirm').show('slow'); $('#bloc_create').html($('#bloc_ident')); $('#part_simple').hide(0).html(); $('#part_left').css({"width":"0.5%"}); $('#liste_boutons3').hide('slow'); $('#part_detail').show('slow'); $('#msg').css({'display':'none'}).html(''); document.compte.mode.value='creation'; } function checkDetail() { return true; } function validInfos(lang) { if (document.compte.cgv.value=="oui") return true; if (lang=="fr") alert("Veuillez accepter les conditions générales de vente pour passer votre commande."); if (lang=="en") alert("PLease accept the terms and conditions to pass your order."); if (lang=="it") alert("Accetto le condizioni generali di vendita."); return false; } function aboverif(lang) { if (document.bilan.nom.value.length<=2) { if (lang=="fr") alert('Veuillez indiquer votre nom.'); if (lang=="en") alert('Please enter your last name.'); if (lang=="it") alert('Inserisci il tuo nome.'); return false; } if (document.bilan.email.value.length<=2) { if (lang=="fr") alert('Veuillez indiquer votre email.'); if (lang=="en") alert('Please enter your email.'); if (lang=="it") alert('Inserisci il tuo email.'); return false; } if (modeleMail.test(document.bilan.email.value)===false) { if (lang=="fr") alert('Veuillez indiquer un email valide.'); if (lang=="en") alert('Please enter a valid email.'); if (lang=="it") alert('Inserisci il tuo email.'); return false; } if (document.bilan.prenom.value.length<=2) { if (lang=="fr") alert('Veuillez indiquer votre prénom.'); if (lang=="en") alert('Please enter your first name.'); if (lang=="it") alert('Inserisci il tuo nome.');return false; } document.bilan.submit(); } function desaboverif(lang) { if (document.bilan.email.value.length<=2) { if (lang=="fr") alert('Veuillez indiquer votre email.'); if (lang=="en") alert('Please enter your email.'); if (lang=="it") alert('Inserisci il tuo email.'); return false; } if (modeleMail.test(document.bilan.email.value)===false) { if (lang=="fr") alert('Veuillez indiquer un email valide.'); if (lang=="en") alert('Please enter a valid email.'); if (lang=="it") alert('Inserisci il tuo email.'); return false; } document.bilan.submit(); } function contactverif(lang) { if (document.bilan.email.value.length<=2) { if (lang=="fr") alert('Veuillez indiquer votre email.'); if (lang=="en") alert('Please enter your email.'); if (lang=="it") alert('Inserisci il tuo email.');return false; } if (modeleMail.test(document.bilan.email.value)===false) { if (lang=="fr") alert('Veuillez indiquer un email valide.'); if (lang=="en") alert('Please enter a valid email.'); if (lang=="it") alert('Inserisci il tuo email.');return false; } document.bilan.submit(); } function strip_tags(html) { //PROCESS STRING if(arguments.length < 3) { html=html.replace(/<\/?(?!\!)[^>]*>/gi, ''); } else { var allowed = arguments[1]; var specified = eval("["+arguments[2]+"]" ); if(allowed){ var regex=']*>'; html=html.replace(new RegExp(regex, 'gi'), ''); } else{ var regex=']*>'; html=html.replace(new RegExp(regex, 'gi'), ''); } } var clean_string = html; //RETURN THE CLEAN STRING return clean_string; } function checkForm(formulaire) { nb_elements = formulaire.elements.length; for( i=0 ; i1)&&(point>1)&&(test<6)&&(test>2)) { form.submit(); } else { if (lang=="fr") alert("Merci de bien vouloir saisir un email valide.\nSans espaces."); if (lang=="en") alert("Merci de bien vouloir saisir un email valide.\nSans espaces."); if (lang=="it") alert("grazie per volere cortesemente completare i campi: nome, nome, smalto .\nSenza spazi.."); } } else { if (lang=="fr") alert("Merci de bien vouloir compléter les champs : nom, prénom, email"); if (lang=="en") alert("Merci de bien vouloir compléter les champs : nom, prénom, email"); if (lang=="it") alert("grazie per volere cortesemente completare i campi: nome, nome, smalto "); } } else { if (lang=="fr") alert("Merci de bien vouloir compléter les champs : nom, prénom, email"); if (lang=="en") alert("Merci de bien vouloir compléter les champs : nom, prénom, email"); if (lang=="it") alert("grazie per volere cortesemente completare i campi: nome, nome, smalto "); } } function openmail(adr) { window.open('mailto:'+adr+'@alexandrevauthier.com?subject=Contact%20Alexandre%20Vauthier','_up'); } function testmailonly(lang) { form=document.forms["bilan"]; mail = form.email.value; arobase = mail.indexOf("@"); espace = mail.indexOf(" "); espace2 = mail.indexOf("'"); doublarob = mail.indexOf("@",arobase+1); right = mail.substring(arobase + 1,mail.length); point = right.lastIndexOf("."); test = right.length-point; if ((espace==-1)&&(espace2==-1)&&(doublarob==-1)&&(arobase>1)&&(point>1)&&(test<6)&&(test>2)) { form.submit(); } else { if (lang=="fr") alert("Merci de bien vouloir saisir un email valide.\nSans espaces."); if (lang=="en") alert("Merci de bien vouloir saisir un email valide.\nSans espaces."); if (lang=="it") alert("Grazie per volere cortesemente afferrare un smalto valido.\nSenza spazi."); } } function isMailValide(emailStr) { return 1; } function sendmail(nom,num) { if (num==1) dmn="alexandrevauthier.com"; else dmn="stationservice.fr"; window.open("mailto:"+nom+"@"+dmn,"_self"); } /* var geocoder; var map; function displayMap(lat,lng,txt) { document.getElementById('contentMap').style.display="block"; var latlng = new google.maps.LatLng(lat, lng); var myOptions = { zoom: 16, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var marker = new google.maps.Marker({ position: new google.maps.LatLng(lat,lng), map: map, title:txt }); } function codeAddress(address) { document.getElementById('contentMap').style.display="block"; var latlng = new google.maps.LatLng(46.75984, 1.738281); var myOptions = { zoom: 12, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); map.setZoom(16); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else { alert("Geocode was not successful for the following reason: " + status); } }); } function closeMap() { document.getElementById('contentMap').style.display="none"; } */ /**********************************************************/ /* GOOGLE MAPS*/ /**********************************************************/ var map; var MyMarker; var MyMarkerCircle; var marker; var AddressePos; var PhonePos; var rendererOptions; var markerArray; var directionDisplay; var directionsService; var mypos; var ZoomRatio = 17; var stepDisplay; var markerArray = []; var FollowMode = false; var GeoOn = false; var DrawRoad = false; var alertCounter = 0; var imagemobile= 'img/device.png'; var imageadresse= 'img/target.png'; var imagewarning= 'img/warning.png'; /* DRAW GEOLOC MARKER*/ function drawMyMarkerAndCircle() { MyMarker = new google.maps.Marker( { position: PhonePos, map: map, icon: imagemobile, zIndex:9999 }); MyMarkerCircle = new google.maps.Circle( { center: PhonePos, radius:400, strokeColor: "#FF0000", strokeOpacity: 0.2, strokeWeight: 1, fillColor: "#FF0000", fillOpacity: 0.2 }); MyMarkerCircle.setMap(map); } /***************************************/ /* GEOLOC FUNCTIONS*/ /***************************************/ /* Draw Mobile devices position at initialisation*/ function LocationOKINIT(position) { GeoOn = true; alertCounter = 0; var latitude = position.coords.latitude; var longitude = position.coords.longitude; PhonePos = new google.maps.LatLng(latitude, longitude) drawMyMarkerAndCircle(); if(DrawRoad == false) { center_map('phonepos'); }else{ FollowMode = false; makeRoute(); } } /* Draw Mobile devices position on mouvement */ function LocationOK(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; PhonePos = new google.maps.LatLng(latitude, longitude); MyMarker.setMap(null); MyMarkerCircle.setMap(null); drawMyMarkerAndCircle() if(FollowMode == true ){ map.setCenter(MyMarker.position);} } /* NO GEOLOC */ function LocationKO() { if(alertCounter == 0) { alertCounter = 1; GeoOn = false; alert('la géolocalisation ne fonctionne plus'); } } function geoLocaliseMoi() { if(GeoOn == false) { navigator.geolocation.getCurrentPosition(LocationOKINIT, LocationKO); navigator.geolocation.watchPosition(LocationOK, LocationKO); }else{ center_map('phonepos'); } } /***************************************/ /* DRAW ROUTES FUNCTIONS*/ /***************************************/ /* Draw direction routes*/ function makeRoute(){ for (i = 0; i < markerArray.length; i++) { markerArray[i].setMap(null); } var request = { origin: PhonePos, destination:marker.position , travelMode: google.maps.DirectionsTravelMode.DRIVING, unitSystem: google.maps.DirectionsUnitSystem.METRIC }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); showSteps(response); }else{ } }); } /* Draw direction marker*/ function showSteps(directionResult) { var myRoute = directionResult.routes[0].legs[0]; for (var i = 0; i < myRoute.steps.length; i++) { var marker = new google.maps.Marker({ position: myRoute.steps[i].start_point, map: map, icon: imagewarning }); attachInstructionText(marker, myRoute.steps[i].instructions); markerArray[i] = marker; } } /* show instruction windows*/ function attachInstructionText(marker, text) { google.maps.event.addListener(marker, 'click', function() { stepDisplay.setContent(text); stepDisplay.open(map, marker); }); } /***************************************/ /* INIT MAP*/ /***************************************/ /*if($("#map_canvas").attr("id")) { initialize(); }*/ function initialize() { var MonAddresse = "Adresse"; var MonAddresseLatlng = new google.maps.LatLng(48.850612,2.325331); var mode = "coord"; if(mode == "adresse") { var param = { 'address': MonAddresse}; }else if(mode == "coord"){ var param = { 'location': MonAddresseLatlng}; } var myLatlng; directionsService = new google.maps.DirectionsService(); geocoder = new google.maps.Geocoder(); geocoder.geocode( param , function(results, status){ if (status == google.maps.GeocoderStatus.OK) { myLatlng = results[0].geometry.location; AddressePos = results[0]; var myOptions = { zoom: ZoomRatio, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); rendererOptions = {map: map}; directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions); marker = new google.maps.Marker({position: myLatlng,map: map,icon: imageadresse,zIndex:9998}); } }); stepDisplay = new google.maps.InfoWindow(); } function center_map(markername) { var bounds; if(markername == "phonepos") { FollowMode = true; map.setCenter(MyMarker.position); }else if(markername == "addresse"){ FollowMode = false; map.setCenter(marker.position); } map.setOptions({zoom: ZoomRatio}); } function bigSwitch($mode) { switch ($mode) { case "addresse": center_map($mode); break; case "phonepos": geoLocaliseMoi(); break; case "road": if(GeoOn == true){ makeRoute(); }else{ DrawRoad = true; geoLocaliseMoi(); } break; } } function selectmode($monselect) { bigSwitch($monselect.options[$monselect.selectedIndex].value); }