Page = $.controller;
$.extend(Page.prototype, {
	
	
	
	
	
/*
	onload: function()
	{
		//this.execute(this.action);
		this.globalExecute();
	},

	initAjaxContent: function(elemId)
	{
		AjaxRequest.updateLink(elemId);
		AjaxRequest.updateForm(elemId);
	},

	loadAjaxContent: function()
	{
		Event.observe(window, 'load', function(event)
		{
			this.initAjaxContent();

		}.bind(this));
	},

	execute: function(action)
	{
		this.preExecute();
		eval(
			'if(typeof(this.'+('execute_'+action).replace('_', '-')+') == "function")'	+
			'{'											+
				'this.'+('execute_'+action).replace('_', '-')+'();'			+
			'}'
		);
		this.postExecute();
	},

	preExecute: function()
	{
		var page = this;
		$j('#btn_live_login').click(function(ev)
		{
			jQuery.get(page.options.urlLogin, function(data)
			{
				data = data.evalJSON();

				$j('<div id="dialog_login_box">'+data.onsuccess.updaters.dialog_login_box+'</div>').dialog({
					resizable: false,
					//height:140,
					autoOpen: false,
					modal: true,
					title: page.options.loginTitle,
					center: true,
					position: 'center',
					close: function(event, ui)
					{
						$j(this).remove();
					}
				}).dialog('open');

				Page.instance.initAjaxContent('dialog_login_box');
			})

			return false;
		});
	},

	postExecute: function()
	{

	},
*/
	globalExecute: function()
	{
		//Cufon.replace('.cufon', {hover:true, fontFamily: 'zurich'});
		//Cufon.replace('.cufon-bold', {hover:true, fontFamily: 'zurich bold'});
	},

	executeHome: function()
	{
		$('#slider').nivoSlider({captionOpacity:0.8, pauseTime:9000, manualAdvance:false});

		$('#slider .nivo-caption').live('click', function(ev)
		{
			if($(this).find('a').size() !== 0)
			{
				window.location.href = $(this).find('a').attr('href');
			}
		});
	},
	
	executeSearchForfait : function()
	{
		$('#go_travel').attr('disabled', 'disabled');
		$('#search_loader').show();
	},
	
	executeAppreciation : function()
	{
		$('#appreciation_form').submit(function(){
			
			var isValid = true; 
			var errorMsg = "";
			
			$('.required').each(function(){
				if($(this).val()==''){
					isValid = false;
					errorMsg = "Tous les champs obligatoires n'ont pas &eacute;t&eacute; remplis.<br />";
				}
				else if($(this).attr('id')=='email'){
					var regexEmail = new RegExp("^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.]{1}[A-Za-z]{2,4}$");
					if(!regexEmail.test($(this).val())){
						isValid = false;
						errorMsg += "L'adresse de courriel soumise est invalide.<br />";
					}
				}
				else{
				
				}
			});
			
			if(!isValid){
				$('#error').html(errorMsg);
				$('html, body').animate({scrollTop:0}, 'slow');
				return false;
			}
		
		});
	},
	
	executeSejour : function()
	{
		
	},

	scrollToElement: function(theElement)
	{
		var selectedPosX = 0;
		var selectedPosY = 0;
		
		while(theElement != null){
			selectedPosX += theElement.offsetLeft;
			selectedPosY += theElement.offsetTop;
			theElement = theElement.offsetParent;
		}

		window.scrollTo(selectedPosX,selectedPosY);
	},

	executeForfait: function()
	{
		var self = this;
		
		$(".tab_content").hide();
		$('#tabsForfait').show()
		$("ul.route-menu li:first").addClass("active").show();
		$(".tab_content:first").show();		

			$('.btn-quotation-now').live('click', function(ev)
			{
				
				var liTabDevis = $('.route-menu .li-tabDevis');
				if($(liTabDevis).is(':visible')){
					self.scrollToElement(liTabDevis[0]);

					liTabDevis.trigger('click');
					liTabDevis.effect("pulsate", {times:2});
				}

				return false;
			});

		$.ajaxAuto(Page.instance.options.urlDevis, {
			data: 	'ajax_action=from_forfait_view',
			success: function(response, type, request)
			{
				$.ajaxCallback(response, type, request);
				Page.instance.executeForfaitQuotation();
			}
		});

		
		//On Click Event
		$("ul.route-menu li").click(function() {

			$("ul.route-menu li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content

			var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
			$(activeTab).fadeIn(); //Fade in the active ID content
			if($(activeTab).attr('id')=='tab1'){
				initForfaitMap();
			}
			

			if($(activeTab).attr('id')=='tabDevis'){
			
				if($('#tabDevis:visible') && !$('#tabDevis').hasClass('ajaxLoaded')) {

					$.ajaxAuto(Page.instance.options.urlDevis, {
						data: 	'ajax_action=from_forfait_view',
						success: function(response, type, request)
						{
							$.ajaxCallback(response, type, request);
							Page.instance.executeForfaitQuotation();
						}
					});

					$('#tabDevis').addClass('ajaxLoaded');
				}
			}
			
			return false;
			
		});


		$('.btn-quotation-now-overlay').remove();
		
	},
	
	loadForfaitQuote:function(){

		var self = this;

		$('.param-col-1').each(
			function(){
				$(this).html('<div><div class="quoation-loader"><div style="padding-left:25px;"><img src="'+self.options.urlBase+'ui/img/ajax-loader-big-red.gif" /></div></div><div><p>Nous calculons actuellement le prix de votre devis. </p><p>Cela peut prendre parfois <strong>jusqu\'&agrave; 30 secondes.</strong></p><p>Merci de patienter...</p></div><div class="quoation-loader-plus">&nbsp;</div></div>');
				Page.instance.quotationLoader();

		});
	},
	
	quotationLoader:function(){
		
		$('.product_link_button').each(function(index) {
			$(this).hide();
		});
		
		var ctr=0;
		intervalID = setInterval(addLoader, 2000);  
	},
	
	executeForfaitQuotation:function()
	{
		
		Page.instance.placeJsQueryCalendar('devis_calendar_box', 'quotation_master_start_date', {
                        minDate: 0,
			maxDate: '+16m',
			date:parseInt(Page.instance.options.devisStartDate),
			selection:[parseInt(Page.instance.options.devisSelectionDate)],
			min:parseInt(Page.instance.options.devisMinDate)
		});
		
		$('#quotation_master_nb_voyageurs').change(function(ev)
		{
			nbPersons = $(this).val();
			nbPersons = (nbPersons == '' || nbPersons == null) ? 0 : parseInt(nbPersons);
		
			Page.instance.createVoyageurFullBox(nbPersons, 'devis_voyageurs_box');
		
		});
	},
	
	
	dialogQuotationFrom:function()
	{
		var html = '<div id="dialog_devis_box" class="authPop"></div>';
	
		var options = {title:'Devis Instantan&eacute;',closeOnEscape:true,autoOpen:true,modal:true,width:550, height:600,
			close: function(event, ui) { $('#dialog_devis_box').remove();}
		}
		
		$.ajax({
			url:Page.instance.options.urlDevis,
			data : 	'ajax_action=from_jswin',
			dataType : "json",
			success : function (data){
				
				$(html).dialog(options);
				$('#dialog_devis_box').append(data.onsuccess.updaters.dialog_devis_box);
				Page.instance.executeForfaitQuotation();
				
			}
			
		});
		
	},

	createVoyageurFullBox: function(nbPersons, containerId)
	{
		var container = $('#'+containerId);
		var nbOtherVoyageurs = nbPersons - 1;
		var delta = nbOtherVoyageurs - $('#'+containerId+' span.aVoyageurFormBox').size();
		
		var nb = $('.aVoyageurFormBox').size();
		
		if(delta > 0)
		{
			for(i=0;i<delta;i++)
			{
				var num = nb + i;

				var htmlContent = '<span class="param-age aVoyageurFormBox"><input type="text" id="voyageur_new_'+num+'_master_age" value="" name="voyageur_new['+num+'][master][age]" class="inputText age"></span>&nbsp;';
				
				$('#'+containerId).append(htmlContent);
			}
		}
		else
		{
			ct = 0;
			$('.aVoyageurFormBox').reverse().each(function(i,el)
			{
				ct--;
				if(ct >= delta) {
					$(el).remove();
				}
				else{
					return false;
				}
			});
		}
	},
	/*************************************
	 * 
	 *  CAMPING-CAR
	 * 
	 * ***********************************/
	executeCampingCar: function(){
		
		Page.instance.placeJsQueryCalendar('devis_calendar_box', 'date_start', {
                        minDate: 0,
			maxDate: '+16m',
			onClose:function(){Page.instance.populateSecondCal();Page.instance.checkTooCold();}
		});
		
		Page.instance.placeJsQueryCalendar('devis_calendar_box', 'date_end', {
                        minDate: 0,
			maxDate: '+16m',
			onClose:function(){Page.instance.populateSecondCal();Page.instance.checkTooCold();}
		});
		
		$('#city_start_id').change(function(ev)
		{
			Page.instance.loadDestinations($('#city_start_id').val());
		
		});
		
	},
	
	loadDestinations: function(startId){
		
		$.ajax({
			url:Page.instance.options.urlAjaxCampingCar,
			data : 	{action:"getDestinations",idDepart:startId},
			success : function (data){		
				$('#city_end_id').html(data);
			}
			
		});
		
	},
	
	placeJsQueryCalendar : function(containerId, fieldId, options, ajaxUrl)
	{
		defaultOptions = {showButtonPanel: true,
			showAnim: 'clip'
			,regional: 'fr'}
		
		options = $.extend({},defaultOptions,options);
		
		$( "#" +fieldId).datepicker(
			options
		);
		
		$( "#" +fieldId).datepicker((jQuery).datepicker.regional['fr']);
		
	},
	
	checkChoicesCC: function(){
		
		var html="<ul>";
		var error=false;
		
		
		var dayMin = 5;
		var dateStartMin = new Date();
		
		dateStartMin.setDate(dateStartMin.getDate() + dayMin );
		if(this.dmyStringToDate($("#date_start").val()) < dateStartMin){
			error=true;
			html+="<li>Vous ne pouvez pas r&eacute;server moins de 5 jours &agrave; l'avance</li>";
		}
		
		var one_day=1000*60*60*24;
		var diff = Math.ceil(this.dmyStringToDate($("#date_end").val()).getTime()-this.dmyStringToDate($("#date_start").val()).getTime())/(one_day);
		if(diff < 6){
			
			error=true;
			html+="<li>La location de camping-car doit obligatoirement se faire pour un minimum de <strong>7 nuits</strong> cons&eacute;cutives</li>";
		}
		
		if(this.dmyStringToDate($("#date_start").val()) > this.dmyStringToDate($("#date_end").val())){
			error=true;
			html+="<li>Votre p&eacute;riode de location n'est pas valide</li>";
		}	
		
		
		if(!$("#city_start_id").val()){
			error=true;
			html+="<li>Selectionnez une ville de prise en charge</li>";		
		}
		
		if(!$("#city_end_id").val()){
			error=true;
			html+="<li>Selectionnez une ville de remise</li>";		
		}
		
		html+="</ul>";
		
		
		if(error){
			this.dialogErrorCC('oops',html);
			return false;
		}
		
		return true;
	},
	
	dmyStringToDate : function (v){
		var d=v.split("/");
		var date = new Date(d[2],parseInt(parseFloat(d[1]))-1, d[0]);
		return date;
	},
	
	checkTooCold : function () {
		var dateStart = $('#date_start').val().split("/");
		dateStart = new Date(dateStart[2],parseInt(parseFloat(dateStart[1]))-1, parseInt(parseFloat(dateStart[0])));
		dateStartWeekDay = dateStart.getDay();
		
		var dateEnd = $('#date_end').val().split("/");
		dateEnd = new Date(dateEnd[2],parseInt(parseFloat(dateEnd[1]))-1, parseInt(parseFloat(dateEnd[0])));
		dateEndWeekDay = dateEnd.getDay();	
		

		if(dateStartWeekDay == 0){
			title ="Note:";
			html ="Toutes les succursales sont <strong>ferm&eacute;s le dimanche</strong>. Veuillez choisir une autre date de prise en charge";
			this.dialogErrorCC(title,html);
			return false;		
		}
		
		if(dateEndWeekDay == 0){
			title = "Note:";
			html = "Toutes les succursales sont <strong>ferm&eacute;s le dimanche</strong>. Veuillez choisir une autre date de remise";
			this.dialogErrorCC(title,html);
			return false;		
		}	


		var ds = $('#date_start').val().substring(3,5);
		var de = $('#date_end').val().substring(3,5);
		var minDate = "05";
		var maxDate = "10";
		
		if((ds > maxDate || ds < minDate) || (de > maxDate || de < minDate)){
			title = "Note:";
			html = "D&ucirc; &agrave; des temp&eacute;ratures trop froides, nous ne recommandons pas la location de camping-car au Canada <strong>avant le 1er mai</strong> et <strong>apr&egrave;s le 31 octobre</strong>.";
			this.dialogErrorCC(title,html);
			return false;	
		}
		
		var one_day=1000*60*60*24;
		var diff = Math.ceil(this.dmyStringToDate($("#date_end").val()).getTime()-this.dmyStringToDate($("#date_start").val()).getTime())/(one_day);
		if(diff < 7){
			title = "Note:";
			html = "La location de camping-car doit obligatoirement se faire pour un minimum de <strong>7 nuits</strong> cons&eacute;cutives";
			this.dialogErrorCC(title,html);
			return false;	
		}
		
		return true;
	},
	
	populateSecondCal: function(){
		var ds=$("#date_start").val();
		var dscomp = $('#date_start').val().substring(6) + $('#date_start').val().substring(3,5) +$('#date_start').val().substring(0,2);
		var decomp = $('#date_end').val().substring(6) + $('#date_end').val().substring(3,5) +$('#date_end').val().substring(0,2);
		
		if(dscomp>=decomp){
			var tmp = ds.split("/");
			var d=new Date(parseInt(tmp[2]), parseInt(parseFloat((tmp[1])))-1, parseInt(parseFloat(tmp[0])) );
			d.setDate(d.getDate()+ 7);
			$("#date_end").val(this.twoDigit(d.getDate()) + "/" + this.twoDigit(parseInt(d.getMonth())+1) + "/" + d.getFullYear());
			$("#date_end").effect("highlight", {}, 3000);
		}
	},
	
	twoDigit: function(v){
		v=v+"";
		if(v.length<2){
			return "0"+v;
		}
		return v;
	},
	
	dialogErrorCC:function(title,content,options)
	{
		var html = '<div id="dialog_error_cc" class="authPop"></div>';
	
		var options = {title:title,closeOnEscape:true,autoOpen:true,modal:true,width:550, height:200,
			close: function(event, ui) { $('#dialog_error_cc').remove();}
		}
		
		options = $.extend({},defaultOptions,options);
			
		$(html).dialog(options);
		$('#dialog_error_cc').append(content);
		
	},
	/*************************************
	 * 
	 *  VOITURES
	 * 
	 * ***********************************/
	executeVoiture:function()
	{
		Page.instance.placeJsQueryCalendar('devis_calendar_box', 'date_start', {
                        minDate: 0,
			maxDate: '+16m',
			onClose:function(){Page.instance.populateSecondCal();Page.instance.getHourDep();Page.instance.updateDays();}
		});
		
		Page.instance.placeJsQueryCalendar('devis_calendar_box', 'date_end', {
                        minDate: 0,
			maxDate: '+16m',
			onClose:function(){Page.instance.populateSecondCal();Page.instance.getHourArr();Page.instance.updateDays();}
		});
		
		/*Page.instance.getHours();*/
		if($('#date_start').length){
			Page.instance.updateDays();
			Page.instance.getDestinations();
		}
	},
	
	getHours:function(){
		
		openDay = this.checkDay("start");
		closeDay = this.checkDay("end");
		startCity = $('#ville_depart').val();
		endCity = $('#ville_arrive').val();
		
		/*
		var pb = $H({action:"getheures",day:openDay,ville_depart:startCity,ville_arrive:endCity}).toQueryString();
		var ar = new Ajax.Request('<?php echo URL_BASE;?>php/ajax_voiture.php', {'postBody':pb, onSuccess:function(origReq){
			$('heure_depart').update(origReq.responseText);
		}});
		*/
		
		$.ajax({
			url:Page.instance.options.urlAjaxVoiture,
			data : 	{action:"getheures",day:openDay,ville_depart:startCity,ville_arrive:endCity},
			success : function (data){		
				$('#heure_depart').html(data);
			}
			
		});
		
		/*
		var pb = $H({action:"getheures",day:closeDay,ville_depart:startCity,ville_arrive:endCity}).toQueryString();
		
		var ar = new Ajax.Request('<?php echo URL_BASE;?>php/ajax_voiture.php', {'postBody':pb, onSuccess:function(origReq){
			$('heure_fermeture').update(origReq.responseText);
		}});
		*/
		
		$.ajax({
			url:Page.instance.options.urlAjaxVoiture,
			data : 	{action:"getheures",day:closeDay,ville_depart:startCity,ville_arrive:endCity},
			success : function (data){		
				$('#heure_fermeture').html(data);
			}
			
		});
	},
	
	updateDays : function(){
		var startDay = this.checkDay("start");
		var endDay = this.checkDay("end");
		
		$('#start_day').val(startDay + 1);
		$('#end_day').val(endDay + 1);
	},
	
	getDestinations : function(){
		var idDepart = $('#ville_depart').val();
		
		$.ajax({
			url:Page.instance.options.urlAjaxVoiture,
			data : 	{action:"getDestinations",idDepart:idDepart},
			success : function (data){		
				$('#ville_arrive').html(data);
				Page.instance.getHours();
			}
			
		});
	},
	
	checkDay : function(start_end){

		var dateStart = $('#date_start').val().split("/");
		dateStart = new Date(dateStart[2],parseInt(parseFloat(dateStart[1]))-1, parseInt(parseFloat(dateStart[0])));
		weekDay = dateStart.getDay();
		return weekDay;
	},
	
	getHourDep : function(){
		
		openDay = this.checkDay("start");
		closeDay = this.checkDay("end");
		startCity = $('#ville_depart').val();
		endCity = $('#ville_arrive').val();
		
		$.ajax({
			url:Page.instance.options.urlAjaxVoiture,
			data : 	{action:"getheures",day:openDay,ville_depart:startCity,ville_arrive:endCity},
			success : function (data){		
				$('#heure_depart').html(data);
			}
			
		});
	},	

	getHourArr : function(){
		openDay = this.checkDay("start");
		closeDay = this.checkDay("end");
		startCity = $('#ville_depart').val();
		endCity = $('#ville_arrive').val();
		
		$.ajax({
			url:Page.instance.options.urlAjaxVoiture,
			data : 	{action:"getheures",day:closeDay,ville_depart:startCity,ville_arrive:endCity},
			success : function (data){		
				$('#heure_fermeture').html(data);
			}
			
		});
		
	},
	
	checkChoices : function(){
		
		var html="<ul>";

		var error=false;
		
		var dayMin = 4;
		var dateStartMin = new Date();
		
		var openH = $('#heure_depart').val();
		var closeH = $('#heure_fermeture').val();
		
		dateStartMin.setDate(dateStartMin.getDate() + dayMin );
		if(this.dmyStringToDate($("#date_start").val()) < dateStartMin){
			error=true;
			html+="<li>Vous ne pouvez pas r&eacute;server moins de 5 jours &agrave; l'avance</li>";
		}
		
		var one_day=1000*60*60*24;
		var diff = Math.ceil(this.dmyStringToDate($("#date_end").val()).getTime() - this.dmyStringToDate($("#date_start").val()).getTime())/(one_day);
		
		if(openH < closeH){
			diff++;
		}
		
		if(diff < 6){
			
			error=true;
			html+="<li>Pour profiter de ces tarifs privil&eacute;gi&eacute;s, votre dur&eacute;e de location doit &ecirc;tre de <strong>7 jours</strong> au minimum</li>";
		}
		
		if(this.dmyStringToDate($("#date_start").val()) > this.dmyStringToDate($("#date_end").val())){
			error=true;
			html+="<li><Votre p&eacute;riode de location n'est pas valide</li>";
		}
		
		if($("#ville_depart").val()=='0'){
			error=true;
			html+="<li>Selectionnez une ville de prise en charge</li>";		
		}
		if($("#ville_depart").val()=='0'){
			error=true;
			html+="<li>Selectionnez une ville de remise</li>";		
		}

		html+="</ul>";
		
		if(error){
			this.dialogErrorCC('oups',html)
			return false;
		}

		return true;
	},
	
	voitureSubmitStep1 : function(){
		if(this.checkChoices())
		{
			$('#form_loc_voiture').submit();
		}
	},
	
	executeModificationDevis: function(){
		
		Page.instance.placeJsQueryCalendar('devis_calendar_box', 'avion_date_depart', {
			minDate: 0,
			maxDate: '+12m',
			constrainInput:true,
			onSelect: function( selectedDate ) {
				$('#avion_date_retour').datepicker('option', 'minDate', selectedDate);
			}
		});
		
		Page.instance.placeJsQueryCalendar('devis_calendar_box', 'avion_date_retour', {
			minDate: 0,
			maxDate: '+12m',
			constrainInput:true,
			onSelect: function( selectedDate ) {
				$('#avion_date_depart').datepicker('option', 'maxDate', selectedDate);
			}
		});
		
	},

	executeFicheAutorisationBancaire: function()
	{
		var self = this;

		if(!this.eventsBinded)
		{
			//Voyageur Form Events

			$('.field-error :input').live('change', function(ev)
			{
				$(this).closest('.field-error')
					.removeClass('field-error');
			});

			$('.inscription-voyageurs-wrap .btn-apply-to-all').live('click', function(ev)
			{
				var rel = $(this).attr('rel');
				var input = $('#'+rel);
	
				if(input.hasClass('inputTextAddress'))
				{
					$('.inscription-voyageur-table .inputTextAddress').val(input.val())
						.closest('.field-error').removeClass('field-error');
				}
				else if(input.hasClass('inputTextCity'))
				{
					$('.inscription-voyageur-table .inputTextCity').val(input.val())
						.closest('.field-error').removeClass('field-error');
				}
				else if(input.hasClass('inputSelectCountry'))
				{
					$('.inscription-voyageur-table .inputSelectCountry').val(input.val())
						.closest('.field-error').removeClass('field-error');
				}
				else if(input.hasClass('inputTextPostalCode'))
				{
					$('.inscription-voyageur-table .inputTextPostalCode').val(input.val())
						.closest('.field-error').removeClass('field-error');
				}
				else if(input.hasClass('inputTextPhone'))
				{
					$('.inscription-voyageur-table .inputTextPhone').val(input.val())
						.closest('.field-error').removeClass('field-error');
				}
			});

			$('.driving-status-list li input[type="radio"]').live('change', function(ev)
			{
				self.checkDrivingStatus(this, 'fast');
			});

			$('.has-flight-choice-list li input[type="radio"]').live('change', function(ev)
			{
				self.checkHasFlight(this, 'fast');
			});

			this.eventsBinded = true;
		}



		$('.fiche-inscription-demande-wrap .first-loading').remove();

		$('.fiche-inscription-demande-wrap').ajaxStart(function(ev)
		{
			//console.debug(this);
			$(this).append('<div class="ui-widget-overlay"></div>');
			$(this).append('<div class="loading-box">'+self.options.loadingLabel+'</div>');
		});

		$('.fiche-inscription-demande-wrap').ajaxStop(function(ev)
		{
			$(this).find('.ui-widget-overlay').remove();
			$(this).find('.loading-box').remove();
		});

		$('.driving-status-list li input[type="radio"]:checked').each(function() {

			self.checkDrivingStatus(this, '');
		});

		$('.has-flight-choice-list li input[type="radio"]:checked').each(function() {

			self.checkHasFlight(this, '');
		});

		$("#fiche_inscription_master_flight_date_start, #fiche_inscription_master_flight_date_end").datepicker(jQuery.extend({}, {

			//datepicker
			minDate:    new Date(self.options.minYear, 1 - 1, 1),
			maxDate:    new Date(self.options.maxYear, 12 - 1, 31),

			timeFormat:"hh:mm",
			stepMinute:5

		}, jQuery.datepicker.regional[self.options.culture], {}, {dateFormat: "yy-mm-dd"}));

		if($('.form-readonly').is('*'))
		{
			$('.fiche-inscription-demande-wrap :input')
				.attr('readonly', true)
				.attr('disabled', true);
		}

		$('#fiche_inscription_master__nb_voyageur').change(function(ev)
		{
			var nbActual = $('.inscription-voyageurs-wrap').find('.inscription-voyageur-wrap').size();
			var nbRequest = $(this).val();

			var delta = nbRequest - nbActual;

			if(delta > 0)
			{
				$.ajaxAuto(self.options.urlCurrent, {
					data : {
						'ajax_action'   : 'add-voyageur',
						'nb_voyageur'   : nbRequest,
						'from_voyageur' : nbActual
					}
				});
			}
			else if(delta < 0)
			{
				$('.inscription-voyageurs-wrap').find('.inscription-voyageur-wrap').each(function(key)
				{
					if(key + 1 > nbRequest)
					{
						$(this).remove();
					}
				});
			}
		});

		if(self.options.use_print)
		{
			window.print();
		}
	},

	executeFicheInscriptionHiver: function()
	{
		this.executeFicheInscription();
	},

	checkDrivingStatus: function(inputRadio, delay)
	{
		var licenseBox = $(inputRadio).closest('.car-rental-info').find('.form-row-driving-license');

		if($(inputRadio).val() === 'NONE')
		{
			licenseBox.hide(delay);
		}
		else
		{
			licenseBox.show(delay);
		}
	},

	checkHasFlight: function(inputRadio, delay)
	{
		var flightBox = $(inputRadio).closest('.flight-info-wrap').find('.flight-info');

		if($(inputRadio).val() === '1')
		{
			flightBox.hide(delay);
		}
		else
		{
			flightBox.show(delay);
		}
	}
	
});

function validateModificationDevis(){
	
	if($('#billet_avion_1').attr('checked')){
	
		if($('#avion_ville_depart').val() == ''){
			$('#alert_box').html("Veuillez fournir une ville de départ pour vos billets d'avion");
			$('#alert_box').dialog({
				modal: true,
				title: "Erreur dans billets d'avion",
				buttons: { "Ok": function() { $(this).dialog("close"); }},
				closeOnEscape: true,
				draggable: false,
				position: 'center',
				resizable: false
			});
			return false;
		}
		if($('#avion_ville_dest').val() == ''){
			$('#alert_box').html("Veuillez fournir une ville de destination pour vos billets d'avion");
			$('#alert_box').dialog({
				modal: true,
				title: "Erreur dans billets d'avion",
				buttons: { "Ok": function() { $(this).dialog("close"); }},
				closeOnEscape: true,
				draggable: false,
				position: 'center',
				resizable: false
			});
			return false;
		}
		if($('#avion_date_depart').val() == ''){
			$('#alert_box').html("Veuillez fournir une date de départ pour vos billets d'avion");
			$('#alert_box').dialog({
				modal: true,
				title: "Erreur dans billets d'avion",
				buttons: { "Ok": function() { $(this).dialog("close"); }},
				closeOnEscape: true,
				draggable: false,
				position: 'center',
				resizable: false
			});
			return false;
		}
		if($('#avion_date_retour').val() == ''){
			$('#alert_box').html("Veuillez fournir une date de retour pour vos billets d'avion");
			$('#alert_box').dialog({
				modal: true,
				title: "Erreur dans billets d'avion",
				buttons: { "Ok": function() { $(this).dialog("close"); }},
				closeOnEscape: true,
				draggable: false,
				position: 'center',
				resizable: false
			});
			return false;
		}
		
	}
	return true;
}

function addLoader(){
	if($('.quoation-loader-plus').size() > 0){
		
		$('.quoation-loader-plus').each(function(index) {
			$(this).append('+');
		});
	}
	else{
		stopLoader();
		$('.product_link_button').each(function(index) {
			$(this).show();
		});
	}
}

function stopLoader(){
	clearInterval(intervalID); 
}

