var timestamp=new Date().getTime(),delta=0,_Roads,gl_markers=[],_LastSearch,directions;$.postJSONRPC=function(d,e,c){delta++;var b=timestamp+delta,f={jsonrpc:"2.0",id:b},a=c||{};$.extend(d,f);$.ajax({data:$.toJSON(d),dataType:"json",processData:false,success:function(g){if(g.result&&parseInt(g.id,10)===b){e(g.result,a)}},type:"POST",url:"/webservices/index/jsonrpc"})};function Roads(b){var a=this;this.lst=[];this.last=0;this.getName=function(d){var c=this.getRoad(d);return c.name};this.getRetRoad=function(e){var d=e||this.last,c=this.getRoad(d);return this.getRoad(c.idRetour)};this.getRoad=function(d){var c=$.grep(this.lst,function(e){return d===e.id});return(1===c.length)?c[0]:""};this.getRoads=function(){return this.lst};this.setLastSearchId=function(c){this.last=c};$.postJSONRPC({method:"getRoadsLstJsonCompliant",params:{obj:"Road"}},function(c){if(c.road){a.lst=c.road;b()}})}function LastSearch(){this.id=0;this.ville="";this.zipcode=0;this.lng=0;this.lat=0;this.clear=function(){this.id=0;this.ville="";this.zipcode=0;this.lng=0;this.lat=0;return this};this.getId=function(){return this.id};this.setId=function(a){this.id=a;return this};this.getVille=function(){return this.ville};this.setVille=function(a){this.ville=a;return this};this.getZipcode=function(){return this.zipcode};this.setZipcode=function(a){this.zipcode=a;return this};this.getLng=function(){return this.lng};this.setLng=function(a){this.lng=a;return this};this.getLat=function(){return this.lat};this.setLat=function(a){this.lat=a;return this}}_LastSearch=new LastSearch();function getDeps(b){var a='<a href="#" class="btnOk" onclick="return (depFromStartPage());"><img alt="ok" src="/images/btn/btnOk.gif"></a><select id="depSearch" class="inputSearch">';$("#critBoxDepCont").empty().html(a);$.postJSONRPC({method:"getDepLstJsonCompliant",params:{obj:"Department"}},b)}function getPumpsByDep(b,a){$.postJSONRPC({method:"getbydep",params:{obj:"Pump",id:b,format:"json"}},a);$("#block"+b).one("click",{id:b},function(c){clearBox(c.data.id,getPumpsByDep);$("#depTabImg"+c.data.id).attr("src","/css/tableStyle/blue/line.gif")});$("#depTabImg"+b).attr("src","/css/tableStyle/blue/asc.gif")}function getPumpsByRoad(b,a){$.postJSONRPC({method:"getbyroad",params:{obj:"Pump",id:b,format:"json"}},a,{block:$("#implantationContent"),pk:true,road:true})}function getPumpsById(b,a){$.postJSONRPC({method:"getbyidville",params:{obj:"Pump",id:b,format:"json"}},function(d){var e=$("#searchVilleCrit"),f=(undefined!==d.dist)?parseInt(d.dist,10):0,c=(0===f)?false:true;if(c){$('<div id="searchDistInfo"></div>').attr("style","float: right; font-style: italic; font-size: 9px; color: #777777;").html("Liste des pompes &agrave; proximit&eacute;&nbsp;"+((0<f)?"("+f+"km)":"directe")).appendTo("#block"+d.id);$("#searchTitle").html('Les stations les plus proches de <span class="green">'+_LastSearch.getVille()+"</span> sont : ")}else{$("#searchTitle").html('Résultat de votre recherche sur <span class="green">'+_LastSearch.getVille()+"</span>")}a(d);putOnMap(d)})}function getMap(mapCallback){$.postJSONRPC({method:"get",params:{obj:"Map"}},function(response){$("#canvas").html(response.html);eval(response.js);if(null!==mapCallback&&undefined!==mapCallback.fn&&"function"===typeof mapCallback.fn){mapCallback.fn(mapCallback.opts,response)}})}function getRoads(e,a,f){var c=[],d=a||"#critBoxRoadCont",b=(false===f)?false:true;if(1===$(a).length){if(b){c.push('<a href="#" class="btnOk" onclick="roadFromStartPage();return false;">','<img alt="ok" src="/images/btn/btnOk.gif"></a>')}c.push('<select id="roadSearch" class="inputSearch"></select>');$(d).append(c.join(""));generateRoadsSelect()}}function generateRow(f,d,b,e,a){if(!a){a="D3FB81"}var c=createBlock(f,d);$(c).attr("style","background-color: #"+a+";");$("#"+e).append(c);$("#"+e+" #block"+f).one("click",{id:f},function(g){b(g.data.id,generatePumpTable)});$("#"+e+" #blockCont"+f).hide()}function createBlock(e,c){var b=$("<div></div>").attr("id","blockMain"+e),d,a;d=$("<div></div>").attr("id","block"+e).attr("class","depLst").html('<img id="depTabImg'+e+'" src="/css/tableStyle/blue/line.gif">'+c).appendTo(b);a=$("<div></div>").attr("id","blockCont"+e).attr("class","blockCont").appendTo(b);return b}function generateDepsSelect(a){if(a.department){var b='<a href="#" class="btnOk" onclick="return (depFromStartPage());"><img alt="ok" src="/images/btn/btnOk.gif"></a><select id="depSearch" class="inputSearch">',c;$(a.department).each(function(d,e){c="{'id': '"+e.id+"',";c+="'code': '"+e.code+"',";c+="'name': '"+e.name+"'}";b+='<option value="'+c+'">'+e.code+" -"+e.name+"</option>"});b+="</select>";return b}}function handleDepsList(b){if(b.department){var a="",c;$(b.department).each(function(d,e){color=(d%2===0?"FFFFFF":"D3FB81");generateRow(e.id,e.code+" - "+e.name,getPumpsByDep,"implantationContentPerm",color);c="{'id': '"+e.id+"',";c+="'code': '"+e.code+"',";c+="'name': '"+e.name+"'}";a+='<option value="'+c+'">'+e.code+" -"+e.name+"</option>"});$("#critBoxDepCont select").empty().html(a);$("#implantationContentPerm").attr("style","border: 1px solid #D3FB81;")}}function generateRoadsSelect(){var a=_Roads.getRoads(),b=[];b.push('<option value="error">Sélectionner un axe routier</option>');if(0<$(a).length){$(a).each(function(d,c){b.push('<option value="',c.id,'">',c.name,"</option>")});$("#roadSearch").empty().html(b.join(""))}}function getPumpsFromDep(param){if(0===param){var val=document.getElementById("depSearch").value,data=eval("("+val+")")}else{data=param}if(undefined!==data.swfCall&&true===data.swfCall){$("#swfmapcontainer").slideUp("slow",function(){$("#showswfmapbutton").show()})}$("#implantationSearchContent").empty();$("#implantationContent").empty();generateRow(data.id,data.code+" - "+data.name,getPumpsByDep,"implantationContent");document.getElementById("implantationContent").setAttribute("style","border: 1px solid #D3FB81;");$("#implantationContent #block"+data.id).trigger("click");$("#searchTitle").html('Résultat de votre recherche sur <span class="green">'+data.name+"</span>")}function getPumpsFromRoad(b){var a=(0===b)?$("#roadSearch").val():b;_Roads.setLastSearchId(a);$("#implantationContent").empty();getPumpsByRoad(a,generatePumpTable);if(undefined===_Roads.getName(a)){$("#searchTitle").html("Aucun axe routier n'a été sélectionné.</span>")}else{$("#searchTitle").html('Résultat de votre recherche sur <span class="green">'+_Roads.getName(a)+"</span>")}}function getPumpsFromRetRoad(){var a=_Roads.getRetRoad();$("#roadSearch").val(a.id);getPumpsFromRoad(a.id)}function PumpFilterItem(){this.name=null;this.picture=null}function PumpFilter(){this.id=null;this.columns=null;this.reversedColumns={};this.items={};this.filterStates={};this.getAllFilterStates=function(){return this.filterStates};this.getFilterStates=function(a){if(this.filterStates[a]!==null){return this.filterStates[a]}else{return new Array()}};this.setFilterStates=function(a,b){this.filterStates[a]=b};this.setId=function(a){this.id=a};this.getId=function(){return this.id};this.setColumns=function(a){this.columns=a;for(column in a){this.filterStates[column]={};this.reversedColumns[a[column]]=column}};this.getColumns=function(){return this.columns};this.addItem=function(a,b){if(this.items[a]==undefined){this.items[a]={}}if(this.items[a][b.id]==undefined){this.items[a][b.id]=b}};this.getItems=function(a){return this.items[a]};this.getColumnByName=function(a){return this.reversedColumns[a]};this.getColumnNameById=function(a){return this.columns[a]}}var PumpFilterManager={PumpFilters:{},addPumFilter:function(a){PumpFilterManager.PumpFilters[a.getId()]=a},getPumpFilter:function(a){return PumpFilterManager.PumpFilters[a]}};function generatePumpTable(f,j,d){if(f.id){var i,n=[],b=j||{},e=b.block||$("#blockCont"+f.id),k,l="",g="",h="",a={appender:appendToSortedTable,headers:{0:{sorter:false}}},c=6;k={pk:(true===b.pk)?true:false,road:(true===b.road)?true:false,del:(true===b.myselection)?true:false,km:((undefined!==f.dist)&&(0<f.dist))?true:false};if(f.pump&&0<$(f.pump).length){var m=new PumpFilter();m.setId(f.id);if(k.pk){l='<th class="pk">PK</th>';c++;$.extend(a.headers,{1:{sorter:"pks"},2:{sorter:false},3:{sorter:false},5:{sorter:false},7:{sorter:"currency"}});m.setColumns({0:"type",2:"enseigne",5:"open"})}else{if(k.km){c++;$.extend(a.headers,{1:{sorter:"digit"},2:{sorter:false},3:{sorter:false},4:{sorter:false},6:{sorter:"currency"}});a.sortList=[[1,0]];cityLatLng=new GLatLng(_LastSearch.getLat(),_LastSearch.getLng());g='<th class="road">Distance</th>';m.setColumns({0:"type",2:"enseigne",4:"open"})}else{$.extend(a.headers,{1:{sorter:false},2:{sorter:false},3:{sorter:false},5:{sorter:"currency"}});m.setColumns({0:"type",1:"enseigne",3:"open"})}}if(k.road){c++;h='<th class="road">Sens</th>';$.extend(a.headers,{4:{sorter:false}})}PumpFilterManager.addPumFilter(m);n.push('<table border="0" cellspacing="0" cellpadding="0" class="tablesorter" id="pumpList',f.id,'">');n.push("<thead>");n.push("<tr>");n.push('<th class="type"><span class="btnFilter"></span>Type</th>',l,g,'<th class="enseigne"><span class="btnFilter"></span>Enseigne</th>','<th class="address">Coordonnées</th>',h,'<th class="open"><span class="btnFilter"></span>Ouverture</th>','<th class="dispo">Disponibilité</th>','<th class="price">Prix/L</th>');n.push("</tr>");n.push("</thead><tbody>");$(f.pump).each(function(p,s){m.addItem(0,s.type);if(k.pk){m.addItem(2,s.enseigne);m.addItem(5,s.opening)}else{if(k.km){m.addItem(2,s.enseigne);m.addItem(4,s.opening)}else{m.addItem(1,s.enseigne);m.addItem(3,s.opening)}}var t=[];t.push("filter_type_"+s.type.id);t.push("filter_enseigne_"+s.enseigne.id);t.push("filter_open_"+s.opening.id);t.push((p%2===0)?"even":"odd","visible","filter");n.push('<tr class="',t.join(" "),'">');n.push('<td colspan="',c,'" class="container"><table border="0" cellspacing="0" cellpadding="0">','<tbody><tr class="cells">');n.push('<td class="type"><img src="',s.type.picture,'"><div>',s.type.name,"</div></td>");if(k.pk){var r="",q="";if(isNaN(s.pk)){r="";q=""}else{if(undefined===s.pk){r="";q=""}else{r="km "+s.pk}}n.push('<td class="pk">',r,"</td>")}if(k.km){var u=cityLatLng.distanceFrom(new GLatLng(s.lat,s.lng));n.push('<td class="pk">'+Math.round(u/1000)+" km</td>")}n.push('<td class="enseigne"><img src="',s.enseigne.picture,'" /></td>');n.push('<td class="address">');n.push('<div class="address">',s.address,"<br />");n.push(s.zipcode," ",s.city,"</div>");n.push("<div>Lat: ",s.lat,"</div><div>Lon: ",s.lng,"</div>");n.push('<div>Tel: <span class="tel">',s.phone,"</span></div>");n.push("</td>");if(k.road){n.push('<td class="road">',("string"===typeof s.road)?s.road:"","</td>")}n.push('<td class="open">',s.opening.name,"</td>");n.push('<td class="dispo"><img src="',s.state.picture,'"></td>');n.push('<td class="price"><div class="priceMain">',s.price,"&nbsp;&euro;</div>",'<div class="priceUpdate">Mis à jour le ',s.update,"</div></td>");n.push("</tr>");if(undefined===d){var o=5}else{var o=d}n.push('<tr class="bt-liste"><td colspan="'+o+'">');n.push('<a href="#" onclick="popupEditPump(',s.id,');return false;">','<img src="/images/btn/btnModif.gif" alt="Modifier les informations" /></a>');n.push('<a href="#" onclick="popupSendByEmail(',s.id,');return false;">','<img src="/images/btn/btnSendMail.gif" alt="Envoyer par mail" /></a>');n.push('<a href="#" onclick="popupSendBySms(',s.id,');return false;">','<img src="/images/btn/btnSendSms.gif" alt="Envoyer par SMS" /></a>');n.push('<a href="#" onclick="popupDirections(',s.id,');return false;">','<img src="/images/btn/btnPlan.gif" alt="Plan d\'accès" /></a></td><td style="text-align: right;">');n.push(("1"===s.selected)?getRowDelFromSelection(s.id,k.del):getRowAddToSelection(s.id));n.push("</td></tr>");n.push("</tbody></table></td></tr>")});n.push("</tbody></table>");i=n.join("")}else{i=$("<div></div>").attr("style","padding:10px;").html("Aucune pompe trouvée")}$(e).html(i).slideDown("5000",function(){var p=$(e).find("table#pumpList"+f.id);$(p).tablesorter(a);$(p).bind("sortEnd",function(){redrawTable(p)});var o=(undefined!==m)?m.getColumns():{};for(column in o){$("table#pumpList"+f.id+" > thead > tr > th:eq("+column+")").css("cursor","pointer").click(function(){var r=$(this).attr("class").split(" "),q=m.getColumnByName(r[0]);generatePopup("Filtrer les données par :",getFilterForm(m.getId(),q,m.getItems(q),m.getFilterStates(q)),300,300,null,"#FFFFFF");$("#form_PumpFilter").submit(function(){popupPumpFilterFormSuccess();return false})})}})}}function redrawTable(b){var a=$(b).find("tbody > tr.visible");$(a).removeClass("even odd");$(a).filter(":even").addClass("even");$(a).filter(":odd").addClass("odd")}function appendToSortedTable(c,d){var a=$(c).find("> tbody"),b=0;for(b;b<d.length;b++){$(a).append($(d[b]).closest("tr.filter"))}}function popupPumpFilterFormSuccess(){var h=$("input[name='data_PumpFilter_id']").attr("value"),d=$("input[name='data_PumpFilter_column']").attr("value"),e,f=[],b=false,c,a=[],g;$("input:radio[name='data_PumpFilter[]']").each(function(){if($(this).attr("checked")){e=$(this).attr("value");f.push(e)}});if(-1==f[0]){b=true;f={}}myPumpFilter=PumpFilterManager.getPumpFilter(h);myPumpFilter.setFilterStates(d,f);c=myPumpFilter.getAllFilterStates();for(filterColumn in c){filterName=myPumpFilter.getColumnNameById(filterColumn);countFilterValues=countObjectValues(c[filterColumn]);if(countFilterValues>0){a.push("filter_"+filterName+"_"+c[filterColumn])}}if(a.length>0){b=false}else{b=true}$.nyroModalRemove();g=$("table#pumpList"+h);$(g).find("tbody > tr.filter").each(function(){$(this).removeClass("visible");if((b)||$(this).is("."+a.join("."))){$(this).show();$(this).addClass("visible")}else{$(this).hide()}});redrawTable(g)}function countObjectValues(b){var a=0;for(values in b){a++}return a}function getFilterForm(b,d,f,g){var a=[],h,e=((countObjectValues(g)===0)?true:false),j,c;a.push('<form id="form_PumpFilter" method="post"><div class="form_PumpFilter_container">');$.each(f,function(i){if((!e)&&(in_array(i,g))){h='checked="checked"'}else{h=""}a.push('<p><input id="',d+i,'" type="radio" ',h,' name="data_PumpFilter[]" value = "',i,'"/> ','<label for="',d+i,'">',f[i].name,"</label></p>")});if(e){h='checked="checked"'}else{h=""}a.push('<p><input id="all" type="radio" ',h,' name="data_PumpFilter[]" value = "-1"/> ','<label for="all">Tous</label></p>');a.push('<p class="form_PumpFilter_buttonContainer">');a.push('<input type="hidden" value="'+d+'" name="data_PumpFilter_column" class="modalFormRowSubmit" />');a.push('<input type="hidden" value="'+b+'" name="data_PumpFilter_id" class="modalFormRowSubmit" />');a.push('<input id="validate_PumpFilter" style="border: 1px solid #FFFFFF;" type="submit" value="Filtrer" class="modalFormRowSubmit" />');a.push("</p>");a.push("</form>");return a.join("")}function getRowAddToSelection(a){return'<a href="#" class="selectedPump" onclick="handleSelection(this,'+a+',true);return false;"><img src="/images/btn/btnAddSelection.gif" alt="Ajouter à ma sélection" /></a>'}function getRowDelFromSelection(b,a){return(true===a)?'<a href="#" class="selectedPump" onclick="handleSelection(this,'+b+',false);return false;"><img src="/images/btn/btnDel.gif" alt="Retirer de ma sélection" /></a>':""}function clearBox(b,a){$("#block"+b).one("click",{id:b,callback:a},function(c){c.data.callback(c.data.id,generatePumpTable)});$("#blockCont"+b).slideUp("5000",function(){$("#blockCont"+b).empty()})}function getDepSearch(){var a=getDeps(generateDepsSelect);$("#implantationSearchContent").html(a);return(false)}function getRoadSearch(){var a=getRoads(generateRoadsSelect);$("#implantationSearchContent").html('<a href="#" class="btnOk" onclick="getPumpsFromRoad(0); return (false);"><img alt="ok" src="/images/btn/btnOk.gif"></a>'+a);return(false)}function getVilleSimpleSearch(){var a='<a href="#" onclick="villeFromStartPage();return false;" class="btnOk"><img alt="ok" src="/images/btn/btnOk.gif"></a>';a+='<input class="inputSearch" type="text" id="villeSearchSimple" />';return a}function doSimpleSearch(){getVilleSearch();villeSearch()}function getVilleSearch(b){var a=['<div id="villeSearchMap">','<div id="searchVilleCrit">Votre ville ou votre code postal&nbsp;:','<div id="villeSearchSpace"></div>','<input value="',_LastSearch.getVille(),'" type="text" id="villeSearch" />','<input type="button" value="Rechercher" onclick="villeSearch();return false;" />','</div><div id="canvas">',"</div></div>"],c=(undefined!==b)?b:null;getMap(c);$("#implantationSearchContent").empty().html(a.join(""));attachAutocompletePluginVilleCp("#villeSearch")}function villeSearch(){if(undefined!==directions&&"object"===typeof directions){directions.clear();$("#directions_panel").remove()}getPumpsFromId(_LastSearch)}function getPumpsFromId(a){$("#implantationContent").empty();generateRow(a.id,a.ville,getPumpsById,"implantationContent");$("#implantationContent").attr("style","border: 1px solid #D3FB81;").find("#block"+a.id).trigger("click");$("#searchTitle").html('Résultat de votre recherche sur <span class="green">'+a.ville+"</span>")}function putOnMap(c){var a=_LastSearch.getVille()+" "+_LastSearch.getZipcode()+" France",b;geocoder=new GClientGeocoder();geocoder.getLatLng(a,function(d){if(!d){alert(a+" n'a pu être localisé")}else{map.setCenter(d,11)}});for(b=0;b<gl_markers.length;b++){map.removeOverlay(gl_markers[b])}gl_markers=[];if(undefined!==c.pump){$(c.pump).each(function(d,e){marker=pumpMarker(new GLatLng(e.lat,e.lng),e);gl_markers.push(marker);map.addOverlay(marker)})}}function pumpMarker(a,c){var f=new GIcon(),b,e,d=[];f.image="/js/pumpimage.png";f.shadow="/js/pumpshadow.png";f.iconSize=new GSize(20,34);f.shadowSize=new GSize(37,34);f.iconAnchor=new GPoint(20,34);f.infoWindowAnchor=new GPoint(10,0);f.printImage="/js/pumpprintImage.gif";f.mozPrintImage="/js/pumpmozPrintImage.gif";f.printShadow="/js/pumpprintShadow.gif";f.transparent="/js/pumptransparent.png";b={icon:f};e=new GMarker(a,b);d.push("<div><p>",c.address,"<br />",c.zipcode," ",c.city,"<br />Téléphone : ",c.phone,"<br />latitude : ",c.lat,"<br />longitude : ",c.lng,"</p></div>");e.bindInfoWindowHtml(d.join(""));return e}function depFromStartPage(){getPumpsFromDep(0);loadSecondContent("<br /><br />Pour connaître les pompes vertes de votre département, cliquez sur celui-ci <br />et visualisez la liste en dessous.",{print:false});return(false)}function villeFromStartPage(){doSimpleSearch();loadSecondContent("<br /><br /><br />Pour connaître les pompes vertes de votre commune, veuillez entrer le nom ou le code postal de celle-ci dans le champs ci-dessous.",{print:false})}function showSelection(a){var c=$("#searchTitle").empty(),b=$("#implantationContent").empty();$("#implantationSearchContent").empty();b.nextAll().remove();loadSecondContent("<br /><br /><br />Voici votre sélection.",{selection:false});$.postJSONRPC({method:"get",params:{obj:"Selection"}},function(e){if(0<$(e.pump).length){var d;generatePumpTable(e,{block:b,pk:true,road:true,myselection:true},7);$(b).find("a.selectedPump").click(function(f){$(this).closest("tr.filter").fadeOut("slow",function(){$(this).remove();d=$(b).find("table tr:gt(0)");$(d).filter(":even").css("background-color","#F6FFE4");$(d).filter(":odd").css("background-color","#E7FDB5")})});if(true===a){window.print();window.close()}}else{$(c).html("Votre sélection est vide")}});$(b).attr("style","border:1px solid #D3FB81;")}function roadFromStartPage(){getPumpsFromRoad(0);var b=['<div class="greenPanel">','<a id="btnRetour" href="#" onclick="getPumpsFromRetRoad();return false;">','<img src="/images/btn/btnRetour.gif" alt="Retour"></a>','<div id="roadSearchContent">',"S&eacute;lectionnez un axe routier&nbsp;:&nbsp;</div></div>",'<div id="return"><img src="/images/btn/return.png" alt=""></dv>'],a;loadSecondContent("<br /><br /><br />Sélectionnez un axe routier pour trouver les pompes vertes présentes sur votre trajet.",{print:false});$("#implantationSearchContent").html(b.join(""));getRoads(generateRoadsSelect,"#roadSearchContent",false);$("#roadSearch").change(function(){getPumpsFromRoad(0)});a=$("#btnRetour");$(a).live("mouseover",function(c){c.preventDefault();$("#return").css("visibility","visible")});$(a).live("mouseout",function(c){c.preventDefault();$("#return").css("visibility","hidden")})}function loadSecondContent(h,c,g){var f=[],e='<a href="#" id="BTNID"><img src="/images/btn/',b,a=c||{},d=new RegExp("BTNID","g");b={proposal:(false===a.proposal)?false:true,selection:(false===a.selection)?false:true,download:(false===a.download)?false:true,print:(false===a.print)?false:true};f.push('<div class="right" id="rightBtn">');if(b.proposal){f.push(e.replace(d,"btnProposer"),'btnProposer.gif" alt="Proposer une station 2"></a>')}if(b.selection){f.push(e.replace(d,"btnSelection"),'btnSelection.gif" alt="Ma sélection"></a>')}if(b.download){f.push(e.replace(d,"btnDownload"),'btnTelecharger.gif" alt="Télécharger la liste"></a>')}if(b.print){f.push(e.replace(d,"btnImprimer"),'btnImprimer.gif" alt="Imprimer"></a>')}f.push("</div>",'<a href="/implantation" id="nouvelleRecherche"><img src="/images/btn/btnNouvelle.gif" alt="Nouvelle recherche"></a>');f.push('<div id="secondContentTitle" class="title"><br />',h,"</div>");$("#simpleSearch").empty().html(f.join(""));$("#btnProposer").click(function(i){i.preventDefault();popupProposer()});$("#btnDownload").click(function(i){i.preventDefault();window.open("/pdf/PompesE85.pdf")});$("#btnImprimer").click(function(i){i.preventDefault();if(undefined!==g){var k="from="+encodeURI(g.directions.from)+"&to="+encodeURI(g.directions.to);var j=k;window.open("/implantation/?mode=map-print&"+j)}else{window.open("/implantation/?mode=selection-print")}})}function handleSelection(b,d,c){delta++;var a=timestamp+delta;$.getJSON("/webservices/index/json",{id:a,method:(true===c)?"add":"del",params:$.toJSON({obj:"Selection",id:d}),version:"2.0"},function(e){if(true===e.result){$(b).replaceWith((true===c)?getRowDelFromSelection(d)+'<img src="/images/btn/autre.png" width="117" height="18" />':getRowAddToSelection(d));if(true===c){var f=['<div class="modalFormRow">','<label class="modalFormLabelNote">',"La station a &eacute;t&eacute; ajout&eacute;e &agrave; votre s&eacute;lection","</label></div>",'<div class="modalFormRow" style="width:200px">','<label class="modalFormPump">','<a href="#" title="Acc&eacute;der &agrave; la s&eacute;lection"',' onclick="$.nyroModalRemove();showSelection();return false;">',"Acc&eacute;der &agrave; ma s&eacute;lection de stations</a>","</label></div>"];generatePopup("Station ajout&eacute;e",f.join(""),250,80)}}})}function generatePopup(g,d,c,f,b,a){$.nyroModalManual({content:d,type:"form",minWidth:c,width:c,css:{content:{width:c+"px",height:(f)+"px",backgroundColor:(a===undefined)?"#639500":a,backgroundImage:(a===undefined)?"url(/images/gradients/gradBox.gif)":"none",backgroundRepeat:"repeat-x",fontWeight:"bold",color:"#FFFFFF","float":"left"},wrapper:{left:"",top:""},wrapper2:{backgroundColor:"#FFFFFF",padding:"10px",height:(f+73)+"px",width:(c+37)+"px"}},closeButton:'<a href="#" class="nyroModalClose" id="closeBut" title="Fermer"><img src="/images/btn/btnClose.gif" alt="Fermer" height="10" weight="10" /></a>',title:g,wrap:{manual:'<div id="wrapper"></div>'},endFillContent:function(i,h){$(i.wrapper).wrap('<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"><tbody><tr><td style="vertical-align:middle;"></td></tr></tbody></table>')}});var e=$("#modalform");$(e).ajaxForm({beforeSubmit:popupFormBeforeSubmit,success:("function"===typeof b)?b:popupFormSuccess,dataType:"json"});$(e).find("input[type='image']").hover(function(i){i.preventDefault();var j=$(this).attr("src"),h=new RegExp("rollout","g");$(this).attr("src",j.replace(h,"rollover"))},function(i){i.preventDefault();var j=$(this).attr("src"),h=new RegExp("rollover","g");$(this).attr("src",j.replace(h,"rollout"))})}function popupProposer(){$.getJSON("/webservices/pump/add",function(a){if(a.form){generatePopup("Proposer une station E-85",a.form,300,520);attachAutocompletePluginCp("#autozipcode");attachAutocompletePluginVille("#autocity")}})}function popupEditPump(a){$.getJSON("/webservices/pump/edit",{idPump:a},function(b){if(b.form){generatePopup("Modifier la station",b.form,300,270)}})}function popupSendByEmail(a){$.getJSON("/webservices/sendby/email",{idPump:a},function(b){if(b.form){generatePopup("Envoyer par mail",b.form,390,380)}})}function popupSendBySms(a){$.getJSON("/webservices/sendby/sms",{idPump:a},function(b){if(b.form){generatePopup("Envoyer par SMS",b.form,390,315)}})}function popupDirections(a){$.getJSON("/webservices/directions/get",{idPump:a},function(b){if(b.form){generatePopup("Accéder à une station",b.form,300,100,popupDirectionsFormSuccess);attachAutocompletePlugin("#autocityorzip","getAutoComplete",null,null,function(c,d){_LastSearch.clear().setId(d.id).setVille(d.name).setZipcode(d.cp);$("#idVille").val(d.id)},2)}})}function popupFormBeforeSubmit(c,b,a){$(b).find("ul.errors").remove();resizePopup()}function popupFormSuccess(f){var c=true,e=false;if(undefined!==f.isValid){if(f.isValid){if(undefined!==f.message){var d=['<div class="modalFormRow">','<label class="modalFormLabelNote">',f.message,"</label></div>",'<div class="modalFormRow">','<label class="modalFormPump">','<a href="#" title="Fermer" onclick="$.nyroModalRemove();return false;">Fermer</a>',"</label></div>"];$("#modalform").html(d.join(""))}else{$.nyroModalRemove();c=false}e=true}else{var b,a;if(undefined!==f.errors){$.each(f.errors,function(g,h){b=$('<ul class="errors"></ul>').insertAfter($("#"+g));$.each(h,function(i,j){$("<li>"+j+"</li>").appendTo(b)})})}if(undefined!==f.captcha){a=$("#captcha");$(a).find("#captcha-id").attr("value",f.captcha.id);$(a).find("#captcha-input").val("");$(a).find("img").attr("src",f.captcha.src)}}if(c){resizePopup()}return e}}function popupDirectionsFormSuccess(a){if(true===popupFormSuccess(a)){$("#showswfmap").remove();$("#swfmapcontainer").remove();getVilleSearch({fn:loadDirections,opts:a});loadSecondContent("<br /><br />Votre itinéraire",{print:print},a)}}function printMap(a){$("#contentFullPage").html('<div id="canvas"></div><div id="directions_panel"></div><div id="nouvelleRecherche"></div>');var b=extractUrlParams();data=new Array();data.directions=new Array();data.directions.from=decodeURI(b.from);data.directions.to=decodeURI(b.to);data.print=a;getVilleSearch({fn:loadDirections,opts:data})}function loadDirections(f,a){var c=$('<div id="directions_panel"></div>'),e=[],b=$("#canvas"),d=Math.floor(a.width/2)+"px";c.insertBefore(b);c.css({width:d,height:(a.height-10)+"px","margin-left":d});directions=new GDirections(map,document.getElementById("directions_panel"));e=["from:",f.directions.from,"to:",f.directions.to];directions.load(e.join(" "));$("#nouvelleRecherche").focus().blur();if(true===f.print){window.print();window.close()}}function resizePopup(){var b=$("#modalform"),c,d,a;c=$(b).outerHeight();d=c+73;a=d+33;$("#nyroModalWrapper").height(a);$("#wrapper").height(d);$("#nyroModalContent").height(c)}function attachAutocompletePlugin(c,i,e,b,f,a){delta++;var g=timestamp+delta,d=("function"===typeof e)?e:function(k){var j=k.result,l=[];if(parseInt(k.id,10)===g&&undefined!==j.ville){$(j.ville).each(function(m,n){l[m]={data:{name:n.name,cp:n.codepostal,id:n.id,lng:n.lng,lat:n.lat},value:n.name,result:n.name}})}return l},h=("function"===typeof b)?b:function(j){return j.name+" ("+j.cp+")"};$(c).autocomplete("/webservices/index/json",{dataType:"json",extraParams:{id:g,method:i,params:$.toJSON({obj:"Ville"}),version:"2.0"},minChars:(undefined!==a)?a:3,max:10,mustMatch:true,parse:d,formatItem:h}).result(f)}function attachAutocompletePluginVilleCp(a){var d="getAutoComplete",e=null,c=null,b;b=function(f,g){_LastSearch.clear().setId(g.id).setVille(g.name).setZipcode(g.cp).setLng(g.lng).setLat(g.lat)};attachAutocompletePlugin(a,d,e,c,b)}function attachAutocompletePluginVille(a){var d="getAutoCompleteVille",e=null,c=null,b;b=function(f,g){$("#autozipcode").val(g.cp);$("#idVille").val(g.id)};attachAutocompletePlugin(a,d,e,c,b)}function attachAutocompletePluginCp(a){var d="getAutoCompleteCp",e=null,c,b;e=function(g){var f=g.result,h=[];if(undefined!==f.ville){$(f.ville).each(function(j,k){h[j]={data:{name:k.name,cp:k.codepostal,id:k.id},value:k.codepostal,result:k.codepostal}})}return h};c=function(f){return f.cp+" ("+f.name+")"};b=function(f,g){$("#autocity").val(g.name);$("#idVille").val(g.id)};attachAutocompletePlugin(a,d,e,c,b,2)}function extractUrlParams(){var c=location.search.substring(1).split("&");var d=[];for(var b=0;b<c.length;b++){var a=c[b].split("=");d[a[0]]=a[1]}return d}$(document).ready(function(){var d=new RegExp("(/?|&)mode=selection-print(&|$)","i"),b=$("div.btnBulle > a"),a=new RegExp("(/?|&)mode=map-print(&|$)","i"),c;if(d.test(window.location.search)){c=$("head");$(c).find("> style").remove();$(c).find('> link[type="text/css"]').remove();$('<link rel="stylesheet" href="/css/implantation-selection-print.css" type="text/css" media="all" />').appendTo(c);showSelection(true);return}if(a.test(window.location.search)){c=$("head");$(c).find("> style").remove();$(c).find('> link[type="text/css"]').remove();$('<link rel="stylesheet" href="/css/implantation-map-print.css" type="text/css" media="all" />').appendTo(c);printMap(true);return}_Roads=new Roads(getRoads);$("#btnProposer").click(function(e){e.preventDefault();popupProposer()});$(b).live("mouseover",function(e){e.preventDefault();$(this).next("div.bulle").css("visibility","visible")});$(b).live("mouseout",function(e){e.preventDefault();$(this).next("div.bulle").css("visibility","hidden")});$("#searchOnMap").click(function(e){e.preventDefault();$("#simpleSearch").slideUp("slow",function(){var f="<div><br /><br /><br />Pour connaître les pompes vertes de votre département,<br />cliquez sur celui-ci et visualisez la liste en dessous.</div>",g=['<div class="clear"></div>','<div id="showswfmap">','<img src="/images/btn/ouvrir-carte.gif" height="22" id="showswfmapbutton" width="172" />',"</div>",'<div id="swfmapcontainer"><hr class="greenHr" />','<div id="swfmap"></div></div>'];loadSecondContent(f,{print:false});$(this).find("+ div.clear").after(g.join(""));$("#showswfmapbutton").click(function(h){h.preventDefault();$("#showswfmapbutton").hide();$("#swfmapcontainer").slideDown("slow")})}).slideDown("slow",function(){swfobject.embedSWF("/swf/carte_france.swf","swfmap","705","596","9.0.0","",{},{wmode:"transparent"})})});$("#btnSelection").live("click",function(e){e.preventDefault();showSelection()});$("#btnDownload").click(function(e){e.preventDefault();window.open("/pdf/PompesE85.pdf")});getDeps(handleDepsList);$("#critBoxVilleCont").html(getVilleSimpleSearch());attachAutocompletePluginVilleCp("#villeSearchSimple");$.tablesorter.addParser({id:"pks",is:function(e){return false},format:function(e){return e.replace(/^km\s+/,"").replace(/^$/,0)},type:"numeric"})});function in_array(e,d,b){var a="",c=!!b;if(c){for(a in d){if(d[a]===e){return true}}}else{for(a in d){if(d[a]==e){return true}}}return false};