function DrawCalendar(l, t) {
	DestroyCalendar();
	var cal = document.getElementById("dpCalendar");
	if(cal.style.left == "" && arguments[0] != null) {	// IE7 work around, should be set ALWAYS though!
		cal.style.left = l + "px";
		cal.style.top = t + "px";
	}

	var sCal = "<table><tr><td class=\"cellButton\"><a href=\"javascript: PrevMonth();\" title=\"Previous Month\">&lt;&lt;</a></td>"+
		"<td class=\"cellMonth\" width=\"80%\" colspan=\"5\">"+MonthNames[m]+" "+y+"</td>"+
		"<td class=\"cellButton\"><a href=\"javascript: NextMonth();\" title=\"Next Month\">&gt;&gt;</a></td></tr>"+
		"<tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>";
	var wDay = 1;
	var wDate = new Date(y,m,wDay);
	if(isLeapYear(wDate)) {
		MonthLengths[1] = 29;
	} else {
		MonthLengths[1] = 28;
	}
	rangeExists = false;
	if(range_start != null && range_end != null) {
		if(typeof(range_start)=="object" && typeof(range_end)=="object") {
			rangeExists = true;
			if(range_start.valueOf() > range_end.valueOf()) {
				// ranges are backwards, so flip
				var range_tmp = range_start;
				range_start = range_end;
				range_end = range_tmp;
			}
		}
	}
	var dayclass = "";
	var isToday = false;
	var linkDay = false;
	for(var r=1; r<7; r++) {
		sCal = sCal + "<tr>";
		for(var c=0; c<7; c++) {
			var wDate = new Date(y,m,wDay);
			if(wDate.getDay() == c && wDay<=MonthLengths[m]) {
				if(wDate.getDate()==sd && wDate.getMonth()==sm && wDate.getFullYear()==sy) {
					dayclass = "cellSelected";
					isToday = true;  // only matters if the selected day IS today, otherwise ignored.
				} else if(wDate.getDate()==nd && wDate.getMonth()==nm && wDate.getFullYear()==ny && HighlightToday) {
					dayclass = "cellToday";
					isToday = true;
				} else {
					dayclass = "cellDay";
					isToday = false;
					// check to see if date lies in range
					if(rangeExists) {
						if(wDate.valueOf() >= range_start.valueOf() && wDate.valueOf() <= range_end.valueOf()) {
							dayclass = "cellRange";
						}
					}
				}
				linkDay = (((now > wDate) && !DisablePast) || (now <= wDate) || isToday);
				if(linkDay) {
					// Day is potentially selectable at this point.  Make sure we aren't restricting future dates as well
					if(restrictFuture != "") {
						// we are restricting future dates
						if(parseInt(restrictFuture) == restrictFuture) {
							// we are restricting by X days
							var dRestriction = new Date()
							dRestriction = new Date(dRestriction.getTime() + (parseInt(restrictFuture) * 24 * 60 * 60 * 1000));	// add X days
							dRestriction = new Date(dRestriction.getFullYear(), dRestriction.getMonth(), dRestriction.getDate(), 23, 59, 59, 999);	// force to end of day
						} else {
							// we are restricting by a future date
							var aRestriction = restrictFuture.split("/"); 	// expected to be n/j/Y
							var dRestriction = new Date(aRestriction[2],aRestriction[0]-1,aRestriction[1],23,59,59,999);
						}
						linkDay = (wDate.getTime() < dRestriction.getTime());
					}
				}
				if(linkDay) {
					// date is selectable
					sCal = sCal + "<td class=\""+dayclass+"\"><a href=\"javascript: ReturnDay("+wDay+");\">"+wDay+"</a></td>";
				} else {
					// date is read only
					sCal = sCal + "<td class=\""+dayclass+"\">"+wDay+"</td>";
				}
				wDay++;
			} else {
				sCal = sCal + "<td class=\"unused\"></td>";
			}
		}
		sCal = sCal + "</tr>";
	}
	if(DisableNoDateButton) {
		sCal = sCal + "<tr><td colspan=\"4\" class=\"unused\"></td>";
	} else {
		sCal = sCal + "<tr><td colspan=\"3\" class=\"cellCancel\"><a href=\"javascript: ReturnDay(0);\">No Date</a></td>";
		sCal = sCal + "<td colspan=\"1\" class=\"unused\"></td>";
	}
	sCal = sCal + "<td colspan=\"3\" class=\"cellCancel\"><a href=\"javascript: DestroyCalendar();\">Cancel</a></td></tr></table>"
	cal.innerHTML = sCal; // works in FireFox, Opera, IE7
	cal.style.display = "inline";
}
/*
	function DrawCalendar(l, t)
	Where:	l = the left position for the calendar
			t = the top position for the calendar

	Purpose: Create the calendar and draw it on the page
*/
function DrawCalendar(l, t)
Where:  l = the left position for the calendar
t = the top position for the calendar

