<!--
var today            = new Date();
var currMonth        = today.getMonth();
var currYear         = today.getFullYear();
var shownCalendarId  = '';

var currField        = null;
var currHiddenField  = null;
var currDate         = new Date();

var urlPrefix       = 'news';

var monthNames   = ['ßíâàðü', 'Ôåâðàëü', 'Ìàðò', 'Àïðåëü', 'Ìàé', 'Èþíü', 'Èþëü', 'Àâãóñò', 'Ñåíòÿáðü', 'Îêòÿáðü', 'Íîÿáðü', 'Äåêàáðü'];
var monthNamesR  = ['ÿíâ', 'ôåâ', 'ìàð', 'àïð', 'ìàÿ', 'èþí', 'èþë', 'àâã', 'ñåí', 'îêò', 'íîÿ', 'äåê'];
var weekdayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var weekdayInits = ['ÏÍ', 'ÂÒ', 'ÑÐ', '×Ò', 'ÏÒ', 'ÑÁ', 'ÂÑ'];

function setDate(dateSet, monthSet, yearSet) {
    var dateToSet = new Date(yearSet, monthSet, dateSet);

    if (currField) {
        currField.value = dateSet + ' ' + monthNamesR[monthSet] + ' ' + yearSet;
    }

    if (currHiddenField) {
        currHiddenField.value = Date.parse(dateToSet.toString());
    }

    hideCurrCalendar();
}

function showCalendar(btnElem, leerId, ancName, fieldName, prefix) {

    urlPrefix = prefix || urlPrefix;

    if (shownCalendarId != '') hideCurrCalendar();

        shownCalendarId  = leerId;
        drawCalendar(leerId, ancName);
}

function hideCurrCalendar() {
    if (shownCalendarId != '') {
        hideLeer(shownCalendarId);
    }

    shownCalendarId  = '';

    currField       = null;
    currHiddenField = null;
}

