<!--
function SelectDate()
{
	D = document.getElementById('Date').value;
	if(D){
		D = D.split('/');
	}else{
		Dat = new Date();
		D = new Array(Dat.getDay(), Dat.getMonth(), Dat.getFullYear());
	}
	win = window.open("index.html","win","status=no,scrollbars=no,toolbar=no,menubar=no,height=150,width=150");
	if (parseInt(navigator.appVersion) == 2 && navigator.appName == "Netscape")
		win = window.open("index.html","win","status=yes,height=325,width=250");
		//win'MakeDate',D[2], D[1],D[0], 'SetDate');
		win.MakeDate(D[2], D[1], D[0]);
}
function SetDate(Day, Month, Year)
{
	document.getElementById('Date').value = Day + '/' + Month + '/' + Year;
}
ReturnFunc = '';
function CalendarNew(iYear, iMonth, iDay, ContainerId, ClassName)
{
	MonthNames = new Array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
	//If no parameter is passed use the current date.
	oDate = new Date();
	Year = (iYear == null) ? oDate.getFullYear() : iYear;
	Month = (iMonth == null) ? oDate.getMonth() : iMonth;
	while(Month < 0){Month += 12;Year--}
	while(Month >= 12){Month -= 12;Year++}
	Day = (iDay == null) ? 0 : iDay;
	oDate = new Date(Year, Month, 1);
	NextMonth = new Date(Year, Month + 1, 1);
	WeekStart = oDate.getDay();
	// Get the number of months in current month
	MonthDays = Math.round((NextMonth.getTime() - oDate.getTime()) / 86400000) + 1;
	// Check whether the Container Id is null
	if(ContainerId != null)
	{
		ContainerId = ContainerId;
		Container = document.getElementById(ContainerId);
		// If an element doesnot exists with the given ContainerId then create it
		if(!Container)
			document.write('<div id="' + ContainerId + '">&nbsp;</div>');
	}
	else
	{
		// Loop until a unique id is obtained for the container
		do
		{
			ContainerId = 'tblCalendar' + Math.round(Math.random() * 1000);
		}
		while(document.getElementById(ContainerId));
		// create an element with the new id
		document.write('<div id="' + ContainerId + '">&nbsp;</div>');
	}
	Container = document.getElementById(ContainerId);
	ClassName = (ClassName == null) ? 'tblCalendar' : ClassName;
	HTML = '<table class="' + ClassName + '" cellspacing="0">';
	// Title bar MES
	var MES = 'mes';
	var DIA = 0;
	HTML += '<tr class="TitleBar"><td class="Nav"><a class="txtdefault" href="javascript:void(0)" onMouseDown="CalendarNew(' + Year + ', ' + (Month - 1) + ', ' + Day+', \''+ContainerId+'\', \''+ClassName+'\');">&laquo;</a></td><td colspan="5" class="Title"><a class="txtdefault" onclick="enabledEventos(\'mes\',\'0\','+parseInt(Month+1)+','+Year+');" href="javascript:void(0)">' + MonthNames[Month] + ' ' + Year + '</a></td><td class="Nav"><a class="txtdefault" href="javascript:void(0)" onMouseDown="CalendarNew(' + Year + ', ' + (Month + 1) + ', ' + Day+', \''+ContainerId+'\', \''+ClassName+'\');">&raquo;</a></td></tr>';
	// Week Names
	//HTML += '<tr class="WeekName"><td>S</td><td>D</td><td>S</td><td>T</td><td>Q</td><td>Q</td><td>S</td></tr>';
	HTML += '<tr class="WeekName"><td>D</td><td>S</td><td>T</td><td>Q</td><td>Q</td><td>S</td><td>S</td></tr>';
	HTML += '<tr class="Days">';
	// Fill the previous month days with space
	for(DayCounter = 0; DayCounter < WeekStart; DayCounter++)
	{
		HTML += '<td>&nbsp;</td>';
	}
	// Populate current month
	for(DayCounter = 1; DayCounter < MonthDays; DayCounter++)
	{
		if((DayCounter + WeekStart) % 7 == 1) HTML += '<tr class="Days">';
		if(DayCounter == Day)
			HTML += '<td class="SelectedDay"><a class="txtdefault" href="javascript:void(0)" onclick="enabledEventos(\'dia\','+DayCounter+','+parseInt(Month+1)+','+Year+');">' + DayCounter + '</a></td>';
		else HTML += '<td><a class="txtdefault" href="javascript:void(0)" onclick="enabledEventos(\'dia\','+DayCounter+','+parseInt(Month+1)+','+Year+');">' + DayCounter + '</a></td>';
		if((DayCounter + WeekStart) % 7 == 0) HTML += '</tr>';
	}
	// Fill the next month days with space
	for(j = (42 - (MonthDays + WeekStart)), DayCounter = 0; DayCounter <= j; DayCounter++)
	{
		HTML += '<td>&nbsp;</td>';
		if((j - DayCounter) % 7 == 0) HTML += '</tr>';
	}
	HTML += '</table>';
	Container.innerHTML = HTML;
	// Returns Id of the element containing the calendar
	return ContainerId;
}
function ReturnDate(Day)
{
	opener.SetDate(Day, Month+1, Year);
	window.close();
}
function MakeDate(iYear, iMonth, iDay, fn)
{
	D = new Date();
	Year = (typeof(iYear) != 'undefined') ? iYear : D.getFullYear();
	Month = (typeof(iMonth) != 'undefined') ? iMonth : D.getMonth();
	Day = (typeof(iDay) != 'undefined') ? iDay : D.getDate();
	ReturnFunc = fn;
	id = CalendarNew(Year, Month, Day, 'cal', 'CalendarRed');
}
//-->