(function(){var b=this.Store=function(d,e,g){var h=this;this.name=d;this.listeners={};if(e){for(var i in e){if(e.hasOwnProperty(i)&&this.get(i)===undefined){this.set(i,e[i])}}}var j=function(l,m){([l,"*"]).each(function(n){if(h.listeners[n]){h.listeners[n].each(function(o){o(m,l,h.name)})}})};var c=this.toObject();var f=function(){k(true)};var k=function(n){if(Object.keys(h.listeners).length!==0){var l=h.toObject();if(!n){for(var m in l){if(l.hasOwnProperty(m)&&l[m]!==c[m]){j(m,l[m])}}for(var m in c){if(c.hasOwnProperty(m)&&!l.hasOwnProperty(m)){j(m,l[m])}}}c=l;setTimeout(k,(g||300))}else{setTimeout(f,1000)}};f()};b.__proto__=function a(){};b.__proto__.clear=function(){localStorage.clear()};b.prototype.get=function(c){var d=localStorage.getItem("store."+this.name+"."+c);if(d===null){return}try{return JSON.parse(d)}catch(f){return null}};b.prototype.set=function(c,d){if(d===undefined){this.remove(c)}else{if(typeof d==="function"){d=null}else{try{d=JSON.stringify(d)}catch(f){d=null}}localStorage.setItem("store."+this.name+"."+c,d)}return this};b.prototype.remove=function(c){localStorage.removeItem("store."+this.name+"."+c);return this};b.prototype.removeAll=function(){var c="store."+this.name+".";for(var d=(localStorage.length-1);d>=0;d--){if(localStorage.key(d).substring(0,c.length)===c){localStorage.removeItem(localStorage.key(d))}}return this};b.prototype.toObject=function(){var c={};var d="store."+this.name+".";for(var f=(localStorage.length-1);f>=0;f--){if(localStorage.key(f).substring(0,d.length)===d){var e=localStorage.key(f).substring(d.length);var g=this.get(e);if(g!==undefined){c[e]=g}}}return c};b.prototype.fromObject=function(c,e){if(!e){this.removeAll()}for(var d in c){if(c.hasOwnProperty(d)){this.set(d,c[d])}}return this};b.prototype.addEvent=function(c,d){if(!this.listeners[c]){this.listeners[c]=[]}this.listeners[c].push(d);return this};b.prototype.removeEvent=function(c,e){for(var d=(this.listeners[c].length-1);d>=0;d--){if(this.listeners[c][d]===e){this.listeners[c].splice(d,1)
}}if(this.listeners[c].length===0){delete this.listeners[c]}return this}})();if(!("localStorage" in window)){window.Store=function(){this.get=function(){return};this.set=function(){};this.removeAll=function(){};this.addEvent=function(){};this.removeEvent=function(){}}}if(typeof(AjaxGeocoder)=="undefined"){var AjaxGeocoder=Class.create({initialize:function(a){if(typeof(Autocomplete)=="undefined"){throw ("Autocomplete is not defined")}var b=$(a);if(!this.serviceUrl){this.serviceUrl="/ajaxv1/Geocoder/search"}var d=new Element("input",{type:"hidden",value:""});if(b.value!=""&&b.value.match(/^[0-9]+$/)){b.hide();b.disabled=true;AjaxGeocoder.getAreaInfos(b.value,{onSuccess:function(i){var h=i.responseText.evalJSON();d.value=b.value;$(b).value=h.infos.full_label;b.show();b.disabled=false}})}else{b.disabled=false}["id","name"].each(function(h){if(b[h]){d[h]=b[h];b[h]="autocomplete_"+b[h]}});b.insert({after:d});var g=Autocomplete;var f=new Element("img",{src:"/images/ajax-loader.gif"});f.hide();g.prototype.getSuggestions=g.prototype.getSuggestions.wrap(function(h){f.show();return h()});g.prototype.suggest=g.prototype.suggest.wrap(function(h){f.hide();return h()});new g(b,{serviceUrl:this.serviceUrl,minChars:2,maxHeight:400,width:300,deferRequestBy:300,onSelect:function(i,h){d.value=h}});var e;var c;b.observe("focus",function(){e=d.value;c=b.value;d.value="none";b.value=""});b.observe("blur",function(){if(d.value=="none"){d.value=e;b.value=c}});b.observe("keypress",function(h){if(h.keyCode==13){h.stopPropagation();h.preventDefault()}});b.addClassName("autocomplete");b.insert({after:f})}});var AjaxGeoCity=Class.create(AjaxGeocoder,{initialize:function($super,a){this.serviceUrl="/ajaxv1/Geocoder/searchCity";$super(a)}});AjaxGeocoder.NO_COUNTRY="";AjaxGeocoder.NO_REGION="";AjaxGeocoder.COUNTRY_ACCURACY=1;AjaxGeocoder.REGION_ACCURACY=2;AjaxGeocoder.SUBREGION_ACCURACY=3;AjaxGeocoder.TOWN_ACCURACY=4;AjaxGeocoder.SHOW_HIDDEN=0;AjaxGeocoder.DEBUG_INFOS=0;AjaxGeocoder.NOCACHE=0;AjaxGeocoder.getSubAreas=function(d,c){var b={method:"get"};
Object.extend(b,c||{});var a="/ajaxv1/Geocoder/getSubAreas?id="+d;if(AjaxGeocoder.SHOW_HIDDEN==1){a+="&show_hidden=1"}if(AjaxGeocoder.DEBUG_INFOS==1){a+="&debug_infos=1"}if(AjaxGeocoder.NOCACHE==1&&d!=""){a+="&nocache=1"}new Ajax.Request(a,b)};AjaxGeocoder.getAreaInfos=function(c,b){var a={method:"get"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Geocoder/getAreaInfos?id="+c,a)};AjaxGeocoder.getFRData=function(b){var a={method:"get"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Geocoder/getFRData",a)};AjaxGeocoder.getDescendantsByAccuracy=function(d,c,b){var a={method:"get"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Geocoder/getDescendantsByAccuracy?accuracy="+c+"&id="+d+"&show_hidden="+AjaxGeocoder.SHOW_HIDDEN+"&debug_infos="+AjaxGeocoder.DEBUG_INFOS,a)};AjaxGeocoder.getUserOldLocation=function(b){var a={method:"get"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Geocoder/getUserOldLocation?",a)};AjaxGeocoder.search=function(c,b){var a={method:"GET"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Geocoder/search?query="+c,a)};AjaxGeocoder.searchCity=function(c,b){var a={method:"GET"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Geocoder/searchCity?query="+c,a)};AjaxGeocoder.searchByCoords=function(d,c,b){var a={method:"GET"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Geocoder/searchByCoords?latitude="+d+"&longitude="+c,a)};(function(){var a="AjaxGeoCity";var b=function(c){new AjaxGeoCity(c)};if(typeof(AjaxUI)=="undefined"){Event.observe(window,"load",function(){$$("."+a).each(function(c){b(c)})})}else{AjaxUI.subscribe(a,b)}})();(function(){var a="AjaxGeocoder";var b=function(c){new AjaxGeocoder(c)};if(typeof(AjaxUI)=="undefined"){Event.observe(window,"load",function(){$$("."+a).each(function(c){b(c)})})}else{AjaxUI.subscribe(a,b)}})()}if(typeof(AjaxStorage)=="undefined"){var AjaxStorage=Class.create({});AjaxStorage.setUserPref=function(f,c,b){try{var a={method:"post",postBody:"data="+escape(c)};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Storage/setUserPref?id="+f.join(","),a)
}catch(d){console.error(d)}};AjaxStorage.getUserPref=function(c,b){var a={method:"get"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Storage/getUserPref?id="+c.join(","),a)};AjaxStorage.setSessionPref=function(f,c,b){try{var a={method:"post",postBody:"data="+escape(c)};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Storage/setSessionPref?id="+f.join(","),a)}catch(d){console.error(d)}};AjaxStorage.getSessionPref=function(c,b){var a={method:"get"};Object.extend(a,b||{});new Ajax.Request("/ajaxv1/Storage/getSessionPref?id="+c.join(","),a)}}if(typeof(FRDeptSelector)=="undefined"){function similar_text(c,b){function d(k,f,j,e){function g(n,r,m,p){var v=0,t=0,u=0,s,q,o;for(s=0;s<r;++s){for(q=0;q<p;++q){for(o=0;(s+o<r)&&(q+o<p)&&(n.charAt(s+o)==m.charAt(q+o));++o){}if(o>u){u=o;v=s;t=q}}}return{pos1:v,pos2:t,max:u}}var i=g(k,f,j,e);var h=i.max;if(h){if(i.pos1&&i.pos2){h+=d(k,i.pos1,j,i.pos2)}if((i.pos1+i.max<f)&&(i.pos2+i.max<e)){h+=d(k.substr(i.pos1+i.max),f-i.pos1-i.max,j.substr(i.pos2+i.max),e-i.pos2-i.max)}}return h}var a=d(c,c.length,b,b.length);return{similar:a,percent:a*200/(c.length+b.length)}}var FRDeptSelector=Class.create({observe:function(c,a,b){a.each(function(d){Event.observe(c,d,b)})},initialize:function(B){var B=$(B);var s=B;var p=B.select("[id=regions]").first();var b=B.select("[id=pays]").first();var m=B.select("[id=region]").first();var i=B.select("[id=dept]").first();var x=B.select("[id=villeSelector]").first();var r=" - "+gettext("Choisissez")+" - ";var d=gettext("Chargement...");var f=" - "+gettext("Vide")+" - ";var a=null;var v={pays:"",region:"",dept:""};var n=16;var w=n;var C=new Store("FRDeptSelector");var z=function(e){e.update("");e.insert((new Element("option",{value:""})).update(r));e.value="";e.disabled=false};var o=function(e){z(e);e.disabled=true};var u=function(e){e.disabled=true;e.update("");e.insert((new Element("option",{value:""})).update(d))};var y=function(e){if(e.childElements().size()==1){e.disabled=true;e.update("");e.insert((new Element("option",{value:""})).update(f))
}};var g=function(e){u(b);AjaxGeocoder.getSubAreas(AjaxGeocoder.NO_REGION,{onSuccess:function(F){var E=F.responseText.evalJSON();var D=[];z(b);E.items.each(function(H){var G=new Element("option",{value:H.id});if(H.label=="separator"){G.update("-----------------")}else{G.update(H.label)}b.insert(G)});if(e){e()}l()}})};var l=function(){if(typeof(AjaxStorage)!="undefined"){}};var c=function(){u(m);u(i);AjaxGeocoder.getFRData({onSuccess:function(D){var e=D.responseText.evalJSON();a=e.fr_id;z(m);z(i);e.regions.each(function(E){m.insert((new Element("option",{value:E.id})).update(E.label))});e.depts.each(function(E){i.insert((new Element("option",{value:E.id})).update(E.label))});m.fire(":updated");i.fire(":updated");l()}})};var h=false;var k=function(){p.value="";$A([b,m,i]).each(function(D){if(D.value!=""){p.value=D.value}});C.set("pays",b.value);C.set("region",m.value);C.set("dept",i.value);if(x){x.fire("location:reset")}h=true};var q=function(){v.pays=b.value;o(m);o(i);k();if(b.value==""){return}if(b.select("option").toArray()[b.selectedIndex].value==n){c()}else{u(m);u(i);AjaxGeocoder.getDescendantsByAccuracy(b.value,AjaxGeocoder.REGION_ACCURACY,{onSuccess:function(D){var e=D.responseText.evalJSON();z(m);e.items.each(function(F){if(F.oldpays=="0"){return}if(typeof m.childElements().last()!="undefined"){var E=similar_text(m.childElements().last().innerHTML,F.label);if(E.percent>=95){m.childElements().last().value+=","+F.id;return}}m.insert((new Element("option",{value:F.id})).update(F.label))});y(m);l()}});AjaxGeocoder.getDescendantsByAccuracy(b.value,AjaxGeocoder.SUBREGION_ACCURACY,{onSuccess:function(D){var e=D.responseText.evalJSON();z(i);e.items.each(function(F){if(F.oldpays=="0"){return}if(typeof i.childElements().last()!="undefined"){var E=similar_text(i.childElements().last().innerHTML,F.label);if(E.percent>=95){i.childElements().last().value+=","+F.id;return}}i.insert((new Element("option",{value:F.id})).update(F.label))});y(i);l()}})}};var t=function(){if(b.value==""){b.value=w
}i.value="";k()};var A=function(){if(b.value==""){b.value=w}m.value="";k()};this.observe(b,["change","keyup"],q);this.observe(m,["change"],t);this.observe(i,["change"],A);if(!b.empty()){g=function(e){if(e){e()}}}if(C.get("pays")){var j=function(){if(C.get("pays")){if(h){return}var e=C.get("pays");if(e==""){return}b.value=e;if(b.value!=w||m.select("option").size()==1){q()}k()}};g(j)}else{if(m.empty()||i.empty()){c();g()}}if(x){new LocationGeocoder(x);x.observe("location:select",function(e){b.value="";p.value=unescape(e.memo.data);o(m);o(i)})}}});(function(){var a="FRDeptSelector";var b=function(c){new FRDeptSelector(c)};if(typeof(AjaxUI)=="undefined"){Event.observe(window,"load",function(){$$("."+a).each(function(c){b(c)})})}else{AjaxUI.subscribe(a,b)}})()};