function DateList(){
 
 
 this.startAvailDate;
 
 this.endAvailDate;
 
 this.startDate;
 
 this.endDate;
 
 this.grpStart;
 
 this.monthsNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
 
 this.daysNames=["S","M","T","W","T","F","S"];
 
 
 this.nbDays=[31,28,31,30,31,30,31,31,30,31,30,31];
 
 this.currentDate=new Date();
 
 this.classDisabled="dateListsDisabled";
 
 this.grpEnd;
 
 this.betweenDays=7;
 
 this.returnDateModify=0;
 
 this.nextDateList=null;
 
 this.hasBeenModifiedByUser=false;
 
 
 this.monthsId=new Array;
 this.monthsLabel=new Array;
 this.startDayOfMonth=new Array;
 this.endDayOfMonth=new Array;
 this.nbMonths;
 
 this.refMondayDate;
 
 
 
 if(navigator.userAgent.toLowerCase().indexOf('opera')!=-1){
 this.navigatorOpera=true;
}else{
 this.navigatorOpera=false;
}
 
 
 
 this.getIntervalAvailabilityDate=DateList_getIntervalAvailabilityDate;
 this.getDateTimeComposed=DateList_getDateTimeComposed;
 this.getDateTimeComposedString=DateList_getDateTimeComposedString;
 this.setDateComposedString=DateList_setDateComposedString;
 this.setDateTimeComposedString=DateList_setDateTimeComposedString;
 this.setDateDecComposedString=DateList_setDateDecComposedString;
 this.getMaxDays=DateList_getMaxDays;
 this.getNameDay=DateList_getNameDay;
 this.addMonth=DateList_addMonth;
 this.addYear=DateList_addYear;
 this.setStartingInfos=DateList_setStartingInfos;
 this.setEndingInfos=DateList_setEndingInfos;
 this.initMonthsDaysTables=DateList_initMonthsDaysTables;
 this.initListMonths=DateList_initListMonths;
 this.getYear=DateList_getYear;
 this.getMonth=DateList_getMonth;
 this.updateDays=DateList_updateDays;
 this.initDate=DateList_initDate;
 this.checkDay=DateList_checkDay;
 this.setReturnDate=DateList_setReturnDate;
 this.updateReturnDate=DateList_updateReturnDate;
 this.initDateLists=DateList_initDateLists;
 
 this.onkeypress=DateList_onkeypress;
 this.nextAddBetweenDays=DateList_nextAddBetweenDays;
 this.onChange=DateList_onChange;
}
 
 function DateList_initDateLists(){
 
 var refDat=new Date(1980,0,1,0,0,0);
 refDat.setHours(0);
 refDat.setMinutes(0);
 refDat.setSeconds(0);
 this.refMondayDate=refDat.getTime();
 
 if(!this.startDate){
 this.setStartingInfos();
}
 if(!this.endDate){
 this.setEndingInfos();
}
 
 this.currentDate.setHours(0);
 this.currentDate.setMinutes(0);
 this.currentDate.setSeconds(0);
 this.initMonthsDaysTables();
 this.initListMonths(this.grpStart[0]);
 if(this.grpEnd){
 this.initListMonths(this.grpEnd[0]);
}
 this.initDate();
 this.checkDay(this.grpStart[1]);
 this.nextAddBetweenDays();
}
 
 
 function DateList_updateDays(cmp){
 
 if(cmp.id==this.grpStart[0].id){
 cmpMonth=this.grpStart[0];
 cmpDay=this.grpStart[1];
}else{
 cmpMonth=this.grpEnd[0];
 cmpDay=this.grpEnd[1];
}
 
 var selectedDay=cmpDay.selectedIndex;
 if(selectedDay<0){
 selectedDay=0;
}
 
 while(cmpDay.options.length>0){
 cmpDay.options[0]=null;
}
 
 var selectedMonth=cmpMonth.selectedIndex;
 var index=0;
 if(selectedMonth==0){
 for(var i=1;i<this.startDayOfMonth[selectedMonth];i++){
 cmpDay.options[index]=new Option(i,i);
 if(this.navigatorOpera){
 cmpDay.options[index].disabled=true;
}else{
 cmpDay.options[index].className=this.classDisabled;
}
 index++;
}
}
 
 for(var i=this.startDayOfMonth[selectedMonth];i<this.endDayOfMonth[selectedMonth]+1;i++){
 cmpDay.options[index]=new Option(i,i);
 if(this.navigatorOpera){
 cmpDay.options[index].disabled=false;
}else{
 cmpDay.options[index].className="";
}
 index++;
}
 if(selectedMonth==this.nbMonths-1){
 for(var i=this.endDayOfMonth[selectedMonth]+1;i<=this.getMaxDays(this.getMonth(this.monthsId[selectedMonth]),this.getYear(this.monthsId[selectedMonth]));i++){
 cmpDay.options[index]=new Option(i,i);
 if(this.navigatorOpera){
 cmpDay.options[index].disabled=true;
}else{
 cmpDay.options[index].className=this.classDisabled;
}
 index++;
}
}
 cmpDay.disabled=false;
 var lenCmpDay=cmpDay.options.length;
 
 
 for(var j=0;j<lenCmpDay;j++){
 cmpDay.options[j].selected=false;
}
 if(selectedDay<lenCmpDay){
 
 
 while(cmpDay.selectedIndex!=selectedDay){
 cmpDay.options[selectedDay].selected=true;
}
}else{
 
 
 while(cmpDay.selectedIndex!=lenCmpDay-1){
 cmpDay.options[lenCmpDay-1].selected=true;
}
}
 
 this.checkDay(cmpDay);
}
 
 
 function DateList_checkDay(cmpDay){
 if((this.navigatorOpera&&cmpDay.options[cmpDay.selectedIndex].disabled==true)||(!this.navigatorOpera&&cmpDay.options[cmpDay.selectedIndex].className==this.classDisabled)){
 var isInDisableTop;
 
 if((this.navigatorOpera&&cmpDay.options[0].disabled==false)||(!this.navigatorOpera&&cmpDay.options[0].className!=this.classDisabled)){
 
 isInDisableTop=false;
}else{
 
 if((this.navigatorOpera&&cmpDay.options[cmpDay.options.length-1].disabled==false)||(!this.navigatorOpera&&cmpDay.options[cmpDay.options.length-1].className!=this.classDisabled)){
 
 isInDisableTop=true;
}else{
 
 
 var dec=0;
 while(dec!=cmpDay.selectedIndex&&((this.navigatorOpera&&cmpDay.options[dec].disabled==true)||(!this.navigatorOpera&&cmpDay.options[dec].className==this.classDisabled))){
 dec++;
}
 isInDisableTop=(dec==cmpDay.selectedIndex);
}
}
 if(isInDisableTop){
 
 var dec=0;
 while((this.navigatorOpera&&cmpDay.options[dec].disabled==true)||(!this.navigatorOpera&&cmpDay.options[dec].className==this.classDisabled)){
 dec++;
}
 cmpDay.options[dec].selected=true;
}else{
 
 var dec=cmpDay.options.length-1;
 while((this.navigatorOpera&&cmpDay.options[dec].disabled==true)||(!this.navigatorOpera&&cmpDay.options[dec].className==this.classDisabled)){
 dec--;
}
 cmpDay.options[dec].selected=true;
}
}
 
 if(cmpDay.id==this.grpStart[1].id){
 this.grpStart[2].innerHTML=this.getNameDay(this.getDateTimeComposed(this.grpStart));
 this.updateReturnDate();
}else{
 this.grpEnd[2].innerHTML=this.getNameDay(this.getDateTimeComposed(this.grpEnd));
}
 
 if(this.nextDateList!=null){
 this.nextAddBetweenDays();
}
}
 
 var cmpOnKeyPress;
 var dateListOnKeyPress;
 
 function DateList_onkeypress(cmp,event){
 cmpOnKeyPress=cmp;
 dateListOnKeyPress=this;
 this.hasBeenModifiedByUser=true;
 if((this.grpStart&&cmp.id==this.grpStart[0].id)||(this.grpEnd&&cmp.id==this.grpEnd[0].id))
 setTimeout('dateListOnKeyPress.updateDays(cmpOnKeyPress)',0);
 if((this.grpStart&&cmp.id==this.grpStart[1].id)||(this.grpEnd&&cmp.id==this.grpEnd[1].id))
 setTimeout('dateListOnKeyPress.checkDay(cmpOnKeyPress)',0);
 if(dateListOnKeyPress.nextDateList!=null){
 setTimeout('dateListOnKeyPress.nextAddBetweenDays()',0);
}
}
 
 
 function DateList_onChange(cmp)
{
 if(this.nextDateList!=null){
 this.nextAddBetweenDays();
}
 
 switch(cmp.id){
 case this.grpStart[0].id:
 this.updateDays(cmp);
 break;
 case this.grpStart[1].id:
 this.checkDay(cmp);
 break;
}
 
 this.hasBeenModifiedByUser=true;
}
 
 
 
 
 
 function DateList_getIntervalAvailabilityDate(){
 var intevalAvailability="";
 intevalAvailability+=this.startDate.getTime();
 intevalAvailability+="|";
 intevalAvailability+=this.endDate.getTime();
 return intevalAvailability;
}
 
 
 function DateList_getDateTimeComposed(lstCmp){
 var retDatYear=this.getYear(this.monthsId[lstCmp[0].selectedIndex]);
 var retDatMonth=this.getMonth(this.monthsId[lstCmp[0].selectedIndex]);
 var retDatDate=1+lstCmp[1].selectedIndex;
 var retDatHours=0;
 if(lstCmp[3]){
 if(lstCmp[3].tagName.toLowerCase()=="select"){
 if(lstCmp[3].selectedIndex!=0){
 retDatHours=lstCmp[3].selectedIndex-1;
}
}else{
 var timeToAdd=lstCmp[3].value;
 if(timeToAdd!="ANY"&&timeToAdd.length==4){
 retDatHours=parseInt(timeToAdd.substr(0,2),10);
}
}
}
 var retDat=new Date(retDatYear,retDatMonth,retDatDate,retDatHours,0,0);
 return retDat;
}
 
 
 function DateList_getDateTimeComposedString(lstCmp){
 var retDatString="";
 retDatString+=this.getYear(this.monthsId[lstCmp[0].selectedIndex]);
 var month=1+this.getMonth(this.monthsId[lstCmp[0].selectedIndex]);
 if(month<10){
 retDatString+="0"+month;
}else{
 retDatString+=month;
}
 var day=1+lstCmp[1].selectedIndex;
 if(day<10){
 retDatString+="0"+day;
}else{
 retDatString+=day;
}
 
 var timeToAdd="0000";
 if(lstCmp[3]){
 if(lstCmp[3].tagName.toLowerCase()=="select"){
 timeToAdd=lstCmp[3].options[lstCmp[3].selectedIndex].value;
}else{
 timeToAdd=lstCmp[3].value;
}
 if(timeToAdd=="ANY"){
 timeToAdd="0000"
}
}
 retDatString+=timeToAdd;
 return retDatString;
}
 
 
 
 
 function DateList_getMaxDays(numMonth,numYear){
 if(numMonth!=1){
 return this.nbDays[numMonth];
}else{
 if(numYear==4*Math.round(numYear/4)){
 return 29;
}else{
 return 28;
}
}
}
 
 
 
 
 function DateList_getNameDay(dat){
 var datYear=dat.getYear();
 if(datYear<1000){
 datYear+=1900;
}
 var nbDaysPassed=0;
 for(var i=1980;i<datYear;i++){
 if(i==4*Math.round(i/4)){
 nbDaysPassed+=366;
}else{
 nbDaysPassed+=365;
}
}
 for(var i=0;i<dat.getMonth();i++){
 nbDaysPassed+=this.getMaxDays(i,datYear);
}
 nbDaysPassed+=1+dat.getDate();
 return this.daysNames[nbDaysPassed%7];
}
 
 
 
 
 function DateList_getYear(YearMonth){
 return parseInt(YearMonth.substr(0,4),10);
}
 
 
 
 
 function DateList_getMonth(YearMonth){
 return parseInt(YearMonth.substr(4),10);
}
 
 
 function DateList_setDateComposedString(lstCmp,dat){
 if(dat.length<8){
 return;
}
 for(var i=0;i<this.nbMonths;i++){
 if(this.monthsId[i]==parseInt(dat.substr(0,6),10)){
 lstCmp[0].options[i].selected=true;
}
}
 this.updateDays(lstCmp[0]);
 lstCmp[1].options[parseInt(dat.substr(6,2),10)-1].selected=true;
 if(lstCmp==this.grpEnd){
 this.returnDateModify=1;
}
 this.updateDays(lstCmp[0]);
 this.updateReturnDate();
}
 
 
 function DateList_setDateDecComposedString(lstCmp,dat){
 if(dat.length<8){
 return;
}
 for(var i=0;i<this.nbMonths;i++){
 if(this.monthsId[i]==parseInt(dat.substr(0,6),10)-1){
 lstCmp[0].options[i].selected=true;
}
}
 this.updateDays(lstCmp[0]);
 lstCmp[1].options[parseInt(dat.substr(6,2),10)-1].selected=true;
 if(lstCmp==this.grpEnd){
 this.returnDateModify=1;
}
 this.updateDays(lstCmp[0]);
 this.updateReturnDate();
}
 
 
 function DateList_setDateTimeComposedString(lstCmp,dat,anyTime){
 if(dat.length<12){
 if(lstCmp==this.grpStart){
 
 lstCmp[0].options[0].selected=true;
 this.updateDays(lstCmp[0]);
 lstCmp[1].options[0].selected=true;
 this.checkDay(lstCmp[1]);
 this.updateReturnDate();
}
 return;
}
 for(var i=0;i<this.nbMonths;i++){
 if(this.monthsId[i]==parseInt(dat.substr(0,6),10)-1){
 lstCmp[0].options[i].selected=true;
}
}
 this.updateDays(lstCmp[0]);
 lstCmp[1].options[parseInt(dat.substr(6,2),10)-1].selected=true;
 
 if(lstCmp[3]){
 if(anyTime!="!"){
 if(anyTime=="TRUE"||anyTime=="ANY"){
 if(lstCmp[3].tagName.toLowerCase()=="select"){
 for(var i=0;i<lstCmp[3].options.length;i++){
 if(lstCmp[3].options[i].value=="ANY"){
 lstCmp[3].options[i].selected=true;
}
}
}else{
 lstCmp[3].value="ANY";
}
}else if(anyTime=="MORNING"||anyTime=="AFTERNOON"||anyTime=="EVENING"){
 if(lstCmp[3].tagName.toLowerCase()=="select"){
 for(var i=0;i<lstCmp[3].options.length;i++){
 if(lstCmp[3].options[i].value==anyTime){
 lstCmp[3].options[i].selected=true;
}
}
}else{
 lstCmp[3].value=anyTime;
}
}else{
 if(lstCmp[3].tagName.toLowerCase()=="select"){
 var timeCast=parseInt(dat.substr(8,2),10);
 timeCast*=100;
 for(var i=0;i<lstCmp[3].options.length;i++){
 if(lstCmp[3].options[i].value==timeCast){
 lstCmp[3].options[i].selected=true;
}
}
}else{
 lstCmp[3].value=dat.substr(8,4);
}
}
}
}
 if(lstCmp==this.grpEnd){
 this.returnDateModify=1;
}
 this.updateDays(lstCmp[0]);
 this.updateReturnDate();
}
 
 
 
 
 function DateList_setReturnDate(newDat){
 var newDay=newDat.getDate();
 var newMonth=newDat.getMonth();
 var newYear=newDat.getYear();
 if(newYear<1000){
 newYear+=1900;
}
 
 var searchedMonth="";
 searchedMonth+=newYear;
 if(newMonth<10){
 searchedMonth+="0";
}
 searchedMonth+=newMonth;
 var foundSelection=0;
 for(var i=0;i<this.grpEnd[0].options.length;i++){
 if(this.monthsId[i]==searchedMonth){
 this.grpEnd[0].options[i].selected=true;
 foundSelection=1;
}else{
 this.grpEnd[0].options[i].selected=false;
}
}
 if(foundSelection==0){
 this.grpEnd[0].options[this.grpEnd[0].options.length-1].selected=true;
 this.updateDays(this.grpEnd[0]);
 this.grpEnd[1].options[this.grpEnd[1].options.length-1].selected=true;
}else{
 this.updateDays(this.grpEnd[0]);
 this.grpEnd[1].options[newDay-1].selected=true;
}
 this.checkDay(this.grpEnd[1]);
}
 
 
 
 
 function DateList_addMonth(initDat,nbMonth){
 var resDat=new Date(initDat);
 if(nbMonth>0){
 for(var i=0;i<nbMonth;i++){
 resDat.setMonth(resDat.getMonth()+1);
}
}else if(nbMonth<0){
 for(var i=nbMonth;i<0;i++){
 resDat.setMonth(resDat.getMonth()-1);
}
}
 if(resDat.getDate()!=initDat.getDate()){
 resDat.setMonth(resDat.getMonth()-1);
 var resDatYear=resDat.getYear();
 if(resDatYear<1000){
 resDatYear+=1900;
}
 resDat.setDate(this.getMaxDays(resDat.getMonth(),resDatYear));
}
 return resDat;
}
 
 
 
 
 function DateList_addYear(initDat,nbYear){
 var resDat=new Date(initDat);
 var initDatYear=initDat.getYear();
 if(initDatYear<1000){
 initDatYear+=1900;
}
 resDat.setYear(initDatYear+nbYear);
 if(resDat.getDate()!=initDat.getDate()){
 resDat.setMonth(resDat.getMonth()-1);
 var resDatYear=resDat.getYear();
 if(resDatYear<1000){
 resDatYear+=1900;
}
 resDat.setDate(this.getMaxDays(resDat.getMonth(),resDatYear));
}
 return resDat;
}
 
 
 
 
 
 function DateList_setStartingInfos(){
 var curDat=new Date(this.currentDate);
 var cDatV=(new Date(this.currentDate)).getTime();
 
 if(this.startAvailDate.length>0){
 var v=parseInt(this.startAvailDate.substr(1),10);
 switch(this.startAvailDate.substr(0,1))
{
 case "N":
 this.startDate=new Date(cDatV+60000*v);
 break;
 case "H":
 this.startDate=new Date(cDatV+3600000*v);
 break;
 case "D":
 this.startDate=new Date(cDatV+86400000*v);
 break;
 case "W":
 this.startDate=new Date(cDatV+604800000*v);
 break;
 case "M":
 this.startDate=this.addMonth(curDat,v);
 break;
 case "Y":
 this.startDate=this.addYear(curDat,v);
 break;
}
}else{
 this.startDate=new Date(curDat);
}
}
 
 
 
 
 
 function DateList_setEndingInfos(){
 var curDat=new Date(this.currentDate);
 var cDatV=(new Date(this.currentDate)).getTime();
 
 if(this.endAvailDate.length>0){
 var v=parseInt(this.endAvailDate.substr(1),10);
 switch(this.endAvailDate.substr(0,1))
{
 case "N":
 this.endDate=new Date(cDatV+60000*v);
 break;
 case "H":
 this.endDate=new Date(cDatV+3600000*v);
 break;
 case "D":
 this.endDate=new Date(cDatV+86400000*v);
 break;
 case "W":
 this.endDate=new Date(cDatV+604800000*v);
 break;
 case "M":
 this.endDate=this.addMonth(curDat,v);
 break;
 case "Y":
 this.endDate=this.addYear(curDat,v);
 break;
}
}else{
 this.endDate=new Date(curDat);
}
}
 
 
 
 function DateList_initMonthsDaysTables(){
 this.nbMonths=0;
 var curDat=new Date(this.startDate);
 while(curDat.getTime()<=this.endDate.getTime()||curDat.getMonth()==this.endDate.getMonth()){
 var year=curDat.getYear();
 if(year<1000){
 year+=1900;
}
 
 this.monthsId[this.nbMonths]="";
 this.monthsId[this.nbMonths]+=year;
 if(curDat.getMonth()<10){
 this.monthsId[this.nbMonths]+="0";
}
 this.monthsId[this.nbMonths]+=curDat.getMonth();
 this.monthsLabel[this.nbMonths]="";
 this.monthsLabel[this.nbMonths]+=this.monthsNames[curDat.getMonth()];
 this.monthsLabel[this.nbMonths]+=year;
 
 this.startDayOfMonth[this.nbMonths]=1;
 this.endDayOfMonth[this.nbMonths]=this.getMaxDays(curDat.getMonth(),year);
 this.nbMonths++;
 curDat=this.addMonth(this.startDate,this.nbMonths);
}
 
 this.startDayOfMonth[0]=this.startDate.getDate();
 this.endDayOfMonth[this.nbMonths-1]=this.endDate.getDate();
}
 
 
 function DateList_initListMonths(cmpMonth){
 for(var i=0;i<this.nbMonths;i++){
 cmpMonth.options[i]=new Option(this.monthsLabel[i],this.monthsId[i]);
}
}
 
 
 
 function DateList_initDate(){
 var curDat=new Date(this.currentDate);
 var curDay=curDat.getDate();
 var curMonth=curDat.getMonth();
 var curYear=curDat.getYear();
 if(curYear<1000){
 curYear+=1900;
}
 
 var searchedMonth="";
 searchedMonth+=curYear;
 if(curMonth<10){
 searchedMonth+="0";
}
 searchedMonth+=curMonth;
 var monthFound=false;
 for(var i=0;i<this.grpStart[0].options.length;i++){
 if(this.monthsId[i]==searchedMonth){
 this.grpStart[0].options[i].selected=true;
 this.grpStart[0].selectedIndex=i;
 monthFound=true;
}else{
 this.grpStart[0].options[i].selected=false;
}
}
 if(!monthFound){
 
 this.grpStart[0].options[0].selected=true;
 this.grpStart[0].selectedIndex=0;
}
 
 this.updateDays(this.grpStart[0]);
 this.grpStart[1].options[0].selected=true;
}
 
 
 
 
 function DateList_updateReturnDate(){
 if(this.returnDateModify==0&&this.grpEnd){
 var outboundDate=this.getDateTimeComposed(this.grpStart);
 var returnDate=new Date(outboundDate);
 returnDate.setDate(outboundDate.getDate()+this.betweenDays);
 this.setReturnDate(returnDate);
}
}
 
 
 
 var tableAddDone=Array();
 function DateList_nextAddBetweenDays(eAnyTime){
 if(tableAddDone[this.grpStart[0].id]==null){
 tableAddDone[this.grpStart[0].id]=true;
}
 
 if(tableAddDone[this.grpStart[0].id]==false&&!this.nextDateList.hasBeenModifiedByUser){
 var expr="this.nextDateList.setDateTimeComposedString(this.nextDateList.grpStart,\"";
 eval("var prevDate=this.getDateTimeComposed(this.grpStart);");
 var prevDateTime=prevDate.getTime();
 prevDate.setTime(prevDateTime+(7*24*60*60*1000));
 
 var prevDateString="";
 var prevDateYear=prevDate.getYear();
 var prevDateMonth=prevDate.getMonth()+1;
 var prevDateDay=prevDate.getDate();
 var prevDateHours=prevDate.getHours();
 var prevDateMinutes=prevDate.getMinutes();
 var prevDateSeconds=prevDate.getSeconds();
 if(prevDateYear<1000)prevDateYear+=1900;
 prevDateString+=prevDateYear;
 if(prevDateMonth<10)prevDateString+="0";
 prevDateString+=prevDateMonth;
 if(prevDateDay<10)prevDateString+="0";
 prevDateString+=prevDateDay;
 if(prevDateHours<10)prevDateString+="0";
 prevDateString+=prevDateHours;
 if(prevDateMinutes<10)prevDateString+="0";
 prevDateString+=prevDateMinutes;
 if(prevDateSeconds<10)prevDateString+="0";
 prevDateString+=prevDateSeconds;
 expr+=prevDateString;
 expr+="\",eAnyTime);";
 tableAddDone[this.grpStart[0].id]=true;
 eval(expr);
}
 else{
 tableAddDone[this.grpStart[0].id]=false;
}
}