function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}


// javascript-код голосования из примера
function sendcalendar(add,gid) {
	//alert (add+vid);	
	if (add==1){
		month--;
	}
	if (add==2){
		month++;
	}
	if (month==13){
		year++;
		month=1;
	}
	if (month==0){
		year--;
		month=12;
	}
	
	//alert(month+" "+year);
	//return;
	//asd.style.color="green";
	// (1) создать объект для запроса к серверу
	var req = getXmlHttp();  
       
        // (2)
	// span рядом с кнопкой
	// в нем будем отображать ход выполнения
	var statusElem = document.getElementById('calendar_e_status'); 
	var otvetElem = document.getElementById('calendar_status');
	
	//statusElem.innerHTML = 'Ожидаю ответа сервера...' ;
	statusElem.innerHTML = '<img src="/images/loader.gif">' ;
	
	req.onreadystatechange = function() {  
        // onreadystatechange активируется при получении ответа сервера

		if (req.readyState == 4) { 
            // если запрос закончил выполняться
					//alert (req.statusText );
			statusElem.innerHTML = "";// показать статус (Not Found, ОК..)

			if(req.status == 200) { 
                 // если статус 200 (ОК) - выдать ответ пользователю
				//alert("Ответ сервера: "+req.responseText);
				otvetElem.innerHTML=req.responseText;
			}
			// тут можно добавить else с обработкой ошибок запроса
		}

	}

       // (3) задать адрес подключения
	 // alert('/page/ajaxcalendar.php?r='+Math.random()+'&month='+month+'&year='+year+'&vid='+vid);
	req.open('GET', '/page/ajaxcalendar.php?r='+Math.random()+'&month='+month+'&year='+year, true);  

	// объект запроса подготовлен: указан адрес и создана функция onreadystatechange
	// для обработки ответа сервера
	 
        // (4)
	req.send(null);  // отослать запрос
  
        // (5)

}



