
function vote(form, msg)
{
	i = 1;
	data = "";
	while(1)
	{
		option = document.getElementById('option'+i);
		if(!option)
		{
			break;
		}
		if(option.checked)
		{
			data= 'option=' + option.value
			break;
		}
		i++;
	}
	if(data != "")
	{
		data += '&actn=' + document.getElementById('surveys_actn').value + '&poll_id=' + document.getElementById('poll_id').value;
		link = '' + form.action + '?' + data;
		show_result(link, "Window1", "menubar=no, width=530, height=360, toolbar=no");
	}
	else
	{
		alert(msg);
	}
	return false;
}
function surveys_show_result(link)
{
	window.open(link, "Window1", "menubar=no, width=540, height=320, toolbar=no");
	return false;
}


//********************************************************************
function show_result(link)
{
	link = link + "&ajax=1";
	pos = document.getElementById('sur_div');
	pos.innerHTML = '<center><img id=\"sur_loading_image\" src="includes/images/LoadingAnimation.gif" /></center>';
	xmlHttp_sur_Obj=GetXmlHttpObject();
	if(xmlHttp_sur_Obj == null)
		return true;
	xmlHttp_sur_Obj.onreadystatechange=resultStateChanged;
	xmlHttp_sur_Obj.open("GET", link, true);
	//xmlHttp_sur_Obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//xmlHttp_sur_Obj.setRequestHeader('Content-Length', data.length);
	xmlHttp_sur_Obj.send(null);
	return false;
}

//********************************************************************

function resultStateChanged() 
{ 
	if (xmlHttp_sur_Obj.readyState == 4)
	{
		image = document.getElementById('sur_loading_image');
		if (image)
		{
			image.style.display = 'none';
		}
		pos = document.getElementById('sur_div');
		response=xmlHttp_sur_Obj.responseText;
		pos.innerHTML = response;
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
  		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
