var fixedX1 = -1		// x position (-1 if to appear below control)
	var	fixedY1 = -1			// y position (-1 if to appear below control)
	var startAt1 = 0			// 0 - sunday ; 1 - monday
	var showWeekNumber1 = 0	// 0 - don't show; 1 - show
	var showToday1 = 0		// 0 - don't show; 1 - show
	var imgDir1 = ""			// directory for images ... e.g. var imgDir="/img/"

	var gotoString1 = "Go To Current Month"
	var todayString1 = "Today is"
	var weekString1 = "Wk"
	var scrollLeftMessage1 = "Click to scroll to previous month. Hold mouse button to scroll automatically."
	var scrollRightMessage1 = "Click to scroll to next month. Hold mouse button to scroll automatically."
	var selectMonthMessage1 = "Click to select a month."
	var selectYearMessage1 = "Click to select a year."
	var selectDateMessage1 = "Select [date] as date." // do not replace [date], it will be replaced by date.

	var	crossobj1, crossMonthObj1, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear

	var	bPageLoaded1=false
	var	ie1=document.all
	var	dom1=document.getElementById

	var	ns41=document.layers
	var	today1 =	new	Date()
	var	dateNow1	 = today1.getDate()
	var	monthNow1 = today1.getMonth()
	var	yearNow1	 = today1.getYear()
	var	imgsrc1 = new Array("drop1.gif","drop2.gif","left1.gif","left2.gif","right1.gif","right2.gif")
	var	img1	= new Array()

	if (dom1)
	{
		for	(i=0;i<imgsrc1.length;i++)
		{
			img1[i] = new Image
			img1[i].src = imgDir1 + imgsrc1[i]
		}
		/*Change color here*/
		var table1 = "<table width='150' border='0' cellspacing='0' cellpadding='0'><tr><td id='calendar1'><table cellspacing='0' cellpadding='0'><tr><td width='100%'><table class='cellTLRB' width='100%' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'><tr><td width='100%'><span id='caption1'></span></td></tr></table></td></tr><tr><td bgcolor='#FFFFFF' width='100%'><span id='content1'></span></td></tr></table></td></tr></table>";
		document.write (table1);
	}

	var	monthName1 =	new	Array("January","February","March","April","May","June","July","August","September","October","November","December")
	if (startAt1==0)
	{
		dayName1 = new Array	("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
	}
	else
	{
		dayName1 = new Array	("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
	}
	var	styleAnchor1="text-decoration:none;color:black;"
	var	styleLightBorder1="border-style:solid;border-width:1px;border-color:#a0a0a0;"

	function swapImage1(srcImg, destImg){
		if (ie1)	{ document.getElementById(srcImg1).setAttribute("src",imgDir1 + destImg1) }
	}

	function init1()	{
		if (!ns41)
		{
			if (!ie1) { yearNow1 += 1900	}

			monthConstructed1=false;
			yearConstructed1=false;

			sHTML1 = "<table width='100%' cellspacing='0' class='dateFormat'><tr><td onclick='javascript:decMonth1()' class='nextFormat'><font class='dateFormat'>&nbsp; < &nbsp;</font></td><td align='center' width='66%' id='spanMonth1'></td><td class='nextFormat' onclick='incMonth1()'>&nbsp > &nbsp</td></tr></table>";
			
			document.getElementById("caption1").innerHTML  =	sHTML1

			bPageLoaded1=true

			//Calling a calendar function and passing the name of the text 
			//box which holds the date field. Added by D.T.

			//Initialize calendar to current date. (11-14 ET)
			dateFormat1='m/d/yyyy';
			
            dateSelected1 = 1;
			     monthSelected1 = 12-1;
			     yearSelected1 = 2009

			odateSelected1=dateSelected1
			omonthSelected1=monthSelected1
			oyearSelected1=yearSelected1
		
	
			constructCalendar1(1, monthSelected1, yearSelected1);
		}
	}

	function padZero1(num) {
		return (num	< 10)? '0' + num : num ;
	}

	function constructDate1(d,m,y)
	{
		sTmp = dateFormat
		sTmp = sTmp.replace	("dd","<e>")
		sTmp = sTmp.replace	("d","<d>")
		sTmp = sTmp.replace	("<e>",padZero1(d))
		sTmp = sTmp.replace	("<d>",d)
		sTmp = sTmp.replace	("mmm","<o>")
		sTmp = sTmp.replace	("mm","<n>")
		sTmp = sTmp.replace	("m","<m>")
		sTmp = sTmp.replace	("<m>",m+1)
		sTmp = sTmp.replace	("<n>",padZero1(m+1))
		sTmp = sTmp.replace	("<o>",monthName1[m])
		return sTmp.replace ("yyyy",y)
	}

	/*** Month Pulldown	***/
	function incMonth1() {
		monthSelected1++
		if (monthSelected1>11) {
			monthSelected1=0
			yearSelected1++
		}
		constructCalendar1()
	}

	function decMonth1() {
		monthSelected1--
		if (monthSelected1<0) {
			monthSelected1=11
			yearSelected1--
		}
		constructCalendar1()
	}


	/*** calendar ***/

	function WeekNbr1(today)
    {
		Year1 = takeYear1(today);
		Month1 = today1.getMonth();
		Day1 = today1.getDate();
		now1 = Date.UTC(Year1,Month1,Day1+1,0,0,0);
		var Firstday = new Date();
		Firstday.setYear1(Year);
		Firstday.setMonth1(0);
		Firstday.setDate1(1);
		then = Date.UTC(Year,0,1,0,0,0);
		var Compensation = Firstday.getDay();
		if (Compensation > 3) Compensation -= 4;
		else Compensation += 3;
		NumberOfWeek =  Math.round((((now-then)/86400000)+Compensation)/7);
		return NumberOfWeek;
	}

	function takeYear1(theDate)
	{
		x = theDate.getYear();
		var y = x % 100;
		y += (y < 38) ? 2000 : 1900;
		return y;
	}


    function formSubmit(day, month, year)
    {
        document.eventCalForm1.dd.value = day;
        document.eventCalForm1.mm.value = month;
        document.eventCalForm1.yy.value = year;
        document.eventCalForm1.submit(); 
    }

	function constructCalendar1() {
		var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31)

		var dateMessage
		var	startDate =	new	Date (yearSelected1,monthSelected1,1)
		var endDate

        /*used for event days*/
        var eventDay = false;

		if (monthSelected1==1)
		{
			endDate	= new Date (yearSelected1,monthSelected1+1,1);
			endDate	= new Date (endDate	- (24*60*60*1000));
			numDaysInMonth = endDate.getDate()
		}
		else
		{
			numDaysInMonth = aNumDays[monthSelected1];
		}

		datePointer	= 0
		dayPointer = startDate.getDay() - startAt1
		
		if (dayPointer<0)
		{
			dayPointer = 6
		}

		sHTML =	"<table width='100%' cellspacing='0' cellpadding='1' border=0 style='font-family:arial;font-size:10px;'><tr>";

		for	(i=0; i<7; i++)	{
			if (i==6)
				sHTML += "<td class='cellTLRB' align='right'><B>"+ dayName1[i]+"</B></td>"
			else
				sHTML += "<td class='cellTLB' align='right'><B>"+ dayName1[i]+"</B></td>"
		}
		sHTML +="</tr><tr>"
		
		if (showWeekNumber1==1)
		{
			sHTML += "<td align='center'>" + WeekNbr1(startDate) + "&nbsp;</td>"
		}

		for	( var i=1; i<=dayPointer;i++ )
		{
			sHTML += "<td class='cellLB'>&nbsp;</td>"
		}
	
		for	(datePointer=1; datePointer<=numDaysInMonth; datePointer++)
		{
            /*check to see if its an event day*/
            eventDay = false;
            for(j=0;j<document.arraycount;j++)
            {
                
                if(document.arrayYear[j]==yearSelected1 && document.arrayMonth[j]==monthSelected1+1 &&                      document.arrayDay[j]==datePointer)
                {
                    eventDay = true;
                }
            }
			dayPointer++;
			if (dayPointer%7 == 0)
            {
                //check to see if its an event day
                if(eventDay)
				    sHTML += "<td class='cellLRBcolor' align='right'>";
                else
                    sHTML += "<td class='cellLRB' align='right'>";
            }
			else
            {
                if(eventDay)
				    sHTML += "<td class='cellLBcolor' align='right'>";
                else
                    sHTML += "<td class='cellLB' align='right'>";

            }
			sStyle=styleAnchor1
			

			dateMessage = "onmousemove='window.status=\'selectDateMessage.replace(\"[date]\",constructDate1(datePointer,monthSelected1,yearSelected1))\' onmouseout='window.status=\'\''"
            var sHint1 = "";
			
            if(eventDay)
            {
                sHTML += "<a \"+dateMessage+\" title='" + sHint1 + "' style='"+sStyle+"' href='javascript:formSubmit("+datePointer + ", " + (monthSelected1) + ", " + yearSelected1 + ");'>&nbsp;<font color=#A04540>" + datePointer + "</font>&nbsp;</a>"
            }
            else if(dayPointer % 7 == (startAt1 * -1)+1)
			{       
                sHTML += "<a \"+dateMessage+\" title='" + sHint1 + "' style='"+sStyle+"' href='javascript:formSubmit("+datePointer + ", " + (monthSelected1) + ", " + yearSelected1 + ");'>&nbsp;<font color=#909090>" + datePointer + "</font>&nbsp;</a>"
            }
			else
			{ 
                sHTML += "<a \"+dateMessage+\" title='" + sHint1 + "' style='"+sStyle+"' href='javascript:formSubmit("+datePointer + ", " + (monthSelected1) + ", " + yearSelected1 + ");'>&nbsp;" + datePointer + "&nbsp;</a>"
            }

			sHTML += ""
			if ((dayPointer+startAt1) % 7 == startAt1) 
            { 
				sHTML += "</tr><tr>" 
				if ((showWeekNumber1==1)&&(datePointer<numDaysInMonth))
				{
					sHTML += "<td align=right>" + (WeekNbr1(new Date(yearSelected1,monthSelected1,datePointer+1))) + "&nbsp;</td>"
				}
			}
		}

        //pad any cells remaininng into calendar
		for(i=(dayPointer%7);i<7;i++)
		{
			
            if(i==6)
               sHTML += "<td class='cellLRB'>&nbsp;</td>";
            else
                sHTML += "<td class='cellLB'>&nbsp;</td>";

		}

		document.getElementById("content1").innerHTML   = sHTML
		document.getElementById("spanMonth1").innerHTML = monthName1[monthSelected1] + " " + yearSelected1;
	}