function QuestionMultipleAnswers(){
    this.sQuestionType = 'MULTIPLE_ANSWERS';
    this.TEXT = 0;
    this.IMAGE = 1;
    
    this.NONE = 0;
    this.LETTERS = 1;
    this.NUMBERS = 2;
    
    //System settings
    this.iInputCellWidth = 50;
    this.iRowHeight = 30;
    this.iTextCellPaddingLeft = 10;
    this.iChoiceRowPaddingTop = 10;
    this.sLabelSuffix = ')';
    this.iChoiceMaxHeight = 250;
    
    //Quiz settings
    this.oMaster = null;
    this.sServerSaveURL = '';
    this.bSaveParticipation = false;
    
    //User settings
    this.bDisplayBorder = false;
    this.sBorderColor = 'gray';
    this.iLabelType = this.NONE;
    
    //Variables
    this.sQuestionText = '';
    this.sTitle = null;
    this.sImageFileName = null;
    this.oVideoInfo = null;
    this.sAudioFileName = null;
    this.sChoices = new Array();
    this.oInputs = new Array();
    this.bCurrChoices = new Array();
    this.iDisplayOrder = new Array();
    this.sImgsToPreload = new Array();
    this.iQuestionID = 0;
    this.condition = new Condition();
    this.sCommentTitle = null;
    this.sCommentText = '';
    
    //Mandatory functions
    this.display = function(oParentElement,iWidthAvail){
        //Create p
        var oP = ns_buildHTMLElement('p',{style:'display:inline;'});
        oP.className = 'QuestionText';
        oP.innerHTML = this.sQuestionText;
        oParentElement.appendChild(oP);
        
        if(this.sQuestionText || this.sQuestionText.length > 0){
            oParentElement.appendChild(ns_buildHTMLElement('br',{}));
            oParentElement.appendChild(ns_buildHTMLElement('img',{src:'images/spacer.gif', width:'5', height:'19'}));
            oParentElement.appendChild(ns_buildHTMLElement('br',{}));
            oParentElement.appendChild(ns_buildHTMLElement('img',{src:'images/question_line.gif', width:iWidthAvail, height:'1'}));
            oParentElement.appendChild(ns_buildHTMLElement('br',{}));
            oParentElement.appendChild(ns_buildHTMLElement('img',{src:'images/spacer.gif', width:'5', height:'19'}));
            oParentElement.appendChild(ns_buildHTMLElement('br',{}));
        }
        
        //Create table
        var oTable = ns_buildHTMLElement('table',{cellpadding:'0',cellspacing:'0',border:'0'});
        oParentElement.appendChild(oTable);
        
        if(this.bDisplayBorder){ 
            oTable.style.borderTop = 'solid 1px ' + this.sBorderColor;
            oTable.style.borderRight = 'solid 1px ' + this.sBorderColor;
        }
        
        var iColIndex = null;
        var oCurrRow = null;
        var oCurrCell = null;
        var sLabel = null
        
        for(var i = 0;i < this.sChoices.length;i++){
            iColIndex = 0;
            oCurrRow = oTable.insertRow(i);
            
            //Label
            if(this.iLabelType != this.NONE){
                oCurrCell = oCurrRow.insertCell(iColIndex);
                if(this.bDisplayBorder){
                    oCurrCell.style.borderLeft = 'solid 1px ' + this.sBorderColor;
                    oCurrCell.style.borderBottom = 'solid 1px ' + this.sBorderColor;
                }
                oCurrCell.width = this.iInputCellWidth;
                oCurrCell.height = this.iRowHeight;
                oCurrCell.align = 'center';
                oCurrCell.style.paddingTop = this.iChoiceRowPaddingTop + 'px';
                if(this.iLabelType == this.LETTERS){
                    sLabel = ns_getLetter(i + 1);
                }else if(this.iLabelType == this.NUMBERS){
                    sLabel = (i + 1);
                }
                oCurrCell.innerHTML = sLabel + this.sLabelSuffix;
                iColIndex++;
            }
            
            //Input
            var oCurrCell = oCurrRow.insertCell(iColIndex);
            if(this.bDisplayBorder){
                oCurrCell.style.borderLeft = 'solid 1px ' + this.sBorderColor;
                oCurrCell.style.borderBottom = 'solid 1px ' + this.sBorderColor;
            }
            oCurrCell.width = this.iInputCellWidth;
            oCurrCell.height = this.iRowHeight;
            oCurrCell.align = 'center';
            oCurrCell.style.paddingTop = this.iChoiceRowPaddingTop + 'px';
            
            var sChecked = (this.bCurrChoices[this.iDisplayOrder[i]] ? 'checked' : null);
            this.oInputs[this.iDisplayOrder[i]] = ns_buildHTMLElement('input',{type:'checkbox',name:'rdo-' + this.iQuestionID,id:'rdo-' + this.iQuestionID + '-' + this.iDisplayOrder[i],value:this.iDisplayOrder[i],checked:sChecked});
            oCurrCell.appendChild(this.oInputs[this.iDisplayOrder[i]]);
            delete oCurrCell;
            
            iColIndex++;
            
            //Text
            oCurrCell = oCurrRow.insertCell(iColIndex);
            if(this.bDisplayBorder){
                oCurrCell.style.borderLeft = 'solid 1px ' + this.sBorderColor;
                oCurrCell.style.borderBottom = 'solid 1px ' + this.sBorderColor;
            }
            oCurrCell.style.paddingLeft = this.iTextCellPaddingLeft + 'px';
            oCurrCell.width = String(iWidthAvail - this.iInputCellWidth - this.iTextCellPaddingLeft);
            oCurrCell.height = this.iRowHeight;
            oCurrCell.style.paddingTop = this.iChoiceRowPaddingTop + 'px';
            
            if(this.sChoices[this.iDisplayOrder[i]][1] == this.TEXT){
                oCurrCell.innerHTML = this.sChoices[this.iDisplayOrder[i]][0];
            }else{
                oCurrCell.appendChild(ns_buildImageObject(this.sChoices[this.iDisplayOrder[i]][0],null,this.iChoiceMaxHeight,this.oMaster.sMediasFolder));
                
            }
        }
        
        oParentElement.appendChild(this.oMaster.buildCommentLayout(this));
    }
    
    this.save = function(){
        for(var i = 0;i < this.sChoices.length;i++){
            this.bCurrChoices[i] = fo(this.oInputs[i].id).checked;
        }
        
        //Comment
        if(this.sCommentTitle){
            this.sCommentText = $(this.oMaster.sTxtCommentPrefix + this.iQuestionID).value;
        }
    }
    
    this.submit = function(){
        if(this.bSaveParticipation){
            var sValue = '';
            for(var i = 0;i < this.bCurrChoices.length;i++){
                if(this.bCurrChoices[i]){
                    sValue += i + ',';
                }
            }
            if(sValue.length > 0){
                sValue = sValue.substr(0,sValue.length - 1);
            }
            this.oMaster.saveParticipation(this.iQuestionID,0,sValue);
            
            //Comment
            if(this.sCommentTitle){
                this.oMaster.saveComment(this.iQuestionID,this.sCommentText);
            }
        }
    }
    
    this.isAnswered = function() {
        for(var i = 0;i < this.bCurrChoices.length;i++){
            if(this.bCurrChoices[i])
                return true;
        }
        
        return false;
    }
    
    this.hide = function(){}
    
    this.setQuestionText = function(s){
        this.sQuestionText = s;
    }
    
    this.setTitle = function(s){
        this.sTitle = s;
    }
    this.setImage = function(s){
        this.sImageFileName = s;
        this.sImgsToPreload[this.sImgsToPreload.length] = s;
    }
    this.setLabelType = function(i){
        this.iLabelType = i;
    }
    this.setVideo = function(s,iWidth,iHeight){
        this.oVideoInfo = {sFileName:'',iWidth:0,iHeight:0};
        this.oVideoInfo.sFileName = s;
        this.oVideoInfo.iWidth = iWidth;
        this.oVideoInfo.iHeight = iHeight;   
    }
    this.setAudio = function(s){
        this.sAudioFileName = s;
    }
    //Question specific functions
    this.addChoice = function(sChoice,iChoiceType){
        this.sChoices[this.sChoices.length] = [sChoice, iChoiceType];
        if(iChoiceType == this.IMAGE){
            this.sImgsToPreload[this.sImgsToPreload.length] = sChoice;
        }
        this.bCurrChoices[this.bCurrChoices.length] = false;
        this.iDisplayOrder[this.iDisplayOrder.length] = this.iDisplayOrder.length;
    }
    this.shuffle = function(){
        this.iDisplayOrder = ns_getShuffledOrder(this.sChoices.length);
    }
}
