
	function loadCalendar(dYear, dMonth, dDay)
	{
		document.getElementById('loadArea').style.visibility="visible";
		var month=new Array(12);
		month[0]="January";
		month[1]="February";
		month[2]="March";
		month[3]="April";
		month[4]="May";
		month[5]="June";
		month[6]="July";
		month[7]="August";
		month[8]="September";
		month[9]="October";
		month[10]="November";
		month[11]="December";
		
		var weekday=new Array(7);
		weekday[0]="Sunday";
		weekday[1]="Monday";
		weekday[2]="Tuesday";
		weekday[3]="Wednesday";
		weekday[4]="Thursday";
		weekday[5]="Friday";
		weekday[6]="Saturday";

		var myDate=new Date() ;
		myDate.setFullYear(dYear, dMonth-1, dDay);
		
		subtractMonth(dYear, dMonth-1);
		addMonth(dYear, dMonth);
		
		var text="<table class=\"displayItem\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		
		var text=text + "<tr class=\"topBar\">";
		text=text + "<td class=\"calendar\"><a class=\"arrow\" href=\"javascript:loadCalendar(" + document.getElementById('lastYear').value + "," + document.getElementById('lastMonth').value +  "," + "1);\">&lt;&lt;</a></td>";
		text=text + "<td class=\"calendar\" colspan=\"5\" align=\"center\"><strong>" + month[myDate.getMonth()] + " " + myDate.getFullYear() + "</strong></td>";
		text=text + "<td class=\"calendar\"><a class=\"arrow\" href=\"javascript:loadCalendar(" + document.getElementById('nextYear').value + "," + document.getElementById('nextMonth').value +  "," + "1);\">&gt;&gt;</a></td>";
		text=text + "</tr>";
		
		text=text + "<tr>";
		text=text + "<td class=\"dayLabel\">Su</td>";
		text=text + "<td class=\"dayLabel\">Mo</td>";
		text=text + "<td class=\"dayLabel\">Tu</td>";
		text=text + "<td class=\"dayLabel\">We</td>";
		text=text + "<td class=\"dayLabel\">Th</td>";
		text=text + "<td class=\"dayLabel\">Fr</td>";
		text=text + "<td class=\"dayLabel\">Sa</td>";
		text=text + "</tr>";
		
		var firstDay = 1;

		var trackDays = 0;
		var displayRow = 1;

		for (i=1; i<= 6; i++)
		{
			if (displayRow == 1)
			{
			text = text + "<tr>";
			
				for(j=0; j<=6; j++)
				{
					if(trackDays == 1)
					{
							var compDate=new Date();
							compDate.setFullYear(dYear, dMonth-1, firstDay);
							var today = new Date();
							var monthInfo = eval(dMonth-1);
							
							if (compDate>=today)
							{
	
								if(compDate.getMonth() > myDate.getMonth() || compDate.getYear() > myDate.getYear())
								{
									text = text + "<td";		
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + ">&nbsp;</td>";	
									trackDays = 0;
									displayRow = 0;
								}
								else
								{
									text = text + "<td";		
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + "><a class=\"calendarDay\" href=\"javascript:setDateNow(" + dYear + ", " + monthInfo + ", " + firstDay + ");\">" + firstDay + "</a></td>";					
								}
							}
							else
							{
								if(compDate.getMonth() > myDate.getMonth() || compDate.getYear() > myDate.getYear())
								{
									text = text + "<td";		
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + ">&nbsp;</td>";	
									trackDays = 0;
									displayRow = 0;
								}
								else
								{
									text = text + "<td ";
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + ">" + firstDay + "</td>";
								}
							}
							firstDay++;
					}
					else
					{
						if(j == myDate.getDay())
						{
							
							trackDays = 1;
							
							var compDate=new Date();
							compDate.setFullYear(dYear, dMonth-1, firstDay);
							var today = new Date();
							var monthInfo = eval(dMonth-1);
							
							if (compDate>=today)
							{
								if(compDate.getMonth() > myDate.getMonth() || compDate.getYear() > myDate.getYear())
								{
									text = text + "<td";		
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + ">&nbsp;</td>";	
									trackDays = 0;
									displayRow = 0;
								}
								else
								{
									text = text + "<td";		
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + "><a class=\"calendarDay\" href=\"javascript:setDateNow(" + dYear + ", " + monthInfo + ", " + firstDay + ");\">" + firstDay + "</a></td>";					
								}
							}
							else
							{
								if(compDate.getMonth() > myDate.getMonth() || compDate.getYear() > myDate.getYear())
								{
									//text = text + "<td class=\"calendar\">&nbsp;</td>";
									text = text + "<td";		
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + ">&nbsp;</td>";					
	
									trackDays = 0;
									displayRow = 0;
								}
								else
								{
									text = text + "<td ";
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + ">" + firstDay + "</td>";
								}
							}
							firstDay++;
						}
						else
						{
									text = text + "<td";		
									if(j == 0 || j == 6)
									{
										text = text + " class=\"weekend\"";
									}
									text = text + ">&nbsp;</td>";	
						}
						
					}
				}
			
			text = text + "</tr>";
			}
			if(firstDay > 31)
			{
				displayRow = 0;
			}
		
		}
		text=text + "<tr>";
		text=text + "<td class=\"calendar\" colspan=\"7\" align=\"center\"><a href=\"javascript:hideCalendar();\">close</a></td>";
		text=text + "</tr>";
		
		text = text + "</table>";
		document.getElementById('loadArea').innerHTML=text;
	}
	
	function subtractMonth(passYear, passMonth)
	{
		document.getElementById('lastYear').value=passYear;
		document.getElementById('lastMonth').value=passMonth;
	}
	
	function addMonth(passYear, passMonth)
	{
		document.getElementById('nextYear').value=passYear;
		document.getElementById('nextMonth').value=parseInt(passMonth)+1;
	}
	
	function setDateNow(myYear, myMonth, myDay)
	{
		var thisDate = new Date(myYear, myMonth, myDay);
		
		document.getElementById('dateField').value = eval(thisDate.getMonth()+1) + "/" + thisDate.getDate() + "/" + thisDate.getFullYear();
		document.getElementById('thisYear').value = thisDate.getFullYear();
		document.getElementById('thisMonth').value = eval(thisDate.getMonth()+1);
		hideCalendar();
	}
	
	function hideCalendar()
	{
		document.getElementById('loadArea').style.visibility="hidden";
	}

