﻿
function OpenCalendarWindow(strfldname)
{
  var winId=null;
  var winId_closed=false;
  var windowToOpen="/EE/testpages/calendarPopup.aspx?src=" + document.forms[0].id + "." + strfldname;
  winId=window.open (windowToOpen,"Calendar","scrollbars=no,status=no,width=250,height=250,left=250,top=280 resizable=no")
  if (winId_closed)
  {
		winId_closed=false;
  }
	  alert(document.forms[0].id + "." + strfldname);
	  alert(document.forms[0].txtDate);
	  alert(document.forms[0][1].value);
	  
}

Date.prototype.addYears = function(number) {
	return new Date(this.getFullYear()+parseInt(number), this.getMonth(), this.getDate());
};
Date.prototype.addMonths = function(number) {
	return new Date(this.getFullYear(), this.getMonth()+parseInt(number), this.getDate());
};
Date.prototype.addDays = function(number) {
	return (new Date(this.getTime()+(number*24*60*60*1000)));
};
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth();
var minimumDate = new Date(year, month, 1);
var maximumDate = minimumDate.addYears(2);
var endOfMaximumMonth = maximumDate.addMonths(1).addDays(-1);

function dayRender(sender, date, cell) {
	if (date<today.addDays(-1) || date>today.addYears(2)) {
		if (date.getMonth() == sender.viewingMonth) {
			cell.innerHTML = "<div class=\"UnavailableDay\"><div class=\"UnavailableDayValue\">"+date.getDate()+"</div></div>";
		}
	}
	return cell;
}
function afterCalendarOpen(sender) {
	hideArrows(sender);
}
function afterVisibleMonthChanged(sender) {
	hideArrows(sender);
}
function hideArrows(sender) {
	var visibleDate = new Date(sender.viewingYear, sender.viewingMonth, 1);
	var headerTR = sender.popUp.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild;
	if (visibleDate.getMonth() == minimumDate.getMonth() && visibleDate.getFullYear() == minimumDate.getFullYear()) {
		sender.clearTimers();
		headerTR.firstChild.onclick = null;
		headerTR.firstChild.firstChild.style.visibility = "hidden";
	}
	if (visibleDate.getMonth() == maximumDate.getMonth() && visibleDate.getFullYear() == maximumDate.getFullYear()) {
		sender.clearTimers();
		headerTR.childNodes[2].onclick = null;
		headerTR.childNodes[2].firstChild.style.visibility = "hidden";
	}
}
var basicDatePickerCulture_en_UK = {monthNames:new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"), monthNamesAbbr:new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), dayNames:new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"), dayNamesAbbr:new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"), firstDayOfWeek:0};
var dateParams = {onClientDayRender:"dayRender", onClientBeforeCalendarOpen:"", onClientBeforeCalendarClose:"", onClientAfterCalendarOpen:"afterCalendarOpen", onClientBeforeSelectionChanged:"", onClientAfterSelectionChanged:"", onClientBeforeVisibleMonthChanged:"", onClientAfterVisibleMonthChanged:"afterVisibleMonthChanged", enabled:true, autoPostBack:false, selectableWeekDays:true, selectableWeekendDays:true, selectablePrevMonthDays:true, selectableNextMonthDays:true, maximumDate:null, minimumDate:null, twoDigitYearBreak:50, openCalendarOnTextBoxFocus:false, monthSelectorEnabled:true, yearSelectorEnabled:true, dayStatusBarText:"{0}", nullDateText:"", xOffset:10, yOffset:-232, nextMonthImageUrl:"/controlImages/arrow_right.gif", prevMonthImageUrl:"/controlImages/arrow_left.gif", nextPrevMonthImageWidth:"12px", nextPrevMonthImageHeight:"10px", nextMonthText:"&gt;", prevMonthText:"&lt;", showWeekNumbers:false, showDaysInNextMonth:false, showDaysInPrevMonth:false, showTodayButton:false, todayButtonText:"Today", showNoneButton:false, noneButtonText:"None", footNoteText:"<a href=\"javascript:void(0);\" onclick=\"basicDatePicker.hidePopUp();\">Close</a>", forceSixRows:true, firstDayOfWeek:7, dateFormat:"ShortDate", dayNameFormat:"FirstLetter", displayType:"TextBoxAndImage", buttonText:"Calendar", nextPrevFormat:"Image", showDayHeader:true, showNextPrevMonth:true, showTitle:true, upYearSelectorImageUrl:"/controlImages/arrow_up.gif", downYearSelectorImageUrl:"/controlImages/arrow_down.gif", upDownYearSelectorImageWidth:9, upDownYearSelectorImageHeight:5, upYearSelectorText:"+", downYearSelectorText:"-", upDownYearSelectorFormat:"Image", monthSelectorXOffset:-11, monthSelectorYOffset:2, yearSelectorXOffset:-11, yearSelectorYOffset:2, visibleDate:null, popUpStyle:"", popUpStyleCssClass:"bdpPopUp", calendarStyle:"", calendarStyleCssClass:"bdpCalendar", noneButtonStyle:"", noneButtonStyleCssClass:"bdpClearButton", todayButtonStyle:"", todayButtonStyleCssClass:"bdpTodayButton", titleStyle:"", titleStyleCssClass:"bdpTitle", nextPrevStyle:"", nextPrevStyleCssClass:"bdpNextPrev", dayHeaderStyle:"", dayHeaderStyleCssClass:"bdpDayHeader", dayStyle:"", dayStyleCssClass:"bdpDay", otherMonthDayStyle:"", otherMonthDayStyleCssClass:"bdpOtherMonthDay bdpDay", weekendDayStyle:"", weekendDayStyleCssClass:"bdpWeekendDay bdpDay", selectedDayStyle:"", selectedDayStyleCssClass:"bdpSelectedDay bdpDay", todayDayStyle:"", todayDayStyleCssClass:"bdpTodayDay bdpDay", footerStyle:"", footerStyleCssClass:"bdpFooter", footNoteStyle:"", footNoteStyleCssClass:"bdpFootNote", weekNumberStyle:"", weekNumberStyleCssClass:"bdpWeekNumber", otherMonthDayWeekendDayStyle:"", otherMonthDayWeekendDayStyleCssClass:"bdpOtherMonthDay bdpDay bdpWeekendDay bdpDay bdpDay", selectedDayTodayDayStyle:"", selectedDayTodayDayStyleCssClass:"bdpTodayDay bdpDay bdpSelectedDay bdpDay bdpDay", selectedDayWeekendDayStyle:"", selectedDayWeekendDayStyleCssClass:"bdpSelectedDay bdpDay bdpWeekendDay bdpDay bdpDay", todayDayWeekendDayStyle:"", todayDayWeekendDayStyleCssClass:"bdpTodayDay bdpDay bdpWeekendDay bdpDay bdpDay", postBackFunction:"", dateFormat:"dd/MM/yyyy", culture:"basicDatePickerCulture_en_UK", specialDates:""};
BasicDatePicker = function (suppressInit) {
	if (!suppressInit) {
		this.init();
	}
	var today = new Date();
	this.todayDate=today.getDate(), this.todayMonth=today.getMonth(), this.todayYear=today.getFullYear(), this.dateCounts=new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), this.viewingYear, this.viewingMonth, this.selectedYear, this.selectedMonth, this.selectedDay, this.buttonElement, this.valueElement, this.labelElement, this.yearInc, this.params, this.timeout, this.interval, this.popUp, this.popUpShim, this.monthSelectorShim, this.yearSelectorShim, this.monthSelector, this.yearSelector, this.stayOpen=false, this.cancelFocus=false, this.cancelTextBoxClick, this.isIE, this.isIEWin, this.isOpera, this.isSafari, this.isNS6, this.isIEMac;
};
BasicDatePicker.prototype.init = function() {
	var ua = navigator.userAgent.toLowerCase();
	var isMac = (ua.indexOf("mac") != -1);
	this.isIE = (ua.indexOf("ie") != -1);
	this.isOpera = (ua.indexOf("opera") != -1);
	this.isSafari = (ua.indexOf("safari") != -1);
	this.isNS6 = (ua.indexOf("netscape6/") != -1);
	this.isIEWin = (this.isIE && !isMac && !this.isOpera);
	this.isIEMac = (this.isIE && isMac && !this.isOpera);
};
BasicDatePicker.prototype.ehTextBoxClick = function(buttonElement, valueElement, labelElement, params) {
	this.stayOpen = true;
	if (this.cancelTextBoxClick) {
		this.cancelTextBoxClick = false;
		return false;
	} else {
		this.showPopUp(buttonElement, valueElement, labelElement, params);
	}
};
BasicDatePicker.prototype.showPopUp = function(buttonElement, valueElement, labelElement, params) {
	if (this.cancelFocus) {
		this.cancelFocus = false;
		return false;
	}
	this.inputFocusValue = valueElement.value;
	if (!params.enabled) {
		return false;
	}
	if (this.params != null && (this.params != params)) {
		/* another popUp is open, close it and open this popup */
		this.hidePopUp();
	} else if (this.params == params && this.buttonElement == buttonElement && this.valueElement == valueElement) {
		/* this popUp was reopened, close it */
		this.hidePopUp();
		return false;
	}
	this.buttonElement = buttonElement;
	this.valueElement = valueElement;
	this.labelElement = labelElement;
	this.params = this.loadParams(params);
	if (!this.popUp) {
		/* create the popup div */
		this.popUp = document.createElement("DIV");
		with (this.popUp) {
			id = "basicDatePickerPopUp";
			style.position = "absolute";
			style.visibility = "hidden";
			style.zIndex = "1000";
		}
		this.popUp.onclick = this.ehPopUpClick;
		document.body.appendChild(this.popUp);
	}
	this.parseDate(this.valueElement.value);
	if (this.params.onClientBeforeCalendarOpen.length>0 && eval("window."+this.params.onClientBeforeCalendarOpen)) {
		var clientFunction = this.params.onClientBeforeCalendarOpen+"(this)";
		if (eval(clientFunction) == false) {
			/* hide the pop up calendar */
			this.hidePopUp();
			return;
		}
	}
	this.buildCalendar();
	var buttonPosition = this.findPosition(this.buttonElement);
	var leftPosition = this.params.xOffset+buttonPosition.x;
	var topPosition = this.params.yOffset+buttonPosition.y;
	this.popUp.style.left = (leftPosition+this.buttonElement.offsetWidth-this.popUp.offsetWidth)+"px";
	this.popUp.style.top = (topPosition+this.buttonElement.offsetHeight)+"px";
	if (parseInt(this.popUp.style.left)<0) {
		this.popUp.style.left = 0;
	}
	if (parseInt(this.popUp.style.top)<0) {
		this.popUp.style.top = 0;
	}
	this.popUpShim = this.showShim(this.popUpShim, this.popUp);
	this.popUp.style.visibility = "visible";
	if (this.params.onClientAfterCalendarOpen.length>0 && eval("window."+this.params.onClientAfterCalendarOpen)) {
		var clientFunction = this.params.onClientAfterCalendarOpen+"(this)";
		if (eval(clientFunction) == false) {
			/* hide the pop up calendar */
			this.hidePopUp();
			return;
		}
	}
	document.onclick = this.ehDocumentClick;
	document.onkeydown = this.ehKeyPress;
};
BasicDatePicker.prototype.showShim = function(v, o) {
	if (this.isIEWin) {
		if (!v) {
			v = document.createElement("IFRAME");
			with (v) {
				src = "javascript:false;";
				style.position = "absolute";
				style.visibility = "hidden";
				style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
			}
			document.body.appendChild(v);
		}
		with (v) {
			style.width = o.offsetWidth;
			style.height = o.offsetHeight;
			style.top = o.style.top;
			style.left = o.style.left;
			style.zIndex = o.style.zIndex-1;
			style.visibility = "visible";
		}
	}
	return v;
};
BasicDatePicker.prototype.hideShim = function(v) {
	if (this.isIEWin) {
		if (v) {
			v.style.visibility = "hidden";
		}
	}
};
BasicDatePicker.prototype.hidePopUp = function() {
	if (this.params.onClientBeforeCalendarClose.length>0 && eval("window."+this.params.onClientBeforeCalendarClose)) {
		var clientFunction = this.params.onClientBeforeCalendarClose+"(this)";
		if (eval(clientFunction) == false) {
			return;
		}
	}
	this.popUp.style.visibility = "hidden";
	this.clearTimers();
	this.hideShim(this.popUpShim);
	this.hideSelectors();
	this.reset();
	document.onclick = null;
	document.onkeydown = null;
};
BasicDatePicker.prototype.hideSelectors = function() {
	if (this.monthSelector) {
		this.monthSelector.style.visibility = "hidden";
	}
	if (this.yearSelector) {
		this.yearSelector.style.visibility = "hidden";
	}
	this.hideShim(this.monthSelectorShim);
	this.hideShim(this.yearSelectorShim);
};
BasicDatePicker.prototype.clearTimers = function() {
	if (this.timeout) {
		clearTimeout(this.timeout);
	}
	if (this.interval) {
		clearInterval(this.interval);
	}
};
BasicDatePicker.prototype.buildStyleAttributes = function(style, cssClass) {
	var atts = "";
	if (style.length>0 || cssClass.length>0) {
		if (style.length>0) {
			atts += " style=\""+style+"\"";
		}
		if (cssClass.length>0) {
			atts += " class=\""+cssClass+"\"";
		}
	}
	return atts;
};
BasicDatePicker.prototype.buildCalendar = function() {
	var specialDates = null;
	if (this.params.specialDates.length>0) {
		specialDates = eval(this.params.specialDates);
	}
	this.hideSelectors();
	if (this.viewingMonth == null || this.viewingYear == null) {
		(this.params.visibleDate) ? this.viewingMonth=this.params.visibleDate.getMonth() : this.viewingMonth=this.todayMonth;
		(this.params.visibleDate) ? this.viewingYear=this.params.visibleDate.getFullYear() : this.viewingYear=this.todayYear;
	}
	/* previous/next month */
	var viewingPrevMonth = this.viewingMonth-1;
	var viewingPrevMonthYear = this.viewingYear;
	if (viewingPrevMonth == -1) {
		viewingPrevMonth = 11;
		viewingPrevMonthYear--;
	}
	var viewingNextMonth = this.viewingMonth+1;
	var viewingNextMonthYear = this.viewingYear;
	if (viewingNextMonth == 12) {
		viewingNextMonth = 0;
		viewingNextMonthYear++;
	}
	var o = "";
	o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\""+this.buildStyleAttributes(this.params.popUpStyle, this.params.popUpStyleCssClass)+">";
	o += "<tr><td>";
	if (this.params.showTitle) {
		o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\""+this.buildStyleAttributes(this.params.titleStyle, this.params.titleStyleCssClass)+">";
		o += "<tr>";
		var monthAndYear = "<th>";
		var monthName = this.params.culture.monthNames[this.viewingMonth];
		if (this.params.monthSelectorEnabled) {
			monthAndYear += "<span onclick=\"basicDatePicker.ehMonthSelectorClick(this)\" style=\"cursor:pointer\">"+monthName+"</span>";
		} else {
			monthAndYear += monthName;
		}
		monthAndYear += " ";
		if (this.params.yearSelectorEnabled) {
			monthAndYear += "<span onclick=\"basicDatePicker.ehYearSelectorClick(this)\" style=\"cursor:pointer\">"+this.viewingYear+"</span>";
		} else {
			monthAndYear += this.viewingYear;
		}
		monthAndYear += "</th>";
		if (this.params.showNextPrevMonth) {
			var prevMonth, nextMonth;
			switch (this.params.nextPrevFormat) {
			case "ShortMonth" :
				prevMonth = this.params.culture.monthNamesAbbr[viewingPrevMonth];
				nextMonth = this.params.culture.monthNamesAbbr[viewingNextMonth];
				break;
			case "FullMonth" :
				prevMonth = this.params.culture.monthNames[viewingPrevMonth];
				nextMonth = this.params.culture.monthNames[viewingNextMonth];
				break;
			case "Image" :
				prevMonth = "<img src=\""+this.params.prevMonthImageUrl+"\"";
				var prevMonthWidthHeight = (this.params.nextPrevMonthImageWidth != "") ? "width:"+this.params.nextPrevMonthImageWidth+";" : "";
				prevMonthWidthHeight += (this.params.nextPrevMonthImageHeight != "") ? "height:"+this.params.nextPrevMonthImageHeight+";" : "";
				if (prevMonthWidthHeight != "") {
					prevMonth += " style=\""+prevMonthWidthHeight+"\"";
				}
				prevMonth += " border=\"0\" />";
				nextMonth = "<img src=\""+this.params.nextMonthImageUrl+"\"";
				var nextMonthWidthHeight = (this.params.nextPrevMonthImageWidth != "") ? "width:"+this.params.nextPrevMonthImageWidth+";" : "";
				nextMonthWidthHeight += (this.params.nextPrevMonthImageHeight != "") ? "height:"+this.params.nextPrevMonthImageHeight+";" : "";
				if (nextMonthWidthHeight != "") {
					nextMonth += " style=\""+nextMonthWidthHeight+"\"";
				}
				nextMonth += " border=\"0\" />";
				break;
			case "CustomText" :
			default :
				prevMonth = this.params.prevMonthText;
				nextMonth = this.params.nextMonthText;
				break;
			}
			o += "<td onclick=\"basicDatePicker.viewPrevMonth()\" onmousedown=\"basicDatePicker.clearTimers();basicDatePicker.timeout=setTimeout('basicDatePicker.ehPrevMonthMouseDown()', 400);\" onmouseup=\"basicDatePicker.clearTimers();\" onmouseout=\"basicDatePicker.clearTimers();\""+this.buildStyleAttributes(this.params.nextPrevStyle, this.params.nextPrevStyleCssClass)+">";
			o += prevMonth;
			o += "</td>";
			o += monthAndYear;
			o += "<td onclick=\"basicDatePicker.viewNextMonth()\" onmousedown=\"basicDatePicker.clearTimers();basicDatePicker.timeout=setTimeout('basicDatePicker.ehNextMonthMouseDown()', 400);\" onmouseup=\"basicDatePicker.clearTimers();\" onmouseout=\"basicDatePicker.clearTimers();\""+this.buildStyleAttributes(this.params.nextPrevStyle, this.params.nextPrevStyleCssClass)+">";
			o += nextMonth;
			o += "</td>";
		} else {
			o += monthAndYear;
		}
		o += "</tr>";
		o += "</table>";
	}
	/* leap year check */
	if (((this.viewingYear%4 == 0) && (this.viewingYear%100 != 0)) || (this.viewingYear%400 == 0)) {
		this.dateCounts[1] = 29;
	} else {
		this.dateCounts[1] = 28;
	}
	/* calendar table */
	o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\""+this.buildStyleAttributes(this.params.calendarStyle, this.params.calendarStyleCssClass)+">";
	/* week number header */
	if (this.params.showDayHeader) {
		o += "<thead><tr>";
		if (this.params.showWeekNumbers && this.params.firstDayOfWeek == 0) {
			o += "<th"+this.buildStyleAttributes(this.params.dayHeaderStyle, this.params.dayHeaderStyleCssClass)+">&nbsp;</th>";
		}
		/* day of week headers */
		var dayPointer = this.params.firstDayOfWeek;
		for (var i = 0; i<7; i++, dayPointer++) {
			if (dayPointer == 7) {
				dayPointer = 0;
			}
			o += "<th"+this.buildStyleAttributes(this.params.dayHeaderStyle, this.params.dayHeaderStyleCssClass)+">";
			switch (this.params.dayNameFormat) {
			case "Short" :
				o += this.params.culture.dayNamesAbbr[dayPointer];
				break;
			case "Full" :
				o += this.params.culture.dayNames[dayPointer];
				break;
			case "FirstTwoLetters" :
				o += this.params.culture.dayNames[dayPointer].substring(0, 2);
				break;
			case "FirstLetter" :
			default :
				o += this.params.culture.dayNames[dayPointer].substring(0, 1);
				break;
			}
			o += "</th>";
		}
		o += "</tr></thead>";
	}
	o += "<tbody><tr>";
	var column = 0;
	var startOfMonth = new Date(this.viewingYear, this.viewingMonth, 1).getDay();
	startOfMonth = startOfMonth-this.params.firstDayOfWeek;
	if (startOfMonth<0) {
		startOfMonth = 7+startOfMonth;
	}
	/* prev month days */
	for (var i = 0; i<startOfMonth; i++, column++) {
		o += this.buildDayCell(viewingPrevMonthYear, viewingPrevMonth, this.dateCounts[viewingPrevMonth]-startOfMonth+i+1, "prev", specialDates);
	}
	var row = 0;
	/* month days */
	for (var i = 1; i<=this.dateCounts[this.viewingMonth]; i++, column++) {
		o += this.buildDayCell(this.viewingYear, this.viewingMonth, i, "current", specialDates);
		if (column == 6) {
			if (i<this.dateCounts[this.viewingMonth]) {
				o += "</tr><tr>";
				row++;
				column = -1;
			}
		}
	}
	/* next month days */
	if (column>0) {
		for (var i = 1; column<7; i++, column++) {
			o += this.buildDayCell(viewingNextMonthYear, viewingNextMonth, i, "next", specialDates);
		}
	}
	/* insure 6th row */
	if (this.params.forceSixRows) {
		for (var y = row; y<5; y++) {
			o += "</tr><tr>";
			for (var x = 0; x<7; x++, i++) {
				o += this.buildDayCell(viewingNextMonthYear, viewingNextMonth, i, "next", specialDates);
			}
		}
	}
	o += "</tr></tbody>";
	o += "</table>";
	o += "<div"+this.buildStyleAttributes(this.params.footerStyle, this.params.footerStyleCssClass)+">";
	if (this.params.showTodayButton) {
		o += "<input type=\"button\" onClick=\"basicDatePicker.selectDate(basicDatePicker.todayYear,basicDatePicker.todayMonth,basicDatePicker.todayDate,true);\" value=\""+this.params.todayButtonText+"\""+this.buildStyleAttributes(this.params.todayButtonStyle, this.params.todayButtonStyleCssClass)+" />";
	}
	if (this.params.showNoneButton) {
		o += "<input type=\"button\" onClick=\"basicDatePicker.clearSelectedDate();\" value=\""+this.params.noneButtonText+"\""+this.buildStyleAttributes(this.params.noneButtonStyle, this.params.noneButtonStyleCssClass)+" />";
	}
	o += "</div>";
	if (this.params.footNoteText != '') {
		o += "<div"+this.buildStyleAttributes(this.params.footNoteStyle, this.params.footNoteStyleCssClass)+">"+this.params.footNoteText+"</div>";
	}
	o += "</td></tr>";
	o += "</table>";
	this.popUp.innerHTML = o;
};
BasicDatePicker.prototype.buildDayCell = function(y, m, d, type, specialDates) {
	var curDate = new Date(y, m, d);
	var arrSpecialDates = null;
	var dayOfWeek = curDate.getDay(), dayClassName = "";
	var isWeekDay = (dayOfWeek != 0 && dayOfWeek != 6);
	var styleToUse = null;
	var styleCssClassToUse = null;
	var specialDateSelectable = true;
	var specialDateOnClick = "";
	var specialDateText = "";
	switch (type) {
	case "current" :
		var isSelectedDay = (this.selectedYear == y && this.selectedMonth == m && this.selectedDay == d);
		var isTodayDay = (this.viewingYear == this.todayYear && this.viewingMonth == this.todayMonth && this.todayDate == d);
		if (isSelectedDay && isTodayDay) {
			if (isWeekDay) {
				styleToUse = this.params.selectedDayTodayDayStyle;
				styleCssClassToUse = this.params.selectedDayTodayDayStyleCssClass;
			} else {
				styleToUse = this.params.selectedDayWeekendDayStyle;
				styleCssClassToUse = this.params.selectedDayWeekendDayStyleCssClass;
			}
		} else if (isSelectedDay) {
			if (isWeekDay) {
				styleToUse = this.params.selectedDayStyle;
				styleCssClassToUse = this.params.selectedDayStyleCssClass;
			} else {
				styleToUse = this.params.selectedDayWeekendDayStyle;
				styleCssClassToUse = this.params.selectedDayWeekendDayStyleCssClass;
			}
		} else if (isTodayDay) {
			if (isWeekDay) {
				styleToUse = this.params.todayDayStyle;
				styleCssClassToUse = this.params.todayDayStyleCssClass;
			} else {
				styleToUse = this.params.todayDayWeekendDayStyle;
				styleCssClassToUse = this.params.todayDayWeekendDayStyleCssClass;
			}
		} else {
			if (isWeekDay) {
				styleToUse = this.params.dayStyle;
				styleCssClassToUse = this.params.dayStyleCssClass;
			} else {
				styleToUse = this.params.weekendDayStyle;
				styleCssClassToUse = this.params.weekendDayStyleCssClass;
			}
		}
		break;
	case "prev" :
	case "next" :
		if (isWeekDay) {
			styleToUse = this.params.otherMonthDayStyle;
			styleCssClassToUse = this.params.otherMonthDayStyleCssClass;
		} else {
			styleToUse = this.params.otherMonthDayWeekendDayStyle;
			styleCssClassToUse = this.params.otherMonthDayWeekendDayStyleCssClass;
		}
		break;
	}
	if (specialDates != null) {
		arrSpecialDates = specialDates.getByDate(curDate);
		for (var i = 0; i<arrSpecialDates.length; i++) {
			styleToUse += arrSpecialDates[i].style;
			styleCssClassToUse += " "+arrSpecialDates[i].styleCssClass;
			specialDateSelectable = arrSpecialDates[i].selectable;
			if (arrSpecialDates[i].text.length>0) {
				if (i != 0) {
					if (this.isIE || this.isOpera || this.isSafari) {
						specialDateText += "\n";
					} else {
						specialDateText += ", ";
					}
				}
				specialDateText += arrSpecialDates[i].text;
			}
			if (arrSpecialDates[i].clientSpecialDateClickFunction.length>0) {
				specialDateOnClick += "eval("+arrSpecialDates[i].clientSpecialDateClickFunction+"(new Date("+this.viewingYear+","+this.viewingMonth+","+d+")));";
			}
		}
		if (arrSpecialDates.length>0) {
			specialDateSelectable = false;
		}
		for (var i = 0; i<arrSpecialDates.length; i++) {
			if (arrSpecialDates[i].selectable == true) {
				specialDateSelectable = true;
				break;
			}
		}
	}
	var o = "";
	if (this.params.showWeekNumbers && dayOfWeek == this.params.firstDayOfWeek && this.params.firstDayOfWeek == 0) {
		var when = new Date(y, m, d);
		var newYear = new Date(y, 0, 1);
		var offset = 7+1-newYear.getDay();
		if (offset == 8) {
			offset = 1;
		}
		var daynum = ((Date.UTC(y, m, d, 0, 0, 0)-Date.UTC(y, 0, 1, 0, 0, 0))/1000/60/60/24)+1;
		var weeknum = Math.floor((daynum-offset+7)/7);
		if (weeknum == this.params.firstDayOfWeek) {
			y--;
			var prevNewYear = new Date(y, 0, 1);
			var prevOffset = 7+1-prevNewYear.getDay();
			if (prevOffset == 2 || prevOffset == 8) {
				weeknum = 53;
			} else {
				weeknum = 52;
			}
		}
		o += "<td"+this.buildStyleAttributes(this.params.weekNumberStyle, this.params.weekNumberStyleCssClass)+">"+weeknum+"</td>";
	}
	o += "<td"+this.buildStyleAttributes(styleToUse, styleCssClassToUse);
	o += " title=\""+specialDateText+"\"";
	if (this.params.dayStatusBarText.length>0) {
		var statusText = this.params.dayStatusBarText;
		if (statusText.indexOf("{0}") != -1) {
			var dateText = this.formatDate(curDate);
			statusText = statusText.replace("{0}", dateText);
		}
		o += " onmouseover=\"window.status = '"+statusText+"';return true;\"";
		o += " onmouseout=\"window.status = '';return true;\"";
	}
	o += ">";
	var onClick = "basicDatePicker.selectDate("+this.viewingYear+","+this.viewingMonth+","+d+", true)";
	if (type == "prev" || type == "next") {
		onClick = "basicDatePicker.selectDate("+y+","+m+","+d+", true)";
	}
	onClick = onClick+";"+specialDateOnClick;
	if (type == "current" || type == "prev" && this.params.showDaysInPrevMonth || type == "next" && this.params.showDaysInNextMonth) {
		if (specialDateSelectable == true && ((isWeekDay && this.params.selectableWeekDays || !isWeekDay && this.params.selectableWeekendDays) && (type == "current" || type == "prev" && this.params.selectablePrevMonthDays || type == "next" && this.params.selectableNextMonthDays) && (!this.params.maximumDate || this.params.maximumDate>=curDate) && (!this.params.minimumDate || this.params.minimumDate<=curDate))) {
			o += "<a href=\"javascript:void(0);"+onClick.replace("{0}", d)+"\" title=\""+specialDateText+"\">"+d+"</a>";
		} else {
			o += d;
		}
	} else {
		o += "&nbsp;";
	}
	o += "</td>";
	if (!this.isNS6 && this.params.onClientDayRender.length>0 && eval("window."+this.params.onClientDayRender)) {
		var objectConverterDIV = document.createElement("DIV");
		objectConverterDIV.innerHTML = "<table><tr>"+o+"</tr></table>";
		var newTD = eval(this.params.onClientDayRender+"(this, curDate , objectConverterDIV.firstChild.firstChild.firstChild.firstChild )");
		if (newTD != null && newTD.tagName && newTD.tagName == "TD") {
			var objectConverterTR = document.createElement("TR");
			objectConverterTR.appendChild(newTD);
			return objectConverterTR.innerHTML;
		}
	}
	return o;
};
BasicDatePicker.prototype.findPosition = function(element, stopElement) {
	var scrollLeft = 0, scrollTop = 0;
	if (element.tagName.toLowerCase() == "div") {
		scrollLeft = element.scrollLeft;
		scrollTop = element.scrollTop;
	}
	var elementPosition = {x:element.offsetLeft-scrollLeft, y:element.offsetTop-scrollTop};
	if ((element.offsetParent) && (typeof (stopElement) == "undefined" || (element.offsetParent.offsetParent && element.offsetParent.offsetParent != stopElement))) {
		var combinedParentPositions = this.findPosition(element.offsetParent, stopElement);
		elementPosition.x += combinedParentPositions.x;
		elementPosition.y += combinedParentPositions.y;
	}
	if (this.isIEMac) {
		var mmLeft = document.body.currentStyle.marginLeft;
		var mmTop = document.body.currentStyle.marginTop;
		if (mmLeft.indexOf("%") != -1) {
			var mpWidth = parseInt(document.body.offsetWidth);
			var mpHeight = parseInt(document.body.offsetHeight);
			mmLeft = (parseInt(mmLeft)/100)*mpWidth;
			mmTop = (parseInt(mmTop)/100)*mpHeight;
		}
		elementPosition.x += parseInt(mmLeft);
		elementPosition.y += parseInt(mmTop);
	}
	return elementPosition;
};
BasicDatePicker.prototype.viewNextMonth = function() {
	var nextMonth = this.viewingMonth+1;
	var nextMonthYear = this.viewingYear;
	if (nextMonth>11) {
		nextMonth = 0;
		nextMonthYear++;
	}
	if (this.params.onClientBeforeVisibleMonthChanged.length>0 && eval("window."+this.params.onClientBeforeVisibleMonthChanged)) {
		var newVisibleDate = new Date(nextMonthYear, nextMonth, 1);
		var clientFunction = this.params.onClientBeforeVisibleMonthChanged+"(this, newVisibleDate)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
	this.viewingMonth = nextMonth;
	this.viewingYear = nextMonthYear;
	this.buildCalendar();
	if (this.params && this.params.onClientAfterVisibleMonthChanged.length>0 && eval("window."+this.params.onClientAfterVisibleMonthChanged)) {
		var clientFunction = this.params.onClientAfterVisibleMonthChanged+"(this)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
};
BasicDatePicker.prototype.viewPrevMonth = function() {
	var prevMonth = this.viewingMonth-1;
	var prevMonthYear = this.viewingYear;
	if (prevMonth<0) {
		prevMonth = 11;
		prevMonthYear--;
	}
	if (this.params.onClientBeforeVisibleMonthChanged.length>0 && eval("window."+this.params.onClientBeforeVisibleMonthChanged)) {
		var newVisibleDate = new Date(prevMonthYear, prevMonth, 1);
		var clientFunction = this.params.onClientBeforeVisibleMonthChanged+"(this, newVisibleDate)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
	this.viewingMonth = prevMonth;
	this.viewingYear = prevMonthYear;
	this.buildCalendar();
	if (this.params.onClientAfterVisibleMonthChanged.length>0 && eval("window."+this.params.onClientAfterVisibleMonthChanged)) {
		var clientFunction = this.params.onClientAfterVisibleMonthChanged+"(this)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
};
BasicDatePicker.prototype.wireUpBeforeSelectionChanged = function(newDate) {
	if (this.params.onClientBeforeSelectionChanged.length>0 && eval("window."+this.params.onClientBeforeSelectionChanged)) {
		var clientFunction = this.params.onClientBeforeSelectionChanged+"(this, newDate)";
		if (eval(clientFunction) == false) {
			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
};
BasicDatePicker.prototype.wireUpAfterSelectionChanged = function() {
	if (this.params.onClientAfterSelectionChanged.length>0 && eval("window."+this.params.onClientAfterSelectionChanged)) {
		var clientFunction = this.params.onClientAfterSelectionChanged+"(this)";
		if (eval(clientFunction) == false) {
			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
};
BasicDatePicker.prototype.clearSelectedDate = function() {
	var prevFormattedDate = this.valueElement.value;
	if (prevFormattedDate != this.params.nullDateText) {
		if (!this.wireUpBeforeSelectionChanged(null)) {
			return;
		}
		this.valueElement.value = this.params.nullDateText;
		this.clearDate = false;
		if (this.params.displayType == "Button") {
			this.buttonElement.value = this.params.buttonText;
		} else if (this.params.displayType == "HyperLink") {
			this.buttonElement.innerHTML = this.params.buttonText;
		} else if (this.labelElement) {
			this.labelElement.innerHTML = this.params.buttonText;
		}
		if (!this.wireUpAfterSelectionChanged()) {
			return;
		}
		if (this.params.autoPostBack) {
			eval(this.params.postBackFunction);
		}
	}
	if (this.params.displayType == "TextBox" || this.params.displayType.indexOf("TextBox") != -1 && this.params.openCalendarOnTextBoxFocus) {
		this.cancelFocus = true;
	}
	if (this.valueElement.style.display != "none") {
		this.valueElement.focus();
	}
	this.hidePopUp();
};
BasicDatePicker.prototype.selectDate = function(y, m, d, hide) {
	this.selectedYear=y, this.selectedMonth=m, this.selectedDay=d;
	this.viewingYear=y, this.viewingMonth=m;
	var prevFormattedDate = this.valueElement.value;
	var formattedDate = this.formatDate(new Date(this.selectedYear, this.selectedMonth, this.selectedDay));
	if (prevFormattedDate != formattedDate) {
		if (!this.wireUpBeforeSelectionChanged(new Date(this.selectedYear, this.selectedMonth, this.selectedDay))) {
			return;
		}
		/* fill the button or label element with the formatted date */
		if (this.params.displayType == "Button") {
			this.buttonElement.value = formattedDate;
		} else if (this.params.displayType == "HyperLink") {
			this.buttonElement.innerHTML = formattedDate;
		} else if (this.labelElement) {
			this.labelElement.innerHTML = formattedDate;
		}
		this.valueElement.value = formattedDate;
		this.clearTimers();
		if (!this.wireUpAfterSelectionChanged()) {
			return;
		}
		if (this.params.autoPostBack && hide) {
			eval(this.params.postBackFunction);
		}
		if (this.params.displayType == "TextBox" || this.params.displayType.indexOf("TextBox") != -1 && this.params.openCalendarOnTextBoxFocus) {
			this.cancelFocus = true;
		}
		if (this.valueElement.style.display != "none") {
			this.valueElement.focus();
		}
	}
	if (hide) {
		this.hidePopUp();
	}
};
BasicDatePicker.prototype.padWithZero = function(num) {
	return (num<10) ? "0"+num : num;
};
BasicDatePicker.prototype.trim = function(string) {
	while ((string.substring(0, 1) == ' ') || (string.substring(0, 1) == '\n') || (string.substring(0, 1) == '\r')) {
		string = string.substring(1, string.length);
	}
	while ((string.substring(string.length-1, string.length) == ' ') || (string.substring(string.length-1, string.length) == '\n') || (string.substring(string.length-1, string.length) == '\r')) {
		string = string.substring(0, string.length-1);
	}
	return string;
};
/* Date Formatting / Parsing ---------------------------------------- */
BasicDatePicker.prototype.formatDate = function(date) {
	if (date) {
		var y = date.getFullYear(), m = date.getMonth(), d = date.getDate(), dow = date.getDay();
		var finalDate = this.params.dateFormat;
		finalDate = finalDate.replace("yyyy", y);
		finalDate = finalDate.replace("yy", this.padWithZero(y%100));
		finalDate = finalDate.replace("dddd", "{0}");
		finalDate = finalDate.replace("ddd", "{1}");
		finalDate = finalDate.replace("dd", "{2}");
		finalDate = finalDate.replace("d", "{3}");
		finalDate = finalDate.replace("MMMM", "{4}");
		finalDate = finalDate.replace("MMM", "{5}");
		finalDate = finalDate.replace("MM", "{6}");
		finalDate = finalDate.replace("M", "{7}");
		finalDate = finalDate.replace("{0}", this.params.culture.dayNames[dow]);
		finalDate = finalDate.replace("{1}", this.params.culture.dayNamesAbbr[dow]);
		finalDate = finalDate.replace("{2}", this.padWithZero(d));
		finalDate = finalDate.replace("{3}", d);
		finalDate = finalDate.replace("{4}", this.params.culture.monthNames[m]);
		finalDate = finalDate.replace("{5}", this.params.culture.monthNamesAbbr[m]);
		finalDate = finalDate.replace("{6}", this.padWithZero(m+1));
		finalDate = finalDate.replace("{7}", m+1);
		return finalDate;
	} else {
		return null;
	}
};
BasicDatePicker.prototype.parseDate = function(valueString) {
	if (valueString && valueString != this.params.nullDateText) {
		var format = this.params.dateFormat;
		var i_value = 0, i_format = 0;
		var c, token;
		var x, y;
		var year = null, month = null, date = null;
		while (i_format<format.length) {
			/* get next token from format string */
			c = format.charAt(i_format);
			token = "";
			while ((format.charAt(i_format) == c) && (i_format<format.length)) {
				token += format.charAt(i_format++);
			}
			switch (token) {
			case "d" :
			case "dd" :
				date = this.getInt(valueString, i_value, token.length, 2);
				if (!date) {
					return null;
				}
				i_value += date.length;
				date = this.parsePaddedInt(date);
				break;
			case "ddd" :
				for (var i = 0; i<this.params.culture.dayNamesAbbr.length; i++) {
					var dayName = this.params.culture.dayNamesAbbr[i];
					if (valueString.substring(i_value, i_value+dayName.length).toLowerCase() == dayName.toLowerCase()) {
						i_value += dayName.length;
						break;
					}
				}
				break;
			case "dddd" :
				for (var i = 0; i<this.params.culture.dayNames.length; i++) {
					var dayName = this.params.culture.dayNames[i];
					if (valueString.substring(i_value, i_value+dayName.length).toLowerCase() == dayName.toLowerCase()) {
						i_value += dayName.length;
						break;
					}
				}
				break;
			case "M" :
			case "MM" :
				month = this.getInt(valueString, i_value, token.length, 2);
				if (!month) {
					return null;
				}
				i_value += month.length;
				month = this.parsePaddedInt(month)-1;
				break;
			case "MMM" :
				for (var i = 0; i<this.params.culture.monthNamesAbbr.length; i++) {
					var monthName = this.params.culture.monthNamesAbbr[i];
					if (valueString.substring(i_value, i_value+monthName.length).toLowerCase() == monthName.toLowerCase()) {
						month = i;
						i_value += monthName.length;
						break;
					}
				}
				break;
			case "MMMM" :
				for (var i = 0; i<this.params.culture.monthNames.length; i++) {
					var monthName = this.params.culture.monthNames[i];
					if (valueString.substring(i_value, i_value+monthName.length).toLowerCase() == monthName.toLowerCase()) {
						month = i;
						i_value += monthName.length;
						break;
					}
				}
				break;
			case "yy" :
			case "yyyy" :
				if (token == "yyyy") {
					x = 1;
					y = 4;
				}
				if (token == "yy") {
					x = 2;
					y = 2;
				}
				year = this.getInt(valueString, i_value, x, y);
				if (year != null) {
					i_value += year.length;
					if (year.length == 2) {
						if (year>this.params.twoDigitYearBreak) {
							year = 1900+(year-0);
						} else {
							year = 2000+(year-0);
						}
					}
				}
				break;
			default :
				i_value += token.length;
			}
		}

        var UserDate = month + "-" + date + "-" + year;
        if (checkUserDateLessThanTodayDate(UserDate) == 0 || checkUserDateGreaterThanBusinessRule(UserDate,2) == 0)
        {
            year = null;
            month = null;
            date = null;
        }

		if (date == null || month == null || year == null || isNaN(date) || isNaN(month) || isNaN(year)) {
			return null;
		} else {
			this.selectDate(year, month, date);
			return new Date(year, month, date);
		}
	} else {
		return null;
	}
};

function checkUserDateGreaterThanBusinessRule(UserDate,BusinessRule)
{
	var today1 = new Date();
	var today2 = new Date(today1.getFullYear()+parseInt(BusinessRule), today1.getMonth(), today1.getDate());

    var value1 = today2.getMonth() + "-" + today2.getDate() + "-" + today2.getFullYear();

    if (compareDates(UserDate,value1,"Y") == "GY") return 0
    else if (compareDates(UserDate,value1,"Y") == "EY"){
        if (compareDates(UserDate,value1,"M") == "GM") return 0
        else if(compareDates(UserDate,value1,"M") == "EM"){
            if (compareDates(UserDate,value1,"D") == "GD") return 0
        }
    }
    return 1
}

function checkUserDateLessThanTodayDate(UserDate)
{
	var today1 = new Date();
    
    var value1 = today1.getMonth() + "-" + today1.getDate() + "-" + today1.getFullYear();
    if (compareDates(UserDate,value1,"Y") == "LY") return 0
    else if (compareDates(UserDate,value1,"Y") == "EY"){
        if (compareDates(UserDate,value1,"M") == "LM") return 0
        else if(compareDates(UserDate,value1,"M") == "EM"){
            if (compareDates(UserDate,value1,"D") == "LD") return 0
        }
    }
    return 1
}

function compareDates (value1, value2,mod) {
   var date1, date2;
   var month1, month2;
   var year1, year2;

   month1 = value1.substring (0, value1.indexOf ("-"));
   date1 = value1.substring (value1.indexOf ("-")+1, value1.lastIndexOf ("-"));
   year1 = value1.substring (value1.lastIndexOf ("-")+1, value1.length);

   month2 = value2.substring (0, value2.indexOf ("-"));
   date2 = value2.substring (value2.indexOf ("-")+1, value2.lastIndexOf ("-"));
   year2 = value2.substring (value2.lastIndexOf ("-")+1, value2.length);

   if (mod == "Y")
   { 
       if (year1 > year2) return "GY";
       else if (year1 < year2) return "LY";
       else if (year1 == year2) return "EY";
   }
   
   if (mod == "M")
   { 
       if (month1 > month2) return "GM";
       else if (month1 < month2) return "LM";
       else if (month1 == month2) return "EM";
   }

   if (mod == "D")
   { 
       if (date1 > date2) return "GD";
       else if (date1 < date2) return "LD";
       else if (date1 == date2) return "ED";
   }
   else return 0;
} 


BasicDatePicker.prototype.isInteger = function(val) {
	var digits = "1234567890";
	for (var i = 0; i<val.length; i++) {
		if (digits.indexOf(val.charAt(i)) == -1) {
			return false;
		}
	}
	return true;
};
BasicDatePicker.prototype.getInt = function(str, i, minlength, maxlength) {
	for (var x = maxlength; x>=minlength; x--) {
		var valuePart = str.substring(i, i+x);
		if (valuePart.length<minlength) {
			return null;
		}
		if (this.isInteger(valuePart)) {
			return valuePart;
		}
	}
	return null;
};
BasicDatePicker.prototype.parsePaddedInt = function(valuePart) {
	if (valuePart.length>1 && valuePart.substring(0, 1) == "0") {
		return valuePart.substring(1, valuePart.length);
	} else {
		return valuePart;
	}
};
/* Event Handlers -------------------------------------------------------------- */
BasicDatePicker.prototype.ehKeyPress = function(e) {
	if (!e) {
		e = window.event;
	}
	if (e.keyCode == 9) {
		basicDatePicker.hidePopUp();
	}
};
BasicDatePicker.prototype.ehPopUpClick = function(e) {
	basicDatePicker.stayOpen = true;
};
BasicDatePicker.prototype.ehDocumentClick = function() {
	if (!basicDatePicker.stayOpen) {
		basicDatePicker.hidePopUp();
	} else {
		basicDatePicker.stayOpen = false;
	}
};
BasicDatePicker.prototype.ehPrevMonthMouseDown = function() {
	basicDatePicker.interval = setInterval("basicDatePicker.viewPrevMonth()", 200);
};
BasicDatePicker.prototype.ehNextMonthMouseDown = function() {
	basicDatePicker.interval = setInterval("basicDatePicker.viewNextMonth()", 200);
};
BasicDatePicker.prototype.ehUpYearMouseDown = function(baseYear) {
	basicDatePicker.interval = setInterval("basicDatePicker.buildYearSelectorLinks("+(baseYear-1)+", -1)", 90);
};
BasicDatePicker.prototype.ehDownYearMouseDown = function(baseYear) {
	basicDatePicker.interval = setInterval("basicDatePicker.buildYearSelectorLinks("+(baseYear-1)+", 1)", 90);
};
BasicDatePicker.prototype.ehMonthSelectorClick = function(oSpan) {
	this.hideSelectors();
	if (!this.monthSelector) {
		/* create the popup div */
		this.monthSelector = document.createElement("DIV");
		with (this.monthSelector) {
			id = "basicDatePickerMonthSelector";
			className = "bdpMonthSelector";
			style.position = "absolute";
			style.zIndex = "1001";
		}
		document.body.appendChild(this.monthSelector);
	}
	this.monthSelector.innerHTML = "";
	var o = "";
	var monthNames = this.params.culture.monthNames;
	for (var i = 0; i<monthNames.length; i++) {
		var className = (i == this.viewingMonth) ? "bdpMonthSelectorSelectedItem" : "bdpMonthSelectorItem";
		o += "<a href=\"javascript:void(0);\" onclick=\"basicDatePicker.ehMonthSelectorMonthClick("+i+");\" class=\""+className+"\">"+monthNames[i]+"</a>";
	}
	this.monthSelector.innerHTML = o;
	var pos = this.findPosition(oSpan, this.popUp);
	this.monthSelector.style.top = (parseInt(this.popUp.style.top)+pos.y+oSpan.offsetHeight+this.params.monthSelectorYOffset)+"px";
	this.monthSelector.style.left = (parseInt(this.popUp.style.left)+pos.x+this.params.monthSelectorXOffset)+"px";
	this.monthSelectorShim = this.showShim(this.monthSelectorShim, this.monthSelector);
	this.monthSelector.style.visibility = "visible";
};
BasicDatePicker.prototype.ehMonthSelectorMonthClick = function(newViewingMonth) {
	if (this.params.onClientBeforeVisibleMonthChanged.length>0 && eval("window."+this.params.onClientBeforeVisibleMonthChanged)) {
		var newVisibleDate = new Date(this.viewingYear, newViewingMonth, 1);
		var clientFunction = this.params.onClientBeforeVisibleMonthChanged+"(this, newVisibleDate)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
	this.viewingMonth = newViewingMonth;
	this.buildCalendar();
	this.ehPopUpClick();
	if (this.params.onClientAfterVisibleMonthChanged.length>0 && eval("window."+this.params.onClientAfterVisibleMonthChanged)) {
		var clientFunction = this.params.onClientAfterVisibleMonthChanged+"(this)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
};
BasicDatePicker.prototype.ehYearSelectorClick = function(oSpan) {
	this.hideSelectors();
	if (!this.yearSelector) {
		/* create the popup div */
		this.yearSelector = document.createElement("DIV");
		with (this.yearSelector) {
			id = "basicDatePickerYearSelector";
			className = "bdpYearSelector";
			style.position = "absolute";
			style.zIndex = "1001";
		}
		document.body.appendChild(this.yearSelector);
	}
	this.buildYearSelectorLinks(this.viewingYear);
	var pos = this.findPosition(oSpan, this.popUp);
	this.yearSelector.style.top = (parseInt(this.popUp.style.top)+pos.y+oSpan.offsetHeight+this.params.yearSelectorYOffset)+"px";
	this.yearSelector.style.left = (parseInt(this.popUp.style.left)+pos.x+this.params.yearSelectorXOffset)+"px";
	this.yearSelectorShim = this.showShim(this.yearSelectorShim, this.yearSelector);
	this.yearSelector.style.visibility = "visible";
};
BasicDatePicker.prototype.ehYearSelectorYearClick = function(newViewingYear) {
	if (this.params.onClientBeforeVisibleMonthChanged.length>0 && eval("window."+this.params.onClientBeforeVisibleMonthChanged)) {
		var newVisibleDate = new Date(newViewingYear, this.viewingMonth, 1);
		var clientFunction = this.params.onClientBeforeVisibleMonthChanged+"(this, newVisibleDate)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
	this.viewingYear = newViewingYear;
	this.buildCalendar();
	this.ehPopUpClick();
	if (this.params.onClientAfterVisibleMonthChanged.length>0 && eval("window."+this.params.onClientAfterVisibleMonthChanged)) {
		var clientFunction = this.params.onClientAfterVisibleMonthChanged+"(this)";
		if (eval(clientFunction) == false) {
			return false;
		}
	}
};
BasicDatePicker.prototype.buildYearSelectorLinks = function(baseYear, optTimeoutChange) {
	var p, m;
	switch (this.params.upDownYearSelectorFormat) {
	case "Image" :
		p = "<img src=\""+this.params.upYearSelectorImageUrl+"\"";
		var pWidthHeight = (this.params.upDownYearSelectorImageWidth != "") ? "width:"+this.params.upDownYearSelectorImageWidth+";" : "";
		pWidthHeight += (this.params.upDownYearSelectorImageHeight != "") ? "height:"+this.params.upDownYearSelectorImageHeight+";" : "";
		if (pWidthHeight != "") {
			p += " style=\""+pWidthHeight+"\"";
		}
		p += " border=\"0\" />";
		m = "<img src=\""+this.params.downYearSelectorImageUrl+"\"";
		var mWidthHeight = (this.params.upDownYearSelectorImageWidth != "") ? "width:"+this.params.upDownYearSelectorImageWidth+";" : "";
		mWidthHeight += (this.params.upDownYearSelectorImageHeight != "") ? "height:"+this.params.upDownYearSelectorImageHeight+";" : "";
		if (mWidthHeight != "") {
			m += " style=\""+mWidthHeight+"\"";
		}
		m += " border=\"0\" />";
		break;
	case "CustomText" :
	default :
		p = this.params.downYearSelectorText;
		m = this.params.upYearSelectorText;
		break;
	}
	baseYear = (optTimeoutChange != null) ? (this.yearInc+optTimeoutChange) : parseInt(baseYear);
	var o = "<a href=\"javascript:void(0);\" onclick=\"basicDatePicker.buildYearSelectorLinks("+(baseYear-1)+");\" onmousedown=\"basicDatePicker.clearTimers();basicDatePicker.timeout = setTimeout('basicDatePicker.ehUpYearMouseDown("+baseYear+")', 300);if(basicDatePicker.isOpera || basicDatePicker.isSafari)basicDatePicker.ehPopUpClick();\" onmouseup=\"basicDatePicker.clearTimers();\" onmouseout=\"basicDatePicker.clearTimers();\" class=\"bdpYearSelectorImg\">"+p+"</a>";
	for (var i = (baseYear-4); i<=(baseYear+4); i++) {
		var className = (i == this.viewingYear) ? "bdpYearSelectorSelectedItem" : "bdpYearSelectorItem";
		o += "<a href=\"javascript:void(0);\" onclick=\"basicDatePicker.ehYearSelectorYearClick("+i+");\" class=\""+className+"\">"+i+"</a>";
	}
	o += "<a href=\"javascript:void(0);\" onclick=\"basicDatePicker.buildYearSelectorLinks("+(baseYear+1)+");\" onmousedown=\"basicDatePicker.clearTimers();basicDatePicker.timeout = setTimeout('basicDatePicker.ehDownYearMouseDown("+baseYear+")', 300);if(basicDatePicker.isOpera || basicDatePicker.isSafari)basicDatePicker.ehPopUpClick();\" onmouseup=\"basicDatePicker.clearTimers();\" onmouseout=\"basicDatePicker.clearTimers();\" class=\"bdpYearSelectorImg\">"+m+"</a>";
	var children = this.yearSelector.childNodes;
	if (children) {
		for (var i = 0; i<children.length; i++) {
			this.yearSelector.removeChild(children[i]);
		}
	}
	var dd = document.createElement("DIV");
	dd.innerHTML = o;
	this.yearSelector.appendChild(dd);
	this.yearInc = baseYear;
};
BasicDatePicker.prototype.ehFocus = function(valueElement) {
	this.inputFocusValue = valueElement.value;
};
BasicDatePicker.prototype.ehBlur = function(buttonElement, valueElement, params) {
	basicDatePicker.buttonElement = buttonElement;
	basicDatePicker.valueElement = valueElement;
	basicDatePicker.params = basicDatePicker.loadParams(params);
	if (basicDatePicker.valueElement.value != basicDatePicker.inputFocusValue) {
		if (!basicDatePicker.wireUpBeforeSelectionChanged(basicDatePicker.getSelectedDate())) {
			return;
		}
		if (!basicDatePicker.wireUpAfterSelectionChanged()) {
			return;
		}
		if (basicDatePicker.params.autoPostBack) {
			eval(basicDatePicker.params.postBackFunction);
		}
	}
	if (this.params.displayType != "TextBox" && !this.params.openCalendarOnTextBoxFocus) {
		basicDatePicker.reset();
	}
};
BasicDatePicker.prototype.reset = function() {
	this.selectedMonth = null;
	this.selectedDay = null;
	this.selectedYear = null;
	this.viewingMonth = null;
	this.viewingYear = null;
	this.params = null;
};
BasicDatePicker.prototype.loadParams = function(params) {
	params.culture = eval(params.culture);
	if (params.firstDayOfWeek == 7) {
		params.firstDayOfWeek = params.culture.firstDayOfWeek;
	}
	return params;
};
/* (Public) Helper Methods ----------------------------------------------------- */
function BasicDatePickerLoadControl(bdpId) {
	var bdp = new BasicDatePicker(true);
	bdp.params = bdp.loadParams(eval(bdpId+"Params"));
	bdp.valueElement = document.getElementById(bdpId+"_textBox");
	bdp.labelElement = null;
	switch (bdp.params.displayType) {
	case "TextBoxAndButton" :
		bdp.buttonElement = document.getElementById(bdpId+"_button");
		break;
	case "TextBoxAndHyperLink" :
		bdp.buttonElement = document.getElementById(bdpId+"_hyperLink");
		break;
	case "TextBoxAndImage" :
		bdp.buttonElement = document.getElementById(bdpId+"_image");
		break;
	case "TextBox" :
		bdp.buttonElement = document.getElementById(bdpId+"_textBox");
		break;
	case "LabelAndButton" :
		bdp.buttonElement = document.getElementById(bdpId+"_button");
		bdp.labelElement = document.getElementById(bdpId+"_label");
		break;
	case "LabelAndHyperLink" :
		bdp.buttonElement = document.getElementById(bdpId+"_hyperLink");
		bdp.labelElement = document.getElementById(bdpId+"_label");
		break;
	case "LabelAndImage" :
		bdp.buttonElement = document.getElementById(bdpId+"_image");
		bdp.labelElement = document.getElementById(bdpId+"_label");
		break;
	case "Label" :
		bdp.buttonElement = document.getElementById(bdpId+"_label");
		bdp.labelElement = document.getElementById(bdpId+"_label");
		break;
	case "Button" :
		bdp.buttonElement = document.getElementById(bdpId+"_button");
		break;
	case "HyperLink" :
		bdp.buttonElement = document.getElementById(bdpId+"_hyperLink");
		break;
	case "Image" :
		bdp.buttonElement = document.getElementById(bdpId+"_image");
		break;
	}
	return bdp;
}
/* Public Methods -------------------------------------------------------------- */
BasicDatePicker.prototype.getControlId = function() {
	return this.popUp.id;
};
BasicDatePicker.prototype.getMaximumDate = function(bdpId) {
	var bdptu = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
	return bdptu.params.maximumDate;
};
BasicDatePicker.prototype.getMinimumDate = function(bdpId) {
	var bdptu = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
	return bdp.params.minimumDate;
};
BasicDatePicker.prototype.setSelectedDate = function(date, bdpId) {
	var bdptu = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
	bdptu.selectedYear = date.getFullYear();
	bdptu.selectedMonth = date.getMonth();
	bdptu.selectedDay = date.getDate();
	var formattedDate = bdptu.formatDate(date);
	if (formattedDate == null) {
		formattedDate = "";
	}
	if (bdptu.params.displayType == "Button") {
		bdptu.buttonElement.value = formattedDate;
	} else if (bdptu.params.displayType == "HyperLink") {
		bdptu.buttonElement.innerHTML = formattedDate;
	} else if (bdptu.labelElement) {
		bdptu.labelElement.innerHTML = formattedDate;
	}
	bdptu.valueElement.value = formattedDate;
};
BasicDatePicker.prototype.getSelectedDate = function(bdpId) {
	var bdptu = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
	return bdptu.parseDate(bdptu.valueElement.value);
};
BasicDatePicker.prototype.getSelectedDateFormatted = function(bdpId) {
	var bdptu = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
	return (bdptu.valueElement.value != "") ? bdptu.valueElement.value : null;
};
BasicDatePicker.prototype.getEnabled = function(bdpId) {
	var bdptu = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
	return bdptu.params.enabled;
};
BasicDatePicker.prototype.setEnabled = function(eVal, bdpId) {
	var bdptu = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
	bdptu.valueElement.disabled = !eVal;
	if (bdptu.buttonElement) {
		bdptu.buttonElement.disabled = !eVal;
	}
	bdptu.params.enabled = eVal;
};
/* Date Helper Methods --------------------------------------------------------- */
Date.prototype.addYears = function(number) {
	return new Date(this.getFullYear()+parseInt(number), this.getMonth(), this.getDate());
};
Date.prototype.addMonths = function(number) {
	return new Date(this.getFullYear(), this.getMonth()+parseInt(number), this.getDate());
};
Date.prototype.addDays = function(number) {
	return (new Date(this.getTime()+(number*24*60*60*1000)));
};
Date.prototype.addHours = function(number) {
	return (new Date(this.getTime()+(number*60*60*1000)));
};
Date.prototype.addMinutes = function(number) {
	return (new Date(this.getTime()+(number*60*1000)));
};
Date.prototype.addSeconds = function(number) {
	return (new Date(this.getTime()+(number*1000)));
};
var basicDatePicker = (window.BasicDatePicker) ? new BasicDatePicker() : "NoJS";
function basicDatePickerButtonElementClick(b, v, l, params, stayOpen) {
	if (basicDatePicker == "NoJS") {
	} else if (basicDatePicker) {
		basicDatePicker.stayOpen = stayOpen;
		basicDatePicker.showPopUp(b, v, l, params);
	}
}

		

