Date Picker
i+=1;
datasN[i]='2012-2-24';
//datasN[i]='';
//HTML += datasN[i]+'e '+i+'
';
i+=1;
datasN[i]='2012-2-27';
//datasN[i]='';
//HTML += datasN[i]+'e '+i+'
';
var datasE = new Array("");
i=0;
MonthNames = new Array('Jan', 'Feb', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez');
//If no parameter is passed use the current date.
oDate = new Date();
Year = (iYear == null) ? oDate.getFullYear() : iYear;
Month = (iMonth == null) ? oDate.getMonth() : iMonth - 1;
Mes = (iMonth == null) ? oDate.getMonth() : iMonth;
while(Month < 0){Month += 12;Year--}
while(Month >= 12){Month -= 12;Year++}
while(Mes < 0){Mes += 12;}
while(Mes >= 12){Mes -= 12;}
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('
');
}
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('
');
}
Container = document.getElementById(ContainerId);
ClassName = (ClassName == null) ? 'tblCalendar' : ClassName;
HTML += '
';
// Title bar
HTML += '| « | ' + MonthNames[Month] + ' ' + Year + ' | » |
';
// Week Names
HTML += '| D | S | T | Q | Q | S | S |
';
HTML += '';
// Fill the previous month days with space
for(DayCounter = 0; DayCounter < WeekStart; DayCounter++)
{
HTML += '| | ';
}
// Populate current month
var marcarDia=0;
var dataA="";
for(DayCounter = 1; DayCounter < MonthDays; DayCounter++)
{
//PERCORRER O ARRAY DE DATAS DAS HISTRIAS
/*if(Month<=0) Mes = 1;
else if(Month>12) Mes = 12;
else Mes = Month;*/
dataA=Year+'-'+(Month+1)+'-'+DayCounter;
marcarDia=0;
for(i=0; i<= datasN.length; i++){
if(datasN[i]==dataA){
marcarDia=1;
}
}
for(i=0; i<= datasE.length; i++){
if(datasE[i]==dataA){
marcarDia=1;
}
}
//HTML +=anoA;
if((DayCounter + WeekStart) % 7 == 1) HTML += '
';
if(DayCounter == Day){
HTML += '| ' + DayCounter + ' | ';
}else{
HTML += '' + DayCounter + ' | ';
}
if((DayCounter + WeekStart) % 7 == 0) HTML += '
';
}
// Fill the next month days with space
for(j = (42 - (MonthDays + WeekStart)), DayCounter = 0; DayCounter <= j; DayCounter++)
{
HTML += ' | ';
if((j - DayCounter) % 7 == 0) HTML += '';
}
HTML += '
';
Container.innerHTML = HTML;
// Returns Id of the element containing the calendar
return ContainerId;
}
function ReturnDate(Day)
{
//opener.SetDate(Day, Month+1, Year);
// window.close();
mes=Month+1;
window.open("http://www.joaosilva.pt/portal_contabilidade/?m=ver_por_data&dia="+Day+"&mes="+mes+"&ano="+Year,"_self");
}
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 = Calendar(Year, Month+1, Day, 'cal', 'CalendarRed');
}
//-->