
function fct_open_resultat_sondage(IDSondage, strCle)
{ 
	strCode = "";
	for(intIndex = 0; intIndex <= 30; intIndex++)
	{
		strCode = strCode + parseInt(Math.random() * 9);
	}
	
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                 document.getElementById("SPANResultatSondage_" + IDSondage + "_" + strCle).innerHTML = xhr.responseText; 
              else 
                 document.getElementById("SPANResultatSondage_" + IDSondage + "_" + strCle).innerHTML = "Error code " + xhr.status;
         }
    }

   xhr.open("GET", "sondage_resultat.php?sondage=" + IDSondage + "&code=" + strCode, true); 
   xhr.send(null); 
} 

function frmSondageRADIO_submit(RADIOSondage, IDSondage, strCle, intNbrReponses)
{ 
	document.getElementById("cmdSoumettre_Sondage_" + IDSondage + "_" + strCle).disabled = true;
	
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
 
	var strReponses = "";
	
	for(intIndex = 0; intIndex < parseInt(intNbrReponses); intIndex++)
	{
		if(RADIOSondage[intIndex].checked) {
			strReponses = strReponses + RADIOSondage[intIndex].value + ";";
		}
	}

	if(strReponses != "")
	{
		strCode = "";
		for(intIndex = 0; intIndex <= 30; intIndex++)
		{
			strCode = strCode + parseInt(Math.random() * 9);
		}
	
		xhr.open("GET", "sondage_miseajour.php?sondage=" + IDSondage + "&reponses=" + strReponses + "&code=" + strCode,  true);  
		xhr.send(null); 
		
		fct_open_resultat_sondage(IDSondage, strCle);
	}
	else
	{
		document.getElementById("cmdSoumettre_Sondage_" + IDSondage + "_" + strCle).disabled = false;
	}
} 

function frmSondageCHECKBOX_submit(IDSondage, strCle, intNbrReponses)
{ 
	document.getElementById("cmdSoumettre_Sondage_" + IDSondage + "_" + strCle).disabled = true;
	
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
 
	var strReponses = "";
	
	for(intIndex = 1; intIndex <= parseInt(intNbrReponses); intIndex++)
	{
		if(document.getElementById("sondage_" + IDSondage + "_" + strCle + "_" + intIndex).checked) {
			strReponses = strReponses + document.getElementById("sondage_" + IDSondage + "_" + strCle + "_" + intIndex).value + ";";
		}
	}

	if(strReponses != "")
	{
		strCode = "";
		for(intIndex = 0; intIndex <= 30; intIndex++)
		{
			strCode = strCode + parseInt(Math.random() * 9);
		}
		
		xhr.open("GET", "sondage_miseajour.php?sondage=" + IDSondage + "&reponses=" + strReponses + "&code=" + strCode,  true);  
		xhr.send(null); 
		
		fct_open_resultat_sondage(IDSondage, strCle);
	}
	else
	{
		document.getElementById("cmdSoumettre_Sondage_" + IDSondage + "_" + strCle).disabled = false;
	}
} 
