function writeHoraire()
{	
	document.write('<option value="">Sans Préférence</option>');
	document.write('<option value="MORNING"/>Matin (9:00-12:00)');
	document.write('<option value="AFTERNOON"/>Après-Midi (12:00-18:00)');
	document.write('<option value="EVENING"/>Soirée (18:00-00:00)');
	for(var i=1;i<10;i++)
		document.write('<option value=\"0'+i+'00\"/>0'+i+':00');

	for(var i=10;i<=23;i++)
		document.write('<option value=\"'+i+'00\"/>'+i+':00');
}

Date.prototype.plus = function(days) {
	this.setTime(this.getTime()+days*24*3600*1000);
	return this;
}

Date.prototype.withDep = function(dep) {
	if (dep>=this) {
		this.setTime(dep.plus(1).getTime());		
	}	
	return this;
}

Date.prototype.withRet = function(ret) {
	if (ret<this) {
		this.setTime(ret.plus(-0).getTime());;		
	}	
	return this;
}


Date.prototype.setDayAndMonthYear = function(DAY, MONTH) {
this.setTime( new Date (MONTH.substring(8,4),"JANFEVMARAVRMAIJUNJULAOUSEPOCTNOVDEC".indexOf(MONTH.substring(0,3))/3,DAY).getTime());
return this;
}

Date.prototype.getDispDay = function() {
return this.getDate();
}

Date.prototype.getDispMonth = function() {
return "JANFEVMARAVRMAIJUNJULAOUSEPOCTNOVDEC".substring(this.getMonth()*3+3,this.getMonth()*3)+" "+this.getFullYear();
}

Date.prototype.getDispYear = function() {
return this.getFullYear();
}

Date.prototype.getDispDayName = function() {
return "lunmarmerjeuvensamdim".substring(this.getDay()*3,this.getDay()*3-3);
}

Date.prototype.getTwoDigitMonth = function() {
return this.getMonth()<10?"0"+this.getMonth():""+this.getMonth();
}

function updateReturnDate(form) {		
	with(form) {
			
			var ret = new Date ().setDayAndMonthYear(R_DAY.value, R_MONTH.value);
			ret.withDep(new Date().setDayAndMonthYear(D_DAY.value, D_MONTH.value));					
				
			R_DAY.options[ret.getDispDay()-1].selected='true';
			R_MONTH.value=(ret.getDispMonth());	
		}
}



function updateDepartureDate(form) {		
	with(form) {			
			var dep = new Date ().setDayAndMonthYear(D_DAY.value, D_MONTH.value);
			dep.withRet(new Date().setDayAndMonthYear(R_DAY.value, R_MONTH.value));

			D_DAY.options[dep.getDispDay()-1].selected='true';
			D_MONTH.value=(dep.getDispMonth());	
		}		
}


function updateReturnVisibility(form)   {
  with(form) {	
	   R_DAY.disabled=inputVolAllerSimple.checked;
  	   R_MONTH.disabled=inputVolAllerSimple.checked;
	   R_ANYTIME.disabled=inputVolAllerSimple.checked;
  }  
}

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

Date.prototype.format = function (format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=this.getYear()+"";
	var M=this.getMonth()+1;
	var d=this.getDate();
	var E=this.getDay();
	var H=this.getHours();
	var m=this.getMinutes();
	var s=this.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}