function popUp(URL,w,h,s,r)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+s+',location=0,statusbar=0,menubar=0,resizable='+r+',width='+w+',height='+h+',left = 100,top = 80');");
}

function vis(d, id)
{
	a=document.getElementById(d);
	b=a.getElementsByTagName('LI');
	for (i=0; i<b.length; i++) b[i].className="";
	sel=document.getElementById("tit_"+id);
	sel.className="selected";
	
	a=document.getElementById(d+'list');
	b=a.getElementsByTagName('DIV');
	for (i=0; i<b.length; i++) b[i].style.display="none";
	sel=document.getElementById(id);
	sel.style.display="block";
}

function stampa() { this.print(); }

/* il codice è duplicato nel main.js di NETWORK */
function createClient()
{
	client = false;
	if (window.XMLHttpRequest) client = new XMLHttpRequest();
	else
	{ 
		if (window.ActiveXObject) client = new ActiveXObject("Microsoft.XMLHTTP");
	    if (!client) client = new ActiveXObject("Msxml2.XMLHTTP");
	}
	return client;
}

function vota(form, id)
{
	risp = false;
	for (i=0; i<document.forms[form].idrisposta.length; i++) if (document.forms[form].idrisposta[i].checked) risp = (document.forms[form].idrisposta[i].value);
	if (risp)
	{
		document.getElementById('button_'+form).disabled = true;
		client = createClient();
		client.onreadystatechange = function(){
			if (client.readyState == 4 && client.responseText!=null) document.getElementById('handler_txt_'+form).innerHTML = client.responseText;
			if (client.readyState == 4 && client.status != 200)
			{
				document.getElementById('handler_txt_'+form).innerHTML = "Errore di sistema"; // azione conclusa ma pagina con errore
				document.getElementById('button_'+form).disabled = false;
			}
			if (client.readyState == 4) { clearTimeout(xmlHttpTimeout); document.getElementById('handler_txt_'+form).style.display = 'block'; document.getElementById('handler_'+form).style.display = 'none'; } 
			if (client.readyState == 1) { document.getElementById('handler_'+form).style.display = 'block'; document.getElementById('handler_txt_'+form).style.display = 'none'; }
		};
		client.open("GET", "action.php?action=sondaggio&idsondaggio="+id+"&idrisposta="+risp);
		client.send();

		xmlHttpTimeout = setTimeout(function() { client.abort(); },5000);
	}
	else
	{
		document.getElementById('handler_txt_'+form).innerHTML = "Non hai selezionato alcuna risposta";
		document.getElementById('handler_txt_'+form).style.display = 'block';
	}
}