/* This files assumes the date.js file has also been included into the page. */

Calendar.prototype.updateDaySelectOptions=function(){
	var options=this.dayField.options;
	var optionsLength=0;
	var selectedIndex=0;
	var m=this.displayDate.getMonth();
	var d=this.displayDate.getDate();
	var temp=new Date(this.displayDate);
	for(var i=1;i<=31;++i){
		temp.setDate(i);
		if(m==temp.getMonth()){
			if(temp.dateWithinRanges(this.dateRanges)){
				if(i==d){
					selectedIndex=optionsLength;
				}
				options[optionsLength]=new Option(temp.format(daySelectFormat),i);
				++optionsLength;
			}
		}
	}
	options.length=optionsLength;
	this.dayField.selectedIndex=selectedIndex;
}
Calendar.prototype.updateMonthYearSelectOptions=function(){
	var options=this.monthYearField.options;
	var optionsLength=0;
	var selectedIndex=0;
	var ddm=this.displayDate.getMonth();
	var ddy=this.displayDate.getFullYear();
	var endM=this.endDate.getMonth();
	var endY=this.endDate.getFullYear();
	var temp=new Date(this.startDate);
	temp.setDate(1);
	var m=temp.getMonth();
	var y=temp.getFullYear();
	while(y<endY||(m<=endM&&y<=endY)){
		if(temp.monthWithinRanges(this.dateRanges)){
			if(m==ddm&&y==ddy){
				selectedIndex=optionsLength;
			}
			var label=buildMonthYearSelectLabel(temp.getShortMonth(),y);
			var value=(m+1)+','+y;
			options[optionsLength]=new Option(label,value);
			++optionsLength;
		}
		temp.setMonth(m+1);
		m=temp.getMonth();
		y=temp.getFullYear();
	}
	options.length=optionsLength;
	this.monthYearField.selectedIndex=selectedIndex;
}
Calendar.prototype.updateHourSelectOptions=function(){

	var options=this.hourField.options;
	var fieldVal=this.hourField.value;

	options.length=0;
	var range=new DateRange(new Date(this.displayDate),new Date(this.displayDate));
	range.from.setHours(0,0,0);
	range.to.setHours(11,59,59);
	var selected=false;
	var selectedIndex=null;
	if (this.isAnytime) {
		if (this.isAnytimeSelected||!this.hasUserSetHour){ selectedIndex=options.length;}
		options[options.length]=new Option(Date.time[0],'Anytime',false,false);
	}
	if(range.intersectsRanges(this.dateRanges)){
		if(this.hourRangeSelected&&range.withinRange(this.displayDate)&& selectedIndex == null){selectedIndex=options.length;}
		options[options.length]=new Option(Date.time[1],'Morning',false,false);
	}
	range.from.setHours(12,0,0);
	range.to.setHours(17,59,59);
	if(range.intersectsRanges(this.dateRanges)){
		if(this.hourRangeSelected&&range.withinRange(this.displayDate)&& selectedIndex == null){selectedIndex=options.length;}
		options[options.length]=new Option(Date.time[2],'Afternoon',false,false);
	}
	range.from.setHours(18,0,0);
	range.to.setHours(20,59,59);
	if(range.intersectsRanges(this.dateRanges)){
		if(this.hourRangeSelected&&range.withinRange(this.displayDate)&& selectedIndex == null){selectedIndex=options.length;}
		options[options.length]=new Option(Date.time[3],'Evening',false,false);

	}

	var temp=new Date(this.displayDate);
	for(var i=1;i<=23;++i){
		temp.setHours(i,0,0);
		if(temp.withinRanges(this.dateRanges)){
			if(selectedIndex==null&&i==this.displayDate.getHours()){selectedIndex=options.length;}
			options[options.length]=new Option((i<10?('0'+i+':00'):(i+':00')),i,false,false);
		}
	}
	this.hourField.selectedIndex=selectedIndex;
}
Calendar.prototype.updateFormInputs=function(){
	if(this.haveFieldsBeenInserted){
		this.timeField.value=this.displayDate.getTime();
		this.formattedField.value=this.displayDate.format('YYYYmmDDHH00');
		this.bookLeadFormattedField.value=this.startDate.format('YYYYmmDDHH00');
		this.yearField.value=this.displayDate.getFullYear();
		this.monthField.value=this.displayDate.getMonth()+1;
		if(this.showMonthYearField){
			this.updateMonthYearSelectOptions();
		}else{
			this.monthYearField.value=this.monthField.value+','+this.yearField.value;
		}
		if(this.showDayField){
			this.updateDaySelectOptions();
		}else{
			this.dayField.value=this.displayDate.getDate();
		}
		if(this.showHourField){
			this.updateHourSelectOptions();
		}else{
			this.hourField.value=this.displayDate.getHours();
		}
	}
}
Calendar.prototype.update=function(displayDate){ // This must be the only method to set 'this.displayDate'
	this.displayDate=new Date(displayDate.getTime()); // construct new date object as ie popup doesn't have date.js.
	if(!this.displayDate.withinRanges(this.dateRanges)){
		this.pullWithinRange();
	}
	this.updateFormInputs();
	this.divCalendar.innerHTML=this.createCalendarHtml();
	if(this.onChangeCallback!=null){
		this.onChangeCallback();
	}	
	if(this.popup!=null){
		if(this.useIePopup){
			this.popup.document.body.innerHTML=this.divCalendar.innerHTML; 
		}else{
			this.popup=this.divCalendar;
		}
	}
}
Calendar.prototype.pullWithinRange=function(){
	var done=false;
	var closestEarlier=null;
	var closestLater=null;
	var valueTime=this.displayDate.getTime();
	for(var i=0;i<this.dateRanges.length;++i){
		var from=this.dateRanges[i].from.getTime();
		var to=this.dateRanges[i].to.getTime();
		if(to<valueTime&&(closestEarlier==null||(valueTime-to)<(valueTime-closestEarlier.getTime()))){
			closestEarlier=new Date(to);
		}else if(valueTime<from&&(closestLater==null||(from-valueTime)<(closestLater.getTime()-valueTime))){
			closestLater=new Date(from);
		}
	}
	if(closestEarlier!=null&&closestEarlier.getMonth()==this.displayDate.getMonth()){
		this.displayDate=closestEarlier;
	}else if(closestLater!=null&&closestLater.getMonth()==this.displayDate.getMonth()){
		this.displayDate=closestLater;
	}else{
		this.displayDate=this.dateRanges[0].from;
	}
}
Calendar.prototype.updateDayOfMonth=function(dayOfMonth){
	var temp=new Date(this.displayDate);
	temp.setDate(dayOfMonth);
	if(this.hasUserSetHour==false&&this.defaultHour!=null&&this.defaultHour>=0&&this.defaultHour<=23){
		temp.setHours(this.defaultHour,0,0); // requirement to go back to a default hour, like morning, if available.
	}
	this.update(temp);
	this.adjustHourOfDay();
}
Calendar.prototype.updateMonthYear=function(monthCommaYear){
	var my=monthCommaYear.split(',');
	var m=my[0]-1;
	var y=my[1];
	var temp=new Date(this.displayDate);
	temp.setFullYear(y);
	temp.setMonth(m);
	while(m!=temp.getMonth()){
		temp.setTime(temp.getTime()-24*60*60*1000);
	}
	if(this.hasUserSetHour==false&&this.defaultHour!=null&&this.defaultHour>=0&&this.defaultHour<=23){
		temp.setHours(this.defaultHour,0,0); // requirement to go back to a default hour, like morning, if available.
	}
	this.update(temp);
	this.adjustHourOfDay();
}
Calendar.prototype.updateHourOfDay=function(hourOfDay){
	this.hasUserSetHour=true;
	this.hourRangeSelected=isNaN(parseInt(hourOfDay));
	var hourOfDayString=hourOfDay.toString().toLowerCase();

	if('morning'==hourOfDayString){hourOfDay=(this.isAnytime==true)?6:1;}
	else if('afternoon'==hourOfDayString){hourOfDay=(this.isAnytime==true)?15:12;}
	else if('evening'==hourOfDayString){hourOfDay=(this.isAnytime==true)?20:18;}

	if('anytime'==hourOfDayString){
		this.isAnytimeSelected = true;
		hourOfDay=12;
	} else {
		this.isAnytimeSelected = false;
	}
	var temp=new Date(this.displayDate);
	temp.setHours(hourOfDay);
	this.update(temp);
	this.adjustHourOfDay();
}
Calendar.prototype.adjustHourOfDay=function(){
	if(this.hourRangeSelected){
		var hourOfDay=this.hourField.value;
		var hourOfDayString=hourOfDay.toString().toLowerCase();

		if('morning'==hourOfDayString){hourOfDay=(this.isAnytime==true)?6:1;}
		else if('afternoon'==hourOfDayString){hourOfDay=(this.isAnytime==true)?15:12;}
		else if('evening'==hourOfDayString){hourOfDay=(this.isAnytime==true)?20:18;}
		if('anytime'==hourOfDayString){

			this.isAnytimeSelected = true;
			hourOfDay=12;
		} else {
			this.isAnytimeSelected = false;
		}
		if(hourOfDay!=this.displayDate.getHours()){
			var temp=new Date(this.displayDate);
			temp.setHours(hourOfDay);
			this.update(temp);
		}
	}
}

