function FormSelectRow(element, warn) {
	if (!element) {
		this.fDiv = oEditor.FCK.EditorDocument.createElement( 'DIV' ) ;
		this.fDiv = oEditor.FCK.InsertElementAndGetIt( this.fDiv ) ;
		
		this.fSwitchDiv = oEditor.FCK.EditorDocument.createElement( 'DIV' ) ;
		this.fLabel = oEditor.FCK.EditorDocument.createElement( 'LABEL' );
		this.fSpan = oEditor.FCK.EditorDocument.createElement( 'SPAN' );
  		this.fSelect = oEditor.FCK.EditorDocument.createElement( 'SELECT' );
		this.ToolTipIMG     = oEditor.FCK.EditorDocument.createElement( 'IMG' );
		this.fCommentTextarea = oEditor.FCK.EditorDocument.createElement( 'TEXTAREA' ) ;
		
		this.fSpan.appendChild(this.fSelect);
		this.fDiv.appendChild(this.fSwitchDiv);
		SetAttribute(this.fSwitchDiv, "class", "commentSwitch");
		this.fDiv.appendChild(this.fLabel);
		this.fDiv.appendChild(this.fSpan);
		
		this.fDiv.appendChild(this.ToolTipIMG);
		SetAttribute(this.ToolTipIMG, "class", "tooltipimg");
		SetAttribute(this.ToolTipIMG, "src", "images/help.gif");
		SetAttribute(this.ToolTipIMG, "align", "top");
		
		this.fDiv.appendChild(this.fCommentTextarea);
		this.fCommentTextarea.className='comment';
		
		this.fDivCl = new ClassList("form formselect");
		
		SetAttribute(this.fLabel, "class", "controllCaption");
		
	} else {
		if (warn == undefined) warn = 0;
		this.fDiv = element;
		this.fLabel = this.fDiv.getElementsByTagName('label')[0];
		this.fSpan = this.fDiv.getElementsByTagName('span')[warn];
		this.fSelect = this.fSpan.childNodes.item(0);
		this.fCommentTextarea = this.fDiv.getElementsByTagName('textarea')[0];
		
		this.fDivCl = new ClassList(DlgGetAttribute(this.fDiv, 'class'));
	}
	this.fDiv.contentEditable = false;
	
}

FormSelectRow.prototype.loadToDialog = function() {
	GetE('txtLabel').value      = this.fLabel.innerHTML;
	GetE('txtName').value       = DlgGetAttribute(this.fDiv, 'ID');
	GetE('txtLines').value      = DlgGetAttribute(this.fSelect, 'size');
	GetE('txtSelValue').value	= this.fSelect.value ;
    GetE('txtToolTip').value    = DlgGetAttribute(this.fDiv, 'title');

	if (DlgGetAttribute(this.fSelect, 'multiple')) {
		GetE('chkMultiple').checked = true;	
	}

	if (this.fDivCl.hasLabel('mandatory')) {
		GetE('txtMandatory').checked = true;
    GetE('txtLabel').value = GetE('txtLabel').value.replace(/<(strong|b).*/i,"");
	}
	
	// Reload all options.
	oListText	= document.getElementById( 'cmbText' ) ;
	oListValue	= document.getElementById( 'cmbValue' ) ;
	for ( var i = 0 ; i < this.fSelect.options.length ; i++ )
	{
        var sText	= this.fSelect.options[i].innerHTML ;
		var sValue	= this.fSelect.options[i].value ;

		AddComboOption( oListText, sText, sText ) ;
		AddComboOption( oListValue, sValue, sValue ) ;
	}
}

FormSelectRow.prototype.saveFromDialog = function(oDom) {

	this.fLabel.innerHTML = GetE('txtLabel').value;
	$('.kotelezo',this.fDivCl).remove();
	if (GetE('txtMandatory').checked) {
    this.fDivCl.addLabel('mandatory');
    var MandatorySign = oEditor.FCK.EditorDocument.createTextNode(' * ');
    var MandatorySignStrong = oEditor.FCK.EditorDocument.createElement( 'STRONG' );
    MandatorySignStrong.className = "kotelezo";
    MandatorySignStrong.appendChild(MandatorySign);
    this.fLabel.appendChild(MandatorySignStrong);
	} else {
		this.fDivCl.removeLabel('mandatory');
	}
	
	if (GetE('chkMultiple').checked) {
		SetAttribute( this.fSelect, 'multiple'	, 'multiple' ) ;
	} else {
		SetAttribute( this.fSelect, 'multiple'	, '' ) ;
	}

	var sSize = GetE('txtLines').value ;
    if ( sSize == null || isNaN( sSize ) || sSize <= 1 ) sSize = '' ;
    SetAttribute( this.fSelect, 'size'	, sSize ) ;

    // Remove all options.
    while ( this.fSelect.options.length > 0 )	this.fSelect.remove(0) ;
    
    oListText	= document.getElementById( 'cmbText' ) ;
	oListValue	= document.getElementById( 'cmbValue' ) ;
    // Add all available options.
    for ( var i = 0 ; i < oListText.options.length ; i++ )
    {
        var sText	= oListText.options[i].value ;
        var sValue	= oListValue.options[i].value ;
        if ( sValue.length == 0 ) sValue = sText ;

        var oOption = AddComboOption( this.fSelect, sText, sValue, oDOM ) ;

        if ( sValue == GetE('txtSelValue').value )
        {
            SetAttribute( oOption, 'selected', 'selected' ) ;
            oOption.selected = true ;
        }
    }

	this.fDiv.className = this.fDivCl.toString();
	SetAttribute( this.fDiv, 'ID', GetE('txtName').value) ;

    SetAttribute( this.fSelect, 'ID', GetE('txtName').value + '_select');
	SetAttribute( this.fSelect, 'name', GetE('txtName').value + '_select') ;
    SetAttribute( this.fDiv, 'title', GetE('txtToolTip').value) ;	

	SetAttribute( this.fCommentTextarea, 'ID', GetE('txtName').value + '_comment');
	SetAttribute( this.fCommentTextarea, 'name', GetE('txtName').value + '_comment');


	return true;
}

FormSelectRow.prototype.validate = function() {
	return !this.isEmpty();
}

FormSelectRow.prototype.isEmpty = function() {
	var el = this.fSelect;
    var sel = false;
	if (el.type == 'select-multiple') {
			for (var i=0; i<el.options.length; i++) {
				sel = sel || el.options[i].selected;
			}
	} else {
		sel = el.value != '-1' && el.value != '';
	}
	
	return !sel;
}