function getComuni(provSelectName,comSelectName) {

    var provID = eval("document.forms['curriculum']."+provSelectName+".value");
    getComList(provID,comSelectName);
}

function removeAllOptions(selectbox)
{
    var i;
    for(i=selectbox.options.length-1;i>=0;i--) {
        selectbox.remove(i);
    }
}

function addOption(selectbox,text,value )
{
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    selectbox.options.add(optn);
}



function getComList(provID,selectName) {

    var handleSuccess = function(o){
        if(o.responseText !== undefined){
            var sel = eval("document.forms['curriculum']."+selectName);
            var lines = o.responseText.split("\n")
            var tokens
            removeAllOptions(sel);
            addOption(sel,'--','');
            for(var i=0; i<(lines.length-1); i++ ) {
                tokens = lines[i].split(' >> ');
                addOption(sel,tokens[1],tokens[0]);
            }
        }
    }

    var handleFailure = function(o){
        if(o.responseText !== undefined){
            alert('KO')
        }
    }

    var sUrl = "/curriculum/comuni.php?prov="+provID;
    YAHOO.util.Connect.asyncRequest('GET', sUrl, {
        success:handleSuccess,
        failure:handleFailure
        });
}