Calendar.prototype.createCalendarHtml=function(){	
	var raw='<table class="calendar" cellspacing="0" ';
	if(this.showCalendarIcon){
		raw+='onmouseout="javascript:'+this.popupVarName()+'.mouseOut();" onmouseover="javascript:'+this.popupVarName()+'.mouseOver();"';
	}
	raw+='>\n<tr>\n<td style="padding:0;">\n<table class="months" cellspacing="0">\n<tr>';

	var ddd=this.displayDate.getDate();
	var ddm=this.displayDate.getMonth();
	var ddy=this.displayDate.getFullYear();
	var endM=this.endDate.getMonth();
	var endY=this.endDate.getFullYear();
	var temp=new Date(this.startDate);
	temp.setDate(1);
	var m=temp.getMonth();
	var y=temp.getFullYear();
	var i=0; 
	while(y<endY||(m<=endM&&y<=endY)||i%7!=0){
		raw+='<th ';
		if(temp.monthWithinRanges(this.dateRanges)){
			var monthCommaYear=(m+1)+','+y;
			if(m==ddm&&y==ddy){
				raw+=' class="active"';
			}else{
				raw+=' class="month"';
				raw+=' onclick="javascript:'+this.popupVarName()+'.updateMonthYear(\''+monthCommaYear+'\');" title="'+temp.getShortMonth()+' '+y+'"';
				raw+=' onmouseover="javascript:this.className+=\' hover\';"';
				raw+=' onmouseout="javascript:this.className=this.className.replace(/ hover/,\'\');"';
			}
		}else{
			raw+=' class="disabled" ';
		}
		raw+='>'+temp.getShortMonth()+'</th>';
		temp.setMonth(m+1);
		m=temp.getMonth();
		y=temp.getFullYear();
		if(++i%7==0){
			raw+='\n</tr>\n<tr>';
		}
	}
	raw+='\n</tr>';
	raw+='\n</table>';
	raw+='\n<table class="date"><tr><th>'+this.displayDate.format(calendarDateDisplayFormat)+'</th></tr></table>';
	raw+='\n<table class="days">';
	raw+='\n<tr><th>'+temp.getShortDayIndex(0)+'</th><th>'+temp.getShortDayIndex(1)+'</th><th>'+temp.getShortDayIndex(2)+'</th><th>'+temp.getShortDayIndex(3)+'</th><th>'+temp.getShortDayIndex(4)+'</th><th>'+temp.getShortDayIndex(5)+'</th><th>'+temp.getShortDayIndex(6)+'</th></tr>';

	var temp=new Date(this.displayDate);
	temp.setDate(1);
	var startDay=temp.getDay();

	for(var i=0;i<6;++i){
		raw+='\n<tr>';
		for(var j=0;j<7;++j){
			if((j+7*i)>=startDay && temp.getMonth()==this.displayDate.getMonth()){
				raw+='<td ';
				if(this.dateRanges==null||temp.dateWithinRanges(this.dateRanges)){
					if(temp.getDate()==ddd&&temp.getMonth()==ddm&&temp.getYear()==ddy){
						raw+=' class="active"';
					}else{
						raw+=' class="date"';
						raw+=' onmouseover="javascript:this.className=this.className+\' hover\';"';
						raw+=' onmouseout="javascript:this.className=this.className.replace(/ hover/ig,\'\');"';
					}
					raw+=' onclick="javascript:'+this.popupVarName()+'.hidePopup();'+this.popupVarName()+'.updateDayOfMonth('+temp.getDate()+');"';
				}else{
					raw+=' class="disabled"';
				}
				raw+='>'+temp.getDate()+'</td>';
				temp.setDate((j+7*i)+2-startDay);
			}else{
				raw+='<td>&nbsp;</td>';
			}
		}
		raw+='</tr>';
	}
	raw+='\n</table>\n</td>\n</tr>\n</table>';
	return raw;
}

