function createXmlHttp(){
	var xmlHttp=false;
	try{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}//try
	catch(e){
		try{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}//try
		catch(E){
			xmlHttp=false;
		}//catch
	}//catch
	if ((!xmlHttp)&&(typeof(XMLHttpRequest)!='undefined')){
		try{
			xmlHttp=new XMLHttpRequest();
		}//try
		catch(e){
			xmlHttp=false;
		}//catch
	}//if
	if ((!xmlHttp)&&(window.createRequest)){
		try {
			xmlHttp=window.createRequest();
		}//try
		catch(e){
			xmlHttp=false;
		}//catch
	}//if
	return xmlHttp;
}//createXmlHttp

function composePollVoteUrl(setID, formID) {
	var form = document.getElementById(formID);
	var radio;
	var ret = '';
	for(i=0;i<form.elements.length;i++) {
		radio = form.elements[i].name.match(/question\[[^\]]*\]/);
		if ((radio != null) && (form.elements[i].checked)) {
			if (ret.length > 0) {
				ret += 'q';
			}//if
			ret += parseInt(form.elements[i].name.substring(9)) + 'a' + form.elements[i].value;
		}//if
	}//for
	ret = './ajax/pools.php?set=' + setID + '&resp=' + ret;
	return ret;
}//composePollVote

function changePoll(allID, xmlHttp) {
	var poll = document.getElementById(allID);
	if (poll) {
		poll.innerHTML = xmlHttp.responseText;
	}//if
	delete xmlHttp;
}//changePoll

function xxx(allID) { alert(allID); }

function sendVote(setID, formID, statusID, allID) {
	var info = document.getElementById(statusID);
	var url;
	var xmlHttp;
	if (info) {
		info.innerHTML = '<div class="error">Wysyłanie wyników&hellip</div>';
	}//if
	url = composePollVoteUrl(setID, formID);
	xmlHttp = createXmlHttp();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4){ changePoll(allID, xmlHttp); } };
	xmlHttp.send("");
}//sendVote

function showResult(setID, statusID, allID) {
	var info = document.getElementById(statusID);
	var url;
	var xmlHttp;
	if (info) {
		info.innerHTML = '<div class="error">Wyświetlanie wyników&hellip</div>';
	}//if
	url = './ajax/pools.php?set=' + setID;
	xmlHttp = createXmlHttp();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4){ changePoll(allID, xmlHttp); } };
	xmlHttp.send("");
}//showResult

function showVote(setID, statusID, allID) {
	var info = document.getElementById(statusID);
	var url;
	var xmlHttp;
	if (info) {
		info.innerHTML = '<div class="error">Wyświetlanie pytań&hellip</div>';
	}//if
	url = './ajax/pools.php?vote=' + setID;
	xmlHttp = createXmlHttp();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4){ changePoll(allID, xmlHttp); } };
	xmlHttp.send("");
}//showVote
