//----------------------------------------------------------------------------------------------
//Crea select da file XML di configurazione
function CreaSelect(ID, XMLQuery, ValueSelected){
    document.write("<select id='" + ID + "' size='1' name='" + ID + "'>");
    var Dati = xml.selectNodes(XMLQuery);
    for (ContaElementi=0; ContaElementi<Dati.length; ContaElementi++){
        if (ValueSelected == Dati(ContaElementi).getAttribute("Key"))
            document.write("<option value='" + Dati(ContaElementi).getAttribute("Key") + "' selected>" + Dati(ContaElementi).text  + "</option>");
        else
            document.write("<option value='" + Dati(ContaElementi).getAttribute("Key") + "'>" + Dati(ContaElementi).text  + "</option>");
    }
    document.write("</select>");
}

//----------------------------------------------------------------------------------------------
//Crea select con numeri progressivi
function CreaSelectCount(ID, DA, A, ValueSelected){
    document.write("<select id='" + ID + "' size='1' name='" + ID + "'>");
    document.write("<option value='ND'>All</option>");
    for (i = DA; i<= A; i++){
        Valore = "00" + i;
        Valore = Valore.substring(Valore.length-2, Valore.length);
        if (ValueSelected == Valore)
            document.write("<option value='" + Valore + "' selected>" + Valore + "</option>");
        else
            document.write("<option value='" + Valore + "'>" + Valore + "</option>");
    }
    document.write("</select>");
}

//----------------------------------------------------------------------------------------------
//Crea un gruppo di radio button da file XML di configurazione
function CreaRadioGruppo(ID, XMLQuery, ValueSelected){
                            var Dati = xml.selectNodes(XMLQuery);
                        for (ContaElementi=0; ContaElementi<Dati.length; ContaElementi++){
                            if (Dati(ContaElementi).getAttribute("Key") == ValueSelected)
		                             document.write("<input id='" + ID + "' name='" + ID + "' type='radio' value='" + Dati(ContaElementi).getAttribute("Key") + "' checked='checked'>" + Dati(ContaElementi).text + "&nbsp;&nbsp;&nbsp;&nbsp;");
                            else
		                             document.write("<input id='" + ID + "' name='" + ID + "' type='radio' value='" + Dati(ContaElementi).getAttribute("Key") + "'>" + Dati(ContaElementi).text + "&nbsp;&nbsp;&nbsp;&nbsp;");
                        }
}







//----------------------------------------------------------------------------------------------
//Crea select da file XML di configurazione per le faccine
function CreaSelectFaccina(ID, XMLQuery){
    document.write("<select id='" + ID + "' size='1' name='" + ID + "' onchange='JavaScript:SetBtnFaccina();'>");
    var Dati = xml.selectNodes(XMLQuery);
    for (ContaElementi=0; ContaElementi<Dati.length; ContaElementi++){
    	document.write("<option value='" + Dati(ContaElementi).getAttribute("Key") + "'>" + Dati(ContaElementi).text  + "</option>");
    }
    document.write("</select>");
}
function SetBtnFaccina(){
	document.forms[0].SetFaccina.value = document.forms[0].Faccine.value;
}
function SendFaccina(Messaggio){
	Messaggio.value = Messaggio.value + document.forms[0].SetFaccina.value;
}
