var it_CarForm=function(c,a){a=Object.append({imgDir:it_basePath+"img/",autoCompleteQueryUrl:it_basePath+"car/suggest.html"+it_languageParameter,autoCompleteOptions:null,departureDateOptions:{dayOfWeekElement:"car_departureDate.dayOfWeek",anchorElement:"car_departureCalendarImg",shortYear:true},returnDateOptions:{dayOfWeekElement:"car_returnDate.dayOfWeek",anchorElement:"car_returnCalendarImg",shortYear:true},departureCity:"",departureDate:null,departureTime:null,returnDate:null,returnTime:null,driversAge:25},a||{},{childObjectNames:["departureDateOptions","returnDateOptions"]});if(!a.departureDate){a.departureDate=it_DateUtils.addDay(it_DateUtils.clone(it_today),7)}CompoundDate.completeDate(a,"departureDate",this.departureDate);if(!a.returnDate){a.returnDate=it_DateUtils.addDay(it_DateUtils.clone(it_today),14)}CompoundDate.completeDate(a,"returnDate",this.returnDate);if(it_DateUtils.isDateBefore(a.departureDate,a.returnDate)){a.returnDate=a.departureDate}c=it_FormUtils.getForm(c);var b=c.elements;var d=function(){var e=$(b.departureCity);e.setProperty("autocomplete","off");new it_CarAutoComplete(e,Object.append({queryUrl:a.autoCompleteQueryUrl},a.autoCompleteOptions));var i=new CompoundDate("departureDate",c,Object.append({today:it_today,selectedDate:a.departureDate,imgDir:a.imgDir,events:{changed:function(){if(it_DateUtils.isDateBefore(i.getDate(),f.getDate())){f.setDate(it_DateUtils.getDateShifted(i.getDate(),1))}}}},a.departureDateOptions));var f=new CompoundDate("returnDate",c,Object.append({today:it_today,selectedDate:a.returnDate,imgDir:a.imgDir},a.returnDateOptions));var g=new it_CompoundTime("departureDate",c);var h=new it_CompoundTime("returnDate",c);if(g.getHourSelect()&&h.getHourSelect()){$(g.getHourSelect()).addEvent("change",function(){it_Select.select(h.getHourSelect(),g.getHourSelect().value)})}$(b.driversAge).addEvent("focus",function(){b.driversAge.select()});if(a.departureCity){b.departureCity.value=a.departureCity}if(a.driversAge){b.driversAge.value=a.driversAge}if(a.departureTime){g.setTime(a.departureTime,false)}else{g.setTimeParts(10,0,false)}if(a.returnTime){h.setTime(a.returnTime,false)}else{h.setTimeParts(10,0,false)}};d()};var it_CarAutoComplete=function(b,a){a=Object.append({width:350,visibleLineCount:10,advertisersVisible:true,popupMenuBuilder:new it_CarAutoCompletePopupBuilder(a)},a);new it_AutoComplete(b,a)};var it_CarAutoCompletePopupBuilder=function(c){var g=14+1;var b=14;var d=11;var a,c;var f;var e;this.init=function(h,i){if(a!=null){throw new Error("The popupBuilder can't be shared")}a=h;c=i;c.lineHeight=18};this.isResultValid=function(h){var i=e[h];return i.adv.length>0};this.getInputValue=function(h){var i=e[h];return i.inputText};this.setData=function(h){f=h};this.isDataShowable=function(){return f.length>0};this.buildContent=function(l){var j=22;var k=[];f[0].usedAdvertisers.split(",").forEach(function(m){k.push(carAdvertisers[m])});var h=c.advertisersVisible?k.length*g:0;var i=[];e=[];f.forEach(function(o,m){var n=function(s,p,r){var w=s.place;var z=e.length;var D={mouseover:function(){a.setSelectedIndex(z)},mousedown:function(){setTimeout(function(){a.lineSelected()},0)}};var A="";if(s.adv.length==0){A+="autoCompleteDisabled"}if(o.important){A+=" autoCompleteImportant"}var E=new Element("div",{styles:{position:"relative",height:c.lineHeight},events:D}).inject(l);var q=0;var v=new Element("div",{styles:{position:"absolute",left:q,top:(c.lineHeight-d)/2,width:j,textAlign:"center"}}).inject(E);if(p&&c.imgDir!=null&&o.flag!=null){new Element("img",{src:c.imgDir+"flags/"+o.flag.toLowerCase()+".png",title:o.countryName?o.countryName:null}).inject(v)}q+=j;var C;if(p||c.imgDir==null){C=0}else{if(w=="T"){C=2}else{C=1}}if(C!=0){for(var u=0;u<C-1;u++){new Element("div",{styles:{position:"absolute",left:q+u*14,width:14,height:"100%",backgroundImage:"url('"+c.imgDir+"autoComplete/I.png')"}}).inject(E)}new Element("div",{styles:{position:"absolute",left:q+(C-1)*14,width:14,height:"100%",backgroundImage:"url('"+c.imgDir+"autoComplete/"+(r?"L":"T")+".png')"}}).inject(E)}q+=C*14;if(c.imgDir!=null&&!p&&w!="T"){var y=null;if(w=="A"){y="airport"}else{if(w=="B"){y="bus"}else{if(w=="R"){y="railway"}else{if(w=="P"){y="port"}else{if(w=="C"){y="downtown"}else{if(w=="H"){y="hotel"}}}}}}if(y!=null){var x=new Element("div",{styles:{position:"absolute",left:q,top:(c.lineHeight-b)/2,width:b,height:"100%",overflow:"hidden",whiteSpace:"nowrap"}}).inject(E);new Element("img",{src:c.imgDir+"misc/picto/"+y+".png",title:it_message("car.form."+y+".name")}).inject(x);q+=b+3}}var t=new Element("div",{styles:{position:"absolute",left:q,top:0,right:h,height:"100%",overflow:"hidden",whiteSpace:"nowrap"}}).inject(E);new Element("div",{"class":A,text:s.text,styles:{position:"absolute",left:0,lineHeight:c.lineHeight}}).inject(t);if(c.advertisersVisible){var B=new Element("div",{styles:{position:"absolute",top:Math.ceil((c.lineHeight-g)/2),right:0,width:h,lineHeight:c.lineHeight}}).inject(E);k.forEach(function(F,G){if(s.adv.contains(F.name)){new Element("img",{src:c.imgDir+"affil/14x14/"+F.name+".gif",title:F.shownName,styles:{position:"absolute",left:G*g}}).inject(B)}})}i.push(E);e.push(s)};n(o.all,true,false);o.stations.forEach(function(q,p){n(q,false,p==o.stations.length-1);if(q.place=="A"&&q.terminals){q.terminals.forEach(function(s,r){n(s,false,r==q.terminals.length-1)})}})});return{lines:i}}};if(!window.it_CompareSite){(function(){window.it_CompareSite=function(c,b){b=Object.append({section:null,inputFields:null},b);if(String.isEmpty(b.section)){throw new Error("Missing options.section")}if(Array.isEmpty(b.inputFields)){throw new Error("Missing options.inputFields")}var a=[];var d=[];var e=function(){c=it_FormUtils.getForm(c);var g=c.getElement(".compareSites");if(g){m();h();var i=c.elements;b.inputFields=b.inputFields.map(function(s){if(typeOf(s)==="string"){return i[s]}else{return s}});b.inputFields.forEach(function(s){s.addEvent("change",r)});var q=new Request.JSON({url:it_basePath+"compareSite.html"+it_persistentParameters,link:"cancel",onSuccess:function(s){if(s.error){console.log("error: "+error)}if(s.message){alert(s.message)}var t=c.getElement(".compareList");t.empty();if(s.content){a=s.content.map(function(w){var v=new Element("span");var x="checkBox"+it_nextRef();var u=new Element("input",{type:"checkbox","data-url":w.url,"data-advertiser":w.name,id:x,events:{change:function(){o(u.name,u.checkBox);var z=true;var y=true;a.forEach(function(A){var B=A.checked;if(z&&!B){z=false}if(y&&B){y=false}});if(z){f()}else{if(y){j()}}}}}).inject(v);if(l(w.name,true)){u.checked="checked"}new Element("label",{"for":x,text:w.text}).inject(v);v.inject(t);return u})}},onFailure:function(){m()}});c.addEvent("submit",function(){try{n();var s=screen.availWidth;var w=screen.availHeight;var u=g.getElements("input:checked");var t=Math.floor(s/u.length)-10;u.forEach(function(A,z){var C=window.open("","","top=0,menubar=1,location=1,resizable=1,scrollbars=1,toolbar=1");C.resizeTo(t,w);C.moveTo((t+10)*z,0);var B=it_baseUrl+"goCompareSite.html"+it_persistentParameters;var x=new StringBuilder();x.a('<html><head></head><body><form id="postForm" method="post" action="').a(B.javaScriptEscape()).a('">').a('<input type="hidden" name="section" value="').a(b.section).a(">").a('<input type="hidden" name="advertiser" value="').a(A.getProperty("data-advertiser")).a(">").a('<input type="hidden" name="url" value="').a(A.getProperty("data-url").javaScriptEscape).a(">").a("</form></body></html>");var y=C.document;y.write(x.toStrin());y.close();y.getElementById("postForm").submit()})}catch(v){console.log("error while opening the compare site: "+v)}return true})}var r=function(){var s=d;d=b.inputFields.map(function(w){return w.value});for(var t=0;t<d.length;t++){var u=d[t];if(String.isEmpty(u)){m();return}if(s.length<t&&u!==s[t]){var v={};b.inputFields.forEach(function(w){v[w.name]=w.value});q.send(v)}}};var m=function(){g.setStyle("display","none")};var p="compareSite_"+b.section;var k={all:false,none:false,selected:{}};var l=function(t,s){if(k.all){return true}if(k.none){return false}var u=k.selected[t];if(u!==undefined){return u}return s};var o=function(s,t){k.all=false;k.none=false;k.selected[s]=t};var f=function(){k.all=true;k.none=false};var j=function(){k.none=true;k.all=false};var h=function(){var s=JSON.decode(Cookie.read(p));if(s!==null){k=s}else{write()}};var n=function(){Cookie.write(p,JSON.encode(k),{duration:15})};e()}}})()}var it_FlightFormData=function(a){this.classOfService=Object.getProperty(a,"classOfService","eco");this.departureAirport=Object.getProperty(a,"departureAirport","");this.departureIata=Object.getProperty(a,"departureIata",null);this.arrivalAirport=Object.getProperty(a,"arrivalAirport","");this.arrivalIata=Object.getProperty(a,"arrivalIata",null);this.departureDate=Object.getProperty(a,"departureDate",null);this.returnDate=Object.getProperty(a,"returnDate",null);this.adultCount=Object.getProperty(a,"adultCount",1);this.childCount=Object.getProperty(a,"childCount",0);this.babyCount=Object.getProperty(a,"babyCount",0);this.returnTicket=Object.getProperty(a,"returnTicket",true);if(!this.departureDate){this.departureDate=it_DateUtils.addDay(it_DateUtils.clone(it_today),7)}CompoundDate.completeDate(a,"departureDate",this.departureDate);if(!this.returnDate){this.returnDate=it_DateUtils.addDay(it_DateUtils.clone(it_today),14)}CompoundDate.completeDate(a,"returnDate",this.returnDate);if(it_DateUtils.isDateBefore(this.departureDate,this.returnDate)){this.returnDate=this.departureDate}this.toExternalJson=function(){return{classOfService:this.classOfService,departureAirport:this.departureAirport,arrivalAirport:this.arrivalAirport,departureDateMillis:this.departureDate.getTime(),returnDateMillis:this.returnDate.getTime(),adultCount:this.adultCount,childCount:this.childCount,babyCount:this.babyCount,returnTicker:this.returnTicket}}};var it_FlightForm=function(a,j){j=Object.append({imgDir:it_basePath+"img/",autoCompleteQueryUrl:it_basePath+"flight/services.html"+it_languageParameter,departureAutoCompleteOptions:null,arrivalAutoCompleteOptions:null,elementsToHideIfSingle:["fl_returnCase","fl_returnDate1","fl_returnDate2"],manageDates:true,departureDateOptions:{dayOfWeekElement:"fl_departureDate.dayOfWeek",anchorElement:"fl_departureCalendarImg",shortYear:true},returnDateOptions:{dayOfWeekElement:"fl_returnDate.dayOfWeek",anchorElement:"fl_returnCalendarImg",shortYear:true}},j||{},{childObjectNames:["departureDateOptions","returnDateOptions"]});var c=new it_FlightFormData(j);var i=a;a=it_FormUtils.getForm(a);if(!a){throw new Error("Form '"+i+" not found")}var d=a.elements;var f,b;var e;var h=this;var g=function(){e=!d.returnTicket.tagName||d.returnTicket.tagName.toLowerCase()!=="select";if(e){it_FormUtils.getRadios(a,"returnTicket").forEach(function(m){it_checkedListener.addCheckedListener(m,function(n,o){if(o){h.update()}})})}else{$(d.returnTicket).addEvent("change",h.update)}var k=$(d.departureAirport);var l=$(d.arrivalAirport);k.set({autocomplete:"off"});l.set({autocomplete:"off"});new it_FlightAutoComplete(k,Object.append({queryUrl:j.autoCompleteQueryUrl},j.departureAutoCompleteOptions));new it_FlightAutoComplete(d.arrivalAirport,Object.append({queryUrl:j.autoCompleteQueryUrl},j.arrivalAutoCompleteOptions));if(j.manageDates){f=new CompoundDate("departureDate",a,Object.append({today:it_today,selectedDate:c.departureDate,imgDir:j.imgDir,events:{changed:function(){if(it_DateUtils.isDateBefore(f.getDate(),b.getDate())){b.setDate(f.getDate())}}}},j.departureDateOptions));b=new CompoundDate("returnDate",a,Object.append({today:it_today,selectedDate:c.returnDate,imgDir:j.imgDir},j.returnDateOptions))}it_SelectUtils.addOptions(d.classOfService,[["eco",it_message("flight.form.class.eco")],["biz",it_message("flight.form.class.biz")],["first",it_message("flight.form.class.first")]],c.classOfService);if(e){it_FormUtils.checkRadios(it_FormUtils.getRadios(a,"returnTicket"),j.returnTicket,"true")}else{it_SelectUtils.select(d.returnTicket,"true")}it_SelectUtils.addNumericOptions(d.adultCount,0,6,c.adultCount);it_SelectUtils.addNumericOptions(d.childCount,0,6,c.childCount);it_SelectUtils.addNumericOptions(d.babyCount,0,6,c.babyCount);if(c.departureAirport){d.departureAirport.value=c.departureAirport}if(c.arrivalAirport){d.arrivalAirport.value=c.arrivalAirport}h.update()};this.update=function(){var k;if(e){k=d.returnTicket[1].checked}else{k=d.returnTicket.get("value")==="true"}it_Utils.setVisible(j.elementsToHideIfSingle,k);if(j.manageDates){b.setVisible(k)}};g()};var it_FlightAutoComplete=function(b,a){a=Object.append({width:250,visibleLineCount:6,popupMenuBuilder:new it_FlightPopupMenuBuilder()},a);new it_AutoComplete(b,a)};var it_FlightPopupMenuBuilder=function(){var a,b;var c;this.init=function(d,e){if(a!=null){it_Utils.throwError("The popupBuilder can't be shared")}a=d;b=e;b.lineHeight=18};this.isResultValid=function(e){var d=c[e];return d.iataCode!=null};this.getInputValue=function(e){var d=c[e];return d.text+" "+d.iataCode};this.setData=function(d){c=d};this.isDataShowable=function(){return c!=null&&c.length>0};this.buildContent=function(i){var f=22;var g=36;var d=i.getWidth();var e=[];c.forEach(function(t,n){var l;var r={mouseover:function(){a.setSelectedIndex(n)},mousedown:function(){setTimeout(function(){a.lineSelected()},0)}};var o="";if(t.iataCode==null){o+="autoCompleteDisabled"}if(t.important){o+=" autoCompleteImportant"}var s=new Element("div",{styles:{position:"relative",height:b.lineHeight},events:r}).inject(i);e.push(s);var m=new Element("div",{styles:{position:"absolute",top:(b.lineHeight-11)/2,width:f,textAlign:"center"}}).inject(s);l=b.imgDir!=null&&t.child;if(!l&&b.imgDir!=null&&t.flag!=null){new Element("img",{src:b.imgDir+"flags/"+t.flag.toLowerCase()+".png",title:t.countryName?t.countryName:null}).inject(m)}var q=new Element("div",{"class":"autoCompleteText",styles:{position:"absolute",left:f,top:0,height:"100%",overflow:"hidden",whiteSpace:"nowrap"}}).inject(s);l=b.imgDir!=null&&t.child;if(l){var k=n==c.length-1||!c[n+1].child;new Element("div",{styles:{position:"absolute",width:14,height:"100%",backgroundImage:"url('"+b.imgDir+"autoComplete/"+(k?"L":"T")+".png')"}}).inject(q)}var p=t.text;if(t.viewOnlySuffix!=null){p+=t.viewOnlySuffix}new Element("div",{"class":o,text:p,styles:{position:"absolute",left:l?14:0,lineHeight:b.lineHeight}}).inject(q);var j=new Element("div",{"class":o+" autoCompleteIata",styles:{position:"absolute",width:g,lineHeight:b.lineHeight}}).inject(s);if(t.iataCode!=null){j.set("text",t.iataCode)}});var h=function(){var j=i.getWidth();var l=j-f-g-4;var k=j-g;e.forEach(function(m){m.getElement(".autoCompleteText").setWidth(l);m.getElement(".autoCompleteIata").setStyle("left",k)})};h();i.addEvent("resize",h);return{lines:e}}};var it_HotelForm=function(c,a){a=Object.append({imgDir:it_basePath+"img/",manageDates:true,arrivalDateOptions:{dayOfWeekElement:"hot_arrivalDate.dayOfWeek",anchorElement:"hot_arrivalCalendarImg",shortYear:true},countryName:it_subSite.toUpperCase(),cityName:"",arrivalDate:null,nightCount:1,roomCount:1,room1PeopleCount:2,room2PeopleCount:1,room3PeopleCount:1,room4PeopleCount:1},a||{},{childObjectNames:["arrivalDateOptions"]});if(!a.arrivalDate){a.arrivalDate=it_DateUtils.addDay(it_DateUtils.clone(it_today),7)}CompoundDate.completeDate(a,"arrivalDate",this.arrivalDate);c=it_FormUtils.getForm(c);var b=c.elements;var d;var e=function(){c.addEvent("submit",function(){if(String.isEmpty(h.value)){alert("Veuillez préciser la ville de destination");return false}else{return true}});var j=$(b.topCitySelect);if(j){j.addEvent("change",function(){var l=j.value;if(!String.isEmpty(l)&&l!=="empty"){var k=l.split("§");h.value=k[1];g.value=k[0]}});var i=function(){j.value="empty"}}var g=$(b.countryName);it_SelectUtils.addOptions(g,hotelCountries,a.countryName);if(j){j.addEvent("change",i)}var h=$(b.cityName).set({value:a.cityName,events:{focus:function(){h.select()}}});if(j){h.addEvent("keydown",i)}if(a.manageDates){new CompoundDate("arrivalDate",c,Object.append({today:it_today,selectedDate:a.arrivalDate,imgDir:a.imgDir},a.arrivalDateOptions))}it_SelectUtils.addNumericOptions(b.nightCount,1,60,a.nightCount);d=b.roomCount;if(d&&d.tagName.toLowerCase()=="select"){it_SelectUtils.addNumericOptions(d,1,4,a.roomCount);d.addEvent("change",f)}else{d=null}it_SelectUtils.addNumericOptions(b.room1PeopleCount,1,4,a.room1PeopleCount);it_SelectUtils.addNumericOptions(b.room2PeopleCount,1,4,a.room2PeopleCount);it_SelectUtils.addNumericOptions(b.room3PeopleCount,1,4,a.room3PeopleCount);it_SelectUtils.addNumericOptions(b.room4PeopleCount,1,4,a.room4PeopleCount);f()};var f=function(){if(d){var g=d.value.toInt();c.getElements(".hot_room2").forEach(function(h){h.setStyle("display",g>=2?"":"none")});c.getElements(".hot_room3").forEach(function(h){h.setStyle("display",g>=3?"":"none")});c.getElements(".hot_room4").forEach(function(h){h.setStyle("display",g>=4?"":"none")})}};e()};
