function setUpCalendar() {	var today=new Date()		var thisday = today.getDate();	var thismonth = today.getMonth();	var thisyear = today.getFullYear();		monthFloater=thismonth;		document.theform.month.value=monthFloater	document.theform.year.value=thisyear		document.theform.startClientDate.value=thisday+"/"+thismonth+"/"+thisyear;	document.theform.endClientDate.value=thisday+"/"+thismonth+"/"+thisyear;		buildCalendar();		todayslink=document.getElementById('link'+thisday).parentNode.id		startFloater=todayslink;	endFloater=todayslink;		getStartBlock(thisday);	getEndBlock(thisday);}function buildCalendar() {    month = document.theform.month.value*1;        month = evalMonth(month);        year  = document.theform.year.value*1;	monthName = months[month]   	text = monthName+" "+year;	document.getElementById('calendarhead').innerHTML=text    NumDays=31;    if (month==3||month==5||month==8||month==10) {    	NumDays=30;    }        if (month==1) {        NumDays=28;        if((year%4==0)&&(year%100!=0)) {NumDays=29;}        if(year%400==0) {NumDays=29;};    }    TempDate = new Date(year, month, 1);    FirstDay = TempDate.getDay();    i = FirstDay + 1;        for (n=1; n<43; n++) {    	dateDiv=document.getElementById('div'+n)    	dateDiv.innerHTML="&nbsp;"    }            for(c=1;c<=NumDays;c++) {                dateDiv=document.getElementById('div'+i)                if (dateDiv==null) alert(dateDiv);        dateDiv.innerHTML="<a href='javascript:void(0)' onclick='getDateBlock(\"div"+i+"\",\""+c+"\")' class='date' id=link"+c+">"+c+"<\/a>";        i++;    }}function evalMonth(month) {	month=month*1    if (month<0) {    	newmonth=month-(-144)    	newmonth=newmonth%12    }        else if (month>11) {    	newmonth=month%12;	}	else newmonth=month;	return newmonth;}var startMonthFloater;var endMonthFloater;var startFloater;var endFloater;var months=new Array("January","February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");var mon=new Array("Jan","Feb", "March", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec");var month=8var year=2002function getDiv(date) {	if (document.getElementById('link'+date).parentNode) {		return document.getElementById('link'+date).parentNode.id	}}function clearBlocks(blocks) {curMonth=document.theform.month.value*1for (i=1; i<43; i++) {	theDiv=document.getElementById('div'+i);	theDiv.style.backgroundColor="";}if (startMonthFloater==curMonth) {	theDiv=document.getElementById(getDiv(startFloater));	theDiv.style.backgroundColor="#999";}if (endMonthFloater==curMonth) {	theDiv=document.getElementById(getDiv(endFloater));	theDiv.style.backgroundColor="#999";}} function getStartBlock(date) {startFloater=date;newdate=months[evalMonth(document.theform.month.value)]+" "+date+", "+document.theform.year.valuenewdate = "(" + mon[evalMonth(document.theform.month.value)] + " " + date + " ";document.theform.startClientDate.value=(evalMonth(document.theform.month.value)*1+1)+"/"+date+"/"+document.theform.year.value;startMonthFloater=document.theform.month.value*1;start=document.getElementById('startdate');start.innerHTML=newdate;clearBlocks();}function getEndBlock(date) {endFloater=date;newdate=months[evalMonth(document.theform.month.value)]+" "+date+", "+document.theform.year.valuenewdate = " - " + mon[evalMonth(document.theform.month.value)]  + " " + date + ")";document.theform.endClientDate.value=(evalMonth(document.theform.month.value)*1+1)+"/"+date+"/"+document.theform.year.value;endMonthFloater=document.theform.month.value*1;end=document.getElementById('enddate');end.innerHTML=newdate;clearBlocks();}function prevMonth() {	nextGet=null;		thisMonth=document.theform.month.value;	thisYear=document.theform.year.value;	newYear=thisYear;	newMonth=thisMonth-1;			if (evalMonth(thisMonth)==0) newYear=thisYear-1;			document.theform.month.value=newMonth;	document.theform.year.value=newYear		clearBlocks();	buildCalendar()		if (newMonth==startMonthFloater) {		getStartBlock(startFloater)	}	if (newMonth==endMonthFloater) {		getEndBlock(endFloater)	}			getRange();}function nextMonth() {	nextGet=null;	thisMonth=document.theform.month.value;	thisYear=document.theform.year.value;	newYear=thisYear;		newMonth=thisMonth-(-1);			if (evalMonth(thisMonth)==11) newYear=thisYear-(-1);			document.theform.month.value=newMonth;	document.theform.year.value=newYear	clearBlocks();	buildCalendar()		if (newMonth==startMonthFloater) {		getStartBlock(startFloater)	}	if (newMonth==endMonthFloater) {		getEndBlock(endFloater)	}			getRange();		}var nextGet=null;var switchBlock=null;function getDateBlock(div,num) {numStart=startFloater*1;numEnd=endFloater*1;num=num*1// set the formdocument.getElementById("specificdate").checked="true";curMonth=document.theform.month.value*1curYear=document.theform.year.value*1if (curMonth==startMonthFloater && curMonth==endMonthFloater) {	if (num==startFloater || num == endFloater) {		getStartBlock(num)		getEndBlock(num)	}		else if (num<startFloater) {		getStartBlock(num);	}		else if (num>numStart && num<numEnd) {		st=Math.abs(num-startFloater);		en=Math.abs(num-endFloater);		if (Math.abs(st-en) > 0) {			if (nextGet==null) {				if (st<en) {					getStartBlock(num);					nextGet="end"				}				else {					getEndBlock(num);					nextGet="start"				}			}			else {				nextGet=="start" ? getStartBlock(num):getEndBlock(num);				nextGet=null;			}		}		else { 			getStartBlock(num)			getEndBlock(num)		}	}		else if (num>endFloater) {		getEndBlock(num);	}}else if (startMonthFloater<curMonth && endMonthFloater<curMonth) {	getEndBlock(num)}else if (startMonthFloater>curMonth && endMonthFloater>curMonth) {	getStartBlock(num)}else if (startMonthFloater<curMonth && endMonthFloater==curMonth) {	if (num<endFloater) {		getStartBlock(num);	}		else {		getEndBlock(num);	}}else if (startMonthFloater==curMonth && endMonthFloater>curMonth) {		if (num>startFloater) {		getEndBlock(num);	}		else {		getStartBlock(num);	}}else if (startMonthFloater<curMonth && endMonthFloater>curMonth) {	getStartBlock(num)	getEndBlock(num)}getRange();}function getRange() {divStart=getDiv(startFloater);divEnd=getDiv(endFloater);curMonth=document.theform.month.value*1;if (startMonthFloater==endMonthFloater && curMonth==startMonthFloater) {	divStart=getDiv(startFloater);	divEnd=getDiv(endFloater);}	else if (startMonthFloater<curMonth && curMonth==endMonthFloater) {	divStart='div0';	divEnd=getDiv(endFloater);		}else if (startMonthFloater==curMonth && curMonth<endMonthFloater) {	divStart=getDiv(startFloater);	divEnd='div43';}else if (startMonthFloater<curMonth && endMonthFloater>curMonth) {	divStart='div0';	divEnd='div43';}divStart=divStart.substring(3,divStart.length)*1;divEnd=divEnd.substring(3,divEnd.length)*1;if (startMonthFloater<=curMonth && endMonthFloater>=curMonth) {	for(i=divStart-(-1); i<divEnd; i++) {		theDiv=document.getElementById('div'+i);		theDiv.style.backgroundColor="#CCC";	}}}
