date_range = new Array("32", "29", "32", "31", "32", "31", "32", "32", "31", "32", "31", "32")
month_string = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
titleMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
days = new Array("S","M","T","W","T","F","S")
weekDays = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");

today = new Date()
this_year = today.getYear()

if (this_year < 2000) { this_year += 1900 }
if (this_year % 4 == 0) { date_range[1] = 30 }
now=today.getSeconds();

function ReturnTextDate() {
	textDateString=weekDays[today.getDay()]+", "+ today.getDate() +" "+titleMonths[today.getMonth()]+" "+this_year;
	return textDateString;
	}

function set_calendar() {
	dateQuery=document.location.search.substring('1');
	if(dateQuery) {
		dateQueryArray=dateQuery.split('.')
		theQueryYear=dateQueryArray[0];theQueryMonth=dateQueryArray[1];
		} else {theQueryYear=this_year;theQueryMonth=today.getMonth();}
	write_calendar(theQueryYear,theQueryMonth) 
	}

function write_calendar(newYear,newMonth) {
	newMonth=newMonth;
	the_max= date_range[newMonth];
	the_first_date=eval("new Date("+newYear+","+newMonth+",1)");
	the_first_day = the_first_date.getDay()
	endpoint=((the_first_day>=5)?43:36);
	document.writeln("<div class=SansBlu11 style='border-style:solid;border-width:1px;border-color:#ddd;padding:2px;padding-bottom:5px;width:160px;'><center>");
	document.writeln("<div class=SansBlu11 style='padding:2px;'><center>"+titleMonths[newMonth].toUpperCase() + " " + newYear + "</center></div>");
	document.writeln("<table cellpadding=2 cellspacing=2 bgcolor=#ffffff border=0 width=100%><tr>");
	writeDayRow();
	window.document.writeln("</tr><tr>")
	for (m=0; m < 7; m++) {
		if (m < the_first_day ) { window.document.writeln("<td class=SansBlu9 bgcolor=#eeeeee>&nbsp;</td>") }
		if (m == the_first_day) { window.document.writeln("<td class=SansBlu9 bgcolor=#eeeeee>1</td>"); 
			if (m!=0 && m % 7 == 0) { window.document.writeln("\n</tr>\n<tr>\n") }
			if (m == 6) { window.document.writeln("\n</tr>\n<tr>\n") }
			}
		}
	date_count = 2
	for (l=the_first_day + 2; l < endpoint; l++) {
		theClass=((date_count == today.getDate())? "SansBlack9" : "SansBlu9");
		if (date_count < the_max) { window.document.writeln("<td class="+theClass+" bgcolor=#eeeeee>"+ date_count + "</td>") }
		if (date_count >= the_max) { window.document.writeln("<td class=SansBlu9 bgcolor=#eeeeee>&nbsp;</td>") }
		if ( l== 7 || l % 7 == 0) { window.document.writeln("\n</tr>\n<tr>\n");}
		date_count++
		}
	document.writeln("</tr></table></div>");

	}

function writeDayRow() {
	for (c=0; c < 7; c++) {
		window.document.writeln("<td bgcolor=#336699 align=center class=SansWhite9><c>" + days[c] + "</td>")
		}
	}
	
function makeBackString(backY,backM) {
		if(backM > 0) {
			backM--;backString="calendar2.html?"+backY+"."+backM;
			} else {
				backY--;backString="calendar2.html?"+backY+".11";
				}		
		return backString;
		}

function makeNextString(nextY,nextM) {
		if(nextM < 11) {
			nextM++;nextString="calendar2.html?"+nextY+"."+nextM;
			} else {
				nextY++;nextString="calendar2.html?"+nextY+".0";
				}		
		return nextString;
		}
	
	

