if(typeof Prototype=="undefined"){alert("CalendarDateSelect Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (.g. <%= javascript_include_tag :defaults %>) *before* it includes calendar_date_select.js (.g. <%= calendar_date_select_includes %>).")}if(Prototype.Version<"1.6"){alert("Prototype 1.6.0 is required.  If using earlier version of prototype, please use calendar_date_select version 1.8.3")}Element.addMethods({purgeChildren:function(a){$A(a.childNodes).each(function(c){$(c).remove()})},build:function(c,e,a,d){var f=Element.buildAndAppend(e,a,d);c.appendChild(f);return f}});Element.buildAndAppend=function(d,a,c){var f=$(document.createElement(d));$H(a).each(function(e){f[e.key]=e.value});if(c){f.setStyle(c)}return f};nil=null;Date.one_day=24*60*60*1000;Date.weekdays=$w("S M T W T F S");Date.first_day_of_week=0;Date.months=$w("January February March April May June July August September October November December");Date.padded2=function(a){var c=parseInt(a,10);if(a<10){c="0"+c}return c};Date.prototype.getPaddedMinutes=function(){return Date.padded2(this.getMinutes())};Date.prototype.getAMPMHour=function(){var a=this.getHours();return(a==0)?12:(a>12?a-12:a)};Date.prototype.getAMPM=function(){return(this.getHours()<12)?"AM":"PM"};Date.prototype.stripTime=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDate())};Date.prototype.daysDistance=function(a){return Math.round((a-this)/Date.one_day)};Date.prototype.toFormattedString=function(c){var a,d;d=Date.months[this.getMonth()]+" "+this.getDate()+", "+this.getFullYear();if(c){a=this.getHours();d+=" "+this.getAMPMHour()+":"+this.getPaddedMinutes()+" "+this.getAMPM()}return d};Date.parseFormattedString=function(a){return new Date(a)};Math.floor_to_interval=function(c,a){return Math.floor(c/a)*a};window.f_height=function(){return([window.innerHeight?window.innerHeight:null,document.documentElement?document.documentElement.clientHeight:null,document.body?document.body.clientHeight:null].select(function(a){return a>0}).first()||0)};window.f_scrollTop=function(){return([window.pageYOffset?window.pageYOffset:null,document.documentElement?document.documentElement.scrollTop:null,document.body?document.body.scrollTop:null].select(function(a){return a>0}).first()||0)};_translations={OK:"OK",Now:"Now",Today:"Today",Clear:"Clear"};SelectBox=Class.create();SelectBox.prototype={initialize:function(e,c,d,a){this.element=$(e).build("select",d,a);this.populate(c)},populate:function(a){this.element.purgeChildren();var c=this;$A(a).each(function(d){if(typeof(d)!="object"){d=[d,d]}c.element.build("option",{value:d[1],innerHTML:d[0]})})},setValue:function(c){var d=this.element;var a=false;$R(0,d.options.length-1).each(function(e){if(d.options[e].value==c.toString()){d.selectedIndex=e;a=true}});return a},getValue:function(){return $F(this.element)}};CalendarDateSelect=Class.create();CalendarDateSelect.prototype={initialize:function(c,a){this.target_element=$(c);if(!this.target_element){alert("Target element "+c+" not found!");return false}if(this.target_element.tagName!="INPUT"){this.target_element=this.target_element.down("INPUT")}this.target_element.calendar_date_select=this;this.last_click_at=0;this.options=$H({embedded:false,popup:nil,time:false,buttons:true,clear_button:true,year_range:10,close_on_click:nil,minute_interval:5,popup_by:this.target_element,month_year:"dropdowns",onchange:this.target_element.onchange,valid_date_check:nil}).merge(a||{});this.use_time=this.options.get("time");this.parseDate();this.callback("before_show");this.initCalendarDiv();if(!this.options.get("embedded")){this.positionCalendarDiv();Event.observe(document,"mousedown",this.closeIfClickedOut_handler=this.closeIfClickedOut.bindAsEventListener(this));Event.observe(document,"keypress",this.keyPress_handler=this.keyPress.bindAsEventListener(this))}this.callback("after_show")},positionCalendarDiv:function(){var p=false;var k=this.calendar_div.cumulativeOffset(),n=k[0],j=k[1],d=this.calendar_div.getDimensions(),q=d.height,c=d.width;var o=window.f_scrollTop(),e=window.f_height();var r=$(this.options.get("popup_by")).cumulativeOffset(),g=r[1],s=r[0],h=$(this.options.get("popup_by")).getDimensions().height,m=g+h;if(((m+q)>(o+e))&&(m-q>o)){p=true}var a=s.toString()+"px",f=(p?(g-q):(g+h)).toString()+"px";this.calendar_div.style.left=a;this.calendar_div.style.top=f;this.calendar_div.setStyle({visibility:""});if(navigator.appName=="Microsoft Internet Explorer"){this.iframe=$(document.body).build("iframe",{src:"javascript:false",className:"ie6_blocker"},{left:a,top:f,height:q.toString()+"px",width:c.toString()+"px",border:"0px"})}},initCalendarDiv:function(){if(this.options.get("embedded")){var parent=this.target_element.parentNode;var style={}}else{var parent=document.body;var style={position:"absolute",visibility:"hidden",left:0,top:0}}this.calendar_div=$(parent).build("div",{className:"calendar_date_select"},style);var that=this;$w("top header body buttons footer bottom").each(function(name){eval("var "+name+"_div = that."+name+"_div = that.calendar_div.build('div', { className: 'cds_"+name+"' }, { clear: 'left'} ); ")});this.initHeaderDiv();this.initButtonsDiv();this.initCalendarGrid();this.updateFooter("&#160;");this.refresh();this.setUseTime(this.use_time)},initHeaderDiv:function(){var a=this.header_div;this.close_button=a.build("a",{innerHTML:"x",href:"#",onclick:function(){this.close();return false}.bindAsEventListener(this),className:"close"});this.next_month_button=a.build("a",{innerHTML:"&gt;",href:"#",onclick:function(){this.navMonth(this.date.getMonth()+1);return false}.bindAsEventListener(this),className:"next"});this.prev_month_button=a.build("a",{innerHTML:"&lt;",href:"#",onclick:function(){this.navMonth(this.date.getMonth()-1);return false}.bindAsEventListener(this),className:"prev"});if(this.options.get("month_year")=="dropdowns"){this.month_select=new SelectBox(a,$R(0,11).map(function(c){return[Date.months[c],c]}),{className:"month",onchange:function(){this.navMonth(this.month_select.getValue())}.bindAsEventListener(this)});this.year_select=new SelectBox(a,[],{className:"year",onchange:function(){this.navYear(this.year_select.getValue())}.bindAsEventListener(this)});this.populateYearRange()}else{this.month_year_label=a.build("span")}},initCalendarGrid:function(){var a=this.body_div;this.calendar_day_grid=[];var h=a.build("table",{cellPadding:"0px",cellSpacing:"0px",width:"100%"});var c=h.build("thead").build("tr");Date.weekdays.each(function(j){c.build("th",{innerHTML:j})});var f=h.build("tbody");var d=0,e;for(var g=0;g<42;g++){e=(g+Date.first_day_of_week)%7;if(g%7==0){days_row=f.build("tr",{className:"row_"+d++})}(this.calendar_day_grid[g]=days_row.build("td",{calendar_date_select:this,onmouseover:function(){this.calendar_date_select.dayHover(this)},onmouseout:function(){this.calendar_date_select.dayHoverOut(this)},onclick:function(){this.calendar_date_select.updateSelectedDate(this,true)},className:(e==0)||(e==6)?" weekend":""},{cursor:"pointer"})).build("div");this.calendar_day_grid[g]}},initButtonsDiv:function(){var e=this.buttons_div;if(this.options.get("time")){var c=$A(this.options.get("time")=="mixed"?[[" - ",""]]:[]);e.build("span",{innerHTML:"@",className:"at_sign"});var a=new Date();this.hour_select=new SelectBox(e,c.concat($R(0,23).map(function(f){a.setHours(f);return $A([a.getAMPMHour()+" "+a.getAMPM(),f])})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({hour:this.value})},className:"hour"});e.build("span",{innerHTML:":",className:"seperator"});var d=this;this.minute_select=new SelectBox(e,c.concat($R(0,59).select(function(f){return(f%d.options.get("minute_interval")==0)}).map(function(f){return $A([Date.padded2(f),f])})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({minute:this.value})},className:"minute"})}else{if(!this.options.get("buttons")){e.remove()}}if(this.options.get("buttons")){e.build("span",{innerHTML:"&#160;"});if(this.options.get("time")=="mixed"||!this.options.get("time")){b=e.build("a",{innerHTML:_translations.Today,href:"#",onclick:function(){this.today(false);return false}.bindAsEventListener(this)})}if(this.options.get("time")=="mixed"){e.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"})}if(this.options.get("time")){b=e.build("a",{innerHTML:_translations.Now,href:"#",onclick:function(){this.today(true);return false}.bindAsEventListener(this)})}if(!this.options.get("embedded")&&!this.closeOnClick()){e.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"});e.build("a",{innerHTML:_translations.OK,href:"#",onclick:function(){this.close();return false}.bindAsEventListener(this)})}if(this.options.get("clear_button")){e.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"});e.build("a",{innerHTML:_translations.Clear,href:"#",onclick:function(){this.clearDate();if(!this.options.get("embedded")){this.close()}return false}.bindAsEventListener(this)})}}},refresh:function(){this.refreshMonthYear();this.refreshCalendarGrid();this.setSelectedClass();this.updateFooter()},refreshCalendarGrid:function(){this.beginning_date=new Date(this.date).stripTime();this.beginning_date.setDate(1);this.beginning_date.setHours(12);var c=this.beginning_date.getDay();if(c<3){c+=7}this.beginning_date.setDate(1-c+Date.first_day_of_week);var e=new Date(this.beginning_date);var a=new Date().stripTime();var d=this.date.getMonth();vdc=this.options.get("valid_date_check");for(var f=0;f<42;f++){day=e.getDate();month=e.getMonth();cell=this.calendar_day_grid[f];Element.remove(cell.childNodes[0]);div=cell.build("div",{innerHTML:day});if(month!=d){div.className="other"}cell.day=day;cell.month=month;cell.year=e.getFullYear();if(vdc){if(vdc(e.stripTime())){cell.removeClassName("disabled")}else{cell.addClassName("disabled")}}e.setDate(day+1)}if(this.today_cell){this.today_cell.removeClassName("today")}if($R(0,41).include(days_until=this.beginning_date.stripTime().daysDistance(a))){this.today_cell=this.calendar_day_grid[days_until];this.today_cell.addClassName("today")}},refreshMonthYear:function(){var a=this.date.getMonth();var d=this.date.getFullYear();if(this.options.get("month_year")=="dropdowns"){this.month_select.setValue(a,false);var c=this.year_select.element;if(this.flexibleYearRange()&&(!(this.year_select.setValue(d,false))||c.selectedIndex<=1||c.selectedIndex>=c.options.length-2)){this.populateYearRange()}this.year_select.setValue(d)}else{this.month_year_label.update(Date.months[a]+" "+d.toString())}},populateYearRange:function(){this.year_select.populate(this.yearRange().toArray())},yearRange:function(){if(!this.flexibleYearRange()){return $R(this.options.get("year_range")[0],this.options.get("year_range")[1])}var a=this.date.getFullYear();return $R(a-this.options.get("year_range"),a+this.options.get("year_range"))},flexibleYearRange:function(){return(typeof(this.options.get("year_range"))=="number")},validYear:function(a){if(this.flexibleYearRange()){return true}else{return this.yearRange().include(a)}},dayHover:function(a){var c=new Date(this.selected_date);c.setYear(a.year);c.setMonth(a.month);c.setDate(a.day);this.updateFooter(c.toFormattedString(this.use_time))},dayHoverOut:function(a){this.updateFooter()},clearSelectedClass:function(){if(this.selected_cell){this.selected_cell.removeClassName("selected")}},setSelectedClass:function(){if(!this.selection_made){return}this.clearSelectedClass();if($R(0,42).include(days_until=this.beginning_date.stripTime().daysDistance(this.selected_date.stripTime()))){this.selected_cell=this.calendar_day_grid[days_until];this.selected_cell.addClassName("selected")}},reparse:function(){this.parseDate();this.refresh()},dateString:function(){return(this.selection_made)?this.selected_date.toFormattedString(this.use_time):"&#160;"},parseDate:function(){var a=$F(this.target_element).strip();this.selection_made=(a!="");this.date=a==""?NaN:Date.parseFormattedString(this.options.get("date")||a);if(isNaN(this.date)){this.date=new Date()}if(!this.validYear(this.date.getFullYear())){this.date.setYear((this.date.getFullYear()<this.yearRange().start)?this.yearRange().start:this.yearRange().end)}this.selected_date=new Date(this.date);this.use_time=/[0-9]:[0-9]{2}/.exec(a)?true:false;this.date.setDate(1)},updateFooter:function(a){if(!a){a=this.dateString()}this.footer_div.purgeChildren();this.footer_div.build("span",{innerHTML:a})},clearDate:function(){if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force"){return false}var a=this.target_element.value;this.target_element.value="";this.clearSelectedClass();this.updateFooter("&#160;");if(a!=this.target_element.value){this.callback("onchange")}},updateSelectedDate:function(d,c){var g=$H(d);if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force"){return false}if(g.get("day")){var f=this.selected_date,e=this.options.get("valid_date_check");for(var a=0;a<=3;a++){f.setDate(g.get("day"))}f.setYear(g.get("year"));f.setMonth(g.get("month"));if(e&&!e(f.stripTime())){return false}this.selected_date=f;this.selection_made=true}if(!isNaN(g.get("hour"))){this.selected_date.setHours(g.get("hour"))}if(!isNaN(g.get("minute"))){this.selected_date.setMinutes(Math.floor_to_interval(g.get("minute"),this.options.get("minute_interval")))}if(g.get("hour")===""||g.get("minute")===""){this.setUseTime(false)}else{if(!isNaN(g.get("hour"))||!isNaN(g.get("minute"))){this.setUseTime(true)}}this.updateFooter();this.setSelectedClass();if(this.selection_made){this.updateValue()}if(this.closeOnClick()){this.close()}if(c&&!this.options.get("embedded")){if((new Date()-this.last_click_at)<333){this.close()}this.last_click_at=new Date()}},closeOnClick:function(){if(this.options.get("embedded")){return false}if(this.options.get("close_on_click")===nil){return(this.options.get("time"))?false:true}else{return(this.options.get("close_on_click"))}},navMonth:function(a){(target_date=new Date(this.date)).setMonth(a);return(this.navTo(target_date))},navYear:function(a){(target_date=new Date(this.date)).setYear(a);return(this.navTo(target_date))},navTo:function(a){if(!this.validYear(a.getFullYear())){return false}this.date=a;this.date.setDate(1);this.refresh();this.callback("after_navigate",this.date);return true},setUseTime:function(c){this.use_time=this.options.get("time")&&(this.options.get("time")=="mixed"?c:true);if(this.use_time&&this.selected_date){var d=Math.floor_to_interval(this.selected_date.getMinutes(),this.options.get("minute_interval"));var a=this.selected_date.getHours();this.hour_select.setValue(a);this.minute_select.setValue(d)}else{if(this.options.get("time")=="mixed"){this.hour_select.setValue("");this.minute_select.setValue("")}}},updateValue:function(){var a=this.target_element.value;this.target_element.value=this.dateString();if(a!=this.target_element.value){this.callback("onchange")}},today:function(a){var e=new Date();this.date=new Date();var c=$H({day:e.getDate(),month:e.getMonth(),year:e.getFullYear(),hour:e.getHours(),minute:e.getMinutes()});if(!a){c=c.merge({hour:"",minute:""})}this.updateSelectedDate(c,true);this.refresh()},close:function(){if(this.closed){return false}this.callback("before_close");this.target_element.calendar_date_select=nil;Event.stopObserving(document,"mousedown",this.closeIfClickedOut_handler);Event.stopObserving(document,"keypress",this.keyPress_handler);this.calendar_div.remove();this.closed=true;if(this.iframe){this.iframe.remove()}if(this.target_element.type!="hidden"&&!this.target_element.disabled){this.target_element.focus()}this.callback("after_close")},closeIfClickedOut:function(a){if(!$(Event.element(a)).descendantOf(this.calendar_div)){this.close()}},keyPress:function(a){if(a.keyCode==Event.KEY_ESC){this.close()}},callback:function(a,c){if(this.options.get(a)){this.options.get(a).bind(this.target_element)(c)}}};_translations={OK:"OK",Now:"Maintenant",Today:"Aujourd'hui",Clear:"Effacer"};Date.weekdays=$w("L Ma Me J V S D");Date.first_day_of_week=1;Date.months=$w("Janvier Février Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Décembre");Date.prototype.toFormattedString=function(a){str=Date.padded2(this.getDate())+"/"+Date.padded2(this.getMonth()+1)+"/"+this.getFullYear();if(a){return str+" "+this.getHours()+":"+this.getPaddedMinutes()}return str};Date.parseFormattedString=function(a){var c="(([0-3]?[0-9]/[0-1]?[0-9])/[0-9]{4}) *([0-9]{1,2}(:[0-9]{2})?)?";var e=a.match(new RegExp(c,"i"));mdy=e[0].split("/");hrs=0;mts=0;if(e[3]!=null){hrs=parseInt(e[3].split("")[0],10);mts=e[4].split(":")[1]}return new Date(mdy[2],parseInt(mdy[1],10)-1,mdy[0],hrs,mts,0)};function RoutingPoint(f,c,e,a,d){this.id=f;this.address=c;this.coords=e;this.marker=a;this.slotIndex=d}RoutingPoint.prototype.restoreSaved=function(a){this.id=a.id;this.address=a.address;this.coords=new GLatLng(a.lat,a.lng)};function PathParams(e,d,c,a){this.points=e;this.routingMode=d;this.trafficTime=c;this.timeMode=a}PathParams.prototype.toQuery=function(){var a=this.trafficTime.getFullYear()+"-"+_padTimeUnit(this.trafficTime.getMonth()+1)+"-"+_padTimeUnit(this.trafficTime.getDate())+"_"+_padTimeUnit(this.trafficTime.getHours())+":"+_padTimeUnit(this.trafficTime.getMinutes());var d="path ";var e="";for(var c=0;c<this.points.length;++c){d+=(c==0?"":",")+this.points[c].id;e+=(c==0?"":"|")+this.points[c].address}d+=" [method:"+this.routingMode.method+" cost:"+this.routingMode.cost+" timemode:"+(this.timeMode?"departure":"reverse")+" trafictime:"+a+"]";d+="&addr="+e;return d};function PathResult(a){this.roadmap=a.getElementsByTagName("roadmap")[0];this.geom=a.getElementsByTagName("geom")[0];this.staticSeconds=parseInt(a.getAttribute("st"))/10;this.dynamicSeconds=parseInt(a.getAttribute("dt"))/10;this.refSeconds=parseInt(a.getAttribute("rt"))/10;this.distance=a.getAttribute("m")}function Path(d,c,f,e,a){this.params=d;this.errorState=c;this.pathResult=f;this.refPathResult=e;this.order=a;this.parsePolyline(f,'"color": "'+this.params.routingMode.color+'","weight": 8,"opacity": 0.7',666);this.parsePolyline(e,'"color": "#0088FF","weight": 5,"opacity": 0.7',10)}Path.prototype.parsePolyline=function(result,style,zIndex){if(!result){return null}var coordString="";var geomNode=result.geom;for(var i=0;i<geomNode.childNodes.length;++i){coordString+=geomNode.childNodes[i].data}result.polyline=GPolyline.fromEncoded(eval("({"+style+","+coordString+"})"));if(zIndex){result.polyline.getZIndex=function(lat){return zIndex}}};Path.prototype.getPoints=function(){var a=[];this.params.points.each(function(c){a.push(c.id)});return a};var _ROUTING=1;function Routing(d,a,c){if(getDRSState()!="y"){return}this.map=d;this.container=$(a);this.rcToColor=["gray","red","red","orange","#6ab023","#6ab023","black","black"];this.POINT_SLOT_MARKUP='<div class="routingPointBlockContent"><img class="routingPointBlockIcon png" id="routingPointBlockIcon_#" src="img/routing/dd-pointing-light.png" alt="" title="Cliquez et placez un point sur la carte" /> <div class="routingPointBlockContentWrapper"><div class="routingPointBlockHeader"> <div id="routingPointPrefix_#" class="routingPointPrefix">À</div><img alt="close" id="routingPointClose_#" class="routingPointClose clickable" style="display:none;" src="img/common/close.gif" /></div><div class="txtFieldIcon" style="width:98%"><img class="savedPointsIcon" id="savedPointsIcon_#" width="16" height="16" src="img/common/bullet_arrow_down.png" alt="s" style="display:none"/><input id="routingPointInput_#" name="address" class="routingAddressField" value=""/></div><div class="routingError" id="routingGCError_#" style="display:none;"></div><select id="routingGCSelect_#" style="display:none;"></select></div></div>';GDownloadUrl("routing.aspx?action=init",function(h,g){if(g!=200){this.container.update("Couldn't initialize routing modes (error "+g+")");return}var j=h.split("######");this.routingModes=j[0].evalJSON();if(c==null){c=new Object()}this.mode=(c.mode!=null)?c.mode:"prod";this.autoRecompute=(c.autoRecompute!=null)?c.autoRecompute:false;this.multiResultDisplay=(c.multiResultDisplay!=null)?c.multiResultDisplay:false;this.nbPointMax=(c.nbPointMax!=null)?c.nbPointMax:5;this.routingPoints=[];this.routingPointHash=$H();this.routingPointSlotIndex=0;this.pointingActiveSlot=-1;this.pointingListener=null;this.pointingCursorListener=null;if((this.geocoder=_geocoder)==null){this.geocoder=new GClientGeocoder();this.geocoder.setBaseCountryCode("FR")}this.addressChoices=[];this.pointBounds=new GLatLngBounds();this.paths=[];this.pathNb=0;this.rmToggleState=false;this.routingPointTemplateIcon=new GIcon();this.routingPointTemplateIcon.image="img/routing/dd-start.png";this.routingPointTemplateIcon.shadow="img/routing/shadow50.png";this.routingPointTemplateIcon.iconSize=new GSize(20,34);this.routingPointTemplateIcon.shadowSize=new GSize(37,34);this.routingPointTemplateIcon.iconAnchor=new GPoint(10,34);this.routingPointTemplateIcon.infoWindowAnchor=new GPoint(5,1);this.pointer=new GMarker(new GLatLng(0,0),{icon:new GIcon(this.routingPointTemplateIcon,"img/routing/dd-pointing.png"),draggable:false});var f=j[1].evalJSON();this.savedPoints=f.points?f.points:[];this.savedPaths=f.paths?f.paths:[];$("routing_selection").update(this.savedPathList=new Element("ul",{id:"savedPaths"}));for(var e=0;e<this.savedPaths.length;++e){this.addSavedPathEntry(this.savedPaths[e])}this.initForm()}.bind(this))}Routing.prototype.initForm=function(){var o="";var f;for(var k=0,g=this.routingModes.length;k<g;k++){f=this.routingModes[k];o+='<input id="routingRadio_'+f.id+'" type="radio" name="timeMode" '+(f.selected?'checked="checked"':"")+'/><label for="routingRadio_'+f.id+'">'+f.label+"</label>"+((k==g-1)?"":"<br/>")}$("routingModeOptions").innerHTML=o;if(this.routingModes.length==1){$("routingModeOptions").hide()}this.addRoutingPointForm();this.addRoutingPointForm();GEvent.bindDom($("routingLaunchButton"),"click",this,function(){if(this.validatePoints()){this.launchPath()}});GEvent.bindDom($("routingReverseButton"),"click",this,function(){this.reversePath()});GEvent.bindDom($("routingCancelButton"),"click",this,function(){this.clear()});var a=$("routingDate"),d=$("routingDateChoice"),c=$("routingHour"),n=$("routingHourChoice");GEvent.bindDom($("routingNow"),"click",this,function(){this.setCurrentTime()});GEvent.bindDom(a,"change",this,function(){this.checkDate()});GEvent.bindDom(c,"blur",this,function(){this.checkHour()});this.setCurrentTime();var e=new CalendarDateSelect(a,{month_year:"label",year_range:[2009,2010],embedded:true,valid_date_check:function(p){return(p.stripTime()>=(new Date).stripTime())}});var j=($$(".calendar_date_select")[0]).hide().setStyle({position:"absolute"});e.selected_date=new Date;e.options.set("onchange",function(){j.hide();d.hide();GEvent.clearListeners($("modalMask").hide())});GEvent.addDomListener($("routingDate_Today"),"click",function(){a.setValue((new Date).toFormattedString(false));d.hide()});GEvent.addDomListener($("routingDate_Tomorrow"),"click",function(){a.setValue((new Date((new Date).getTime()+86400000)).toFormattedString(false));d.hide()});GEvent.addDomListener($("routingDate_Specific"),"mouseover",function(){j.show();j.clonePosition(this,{setWidth:false,setHeight:false,offsetLeft:this.getWidth()})});GEvent.addDomListener($("routingDate_Today"),"mouseover",function(){j.hide()});GEvent.addDomListener($("routingDate_Tomorrow"),"mouseover",function(){j.hide()});GEvent.addDomListener($("routingDateCalendar"),"click",function(){j.hide();if(d.visible()){d.hide()}else{dropdownEqualsSize($("routingDateBlock"),d,2,function(){j.hide()})}});function h(p,q){elt=new Element("li").update(_padTimeUnit(p)+":"+_padTimeUnit(q));GEvent.addDomListener(elt,"click",function(){c.value=this.innerHTML;n.hide().update()});n.insert(elt)}function m(){var p=new Date;var r=$("routingDate").value.split("/");var s=0;if(r[2]==p.getFullYear()&&(parseInt(r[1])-1)==p.getMonth()&&r[0]==p.getDate()){s=p.getHours()}for(var q=s;q<24;++q){h(q,0);h(q,30)}dropdownEqualsSize($("routingHourBlock"),n,2)}GEvent.addDomListener($("routingHourIcon"),"click",function(){if(!n.visible()){m()}else{n.hide().update()}});this.reassignTabIndexes();if(!Prototype.Browser.IE){$("routingPointInput_0").focus()}GEvent.addDomListener($("routingTimeOptionsToggle"),"click",function(){GEvent.clearListeners(this,"click");$("routingSummaryOptions").hide();$("routingTimeOptions").show()})};Routing.prototype.onAllPathPolylines=function(a){var c;for(i=0;i<this.paths.length;++i){if((c=this.paths[i].pathResult)!=null&&c.polyline){a(c.polyline)}if((c=this.paths[i].refPathResult)!=null&&c.polyline){a(c.polyline)}}};Routing.prototype.clearResults=function(){$("routingReverseButton").hide();this.map.closeInfoWindow();this.onAllPathPolylines(function(a){this.map.removeOverlay(a)}.bind(this));this.paths=[];this.pathNb=0;$("routingResultList").innerHTML=""};Routing.prototype.clear=function(){this.clearResults();for(i=0;i<this.routingPoints.length;++i){if((marker=this.routingPoints[i].marker)!=null){this.map.removeOverlay(marker)}}this.routingPoints=[];this.routingPointHash=$H();this.pointBounds=new GLatLngBounds();this.pointingActiveSlot=-1;this.pointingListener=null;this.pointingCursorListener=null;this.routingPointSlotIndex=0;$("routingPointStack").innerHTML="";this.addRoutingPointForm();this.addRoutingPointForm();this.setCurrentTime();this.reassignTabIndexes();$("routingPointInput_0").focus();$("routingReverseButton").removeAttribute("disabled");$("routingLaunchButton").removeAttribute("disabled")};Routing.prototype.hide=function(){this.onAllPathPolylines(function(a){a.hide()});for(i=0;i<this.routingPoints.length;i++){if((marker=this.routingPoints[i].marker)!=null){marker.hide()}}};Routing.prototype.show=function(){this.onAllPathPolylines(function(a){a.show()});for(i=0;i<this.routingPoints.length;i++){if((marker=this.routingPoints[i].marker)!=null){marker.show()}}};Routing.prototype.setCurrentTime=function(){var a=new Date;$("routingDate").value=_padTimeUnit(a.getDate())+"/"+_padTimeUnit(a.getMonth()+1)+"/"+a.getFullYear();$("routingHour").value=_padTimeUnit(a.getHours())+":"+_padTimeUnit(a.getMinutes())};Routing.prototype.checkHour=function(){var c=$("routingHour").value.split(":");var a=((c.length==2)&&(parseInt(c[0],10)>=0)&&(parseInt(c[0],10)<24)&&(parseInt(c[1],10)>=0)&&(parseInt(c[1],10)<60));if(!a){alert("Format d'heure invalide.\nVeuillez entrer l'heure sous la forme :\nhh:mm");$("routingHour").select()}};Routing.prototype.checkDate=function(){var a=$("routingDate").value.split("/");var c=((a.length==3)&&(parseInt(a[0],10)>0)&&(parseInt(a[0],10)<=31)&&(parseInt(a[1],10)>0)&&(parseInt(a[1],10)<=12)&&(a[2].length==4)&&(parseInt(a[2],10)));if(!c){alert("Format de date invalide.\nVeuillez utiliser le calendrier ou entrer la date sous la forme :\njj/mm/aaaa");$("routingDate").select()}};Routing.prototype.pointByAddress=function(c){var a=$("routingPointInput_"+c).value.strip();if(a==""){this.reinitField(c);return}var d=this.routingPointHash["s"+c];if(a==d.address){return}this.geocoder.setViewport(this.map.getBounds());this.geocoder.getLocations(a,function(h){if((h.Status.code!=G_GEO_SUCCESS)||(h.Placemark[0].AddressDetails.Country.CountryNameCode!="FR")){$("routingGCError_"+c).update("Adresse inconnue").show()}else{if(h.Placemark.length>1){var e=$("routingGCSelect_"+c);e.update().appendChild(new Element("option",{value:-1}).update("Choisissez une localisation..."));var g;for(var j=0,f=h.Placemark.length;j<f;j++){if((g=h.Placemark[j]).AddressDetails.Country.CountryNameCode!="FR"){continue}this.addressChoices[j]=g;e.appendChild(new Element("option",{value:j}).update(this.locationToString(g)))}e.setStyle({width:$("routingPointInput_"+c).getWidth()+"px"}).show().focus()}else{this.addressEntered(d,h.Placemark[0])}}}.bind(this))};Routing.prototype.locationToString=function(d){var f=d.AddressDetails.Accuracy;if(f<4){return d.address}try{var a=d.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea,c=a.Locality;if(f>=6){return c.Thoroughfare.ThoroughfareName+", "+c.PostalCode.PostalCodeNumber+" "+c.LocalityName}return((f>=5)?c.PostalCode.PostalCodeNumber+" ":"")+c.LocalityName+" ("+a.SubAdministrativeAreaName+")"}catch(e){return d.address}};Routing.prototype.addressEntered=function(e,c){try{var a=c.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality;if(c.AddressDetails.Accuracy>=6){e.address=a.Thoroughfare.ThoroughfareName+", "+a.LocalityName}else{e.address=a.LocalityName}}catch(d){e.address=c.address}this.reverseGeocodePoint(e,new GLatLng(c.Point.coordinates[1],c.Point.coordinates[0]),false)};Routing.prototype.addressSelected=function(a){var c=$("routingGCSelect_"+a);this.addressEntered(this.routingPointHash["s"+a],this.addressChoices[c.options[c.selectedIndex].value]);this.addressChoices=[]};Routing.prototype.toggleClickingMode=function(a){if(this.pointingActiveSlot==-1){this.map.addOverlay(this.pointer);this.pointingCursorListener=GEvent.addListener(this.map,"mousemove",function(c){this.pointer.setLatLng(c)}.bind(this));this.pointingListener=GEvent.addListener(this.map,"click",function(c,d){this.pointByCoordinates(c,d)}.bind(this));this.pointingActiveSlot=a}else{this.turnClickingModeOff()}};Routing.prototype.turnClickingModeOff=function(){GEvent.removeListener(this.pointingListener);GEvent.removeListener(this.pointingCursorListener);this.map.removeOverlay(this.pointer);this.pointingActiveSlot=-1};Routing.prototype.reverseGeocodePoint=function(d,c,a){_logPageview("/vtactic/point");GDownloadUrl("proxy.aspx?mod=vtactic_getPoint&latitude="+c.lat()+"&longitude="+c.lng(),function(e){var f=GXml.parse(e).getElementsByTagName("node")[0];if((d.id=f.getAttribute("id"))==-1){$("routingGCError_"+d.slotIndex).update("V-Tactic n'est disponible que pour la France métropolitaine").show();this.setAddressInSlot(d);this.clearResults();return}$("routingGCError_"+d.slotIndex).hide();d.coords=new GLatLng(parseFloat(f.getAttribute("lat")),parseFloat(f.getAttribute("lng")));if(d.address==null){this.geocoder.getLocations(d.coords,function(h){if(h.Status.code!=G_GEO_SUCCESS&&f.getAttribute("address")!=null){d.address=f.getAttribute("address")}else{var j=h.Placemark[0];try{var g=j.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality;if(j.AddressDetails.Accuracy>=6){d.address=g.Thoroughfare.ThoroughfareName+", "+g.LocalityName}else{d.address=g.LocalityName}}catch(k){d.address=j.address}}this.setAddressInSlot(d);this.putMarkerForPoint(d);this.pointsChanged(a)}.bind(this))}else{this.setAddressInSlot(d);this.putMarkerForPoint(d);this.pointsChanged(a)}}.bind(this))};Routing.prototype.putMarkerForPoint=function(a){if(a.marker!=null){this.map.removeOverlay(a.marker)}a.marker=new GMarker(a.coords,{icon:this.routingPointTemplateIcon,draggable:true,bouncy:false});this.map.addOverlay(a.marker);GEvent.addListener(a.marker,"dragend",function(){this.dropPointMarker(a)}.bind(this));this.pointBounds.extend(a.coords);if(!this.map.getBounds().containsBounds(this.pointBounds)){this.map.setCenter(this.pointBounds.getCenter(),this.map.getBoundsZoomLevel(this.pointBounds))}};Routing.prototype.reinitField=function(a){};Routing.prototype.setAddressInSlot=function(d){$("routingGCError_"+d.slotIndex).hide();$("routingGCSelect_"+d.slotIndex).hide();var c=$("routingPointBlockIcon_"+d.slotIndex);GEvent.clearInstanceListeners(c);if(d.id!=-1){var a=(d.address=="")?("["+d.id+"]"):d.address;$("routingPointInput_"+d.slotIndex).value=a;GEvent.addDomListener(c,"click",function(){this.map.setCenter(d.coords)}.bind(this))}else{$("routingPointInput_"+d.slotIndex).value="";GEvent.addDomListener(c,"click",function(){this.toggleClickingMode(d.slotIndex)}.bind(this))}var c=$("savedPointsIcon_"+d.slotIndex);GEvent.clearListeners(c,"click");if(this.isSavedPoint(d)){c.src="img/common/bullet_star.png";c.alt=c.title="Cette adresse fait partie de vos favoris."}else{c.src="img/common/bullet_disk.png";c.alt=c.title="Ajouter cette adresse aux favoris.";GEvent.bindDom($("savedPointsIcon_"+d.slotIndex),"click",this,function(){this.savePointDialog(d)})}};Routing.prototype.showZoomedViewAt=function(c,a){this.map.showMapBlowup(new GLatLng(c,a))};Routing.prototype.pointByCoordinates=function(a,c){var d=this.routingPointHash["s"+this.pointingActiveSlot];$("routingGCError_"+this.pointingActiveSlot).hide();this.reverseGeocodePoint(d,c,false);this.turnClickingModeOff()};Routing.prototype.addRoutingPointForm=function(a){if(a==null){a=this.routingPoints.length}var d=this.routingPointSlotIndex++;var e;$("routingReverseButton").hide();Sortable.destroy("routingPointStack");var h=new Element("li",{"class":"routingPointBlock",id:"routingPointBlock_"+d}).update(this.POINT_SLOT_MARKUP.replace(/#/g,d));var g=this.routingPointHash["s"+d]=new RoutingPoint(null,null,null,null,d);if(a==this.routingPoints.length){$$(".routingAddPoint").each(function(j){j.update("Ajouter un point intermédiaire")});h.appendChild(new Element("a",{id:"routingAddPoint_"+d,"class":"routingAddPoint",href:"javascript:void(0)"}).update("Ajouter une destination"))}else{h.appendChild(new Element("a",{id:"routingAddPoint_"+d,"class":"routingAddPoint",href:"javascript:void(0)"}).update("Ajouter un point intermédiaire"))}this.routingPoints.splice(a,0,g);if($("routingPointStack").empty()){$("routingPointStack").appendChild(h)}else{$("routingPointBlock_"+this.routingPoints[a-1].slotIndex).insert({after:h})}var f=this.routingPoints.length;if(f==1){$("routingPointPrefix_"+d).update("De")}var c=$("routingPointInput_"+d);if(_isUserConnected()){c.setStyle({width:"245px"});GEvent.addDomListener($("savedPointsIcon_"+d).show(),"click",function(){this.displaySavedPoints(d)}.bind(this))}else{c.setStyle({width:"100%"})}var e=$("routingPointBlockIcon_"+d);GEvent.addDomListener(e,"click",function(){this.toggleClickingMode(d)}.bind(this));GEvent.addDomListener(e,"mouseover",function(){this.src="img/routing/dd-pointing.png"});GEvent.addDomListener(e,"mouseout",function(){this.src="img/routing/dd-pointing-light.png"});GEvent.addDomListener($("routingPointClose_"+d),"click",function(){this.removePoint(d)}.bind(this));GEvent.addDomListener(c,"change",function(){this.pointByAddress(d)}.bind(this));GEvent.addDomListener($("routingGCSelect_"+d),"change",function(){this.addressSelected(d)}.bind(this));GEvent.addDomListener($("routingAddPoint_"+d),"click",function(){var j;for(j=0;(j<this.routingPoints.length)&&(this.routingPoints[j].slotIndex!=d);++j){}$("routingPointInput_"+this.addRoutingPointForm(j+1)).focus();this.reassignTabIndexes()}.bind(this));if(f>=this.nbPointMax){$$(".routingAddPoint").each(function(j){j.hide()})}if(f>2){$$(".routingPointClose").each(function(j){j.show()})}Sortable.create("routingPointStack",{handle:"routingPointBlock",ghosting:false,onUpdate:function(j){this.pointOrderChanged()}.bind(this)});return d};Routing.prototype.reassignTabIndexes=function(){var a;for(a=0,l=this.routingPoints.length;a<l;a++){$("routingPointInput_"+this.routingPoints[a].slotIndex).setAttribute("tabindex",500+a)}$("routingLaunchButton").setAttribute("tabindex",500+a)};Routing.prototype.displaySavedPoints=function(d){var e=$("savedPointsIcon_"+d);if(this.savedPoints.length==0){return}var j=$("savedPointSelect").update();e.src="img/common/bullet_arrow_up.png";var a,f,c;var h=this.routingPointHash["s"+d];this.savedPoints.each(function(k){a=new Element("li").insert(c=new Element("img",{alt:"Supprimer",title:"Supprimer",src:"img/routing/bin_empty.png","class":"clickable",style:"float:right"})).insert(f=new Element("div",{style:"margin-right:18px;border-right:1px solid gray"}));if(k.label){f.insert("<strong>"+k.label+"</strong><br/>")}f.insert(k.address);GEvent.bindDom(c,"click",this,function(){this.deletePoint(k);e.src="img/common/bullet_arrow_down.png"});GEvent.bindDom(f,"click",this,function(){e.src="img/common/bullet_arrow_down.png";j.hide();h.id=k.id;h.coords=new GLatLng(k.lat,k.lng);h.address=k.address;this.setAddressInSlot(h);this.putMarkerForPoint(h);this.pointsChanged(false)});j.insert(a)}.bind(this));var g=$($("routingPointInput_"+d).parentNode);dropdownEqualsSize(g,j,2,function(){e.src="img/common/bullet_arrow_down.png"})};Routing.prototype.getPathUsingPoint=function(a){var d=[];for(var c=0;c<this.savedPaths.length;++c){if(this.savedPaths[c].points.indexOf(a.id)!=-1){d.push(this.savedPaths[c])}}return d};Routing.prototype.deletePoint=function(a){var c=this.getPathUsingPoint(a);if(c.length==0||window.confirm("Vos chemins sauvegardés qui utilisent ce point seront également supprimés.")){GDownloadUrl("routing.aspx?action=delPt&pt="+a.id,function(d,e){if(e==200&&d=="OK"){var f;for(f=0;f<this.savedPoints.length;++f){if(this.savedPoints[f].id==a.id){break}}this.savedPoints.splice(f,1);$("savedPointSelect").hide();for(f=0;f<c.length;++f){this.removeSavedPathEntry(c[f]);this.savedPaths.splice(f,1)}}}.bind(this))}};Routing.prototype.deletePath=function(a){GDownloadUrl("routing.aspx?action=delPa&pa="+a.id,function(c,d){if(d==200&&c=="OK"){this.removeSavedPathEntry(a);this.savedPaths.splice(this.savedPaths.indexOf(a),1)}}.bind(this))};Routing.prototype.savePointDialog=function(d){var a;if((a=$("savePoint")).visible()){a.hide();return}GEvent.clearNode($("savedPointOk"));GEvent.bindDom($("savedPointOk"),"click",this,function(){this.savePoint(d,$("savedPointLabel").value)});var c=$($("routingPointInput_"+d.slotIndex).parentNode);dropdownEqualsSize(c,a,2);if(!Prototype.Browser.IE){$("savedPointLabel").focus().value=""}else{$("savedPointLabel").value=""}};Routing.prototype.isSavedPoint=function(c){for(var a=0;a<this.savedPoints.length;a++){if(this.savedPoints[a].id==c.id){return true}}return false};var _pointsToSaveStack=[];var _callbackStack=[];Routing.prototype.savePoint=function(a,e,d){if(d){a=_pointsToSaveStack.pop();e=""}var c="routing.aspx?action=addPt&pt="+a.id+"&a="+a.address+"&lat="+a.coords.lat()+"&lng="+a.coords.lng();if(e&&e!=""){c+="&l="+e}GDownloadUrl(c,function(f,g){if(g==200&&f=="OK"){this.savedPoints.push({label:e,address:a.address,id:a.id,lat:a.coords.lat(),lng:a.coords.lng()});$("savePoint").hide();var h=$("savedPointsIcon_"+a.slotIndex).writeAttribute({src:"img/common/bullet_star.png",title:"Cette adresse fait partie de vos favoris."});GEvent.clearListeners(h,"click");if(d){(_callbackStack.pop())()}}}.bind(this))};Routing.prototype.savePointsAndPath=function(d){_callbackStack=[];_pointsToSaveStack=[];_callbackStack.push(function(){this.savePath(d)}.bind(this));var c=d.params.points;for(var a=0;a<c.length;a++){if(!this.isSavedPoint(c[a])){_pointsToSaveStack.push(c[a]);_callbackStack.push(function(){this.savePoint(null,null,true)}.bind(this))}}(_callbackStack.pop())()};Routing.prototype.savePath=function(d,c){var a="routing.aspx?action=addPa&pts=";d.params.points.each(function(e){a+=e.id+"|"});if(c){a+="&l="+c}GDownloadUrl(a,function(e,f){if(f==200&&e!="-1"){GEvent.clearListeners($("savePath_"+d.order).removeClassName("savePathToggle").addClassName("savePathToggleSaved").update("Itinéraire sauvegardé"));var g={id:parseInt(e),label:c,points:d.getPoints()};this.savedPaths.push(g);this.addSavedPathEntry(g)}}.bind(this))};Routing.prototype.getPointFromId=function(c){for(var a=0;a<this.savedPoints.length;++a){if(this.savedPoints[a].id==c){return(this.savedPoints[a])}}return null};Routing.prototype.getSavedPointTag=function(a,e,d){var c=new Element("span",{"class":"viaPt "+e,href:"javascript:void(0)",title:a.address}).update(a.label?a.label:a.address);return c};Routing.prototype.restoreSavedPath=function(e){this.clear();var a,d;for(var c=0;c<e.points.length;++c){if(c>=this.routingPoints.length){this.addRoutingPointForm()}a=this.getPointFromId(e.points[c]);(d=this.routingPoints[c]).restoreSaved(a);this.setAddressInSlot(d);this.putMarkerForPoint(d)}this.reassignPointIcons();this.launchPath()};Routing.prototype.removeSavedPathEntry=function(a){$("savedPath_"+a.id).remove()};Routing.prototype.addSavedPathEntry=function(e){var f,c;var a=new Element("li",{id:"savedPath_"+e.id}).update("De ").insert(this.getSavedPointTag(this.getPointFromId(e.points[0]),"from",0));a.insert(" à ").insert(this.getSavedPointTag(this.getPointFromId(e.points[e.points.length-1]),"to",e.points.length-1));if(e.points.length>2){a.insert("<br/>&nbsp;-&nbsp;par ");for(var d=1;d<e.points.length-1;++d){if(d!=1){a.insert(", ")}a.insert(this.getSavedPointTag(this.getPointFromId(e.points[d]),"through",d))}}a.insert(new Element("div",{"class":"actions"}).insert(f=new Element("a",{"class":"launch",href:"javascript:void(0)"}).update("Calculer")).insert("&nbsp;|&nbsp;").insert(c=new Element("a",{"class":"del",href:"javascript:void(0)"}).update("Supprimer")));GEvent.bindDom(f,"click",this,function(){this.restoreSavedPath(e)});GEvent.bindDom(c,"click",this,function(){this.deletePath(e)});this.savedPathList.insert(a)};Routing.prototype.setEditingMode=function(a,c){if(c){a.value="";a.style.color="black";a.style.fontStyle="normal"}else{a.value=this.getExampleAddressString();a.style.color="silver";a.style.fontStyle="italic"}};Routing.prototype.getExampleAddressString=function(){return("Ex : 121 rue de Rivoli, Paris")};Routing.prototype.removePoint=function(c){if(this.pointingActiveSlot==c){this.turnClickingModeOff()}var a=this.routingPointHash["s"+c].marker;if(a){this.map.removeOverlay(a)}$("routingPointStack").removeChild($("routingPointBlock_"+c));this.routingPointHash.unset("s"+c);var d;for(d=0;d<this.routingPoints.length;d++){if(this.routingPoints[d].slotIndex==c){this.routingPoints.splice(d,1);break}}if(d==0){$("routingPointPrefix_"+this.routingPoints[d].slotIndex).update("De")}else{if(d==this.routingPoints.length){$("routingAddPoint_"+this.routingPoints[d-1].slotIndex).update("Ajouter une destination")}}if(this.routingPoints.length<this.nbPointMax){$$(".routingAddPoint").each(function(e){e.show()})}this.recomputeViewBounds();this.pointsChanged(false);if(this.routingPoints.length==2){$$(".routingPointClose").each(function(e){e.hide()})}this.reassignTabIndexes()};Routing.prototype.reversePath=function(){var a,g,f,e;var d=this.routingPoints.length;for(var c=0;c<d/2;c++){g=this.routingPoints[c];f=this.routingPoints[d-1-c];a=g.slotIndex;g.slotIndex=f.slotIndex;f.slotIndex=a;this.setAddressInSlot(g);this.setAddressInSlot(f);this.routingPoints[d-1-c]=g;this.routingPoints[c]=f}this.reassignPointIcons();this.launchPath()};Routing.prototype.pointOrderChanged=function(){var f=Sortable.serialize("routingPointStack",{name:"i"});this.routingPoints=[];var a=f.split("&"),d;for(var e=0,c=a.length;e<c;e++){d=a[e].slice(4);this.routingPoints.push(this.routingPointHash["s"+d]);$("routingPointPrefix_"+d).update((e==0)?"De":"À");$("routingAddPoint_"+d).update((e==c-1)?"Ajouter une destination":"Ajouter un point intermédiaire")}this.reassignTabIndexes();this.pointsChanged(false)};Routing.prototype.pointsChanged=function(a){$("routingReverseButton").hide();this.reassignPointIcons();if(this.paths.length!=0){this.onAllPathPolylines(function(c){this.map.removeOverlay(c)}.bind(this));if(this.validatePoints()&&(this.autoRecompute||a)){this.recomputePaths()}else{this.clearResults()}}};Routing.prototype.recomputeViewBounds=function(){this.pointBounds=new GLatLngBounds();this.routingPoints.each(function(a){if(a.coords!=null){this.pointBounds.extend(a.coords)}}.bind(this));if(!this.map.getBounds().containsBounds(this.pointBounds)){this.map.setCenter(this.pointBounds.getCenter(),this.map.getBoundsZoomLevel(this.pointBounds))}};Routing.prototype.reassignPointIcons=function(){var a,c;var d=0;var e;for(i=0;i<this.routingPoints.length;i++){a=this.routingPoints[i];if(a.id!=null){e=$("routingPointBlockIcon_"+a.slotIndex);if(i==0){a.marker.setImage("img/routing/dd-start.png");e.src="img/routing/dd-start.png"}else{a.marker.setImage("img/routing/dd-wp"+i+".png");e.src="img/routing/dd-wp"+i+".png"}e.style.display="block";c=a}}if((c!=null)&&(c!=this.routingPoints[0])){c.marker.setImage("img/routing/dd-end.png");$("routingPointBlockIcon_"+c.slotIndex).src="img/routing/dd-end.png"}};Routing.prototype.dropPointMarker=function(a){a.address=null;this.reverseGeocodePoint(a,a.marker.getLatLng(),true);this.recomputeViewBounds()};Routing.prototype.recomputePaths=function(){if(!this.validatePoints()){return}for(i=0;i<this.paths.length;i++){this.paths[i].params.points=this.routingPoints;this.queryPath(this.paths[i].params,this.paths[i].order,i)}};Routing.prototype.validatePoints=function(){for(var a=0;a<this.routingPoints.length;a++){if(this.routingPoints[a].id==null||this.routingPoints[a].id==-1){return false}}return true};Routing.prototype.getRoutingMode=function(){for(var a=0;a<this.routingModes.length;a++){if($("routingRadio_"+this.routingModes[a].id).checked){return this.routingModes[a]}}return 0};Routing.prototype.launchPath=function(){this.map.closeInfoWindow();if(!this.multiResultDisplay){this.onAllPathPolylines(function(e){this.map.removeOverlay(e)}.bind(this));this.paths=[];this.pathNb=0;$("routingResultList").innerHTML=""}this.addResultBlock(++this.pathNb);var c=$("routingDate").value.split("/");var d=$("routingHour").value.split(":");var a=new Date(c[2],parseInt(c[1],10)-1,c[0],d[0],d[1]);if(a<new Date){this.setCurrentTime();a=new Date}this.queryPath(new PathParams(this.routingPoints,this.getRoutingMode(),a,$("routingDepartureRadio").checked),this.pathNb,-1)};Routing.prototype.queryPath=function(d,a,c){_logPageview("/vtactic/path");this.toggleLoadingResult(a,true);GDownloadUrl("proxy.aspx?mod=vtactic_getIti",function(p,g){if(g!=200){this.displayPathError(1,a)}else{var j,e;try{var n=GXml.parse(p).getElementsByTagName("method");j=n[0].getElementsByTagName("path")[0];e=n[1].getElementsByTagName("path")[0]}catch(f){}var o=(j==null)?new Path(d,-1,null,null,a):new Path(d,0,new PathResult(j),(e==null?null:new PathResult(e)),a);if(!this.multiResultDisplay){this.paths[0]=o}else{if(c==-1){this.paths.push(o)}else{this.paths[c]=o}}if(o.errorState==0){var k;this.map.addOverlay(k=o.pathResult.polyline);var m=k.getBounds();var h=this.map.getBoundsZoomLevel(m);if(!this.map.getBounds().containsBounds(m)||(h-this.map.getZoom())>2){this.map.setCenter(m.getCenter(),h)}this.displayRoadmap(o);$("routingReverseButton").show()}else{$("routingResultHeader_"+o.order).update(new Element("p",{"class":"routingError"}).update("Nous n'avons pas pu calculer d'itinéraire entre ces deux points. Veuillez nous en excuser."))}}this.toggleLoadingResult(a,false)}.bind(this),"query="+d.toQuery())};Routing.prototype.displayPathError=function(c,a){if(c==1){$("routingResultHeader_"+a).innerHTML="<strong>ERREUR SERVEUR !<strong>"}};Routing.prototype.toggleLoadingResult=function(a,c){if(c){$("routingLaunchButton").setAttribute("disabled","disabled");$("routingReverseButton").setAttribute("disabled","disabled");$("routingResultLoading_"+a).show();$("routingResult_"+a).hide()}else{$("routingResult_"+a).show();$("routingResultLoading_"+a).hide();$("routingReverseButton").removeAttribute("disabled");$("routingLaunchButton").removeAttribute("disabled")}};Routing.prototype.addResultBlock=function(c){var d=new Element("li",{"class":"routingResultBlock",id:"routingResultBlock_"+c}).update(new Element("div",{id:"routingResultLoading_"+c,"class":"routingResultLoading"}).update('<img src="img/routing/loading.gif" alt="Calcul du chemin..." />').hide());var a=new Element("div",{id:"routingResult_"+c}).insert(new Element("div",{id:"routingResultHeader_"+c,"class":"routingResultHeader"})).insert(new Element("div",{id:"routingResultGain_"+c,"class":"routingResultGain small_text"}).hide()).insert(new Element("div",{id:"roadmap_"+c,"class":"roadmap"})).insert(new Element("div",{id:"savePath_"+c,"class":"small_text"}).hide());$("routingResultList").insert(d.insert(a))};Routing.prototype.displayRoadmap=function(n){var g,q;if(n.params.timeMode){g=n.params.trafficTime;q=new Date(n.params.trafficTime.getTime()+n.pathResult.dynamicSeconds*1000)}else{q=n.params.trafficTime;g=new Date(n.params.trafficTime.getTime()-n.pathResult.dynamicSeconds*1000)}var t=new Template(n.params.routingMode.summaryTemplate).evaluate({label:n.params.routingMode.label,distance:formatDistance(n.pathResult.distance),staticTime:formatTime(n.pathResult.staticSeconds,false),refTime:formatTime(n.pathResult.refSeconds,false),dynTime:formatTime(n.pathResult.dynamicSeconds,false),depTime:formatHourMinTime(g),arrTime:formatHourMinTime(q)});$("routingResultHeader_"+n.order).update(t);if(n.refPathResult!=null&&(n.refPathResult.dynamicSeconds-n.pathResult.dynamicSeconds)>60){$("routingResultGain_"+n.order).update(formatTime(n.refPathResult.dynamicSeconds-n.pathResult.dynamicSeconds,false)+" de moins que <span id='classicRouteLabel' style='border-bottom:1px dashed #6AB023;cursor:help'>l'itinéraire classique</span>&nbsp;-&nbsp;").insert(new Element("input",{type:"checkbox",id:"routingDispRef_"+n.order,checked:false,style:"vertical-align:bottom;"})).insert(new Element("label",{"class":"small_text","for":"routingDispRef_"+n.order}).update("Afficher")).show();$("classicRouteLabel").observe("mousemove",function(v){tooltip($("classicRouteExpl"),v,true)});$("classicRouteLabel").observe("mouseout",function(v){tooltip($("classicRouteExpl"),v,false)});GEvent.clearListeners($("routingDispRef_"+n.order));GEvent.bindDom($("routingDispRef_"+n.order),"click",this,function(){if($("routingDispRef_"+n.order).checked){this.map.addOverlay(n.refPathResult.polyline)}else{this.map.removeOverlay(n.refPathResult.polyline)}})}else{$("routingResultGain_"+n.order).hide()}var o=n.pathResult.roadmap.getElementsByTagName("section");var d=n.pathResult.roadmap.getElementsByTagName("turn");var k,p;var h;var f=0;var m=$("roadmap_"+n.order);var c;m.update(new Element("div",{"class":"rmViaPoint"}).update("<img alt='' src='img/routing/flag_green.png'/>&nbsp;<strong>"+this.routingPoints[0].address+"</strong><div class='small_text'>Départ à "+formatHourMinTime(g)+"</div>"));var a,u,e;m.insert(a=new Element("a",{id:'rmToggle_"+path.order+"',style:"background:transparent url(img/common/bullet_toggle_plus.png) no-repeat scroll left center;font-size:0.9em;padding-left:15px;float:left",href:"javascript:void(0)"}).update("Feuille de route"));if(this.rmToggleState){a.setStyle({backgroundImage:"url(img/common/bullet_toggle_minus.png)"})}m.insert(u=new Element("a",{id:"rmPrint",style:"background:transparent url(img/routing/printer.png) no-repeat scroll left center;padding-left:20px;line-height:16px;float:right",href:"javascript:void(0)"}).update("Imprimer"));GEvent.bindDom(u,"click",this,function(){this.printWindow=window.open("printableRoadmap.aspx?q="+n.params.toQuery())});m.insert(e=new Element("div",{"class":"rmTableWrapper",style:"display:"+(this.rmToggleState?"block":"none")}).insert(new Element("table",{id:"rmTable_"+n.order}).insert(c=new Element("tbody"))));var j,r;for(var s=0;s<o.length;++s){k=o[s];p=parseInt(k.getAttribute("dyn-time"))/10;f+=p;h=(s==0)?"Prenez ":((d.length!=0)?this.angleToDrivingDirection(parseFloat(d[s-1].getAttribute("angle"))):"Continuez sur ");r=k.getElementsByTagName("rc");r=(!r)?0:r[0].getAttribute("v");c.appendChild(this.createRoadmapSection(k,s,p,f,h,r))}$$("#roadmap_"+n.order+" tbody > tr:nth-child(odd)").each(function(v){v.addClassName("odd")});m.insert(new Element("div",{"class":"rmViaPoint"}).update("<div class='small_text'>Arrivée à "+formatHourMinTime(q)+"</div><img alt='' src='img/routing/flag_red.png'/>&nbsp;<strong>"+this.routingPoints[this.routingPoints.length-1].address+"</strong>"));GEvent.bindDom(a,"click",this,function(){if(this.rmToggleState){a.setStyle({backgroundImage:"url(img/common/bullet_toggle_plus.png)"});e.hide()}else{a.setStyle({backgroundImage:"url(img/common/bullet_toggle_minus.png)"});e.show()}this.rmToggleState=!this.rmToggleState});if(!_isUserConnected()){$("savePath_"+n.order).update("Inscrivez-vous à Mon V-Trafic pour sauvegarder vos itinéraires").show()}else{GEvent.bindDom($("savePath_"+n.order).update("Sauvegarder cet itinéraire").removeClassName("savePathToggleSaved").addClassName("savePathToggle").show(),"click",this,function(){this.savePointsAndPath(n)})}};Routing.prototype.createRoadmapSection=function(d,e,f,c,j,a){var k=new Element("tr").insert(new Element("td",{"class":"rmSecNum"}).update(e+1)).insert(new Element("td",{"class":"rmSecDetails"}).update(j+"<strong>"+d.getAttribute("name")+"</strong><br /><span class='rmSecLen'>sur "+formatDistance(d.getAttribute("length"))+", pendant "+formatTime(f,true)+"</span>")).insert(new Element("td",{"class":"rmSecTime"}).update(formatTime(c,true))).insert(new Element("td",{"class":"rmSecRC",style:"background-color:"+this.rcToColor[a]}).update("&nbsp;"));var g=d.getAttribute("lat"),h=d.getAttribute("lng");GEvent.bindDom(k,"click",this,function(){this.showZoomedViewAt(g,h)});return k};Routing.prototype.angleToDrivingDirection=function(d){var a=Math.abs(d);if(a>(5*Math.PI/6)){return"<img src='img/routing/arrow_up.png' class='png' alt=''/>&nbsp;Continuez sur "}var c=(a==d)?"à droite sur ":"à gauche sur ";return"<img src='img/routing/arrow_turn_"+((a==d)?"right":"left")+".png' class='png' alt=''/>&nbsp;"+((a>(2*Math.PI/3))?("Tournez légèrement "+c):("Tournez "+c))};function formatTime(f,a){var g=parseInt(f/3600);var d=parseInt((f%3600)/60);var e=parseInt(f-(g*3600+d*60));var c;if(a){if(g==0){c=d+"'";if(d<10&&e!=0){c+=_padTimeUnit(e)+"''"}}else{c=g+"h"+_padTimeUnit(d)}}else{c=(g==0)?(d+" min"):(g+"h"+_padTimeUnit(d))}return c}function formatDistance(a){var c=parseInt(a);return(c<1000)?(""+c+" m"):(""+parseInt(c/1000)+" km")}function formatHourMinTime(a){return""+a.getHours()+"h"+_padTimeUnit(a.getMinutes())}function dropdownEqualsSize(c,f,d,e){var a=$("modalMask").show();GEvent.bindDom(a,"click",a,function(){GEvent.clearListeners(f.hide());GEvent.clearListeners(this.hide());if(e){e()}});f.setStyle({width:(c.getWidth()-d)+"px"}).clonePosition(c,{setWidth:false,setHeight:false,offsetTop:c.getHeight()}).show();GEvent.bindDom(f,"click",this,function(){GEvent.clearListeners(a.hide());GEvent.clearListeners(this)})};