function drawCalendar(leerId, ancName, showYear, showMonth) {
    // insetting the button
    var month = new Date();


if (showMonth != null) month.setMonth(showMonth, 1);
else month.setMonth(currDate.getMonth());
if (showYear != null) month.setYear(showYear);
else month.setYear(currDate.getFullYear());
var thisMonth = month.getMonth();
var nextMonth = (thisMonth == 11)? 0 : thisMonth + 1;
var prevMonth = (thisMonth == 0)? 11 : thisMonth - 1;
var thisYear = month.getFullYear();
var nextYear = (thisMonth == 11)? thisYear + 1 : thisYear;
var prevYear = (thisMonth == 0)? thisYear - 1 : thisYear;
var isThisMonth = (month.getFullYear() == currDate.getFullYear() && month.getMonth() == currDate.getMonth())? true : false;


// table starts
var calendarHTML = '<div class="image-right"><div class="image-bottom">\n<table class="calendarDays">\n<tr><td colspan="7" class="cal-title">';
// link back
calendarHTML += '\n<a href="javascript:;"' +
'onClick="drawCalendar(\'' + leerId + '\', \'' + ancName + '\', ' + prevYear + ', ' + prevMonth +
'); return false;">&lt;&lt;<\/a>';
// month, year row
calendarHTML += '\n' + monthNames[month.getMonth()] + ' ' + month.getFullYear();
// link fwd
calendarHTML += '\n<a href="javascript:;" onClick="drawCalendar(\'' + leerId + '\', \'' + ancName + '\', ' + nextYear + ', ' + nextMonth + '); return false;">&gt;&gt;<\/a>\n' + '\n</td></tr>';

calendarHTML += '\n<tr class="days">'
// appending day initials

for (var i = 0; i < weekdayInits.length; i++) {
    calendarHTML += '<td>' + weekdayInits[i] + '<\/td>\n'
}

calendarHTML += '\n<tr>'

// getting the first day of the month
month.setDate(1);
var daysToStart = (month.getDay() == 0)? 7 : month.getDay();
// drawing empty cells
for (var i = 0; i < daysToStart - 1; i++) calendarHTML += '\n<td class="empty">&nbsp;<\/td>';
// drawing the calendar itself
for (var i = 1; i < 33; i++) {
month.setDate(i);

if (month.getMonth() == thisMonth) {
    if (isThisMonth && currDate.getDate() == i) {
        calendarHTML += '<td class="today">' + i + '<\/td>';
    } else {
        if ((ar_links[thisYear] != null) && (ar_links[thisYear][thisMonth+1] != null) && (ar_links[thisYear][thisMonth+1][i] != null)) {
            calendarHTML += '<td><a href="/rus/'+urlPrefix+'/' + thisYear + '/' + (thisMonth+1) + '/' + i + '/">' + i + '<\/a><\/td>';
        } else {
            calendarHTML += '<td class="empty">' + i + '<\/td>';
        }
    }
} else break;


if (month.getDay() == 0) calendarHTML += '<\/tr><tr>';
}
// drawing empty cells if any
if (month.getDay() != 1) {
    var finalDay = (month.getDay() == 0)? 7 : month.getDay();
    var daysToEnd = 8 - finalDay;
    for (var i = 0; i < daysToEnd; i++) calendarHTML += '<td class="empty">&nbsp;<\/td>';
}
// tables ends
calendarHTML += '<\/tr><\/table></div></div>';
var leerPos = new getCalendarPosition(ancName);

if (document.getElementById) {
    var leerElem = document.getElementById(leerId);
    leerElem.innerHTML = calendarHTML;
    leerElem.style.left = leerPos.x - 150 + 'px';
    leerElem.style.top = leerPos.y + 5 + 'px';
    leerElem.style.visibility = 'visible';
} else if (document.all) {
    var leerElem = document.all[leerId];
    leerElem.innerHTML = calendarHTML;
    leerElem.style.left = leerPos.x;
    leerElem.style.top = leerPos.y;
    leerElem.style.visibility = 'visible';
} else if (document.layers) {
    document.layers[leerId].left = leerPos.x;
    document.layers[leerId].top = leerPos.y;
    document.layers[leerId].document.open();
    document.layers[leerId].document.write(calendarHTML);
    document.layers[leerId].document.close();
    document.layers[leerId].visibility = 'show';
}
}

function hideLeer(leerId) {
    if (document.layers) {
        document.layers[leerId].visibility = 'hide';
    } else if (document.getElementById) {
        document.getElementById(leerId).style.visibility = 'hidden';
    } else if (document.all) {
        document.all[leerId].style.visibility = 'hidden';
    }
}

function ancPosX(anchorPtr) {
    if (document.layers) {
        return anchorPtr.x;
    } else if (document.getElementById || document.all) {
        var pos = anchorPtr.offsetLeft;

        while (anchorPtr.offsetParent != null) {
            anchorPtr = anchorPtr.offsetParent;
            pos += anchorPtr.offsetLeft;
        }
    return pos;
    }
}

function ancPosY(anchorPtr) {
    if (document.layers) {
        return anchorPtr.y;
    } else if (document.getElementById || document.all) {
        var pos = anchorPtr.offsetTop;

        while (anchorPtr.offsetParent != null) {
            anchorPtr = anchorPtr.offsetParent;
            pos += anchorPtr.offsetTop;
        } return pos;
    }
}

function getCalendarPosition(ancName) {
    for (var i = 0; i < document.anchors.length; i++) {
        if (document.anchors[i].name == ancName) {
            this.x = ancPosX(document.anchors[i]);
            this.y = ancPosY(document.anchors[i]);
            return this;
        }
    }
}

function isParent(elemPtr, parentId) {
    if (document.getElementById) {
//	while (elemPtr.parentNode != null) {
//	if //	}
    }
    return false;
}

if (document.layers) {
    origWidth = window.innerWidth;
    origHeight = window.innerHeight;
}

function resizing() {
    if (document.layers) {
        if (window.innerWidth != origWidth || window.innerHeight != origHeight) {
            location.reload();
        }
    } else {
        hideCurrCalendar();
    }
}
window.onresize = resizing;

// -->