

var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var totalDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31)




function openCalWin_SD() { 
	stats='toolbar=no,location=no,directories=no,status=no,menubar=no,'
	stats += 'scrollbars=no,resizable=no,width=300,height=250'
	CalWin = window.open ("","Calendar",stats)
	
	
	var calMonth = 8
	var calYear = 2007
	
	
	theDate = new Date(calYear, (calMonth - 1), 1)

	buildCal_SD(theDate)
	
}

function buildCal_SD(theDate) {
	
	var startDay = theDate.getDay()
	var printDays = false
	var currDay = 1
	var rowsNeeded = 5
	
	if (startDay + totalDays[theDate.getMonth()] > 35)
		rowsNeeded++
	
	CalWin.document.write('<html><head><Title>Select a Date</title>')
	CalWin.document.write('<STYLE TYPE="text/css">')
	CalWin.document.write('A { color: #000000; font-family:Arial,Helvetica;font-size:8pt; font-weight: bold; text-decoration: none}')
	CalWin.document.write('A:hover { color: red; }')
	CalWin.document.write('</STYLE></head>')
	CalWin.document.write('<body><a name="this"></a>')
	CalWin.document.write('<table align=center height=100% width=100% border=2 bordercolor=Black cellpadding=0 cellspacing=0>')
	CalWin.document.write('<tr><th bgcolor=Navy colspan=7><font size=2 face=Arial color=white>' + months[theDate.getMonth()] + ' ' + theDate.getFullYear() + '</font></th></tr>')
	CalWin.document.write('<tr bgcolor="#6699CC"><th><font size=1 face=Arial color=white>Su</font></th><th><font size=1 face=Arial color=white>Mo</font></th><th><font size=1 face=Arial color=white>Tu</font></th><th><font size=1 face=Arial color=white>We</font></th><th><font size=1 face=Arial color=white>Th</font></th><th><font size=1 face=Arial color=white>Fr</font></th><th><font size=1 face=Arial color=white>Sa</font></th></tr>')
	for (x=1; x<=rowsNeeded; x++){
		CalWin.document.write('<tr>')
		for (y=0; y<=6; y++){
			if (currDay == 1 && !printDays && startDay == y)
				printDays = true
			CalWin.document.write('<td align="center" width=14.28%>')
			if (printDays){
        		CalWin.document.write('<a href="javascript:opener.placeDate_SD(' + theDate.getMonth() + ',' +  currDay + ',' + theDate.getFullYear() + ')">' + currDay++ + '</a></td>')
				if (currDay > totalDays[theDate.getMonth()])
					printDays = false
			}
			else
				CalWin.document.write('&nbsp;</td>')
		}		
		CalWin.document.write('</tr>')
	}	
	CalWin.document.write('<form><tr bgcolor="#6699CC"><td colspan=7 align="center"><input type="Button" size="2" name="Back" value="<<" onClick="opener.getNewCal_SD(-1)"><font face=Arial color=white size="1"> Use the arrows to browse through the months.</font> <input type="Button" size="2" name="Forward" value=">>" onClick="opener.getNewCal_SD(1)"></td></tr></form>')
	CalWin.document.write('</table></body></html>')
	CalWin.document.close()
	
}

function getNewCal_SD(newDir) {
	if (newDir == -1){
		theDate.setMonth(theDate.getMonth() - 1)
		if (theDate.getMonth() == 0){
			theDate.setMonth(12)
			theDate.setYear(theDate.getYear() - 1)
		}
	}
	else if (newDir == 1){
		theDate.setMonth(theDate.getMonth() + 1)
		if (theDate.getMonth() == 13){
			theDate.setMonth(1)
			theDate.setYear(theDate.getYear() + 1)
		}
	}
		
		
	CalWin.document.clear();
	buildCal_SD(theDate);

}

function placeDate_SD(monthNum, dayNum, yearNum){
	var dateString = (monthNum + 1) + '/' + dayNum + '/' + yearNum

	document.demorequest.SD.value = dateString
		 
	CalWin.close()
}


