
function getTime()
{
 //Инициализируем переменные с параметрами текущего времени
 var now = new Date()
}
//Функция проверки на високосный год
function isLeapYear(year)
{
 if (year % 4 == 0) return true // Является високосным годом
 return false // Не является високосным годом
}

//Функция возвращает колличество дней в месяце взависимости от года
function getDays(month, year)
{
 // Создаем массив, для хранения числа дней в каждом месяце
 var ar = new Array(12)
 ar[0] = 31 // Январь
 ar[1] = (isLeapYear(year)) ? 29 : 28 // Февраль
 ar[2] = 31 // Март
 ar[3] = 30 // Апрель
 ar[4] = 31 // Май
 ar[5] = 30 // Июнь
 ar[6] = 31 // Июль
 ar[7] = 31 // Август
 ar[8] = 30 // Сентябрь
 ar[9] = 31 // Остябрь
 ar[10] = 30 // Ноябрь
 ar[11] = 31 // Декабрь
 return ar[month]
}

//Функция возвращает название месяца
function getMonthName(month,nameMonth)
{
 // Создаем массив, для хранения названия каждого месяца
 var ar = new Array(12)
if (nameMonth=="rus"||nameMonth=="russ"||nameMonth=="russs")
{

 ar[0] = "January"
 ar[1] = "February"
 ar[2] = "March"
 ar[3] = "April"
 ar[4] = "May"
 ar[5] = "June"
 ar[6] = "July"
 ar[7] = "August"
 ar[8] = "September"
 ar[9] = "October"
 ar[10] = "Novemer"
 ar[11] = "December"
}
 return ar[month]
}
// Функция установки настроек календаря с последующей прорисовкой
function setCalendar()
{
 var nameMonth="rus" // rus, russ, russs, eng, engs, engss
 drawCalendar(
  tableBgColor,
  headerHeight,
  border,
  cellspacing,
  cellpadding,
  headerColor,
  headerBgColor,
  headerSize,
  headerBold,
  colWidth,
  dayCellHeight,
  dayColor,
  dayBgColor,
  dayBold,
  daySize,
  cellHeight,
  todayColor,
  todayBgColor,
  todayBold,
  todaySize,
  allDayColor,
  allDayBgColor,
  allDayBold,
  allDaySize,
  timeColor,
  timeSize,
  timeBold,
  isTime,
  nameMonth)
}
// Функция рисования календаря
function drawCalendar(
 tableBgColor,
 headerHeight,
 border,
 cellspacing,
 cellpadding,
 headerColor,
 headerBgColor,
 headerSize,
 headerBold,
 colWidth,
 dayCellHeight,
 dayColor,
 dayBgColor,
 dayBold,
 daySize,
 cellHeight,
 todayColor,
 todayBgColor,
 todayBold,
 todaySize,
 allDayColor,
 allDayBgColor,
 allDayBold,
 allDaySize,
 timeColor,
 timeSize,
 timeBold,
 isTime,
 nameMonth,
 tyear,
 tmonth,
 setday
)
{
 // Переменные 
 var now = new Date()
// var year = now.getYear()
 var year = tyear
// var month = now.getMonth()
var month = tmonth
 var monthName = getMonthName(month, nameMonth)
 now = null
 var firstDayInstance = new Date(year, month, 1)
 var firstDay = firstDayInstance.getDay()+1
 firstDayInstance = null
 // Число дней в текущем месяце
 var date = 11
 var lastDate= getDays(month, year)
 // Создаем основную структуру таблицы
 var text = "" 
 text += '<font face="Arial, Helvetica, sans-serif"><table border=' + border + ' cellspacing=' + cellspacing + ' cellpadding='+cellpadding+' bgcolor='+tableBgColor+'>'
 text += '<th colspan=7 height=' + headerHeight +' bgcolor='+headerBgColor+ '>'
 text += '<font color="' + headerColor + '" size=' + headerSize + '>'
 if(headerBold)text+='<b>'
 text += monthName + ' ' + year 
 if(headerBold)text+='</b>'
 text += '</font>'
 text += '</th>'
 var openCol = '<td width=' + colWidth + ' height=' + dayCellHeight + ' bgcolor='+dayBgColor+'>'
 openCol+='<font color="' + dayColor + '" size='+daySize+'>'
 if(dayBold)openCol+='<b>'
 var closeCol = '</font></td>'
 if(dayBold)closeCol='</b>'+closeCol
 // Создаем массив сокращенных названий дней недели
 var weekDay = new Array(7)
 if(nameMonth=="rus")
 {

  weekDay[0] = "Mon"
  weekDay[1] = "Tue"
  weekDay[2] = "Wed"
  weekDay[3] = "Thu"
  weekDay[4] = "Fri"
  weekDay[5] = "Sat"
 weekDay[6] = "Sun"
 }
 else if(nameMonth=="russ")
 {

  weekDay[0] = "Mon"
  weekDay[1] = "Tue"
  weekDay[2] = "Wed"
  weekDay[3] = "Thu"
  weekDay[4] = "Fri"
  weekDay[5] = "Sat"
 weekDay[6] = "Sun"
  
 }
  text += '<tr align="center" valign="center">'
 for (var dayNum = 0; dayNum < 7; ++dayNum)
 {
  text += openCol + weekDay[dayNum] + closeCol 
 }
 text += '</TR>'
 var digit = 1
 var curCell = 2
 var i=1
 for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row)
 {
  text += '<tr align="center" valign="top">'
  for (var col = 1; col <= 7; ++col)
  {
   if (digit > lastDate) break
   if (curCell < firstDay)
   {
    text += '<td><font size='+allDaySize+' color='+allDayColor+'> </font></td>'
    curCell++
   } 
   else
   {
    if (digit == setday[i]) 
    { // Текущая ячейка представляет сегодняшнюю дату


     text += '<td height=' + cellHeight + ' bgcolor='+allDayBgColor+'><font size='+allDaySize+' color='+allDayColor+'>'

//     text += '<td height=' + cellHeight + ' bgcolor=#fafafa>'
     text += '<font color="' + todayColor + '" size='+todaySize+'>'
     if(todayBold)text +=''
     text += '<b><a href=archives.php?data='
     text += year+'-'
     month1=month+1
     text += month1+'-'
     text += digit
     text += ' style="font-weight:bold">'
     text += digit
     text += '<b></a>'

     if(todayBold)text +='</b>'

     text += '</FONT>'
   
     text += '</td>'
    } 
    else 
    {
     text += '<td height=' + cellHeight + ' bgcolor='+allDayBgColor+'><font size='+allDaySize+' color='+allDayColor+'>'
     if(allDayBold)text +='<b>'
//     text += '<a href=archives.php?data='
//     text += year+'-'
//     month1=month+1
//     text += month1+'-'
//     text += digit
//     text += '>'
     text += digit
//     text += '</a>'
     if(allDayBold)text +='</b>'
     text +='</font></td>'
    }
    digit++
    i++
   }
  }
  text += '</tr>'
 }
 text += '</table></font>'
 // Выводим полученную строку
 document.write(text) 
}

// -->
