function Task_Variant_3(config)
{
	Task_Variant_3.superclass.constructor.call(this);
	
	this._baseElement = Rup.create("input");
	
	this._input = this._baseElement;
	
	this._baseElement.type = "text";
	this._baseElement.name = "text_variant";
	this._baseElement.className = "empty";
	this._baseElement.onkeyup = function (e) {
			if (this.value == '') 
				this.className = 'empty'; 
			else 
				this.className = 'notempty';
			};
	
	if( !config.size ) config.size = 1;
	
	this._baseElement.style.width = config.size + 'em';
	this._baseElement.maxLength = config.size;
	
}

Rup.extend(Task_Variant_3, Task_Variant_Abstract);

Task_Variant_3.prototype.setValue = function(value)
{
	value = value.split('~')[0];
	if (value == '‘' || value == '’') value = '\'';
	this._baseElement.value = this._removeSpecChars(value);
	if (this._baseElement.value == '')
		this._baseElement.className = "empty";
	else
		this._baseElement.className = "notempty";
}

Task_Variant_3.prototype.getValue = function()
{
	var val = this._baseElement.value;
	if (val == '') val = '^';
	else if (val == ' ') val = '_';
	else val = val.replace(/[’|‘]/gi, '\'');
	return val;
}

Task_Variant_3.prototype._removeSpecChars = function(txt)
{
	if (txt == '^') txt = '';
	else if (txt == '_') txt = ' ';
	else if (txt == '‘' || txt == '’') txt = '\'';
	return txt;
}

Task_Variant_3.prototype.setDisabled = function()
{
	this._baseElement.disabled = true;
}

Task_Variant_3.prototype.setHandler = function(handler, scope, num)
{
	this._baseElement.onblur = function(){ handler.call(scope, num);};
}

Task_Variant_3.prototype.compareAnswer = function(rans)
{
	var ranswers = rans.split('~');
	this.correct = false;
	for (var i = 0; i < ranswers.length; i++)
	{
		if (ranswers[i] == '‘' || ranswers[i] == '’') ranswers[i] = '\'';
		if (ranswers[i] == this.getValue()) {this.correct = true; break;}
	}
	var newelem;
	if (this.correct)
	{
		newelem = Rup.create('span');
		newelem.className = 'textcorrect';
		newelem.innerHTML = this._baseElement.value;
	}
	else
	{
		newelem = Rup.create('span');
		newelem.innerHTML = '<span class="textmistake">' + this._baseElement.value + '</span><span class="redunderline"><span class="textcorrect">' + this._removeSpecChars(ranswers[0]) + '</span></span>';
	}
	this._baseElement.parentNode.replaceChild(newelem, this._baseElement);
	return this.correct;
}