function QuestionShortText(){
    this.sQuestionType = 'SHORT_TEXT';
    this.HORIZONTAL = 0;
    this.VERTICAL = 1;
    
    this.NONE = 0;
    this.LETTERS = 1;
    this.NUMBERS = 2;
    
    //System settings
    this.iMinCharWidth = 10;
    this.iMaxCharWidth = 50;
    this.oFieldValidator = null;
    this.iRowHeight = 30;
    this.iCellHPadding = 10;
    this.iSegmentPadding = 20;
    this.sLabelSuffix = ')&nbsp;&nbsp;';
    
    //Quiz settings
    this.oMaster = null;
    this.sServerSaveURL = '';
    this.bSaveParticipation = false;
    
    //User settings
    this.bDisplayBorder = true;
    this.sBorderColor = 'gray';
    this.iLabelType = this.NONE;
    this.iOrientation = this.HORIZONTAL;
    
    //Variables
    this.sQuestionText = '';
    this.sTitle = null;
    this.sImageFileName = null;
    this.oVideoInfo = null;
    this.sAudioFileName = null;
    this.iQuestionID = 0;
    this.sImgsToPreload = new Array();
    this.aChoices = new Array();
    this.condition = new Condition();
    this.sCommentTitle = null;
    this.sCommentText = '';
    
    //Mandatory functions
    this.display = function(oParentElement,iWidthAvail){
        this.oFieldValidator = new FieldValidator();
    
        //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'});
        var oChoiceTable = null;
        var oChoiceRow = null;
        var oChoiceCell = null;
        var sLabel = '';
        var iRowIndex = 0;
        oParentElement.appendChild(oTable);
        
        if(this.bDisplayBorder){ 
            oTable.style.borderTop = 'solid 1px ' + this.sBorderColor;
            oTable.style.borderRight = 'solid 1px ' + this.sBorderColor;
        }
        
        for(var i = 0;i < this.aChoices.length;i++){
            var oCurrRow = oTable.insertRow(iRowIndex);
            //Text
            var oCurrCell = oCurrRow.insertCell(0);
            if(this.bDisplayBorder){
                oCurrCell.style.borderLeft = 'solid 1px ' + this.sBorderColor;
                oCurrCell.style.borderBottom = 'solid 1px ' + this.sBorderColor;
            }
            oCurrCell.style.paddingLeft = this.iCellHPadding + 'px';
            if(this.iOrientation == this.VERTICAL) oCurrCell.width = iWidthAvail;
            oCurrCell.height = this.iRowHeight;
            oCurrCell.align = 'left';
            
            if(this.iLabelType != this.NONE){
                if(this.iLabelType == this.LETTERS){
                    sLabel = ns_getLetter(i + 1) + this.sLabelSuffix;
                }else if(this.iLabelType == this.NUMBERS){
                    sLabel = (i + 1) + this.sLabelSuffix;
                }
                
                oChoiceTable = ns_buildHTMLElement('table',{cellpadding:'0',cellspacing:'0',border:'0'});
                oChoiceRow = oChoiceTable.insertRow(0);
                oChoiceCell = oChoiceRow.insertCell(0);
                oChoiceCell.vAlign = 'top';
                oChoiceCell.width = '25';                
                oChoiceCell.innerHTML = sLabel;
                
                
                oChoiceRow.insertCell(1).innerHTML = this.aChoices[i].sText;
                
                oCurrCell.appendChild(oChoiceTable);
            }else{
                oCurrCell.innerHTML = this.aChoices[i].sText;
            }
            delete oCurrCell;
            
            //Input
            if(this.iOrientation == this.HORIZONTAL){
                oCurrCell = oCurrRow.insertCell(1);
            }else{
                iRowIndex++;
                oCurrRow = oTable.insertRow(iRowIndex);
                oCurrCell = oCurrRow.insertCell(0);
            }
            
            if(this.bDisplayBorder){
                if(this.iOrientation == this.VERTICAL){
                    oCurrCell.style.borderLeft = 'solid 1px ' + this.sBorderColor;
                }
                oCurrCell.style.borderBottom = 'solid 1px ' + this.sBorderColor;
            }
            oCurrCell.style.paddingLeft = this.iCellHPadding + 'px';
            oCurrCell.style.paddingRight = this.iCellHPadding + 'px';
            
            oCurrCell.height = this.iRowHeight;
            
            var iInputSize = Math.min(Math.max(this.iMinCharWidth,this.aChoices[i].iNbMaxChar),this.iMaxCharWidth);
            this.aChoices[i].oInput = ns_buildHTMLElement('input',{id:'txt_' + this.iQuestionID + '_' + i,type:'text',size:iInputSize,maxlength:this.aChoices[i].iNbMaxChar,value:this.aChoices[i].sCurrText});
            oCurrCell.appendChild(this.aChoices[i].oInput);
            
            if(this.aChoices[i].bNumericOnly){
                this.oFieldValidator.addValidation(this.aChoices[i].oInput, eInputRule.Float, null,null);
            }
            
            iRowIndex++;
        }
        
        oParentElement.appendChild(this.oMaster.buildCommentLayout(this));
    }
    
    this.save = function(){
        for(var i = 0;i < this.aChoices.length;i++){
            this.aChoices[i].sCurrText = this.aChoices[i].oInput.value;
            
            if(this.bSaveParticipation){
                this.oMaster.saveParticipation(this.iQuestionID,i,this.aChoices[i].oInput.value);
            }
        }
        
        //Comment
        if(this.sCommentTitle){
            this.sCommentText = $(this.oMaster.sTxtCommentPrefix + this.iQuestionID).value;
        }
    }
    
    this.submit = function(){
        var value = null;
    
        if(this.bSaveParticipation){
            for(var i = 0;i < this.aChoices.length;i++){
                value = (this.aChoices[i].oInput ? this.aChoices[i].oInput.value : null);
            
                this.oMaster.saveParticipation(this.iQuestionID,i,value);
            }
            
            //Comment
            if(this.sCommentTitle){
                this.oMaster.saveComment(this.iQuestionID,this.sCommentText);
            }
        }
    }
    
    this.isAnswered = function() {
        for(var i = 0;i < this.aChoices.length;i++){
            if(!this.aChoices[i].oInput || this.aChoices[i].oInput.value.length == 0)
                return false;
        }
        
        return true;
    }
    
    this.hide = function(){
        delete this.oFieldValidator;
        this.oFieldValidator = null;
    }
    
    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(sText,iNbMaxChar,bNumericOnly){
        var oNewChoice = {sText:'', iNbMaxChar:0, bNumericOnly:false, sCurrText:'', oInput:null};
        
        oNewChoice.sText = sText;
        oNewChoice.iNbMaxChar = iNbMaxChar;
        oNewChoice.bNumericOnly = bNumericOnly;
        
        this.aChoices[this.aChoices.length] = oNewChoice;
    }
    this.setOrientation = function(i){
        this.iOrientation = i;
    }
}
