Array.prototype.asOptions = function (selected) {
for (var i=0; i<this.length; i++){
this[i] = "<option value=\""+this[i]+"\" "+(selected==this[i]?"selected=\"selected\"":"")+">"+this[i]+"</option>";
}
//return this.map(function(f){return "<option value=\""+f+"\" "+(selected==f?"selected=\"selected\"":"")+">"+f+"</option>"}).concat();
return this;
}


Array.prototype.concatAsString = function () {
var result = "";
for (var i=0; i<this.length; i++){
result = result + this[i];
}
//this.forEach(function (element, index, array) {result = result + element});
return result;
}

Array.prototype.asOptionsValues = function (selected) {
for (var i=0; i<this.length; i++){
this[i] = "<option value=\""+this[i][0]+"\" "+(selected==this[i][1]?"selected=\"selected\"":"")+">"+this[i][1]+"</option>";
}
return this;
}

Array.prototype.fill = function () {
var min=this[0];
var max=this[1];
if(min==max){this.length=1;}
else {
	try {for(var i=0; i<max-min+1; i++) {this[i]=min+i;}}
	catch(e) {alert(e);}
}
return this;
}


Date.prototype.plus = function(days) {
	this.setTime(this.getTime()+days*24*3600*1000);
	return this;
}

Date.prototype.isSameDay = function(otherDay) {
	return ((this.getTime()-otherDay.getTime())<24*3600*1000);
}

Date.prototype.withDep = function(dep) {
	if (dep>this) {
		this.setTime(dep.plus(0).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.getDispDayTwoDigits = function() {
return (this.getDispDay()<10?"0":"")+this.getDispDay();
}

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.getDispDayCompleteName = function() {
return (new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"))[this.getDay()];
}









Date.prototype.getFollowingMonthsYears = function (nbMonths) {
var followingMonths = new Array();
var backup = this.getTime();
this.setDate (1);
for (var i=0; i<nbMonths; i++){
	followingMonths[i] = this.getDispMonth();
	this.setMonth(this.getMonth()+1);
	}
this.setTime(backup);
return followingMonths;
}



Date.prototype.getMonthsOptions = function (nbMonths) {
return this.getFollowingMonthsYears(nbMonths).asOptions(this.getDispMonth()).concatAsString();
}


Date.prototype.getDaysOfTheMonth = function () {
var days = new Array();
var slide = new Date(this.getTime());
slide.setDate(1);
while(slide.getMonth()==this.getMonth()){
	days.push(new Array((slide.getDate()<10?"0":"")+slide.getDate(),""+slide.getDate()));
	slide.setDate(slide.getDate()+1);
}
return days;
}




Date.prototype.getDaysOptions = function (nbMonths) {
return this.getDaysOfTheMonth().asOptionsValues(dep.getDate()).concatAsString();
}