
    var lastligneid=0;

    var blocid=0;
    var ligneid=0;
    var questid=0;
    function setid (id,whatid) {
        if (whatid == "bloc") {
            blocid=id ;
        }
        if (whatid == "ligne") {
            ligneid=id ;
        }
        if (whatid == "quest") {
            questid=id ;
        }
    }
    function getblocid (whatid) {
        if (whatid == "bloc") {
            return blocid;
        }
        if (whatid == "ligne") {
            return ligneid;
        }
        if (whatid == "quest") {
            return questid;
        }
    }


function fillBlocField ( idbloc,idquest,oldvalue)  {
    document.getElementById('oldblocid').value = idbloc;
    document.getElementById('addbloc').value = "modifier le titre de cet ensemble de questions";
    document.getElementById('newbloc').value = oldvalue;
    return false;

}


function addligne (idbloc,idquest,idligne) {
    setid(idbloc,'bloc');
    setid(idquest,'quest');
    setid(idligne,"ligne");
//    alert(blocid +  " "  + questid);
    var formbloc = document.getElementById('formline');
    var ici = document.getElementById('bloc' + idbloc);
    ici.innerHTML = formbloc.innerHTML;
    document.getElementById("bloc"+idbloc).style.display="block";
    document.getElementById('blocid').value=idbloc;
    document.getElementById('questid').value=idquest;
    if ( idligne ) {    
        document.getElementById('ligneid').value=idligne;
    }
}



function registreligne () {
    var url = '/newquest';
    var pars = "addligne=yes&blocid="+blocid+"&questid="+questid;
    var typeligne = document.getElementById('typeligne').value;
    var borderligne = document.getElementById('borderligne').value;
    var texteligne = document.getElementById('texteligne').value;
    escape(texteligne);
    var repligne = document.getElementById('reponseligne');
    var reponseligne = repligne.options[repligne.selectedIndex].value;
    escape(reponseligne);
    pars += "&typel="+typeligne+"&borderl="+borderligne+"&textel="+texteligne+"&reponsel="+reponseligne;
//    alert( pars );
    var pax = new Ajax.Request(
                    url,
                    {
                        method:'post',
                        parameters:pars,
                        onComplete:lignefaite
                    }
                );

}

function lignefaite (r) {
    var rs = r.responseText.split(':');
    lastligneid =  rs[1];
    
    document.getElementById("bloc"+blocid).style.display="none";
    document.getElementById('texteligne').value = '';
    document.getElementById('borderligne').value='';
    
}


function verifChamp ( ts, idchamp, genre ) {
    if (genre == "date" && ts.value.match(/AAAA/i)) {
        ts.value='';
        ts.style.background="white";
        ts.style.border="3px inset black";
    }
}

function initquest () {

}