Create the calendar and draw it on the page
function DrawCalendar ( l t ) Where : l = the left position for the calendar t = the top position for the calendar Create the calendar and draw it on the page
function DrawCalendar(l, t) {
	DestroyCalendar();
	var cal = document.getElementById("dpCalendar");
	if(cal.style.left == "" && arguments[0] != null) {	
		cal.style.left = l + "px";
		cal.style.top = t + "px";
	}
	var sCal = "<table><tr><td class=\"cellButton\"><a href=\"javascript: PrevMonth();\" title=\"Previous Month\">&lt;&lt;</a></td>"+
		"<td class=\"cellMonth\" width=\"80%\" colspan=\"5\">"+MonthNames[m]+" "+y+"</td>"+
		"<td class=\"cellButton\"><a href=\"javascript: NextMonth();\" title=\"Next Month\">&gt;&gt;</a></td></tr>"+
		"<tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>";
	var wDay = 1;
	var wDate = new Date(y,m,wDay);
	if(isLeapYear(wDate)) {
		MonthLengths[1] = 29;
	} else {
		MonthLengths[1] = 28;
	}
	rangeExists = false;
	if(range_start != null && range_end != null) {
		if(typeof(range_start)=="object" && typeof(range_end)=="object") {
			rangeExists = true;
			if(range_start.valueOf() > range_end.valueOf()) {
				var range_tmp = range_start;
				range_start = range_end;
				range_end = range_tmp;
			}
		}
	}
	var dayclass = "";
	var isToday = false;
	var linkDay = false;
	for(var r=1; r<7; r++) {
		sCal = sCal + "<tr>";
		for(var c=0; c<7; c++) {
			var wDate = new Date(y,m,wDay);
			if(wDate.getDay() == c && wDay<=MonthLengths[m]) {
				if(wDate.getDate()==sd && wDate.getMonth()==sm && wDate.getFullYear()==sy) {
					dayclass = "cellSelected";
					isToday = true;  
				} else if(wDate.getDate()==nd && wDate.getMonth()==nm && wDate.getFullYear()==ny && HighlightToday) {
					dayclass = "cellToday";
					isToday = true;
				} else {
					dayclass = "cellDay";
					isToday = false;
					if(rangeExists) {
						if(wDate.valueOf() >= range_start.valueOf() && wDate.valueOf() <= range_end.valueOf()) {
							dayclass = "cellRange";
						}
					}
				}
				linkDay = (((now > wDate) && !DisablePast) || (now <= wDate) || isToday);
				if(linkDay) {
					if(restrictFuture != "") {
						if(parseInt(restrictFuture) == restrictFuture) {
							var dRestriction = new Date()
							dRestriction = new Date(dRestriction.getTime() + (parseInt(restrictFuture) * 24 * 60 * 60 * 1000));	
							dRestriction = new Date(dRestriction.getFullYear(), dRestriction.getMonth(), dRestriction.getDate(), 23, 59, 59, 999);	
						} else {
							var aRestriction = restrictFuture.split("/"); 	
							var dRestriction = new Date(aRestriction[2],aRestriction[0]-1,aRestriction[1],23,59,59,999);
						}
						linkDay = (wDate.getTime() < dRestriction.getTime());
					}
				}
				if(linkDay) {
					sCal = sCal + "<td class=\""+dayclass+"\"><a href=\"javascript: ReturnDay("+wDay+");\">"+wDay+"</a></td>";
				} else {
					sCal = sCal + "<td class=\""+dayclass+"\">"+wDay+"</td>";
				}
				wDay++;
			} else {
				sCal = sCal + "<td class=\"unused\"></td>";
			}
		}
		sCal = sCal + "</tr>";
	}
	if(DisableNoDateButton) {
		sCal = sCal + "<tr><td colspan=\"4\" class=\"unused\"></td>";
	} else {
		sCal = sCal + "<tr><td colspan=\"3\" class=\"cellCancel\"><a href=\"javascript: ReturnDay(0);\">No Date</a></td>";
		sCal = sCal + "<td colspan=\"1\" class=\"unused\"></td>";
	}
	sCal = sCal + "<td colspan=\"3\" class=\"cellCancel\"><a href=\"javascript: DestroyCalendar();\">Cancel</a></td></tr></table>"
	cal.innerHTML = sCal; 
	cal.style.display = "inline";
}
function DrawCalendar ( l , t ) { DestroyCalendar ( ) ; var cal = document . getElementById ( "dpCalendar" ) ; if ( cal . style . left == "" && arguments [ 0 ] != null ) { cal . style . left = l + "px" ; cal . style . top = t + "px" ; } var sCal = "<table><tr><td class=\"cellButton\"><a href=\"javascript: PrevMonth();\" title=\"Previous Month\">&lt;&lt;</a></td>" + "<td class=\"cellMonth\" width=\"80%\" colspan=\"5\">" + MonthNames [ m ] + " " + y + "</td>" + "<td class=\"cellButton\"><a href=\"javascript: NextMonth();\" title=\"Next Month\">&gt;&gt;</a></td></tr>" + "<tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>" ; var wDay = 1 ; var wDate = new Date ( y , m , wDay ) ; if ( isLeapYear ( wDate ) ) { MonthLengths [ 1 ] = 29 ; } else { MonthLengths [ 1 ] = 28 ; } rangeExists = false ; if ( range_start != null && range_end != null ) { if ( typeof ( range_start ) == "object" && typeof ( range_end ) == "object" ) { rangeExists = true ; if ( range_start . valueOf ( ) > range_end . valueOf ( ) ) { var range_tmp = range_start ; range_start = range_end ; range_end = range_tmp ; } } } var dayclass = "" ; var isToday = false ; var linkDay = false ; for ( var r = 1 ; r < 7 ; r ++ ) { sCal = sCal + "<tr>" ; for ( var c = 0 ; c < 7 ; c ++ ) { var wDate = new Date ( y , m , wDay ) ; if ( wDate . getDay ( ) == c && wDay <= MonthLengths [ m ] ) { if ( wDate . getDate ( ) == sd && wDate . getMonth ( ) == sm && wDate . getFullYear ( ) == sy ) { dayclass = "cellSelected" ; isToday = true ; } else if ( wDate . getDate ( ) == nd && wDate . getMonth ( ) == nm && wDate . getFullYear ( ) == ny && HighlightToday ) { dayclass = "cellToday" ; isToday = true ; } else { dayclass = "cellDay" ; isToday = false ; if ( rangeExists ) { if ( wDate . valueOf ( ) >= range_start . valueOf ( ) && wDate . valueOf ( ) <= range_end . valueOf ( ) ) { dayclass = "cellRange" ; } } } linkDay = ( ( ( now > wDate ) && ! DisablePast ) || ( now <= wDate ) || isToday ) ; if ( linkDay ) { if ( restrictFuture != "" ) { if ( parseInt ( restrictFuture ) == restrictFuture ) { var dRestriction = new Date ( ) dRestriction = new Date ( dRestriction . getTime ( ) + ( parseInt ( restrictFuture ) * 24 * 60 * 60 * 1000 ) ) ; dRestriction = new Date ( dRestriction . getFullYear ( ) , dRestriction . getMonth ( ) , dRestriction . getDate ( ) , 23 , 59 , 59 , 999 ) ; } else { var aRestriction = restrictFuture . split ( "/" ) ; var dRestriction = new Date ( aRestriction [ 2 ] , aRestriction [ 0 ] - 1 , aRestriction [ 1 ] , 23 , 59 , 59 , 999 ) ; } linkDay = ( wDate . getTime ( ) < dRestriction . getTime ( ) ) ; } } if ( linkDay ) { sCal = sCal + "<td class=\"" + dayclass + "\"><a href=\"javascript: ReturnDay(" + wDay + ");\">" + wDay + "</a></td>" ; } else { sCal = sCal + "<td class=\"" + dayclass + "\">" + wDay + "</td>" ; } wDay ++ ; } else { sCal = sCal + "<td class=\"unused\"></td>" ; } } sCal = sCal + "</tr>" ; } if ( DisableNoDateButton ) { sCal = sCal + "<tr><td colspan=\"4\" class=\"unused\"></td>" ; } else { sCal = sCal + "<tr><td colspan=\"3\" class=\"cellCancel\"><a href=\"javascript: ReturnDay(0);\">No Date</a></td>" ; sCal = sCal + "<td colspan=\"1\" class=\"unused\"></td>" ; } sCal = sCal + "<td colspan=\"3\" class=\"cellCancel\"><a href=\"javascript: DestroyCalendar();\">Cancel</a></td></tr></table>" cal . innerHTML = sCal ; cal . style . display = "inline" ; }
function DrawCalendar(l, t)
Where:  l = the left position for the calendar
t = the top position for the calendar
function DrawCalendar ( l t ) Where : l = the left position for the calendar t = the top position for the calendar
// IE7 work around, should be set ALWAYS though! // ranges are backwards, so flip // only matters if the selected day IS today, otherwise ignored. // check to see if date lies in range // Day is potentially selectable at this point.  Make sure we aren't restricting future dates as well // we are restricting future dates // we are restricting by X days // add X days // force to end of day // we are restricting by a future date // expected to be n/j/Y // date is selectable // date is read only // works in FireFox, Opera, IE7