Calendar.prototype.millisecondTimeout=500;
Calendar.prototype.useIePopup=(window.createPopup?true:false); // IE-Popups used in IE 5.5 onwards
Calendar.prototype.popupVarName=function(){return(this.useIePopup?('parent.'+this.varName):this.varName);}
Calendar.prototype.popupCreate=function(){
	this.clearPopupTimers();
	this.mouseOverCounter=0;	
	this.popupX=0;
	this.popupY=this.dayField.offsetHeight+1;
	if(this.useIePopup){
		this.popup=this.win.createPopup();
		var link=this.popup.document.createElement('link');
		link.href=this.calendarCSS;
		link.rel='stylesheet';
		link.type='text/css';
		this.popup.document.body.parentNode.insertBefore(link,this.popup.document.body);
		this.popup.document.body.innerHTML=this.divCalendar.innerHTML; 
		this.popup.show(0,this.monthYearField.offsetHeight,$j(this.divCalendar).width(),$j(this.divCalendar).height()+2,this.monthYearField);
	}else{
		var temp = this.monthYearField;
		while(temp.offsetParent!=null){
			temp=temp.offsetParent;
		}
		this.popup=this.divCalendar;
		$j(this.popup).show();
	}
	this.mouseOver();
}
Calendar.prototype.mouseOver=function(){
	this.mouseOverCounter++;
}
Calendar.prototype.mouseOut=function(){
	this.mouseOverCounter--;
	var objName;
	
	if(($j('body').find('.searchFragment').html() != null)&& (this.useIePopup))
	{
		objName = this.popupVarName().split('.')[1];
	}
	else
	{
		objName = this.popupVarName();
	}
	
	this.popupTimers.push(window.setTimeout(objName+'.timeoutPopup();',this.millisecondTimeout));
}
Calendar.prototype.timeoutPopup=function(){
	if(this.mouseOverCounter<=0){
		this.hidePopup();
	}
}
Calendar.prototype.clearPopupTimers=function(){
	while(this.popupTimers.length>0){
		window.clearTimeout(this.popupTimers.shift());
	}
	this.mouseOverCounter=0;
}
Calendar.prototype.hidePopup=function(){
	this.clearPopupTimers();
	if(this.popup!=null){
		if(this.useIePopup){
			this.popup.hide();
		}else{
			$j(this.popup).hide();
		}
	}
	this.popup=null;
}
Calendar.prototype.popupToggle=function(){
	if(this.popup==null&&!this.dayField.disabled&&!this.monthYearField.disabled){
		this.popupCreate();
	}else{
		this.hidePopup();
	}
}
Calendar.prototype.setEnabled=function(enabled){
	if(this.dayField.type!='hidden'){this.dayField.disabled=(!enabled);}
	if(this.monthYearField.type!='hidden'){this.monthYearField.disabled=(!enabled);}
	if(this.hourField.type!='hidden'){this.hourField.disabled=(!enabled);}
	if(enabled){
		this.calendarIcon.className=this.calendarIcon.className.replace(/disabled/ig,'');
	}else{
		this.calendarIcon.className+=' disabled';
	}
}
Calendar.prototype.createCalendar=function(obj){
	this.fieldTag=this.doc.getElementById(this.fieldTagId);		
	while(this.fieldTag.hasChildNodes()){
		this.fieldTag.removeChild(this.fieldTag.firstChild);
	}
	this.calendarTag=((this.calendarTagId==null)?null:this.doc.getElementById(this.calendarTagId));
	
	while(this.calendarTag!=null&&this.calendarTag.hasChildNodes()){
		this.calendarTag.removeChild(this.calendarTag.firstChild);
	}
	
	var temp=this.doc.createElement('div');
	temp.className='clearit';
	temp.appendChild(this.monthYearField);
	temp.appendChild(this.dayField);
	if(this.showCalendarIcon){temp.appendChild(this.calendarIcon);}
	temp.appendChild(this.hourField);
	temp.appendChild(this.yearField);
	temp.appendChild(this.monthField);
	temp.appendChild(this.timeField);
	temp.appendChild(this.formattedField);
	temp.appendChild(this.bookLeadFormattedField);

	this.fieldTag.appendChild(temp);
	this.haveFieldsBeenInserted=true;
	this.update(this.startDate);
	

	if (obj)
	{
		if(this.showCalendarIcon||this.calendarTagId==null)
		{
			$j('#'+obj).prepend(this.divCalendar);
		}
		else
		{
			this.calendarTag.appendChild(this.divCalendar);
		}
	}
	else
	{
		if(this.showCalendarIcon||this.calendarTagId==null)
		{
			$j('#'+this.fieldTagId).prepend(this.divCalendar);
		}
		else
		{
			this.calendarTag.appendChild(this.divCalendar);
		}
	}
}
Calendar.prototype.setOnChangeCallback=function(onChangeCallback){
	this.onChangeCallback=onChangeCallback;
}
Calendar.prototype.getDate=function(){
	return(this.displayDate==null?this.startDate:this.displayDate);
}
Calendar.prototype.setCalendarCSS=function(calendarCSS){
	this.calendarCSS=calendarCSS;
}
Calendar.prototype.setDefaultHour=function(defaultHour){
	this.defaultHour=defaultHour;
}
Calendar.prototype.setAnytime=function(value){
	this.isAnytime=value;
	if(this.showHourField){
		this.updateHourSelectOptions();
	}else{
		this.hourField.value=this.displayDate.getHours();
	}
}
Calendar.prototype.serialize=function(){
	return ''+this.getDate().getTime()+'-'+(this.hourRangeSelected?1:0)+'-'+(this.hasUserSetHour?1:0)+'-'+(this.isAnytimeSelected?1:0);
}
Calendar.prototype.deserialize=function(value){
	var s=value.split('-');
	this.isAnytimeSelected=(s[3]=='1'?true:false);
	this.hasUserSetHour=(s[2]=='1'?true:false);
	this.hourRangeSelected=(s[1]=='1'?true:false);
	this.update(new Date(parseInt(s[0])));
}
Calendar.prototype.showHours=function(){
	this.hourField.style.visibility = 'visible';
}
Calendar.prototype.hideHours=function(){
	this.updateHourOfDay('Anytime');
	this.hourField.style.visibility = 'hidden';
}
function Calendar(varName,inputIdPrefix, inputNamePrefix,dateRanges,fieldTagId,showMonthYearField,showDayField,showHourField,showCalendarIcon,calendarTagId,fieldsToHide){	

	this.win=window;
	this.doc=document;
	this.varName=varName;
	this.fieldTagId=fieldTagId;
	this.calendarTagId=calendarTagId;
	this.isAnytime=false;
	this.isAnytimeSelected=true;
	this.dateRanges=dateRanges;
	this.startDate=dateRanges[0].from;
	this.endDate=dateRanges[dateRanges.length-1].to;
	this.displayDate=null;
	this.fieldsToHide = fieldsToHide;
	this.inputIdPrefix=inputIdPrefix;
	this.inputNamePrefix=inputNamePrefix;
	this.showMonthYearField=((showMonthYearField==true||showMonthYearField==null)?true:false);
	this.showDayField=((showDayField==true||showDayField==null)?true:false);
	this.showHourField=((showHourField==true||showHourField==null)?true:false);
	this.showCalendarIcon=((showCalendarIcon==true||showCalendarIcon==null)?true:false);
	this.contextURL=document.URL.substring(0,document.URL.indexOf('/',9));
	this.calendarCSS=this.contextURL+'/styles/themes/red08/common.css';	
	this.onChangeCallback=null;
	this.hourRangeSelected=true;
	this.defaultHour=null;
	this.hasUserSetHour=false;
	this.haveFieldsBeenInserted=false;	
	this.divCalendar=this.doc.createElement('div');
			
	this.divCalendar.id=this.inputIdPrefix+'CalendarPage';
	this.divCalendar.className='calendarPage';
	if(this.showCalendarIcon||this.calendarTagId==null)
	{
		$j(this.divCalendar).hide();
	}

	// The formated YYYYmmDDHH00 date-time.
	this.formattedField=this.doc.createElement('input');
	this.formattedField.type='hidden';
	this.formattedField.name=inputNamePrefix+'Formatted';
	this.formattedField.id=inputIdPrefix+'Formatted';
	

	// The minimum departure time formated YYYYmmDDHH00 date-time.
	this.bookLeadFormattedField=this.doc.createElement('input');
	this.bookLeadFormattedField.type='hidden';
	this.bookLeadFormattedField.name=inputNamePrefix+'BookLeadFormatted';
	this.bookLeadFormattedField.id=inputIdPrefix+'BookLeadFormatted';
	

	// The timeField stores the millisecond time since midnight 1st Jan 1970 (UTC).
	this.timeField=this.doc.createElement('input');
	this.timeField.type='hidden';
	this.timeField.name=inputNamePrefix+'Time';
	this.timeField.id=inputIdPrefix+'Time';
	

	this.yearField=this.doc.createElement('input');
	this.yearField.type='hidden';
	this.yearField.name=inputNamePrefix+'Year';
	this.yearField.id=inputIdPrefix+'Year';
	

	this.monthField=this.doc.createElement('input');
	this.monthField.type='hidden';
	this.monthField.name=inputNamePrefix+'Month';
	this.monthField.id=inputIdPrefix+'Month';
	

	if(this.showMonthYearField){
		this.monthYearField=this.doc.createElement('select');
		this.monthYearField.onchange=new Function(varName+'.updateMonthYear(this.options[this.selectedIndex].value);'+varName+'.hidePopup();');
	}else{
		this.monthYearField=this.doc.createElement('input');
		this.monthYearField.type='hidden';
	}

	if(this.showDayField){
		this.dayField=this.doc.createElement('select');
		this.dayField.onchange=new Function(varName+'.updateDayOfMonth(this.options[this.selectedIndex].value);'+varName+'.hidePopup();');
	}else{
		this.dayField=this.doc.createElement('input');
		this.dayField.type='hidden';
	}

	if(this.showHourField){
		this.hourField=this.doc.createElement('select');
		this.hourField.onchange=new Function(varName+'.updateHourOfDay(this.options[this.selectedIndex].value);'+varName+'.hidePopup();');
	}else{
		this.hourField=this.doc.createElement('input');
		this.hourField.type='hidden';
	}

	this.monthYearField.className='calMonthYear';
	//this.monthYearField.title="Select Month and Year";
	this.monthYearField.name=inputNamePrefix+'MonthYear';
	this.monthYearField.id=inputIdPrefix+'MonthYear';

	this.dayField.className='calDay';
	//this.dayField.title="Select Day";
	this.dayField.name=inputNamePrefix+'Day';
	this.dayField.id=inputIdPrefix+'Day';

	this.hourField.className='calHour';
	//this.hourField.title="Select Time of Day";
	this.hourField.name=inputNamePrefix+'Hour';
	this.hourField.id=inputIdPrefix+'Hour';

	if(navigator.userAgent.indexOf('Safari')>=0){
		this.calendarIcon=this.doc.createElement('a');
		this.calendarIcon.innerHTML='&nbsp;'
	}else{
		this.calendarIcon=this.doc.createElement('input');
		this.calendarIcon.type='text';
	}

	this.calendarIcon.readOnly='readOnly';
	this.calendarIcon.className='calendarIcon';
	this.calendarIcon.id=inputIdPrefix+'PopupCalendarIcon';
	this.calendarIcon.onclick=new Function(varName+'.popupToggle()');
	this.calendarIcon.onmouseover=new Function(varName+'.mouseOver()');
	this.calendarIcon.onmouseout=new Function(varName+'.mouseOut()');
	if(Calendar.title)	
		this.calendarIcon.title=Calendar.title;
	else
	    this.calendarIcon.title="Click for a month-by-month calendar";	


	this.mouseOverCounter=0;
	this.popupTimers=new Array();
	this.popup=null;
	this.popupX=0;
	this.popupY=0;
	this.popupW=0;
	this.popupH=0;
}
//This function will set the new Date Range  for the Calendar
Calendar.prototype.setDateRange=function(dateRanges){
	this.dateRanges=dateRanges;
	this.startDate=dateRanges[0].from;
	this.endDate=dateRanges[dateRanges.length-1].to;
	this.displayDate=null;
	this.update(this.startDate);
}
