var request = null;
   try {
     request = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         request = null;
       }
     }
   }

if (request == null)
  alert("Ошибка создания объекта запроса!");
  
function getAnswerData(cnt_answer) {
		var answer_str = '';
		for (i=0; i<cnt_answer; i++)
			{
				if(document.getElementById('answer['+i+']').checked)
					{
						answer_str = answer_str+'&answer['+i+']=1';
					}
			}
		
    var url = "./poll/poll.php?do=yes"+answer_str;
     request.open("GET", url, true);
     request.onreadystatechange = showResult;
     request.send(null);
   }

function showResult() 
	{
     if (request.readyState == 4) 
     	{
     		toggleLayer('poll_form', 'none');
     		toggleLayer('poll_votes', 'block');
     		document.getElementById('result').innerHTML = request.responseText;
     	}
  }

function toggleLayer(whichLayer, displayValue) {
  var elem, vis;
  if(document.getElementById) // this is the way the standards work
    elem = document.getElementById(whichLayer);
  else if(document.all) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if(document.layers) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  
  vis.display = displayValue;
}