var QuestionMultipleChoices = Class.create({
    ALPHA: 0,
    NUMERIC: 1,
    
    labelType: 0,
    
    choices: null,
    inputs: null,
    currentChoice: null,
    
    initialize: function(questionNb){
        this.questionNb = questionNb;

        this.choices = new Array();
        this.inputs = new Array();
    },
    
    addChoice: function(s){
        this.choices[this.choices.length] = s;
    },
    
    display : function(){
        var divLabel = null;
        var divText = null;
        var divInput = null;
        var divChoice = null;
        var form = null;

       // var oTable = null;
        var iColIndex = null;
        var oCurrRow = null;
        var oCurrCell = null;

        var iRowHeight = 22;
        var iTextCellPaddingLeft = 10;
        var iChoiceRowPaddingTop = 10;

        form = document.createElement('form');
        
        //alert(this.choices.length);

        oTable = document.createElement('table');
        oTable.width = '100%';
        
        for(i = 0;i < this.choices.length;i++){
            //label

            iColIndex = 0;
            oCurrRow = oTable.insertRow(i);
            oCurrCell = oCurrRow.insertCell(iColIndex);

            oCurrCell.height = iRowHeight;
            oCurrCell.style.paddingTop = iChoiceRowPaddingTop + 'px';
            oCurrCell.align = 'left';

            if(this.labelType == this.ALPHA)
                oCurrCell.innerHTML = getLetterLabel(i + 1).toUpperCase() + ')';
            else
                oCurrCell.innerHTML = (i + 1) + ')';

            iColIndex++;

            oCurrCell = oCurrRow.insertCell(iColIndex);

            this.inputs[i] = tcals_createElement('input','rdoQuestion');
            this.inputs[i].type = 'radio';
            oCurrCell.appendChild(this.inputs[i]);

            oCurrCell.height = iRowHeight;
            oCurrCell.style.paddingTop = iChoiceRowPaddingTop + 'px';
            oCurrCell.align = 'left';
            oCurrCell.style.paddingBottom = '3px';
            oCurrCell.style.paddingLeft = '8px';

            iColIndex++;


            oCurrCell = oCurrRow.insertCell(iColIndex);

            oCurrCell.width = '100%';
            oCurrCell.height = iRowHeight;
            oCurrCell.style.paddingTop = iChoiceRowPaddingTop + 'px';
            oCurrCell.align = 'left';

            oCurrCell.innerHTML = this.choices[i];

        }

        //main
        divChoice = document.createElement('div');
        divChoice.className = 'questionChoice';
        divChoice.appendChild(oTable);
            
        form.appendChild(divChoice);
        
        $('question').update(form);
    },

    save : function(){
        for(i = 0;i < this.inputs.length;i++){
            if (this.inputs[i].checked){
                this.currentChoice = i;
            }
        }
        
        return this.currentChoice;
    },
    
    isAnswered: function() {
        var toReturn = false;
    
        for(i = 0;i < this.inputs.length;i++){
            if (this.inputs[i].checked){
                toReturn = true;
            }
        }
        
        return toReturn;
    }
});
