function gOfs(obj){
    var x=0,y=0;
    if(window.opera)
    {
        if(obj.style.position=='absolute')
        {
            x=obj.style.posLeft;
            y=obj.style.posTop;
        }else{
            while (obj.offsetParent)
            {
                x+=obj.offsetLeft;
                y+=obj.offsetTop;
                obj=obj.offsetParent;
            }
        }
    }else if(obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            x+=obj.offsetLeft;
            y+=obj.offsetTop;
            obj=obj.offsetParent;
        }
    }else if (obj.x)
    {
        x += obj.x;
        y += obj.y;

    }
    //alert(x+' '+y);
    return {x: x, y: y}
}

function doGetLoad_cal(url, show_in)
	{
    ofs = gOfs(document.getElementById(show_in));
    if (window.XMLHttpRequest)
		{
		request = new XMLHttpRequest();
		request.onreadystatechange = function()
			{
			abortRequest = window.setTimeout("request.abort();", 10000);
			if (request.readyState == 4)
				{
				clearTimeout(abortRequest);
				if (request.status == 200)
					{
                    document.getElementById('calendar_bootdiv').style.display = 'none';
                    document.getElementById(show_in).innerHTML = request.responseText;
					}
				else
					{
					alert("Не удалось получить данные:\n" + request.statusText);
					}
                }
            else if (request.readyState == 3 || request.readyState == 1)
    				{
                    document.getElementById('calendar_bootdiv').style.display = '';
                    document.getElementById('calendar_bootdiv').style.top = ofs.y;
                    document.getElementById('calendar_bootdiv').style.left = ofs.x;
                    document.getElementById('calendar_bootdiv').style.width = document.getElementById('calendar_area').offsetWidth;
                    document.getElementById('calendar_bootdiv').style.height = document.getElementById('calendar_area').offsetHeight;
    				}
			return false;
			}
		request.open("GET", url, true);
		request.send(null);
		return false;
		}
	else if (window.ActiveXObject)
		{
		request = new ActiveXObject("Microsoft.XMLHTTP");
		if (request)
			{
			request.onreadystatechange = function()
				{
				abortRequest = window.setTimeout("request.abort();", 10000);
				if (request.readyState == 4)
					{
					clearTimeout(abortRequest);
					if (request.status == 200)
						{
                        document.getElementById('calendar_bootdiv').style.display = 'none';
                        document.getElementById(show_in).innerHTML = request.responseText;
						}
					else
						{
						alert("Не удалось получить данные:\n" + request.statusText);
						}
					}
                else if (request.readyState == 3 || request.readyState == 1)
        				{
                        document.getElementById('calendar_bootdiv').style.display = '';
                        document.getElementById('calendar_bootdiv').style.top = ofs.y;
                        document.getElementById('calendar_bootdiv').style.left = ofs.x;
                        document.getElementById('calendar_bootdiv').style.width = document.getElementById('calendar_area').offsetWidth;
                        document.getElementById('calendar_bootdiv').style.height = document.getElementById('calendar_area').offsetHeight;
        				}
				return false;
				}
			request.open("GET", url, true);
			request.send();
			return false;
			}
		}

	return false;
	}


function update_calendar(year, month, day)
    {
    if(doGetLoad_cal("ajax_calendar.php?year="+year+"&month="+month+"&day="+day, "calendar_area"))
        {
        doGetLoad_cal("date.notes.list.php?year="+year+"&month="+month+"&day="+day, "side_note_list");
        }
    return false;
    }