function QuestionDropDownChoices(){
    this.sQuestionType = 'DROP_DOWN_CHOICES';
    this.HORIZONTAL = 0;
    this.VERTICAL = 1;
    
    this.NONE = 0;
    this.LETTERS = 1;
    this.NUMBERS = 2;
    
    //System settings
    this.iRowHeight = 30;
    this.iCellHPadding = 10;
    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.aChoices = new Array();
    this.sChoicesText = new Array();
    this.oInputElements = new Array();
    this.iCurrChoiceID = 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'});
        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.sChoicesText[i];
                
                oCurrCell.appendChild(oChoiceTable);
            }else{
                oCurrCell.innerHTML = this.sChoicesText[i];
            }
            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;
            
            this.oInputElements[i] = this.buildDropDown({},this.aChoices[i],this.iCurrChoiceID[i],true); 
            oCurrCell.appendChild(this.oInputElements[i]);
            
            iRowIndex++;
        }
        oParentElement.appendChild(this.oMaster.buildCommentLayout(this));
    }
    
    this.save = function(){
        for(var i = 0;i < this.oInputElements.length;i++){
            this.iCurrChoiceID[i] = this.oInputElements[i][this.oInputElements[i].selectedIndex].value;
        }
        
        //Comment
        if(this.sCommentTitle){
            this.sCommentText = $(this.oMaster.sTxtCommentPrefix + this.iQuestionID).value;
        }
    }
    
    this.submit = function(){
        if(this.bSaveParticipation){
            for(var i = 0;i < this.iCurrChoiceID.length;i++){
                this.oMaster.saveParticipation(this.iQuestionID,i,this.iCurrChoiceID[i]);
            }
            
            //Comment
            if(this.sCommentTitle){
                this.oMaster.saveComment(this.iQuestionID,this.sCommentText);
            }
        }
    }
    
    this.isAnswered = function() {
        for(var i = 0;i < this.iCurrChoiceID.length;i++){
            if(this.iCurrChoiceID[i] == null || this.iCurrChoiceID[i] == 'null')
                return false;
        }
        
        return true;
    }
    
    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(sChoiceText, aChoices){
        this.sChoicesText[this.sChoicesText.length] = sChoiceText;
        this.aChoices[this.aChoices.length] = aChoices;
    }
    this.buildDropDown = function(aAtts,aContent,iSelectedID,bFirstEmpty){
        var oList = ns_buildHTMLElement('select',aAtts);
        var iCurrID = 0;
        
        if(bFirstEmpty){
            var oOpt = ns_buildHTMLElement('option',{value:'null',selected:null});
	        oList.appendChild(oOpt);
	    }
        
        for(var i = 0;i < aContent.length;i++){
            var sSelected = (iCurrID == iSelectedID ? 'selected' : null);
        
            var oOpt = ns_buildHTMLElement('option',{value:i,selected:sSelected});
		    oOpt.innerHTML = aContent[i];
    		
		    oList.appendChild(oOpt);
    		
		    iCurrID++;
        }
        
        return oList;
    }
    this.setOrientation = function(i){
        this.iOrientation = i;
    }
}
