function getBodyScrollTop()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function Change(sUrl){
  oDiv = document.getElementById('divCalendar');
  oFrm = document.getElementById('frCal');
  oSeM = document.getElementById('tMonth');
  oSeY = document.getElementById('tYear');
  if (oDiv && oFrm){
    oFrm.src = sUrl + 'Forms/calendar.php?nYear=' + oSeY.value + '&nMonth=' + oSeM.value;
    oDiv.innerHTML = 'загрузка календаря';
  }
  else alert('Нет необходимых объектов');
}

function FrmLoad(){
  try{
    oDiv = document.getElementById('divCalendar');
    oDiv.innerHTML = document.getElementById('frCal').contentWindow.document.body.innerHTML;
  }
  catch(e){setTimeout("FrmLoad('')", 0);}
}

function MouseOn(oObj){ 
  if (oObj.id != 'check')
    oObj.style.background = '#BFDBFF';
}

function MouseOut(oObj){
  if (oObj.id != 'check'){
    if (oObj.className == "td_cB")
      oObj.style.background = '#F0F0F0';
    if (oObj.className == "td_cV")
      oObj.style.background = '#C0C0C0';
    if (oObj.className == "td_cN")
      oObj.style.background = '#F69600';
  }
}

function MouseClick(oObj){
  oTmpObj = document.getElementById('check');
  if (oTmpObj){
   oTmpObj.id = '';
   if (oTmpObj.className == "td_cB")
     oTmpObj.style.background = '#F0F0F0';
   if (oTmpObj.className == "td_cV")
     oTmpObj.style.background = '#C0C0C0';
   if (oTmpObj.className == "td_cN")
     oTmpObj.style.background = '#F69600';
  }
  oObj.style.background = '#FA5E37'; 
  oObj.id = 'check';
}

function ToDay(sUrl){
  dNow= new Date();
  dMonth= dNow.getMonth()+1;
  dYear= dNow.getYear();
  dDay= dNow.getDate();
  document.getElementById('frCal').src = sUrl + 'Forms/calendar.php?nYear=' + dYear + '&nMonth=' + dMonth;
}

function CalDis(){
  oObj = document.getElementById('divAllCalendar');
  oScroll = document.getElementById('bodyLayer');
  //определяем координаты мышки
	if (brouser == "Microsoft Internet Explorer"){
	  nX = window.event.clientX - 115;
	  nY = window.event.clientY + 450;
	}
	else {
	  nX = getBodyScrollLeft() + 400; 
	  nY = getBodyScrollTop() + 420;
	  nX = nX + 'px';
	  nY = nY + 'px';
	}
	
	if (oObj.style.display == 'none'){
	  oObj.style.top =  nY; 
	  oObj.style.left = nX;
	  oObj.style.display = 'block';
	}
  else if (oObj.style.display == 'block')
    oObj.style.display = 'none';
}

function Save(){
  oDayObj = document.getElementById('check');
  oMonObj = document.getElementById('tMonth');
  oYeaObj = document.getElementById('tYear');
  if(oDayObj){
    dDay = oDayObj.innerHTML;
    dMon = oMonObj.value;
    dYea = oYeaObj.value;
  }
  else{
    dNow = new Date();
    dDay = dNow.getDate();
    dMon = dNow.getMonth()+1;
    dYea = dNow.getYear();
  }
  dDate = dDay + '.' + dMon + '.' + dYea;
  oIntObj = document.getElementById('in_dDate');
  oIntObj.value = dDate;
  CalDis();
}