function Task_Panel(stringTaskList, mode) // mode==0 - без кнопок, mode==1 - с кнопками "справка" и "подсказки"
{
	Task_Panel.superclass.constructor.call(this);
	var testCont = Rup.create('div');
	var workdv = Rup.get.id('workdv');
	workdv.appendChild(testCont);
	this._setContainerElement(testCont);
	//this._setContainerElement(Rup.get.id('workdv'));
	this._containerElement.innerHTML = '';
	this._containerElement.className = 'testcont';
	this._tasks = [];
	this.mode = mode || 0;
	
	var taskList = [];
	stringTaskList = stringTaskList.split(';');
	for (var i = 0; i < stringTaskList.length; i++)
	{
		var strTask = stringTaskList[i].split('_');
		if (strTask.length != 2) continue;
		var taskid = parseInt(strTask[0], 10);
		var taskType = parseInt(strTask[1], 10);
		if (isNaN(taskid) || isNaN(taskType)) continue;
		var oTask = this._getTask({id: taskid, type: taskType} /*taskList[i]*/);
		this._tasks.push( oTask );
		this.showTask(i);
	}
	this._buttonsDiv = Rup.create('div');
	this._buttonsDiv.className = 'testbuttons';
	workdv.appendChild(this._buttonsDiv);
	var instance = this;
	var answerButton = Rup.GetButton('Проверить', function(){
									instance.checkAnswers();
								});
	this._buttonsDiv.appendChild(answerButton);
}

Rup.extend(Task_Panel, Container_Element_Abstract);

/*Task_Panel.prototype.startTest = function()
{
	this.showButtons();
	
	for( var i = 0; i < this._links.length; i++ )
	{
		this._links[i].addHandler();
	}
	
	this.showTask(0);
	
	var startTime = (new Date()).getTime();
	
	testInfoInterval = window.setInterval(function(){
	
		var checkValue = function(value)
		{
			if( value < 10 )
			{
				value = "0" + value;
			}
			return value;
		}
	
		var now = (new Date()).getTime();
		
		time = new Date(now - startTime);
		
		var h = checkValue(time.getUTCHours());
		var m = checkValue(time.getUTCMinutes());
		var s = checkValue(time.getUTCSeconds());
		
		Rup.get.id("datetimeValue").innerHTML = h + ":" + m + ":" + s;
	
	}, 100);
}*/

/*Task_Panel.prototype.nextTask = function()
{
	if( this._currentTask == undefined )
	{
	   return;
	}
	
	if( !this.hasUnansweredLinks() )
	{
		return;
	}
	
	var oCurLink = this._links[ this._currentTask ];
	var oNewLink = oCurLink._nextLink;
	
	while( oNewLink._answered )
	{
		oNewLink = oNewLink._nextLink;
	}
	
	this.showTask(oNewLink._number);
	
}*/

/*Task_Panel.prototype.prevTask = function()
{
    if( this._currentTask == undefined )
    {
       return;
    }
    
    if( !this.hasUnansweredLinks() )
	{
		return;
	}

	var oCurLink = this._links[ this._currentTask ];
	var oNewLink = oCurLink._prevLink;
	
	while( oNewLink._answered )
	{
		oNewLink = oNewLink._prevLink;
	}
	
	this.showTask(oNewLink._number);

}*/

/*Task_Panel.prototype.hasUnansweredLinks = function()
{
	for( i = 0; i < this._links.length; i++ )
	{
		if( !this._links[i]._answered )
		{
			return true;
		}
	}
	return false;
}*/

/*Task_Panel.prototype.showButtons = function()
{
	var instance = this;
	
	var oPrevButton = Rup.GetImgButton({src: '/Images/backk.jpg',
	                handler: function(){
                                instance.prevTask();
                            },
                    alt: '<',
                    title: 'Предыдущее задание'//,
                    //cursor: 'pointer'
    });
        
    //var oNextButton = Rup.GetButton(" >> ", function(){
    //    instance.nextTask();
    //});
    
    var oNextButton = Rup.GetImgButton({src: '/Images/frwk.jpg',
	                handler: function(){
                                instance.nextTask();
                            },
                    alt: '>',
                    title: 'Следующее задание'//,
                    //cursor: 'pointer'
    });
        
    this._buttons.appendChild(oPrevButton);
    this._buttons.appendChild(oNextButton);
}

Task_Panel.prototype.hideButtons = function()
{
	this._buttons.innerHTML = '';
}*/

Task_Panel.prototype._getTask = function( task )
{
	switch( task.type )
	{
		case 1:
			return new Task_Module_1( task.id, this);
		break;
		case 2:
			return new Task_Module_2( task.id, this);
		break;
		case 3:
			return new Task_Module_3( task.id, this);
		break;
		case 4:
			return new Task_Module_4( task.id, this);
		break;
		case 7:
			return new Task_Module_7( task.id, this);
	}
}

Task_Panel.prototype.showTask = function( iNumber )
{
	/*if( this._currentTask != undefined )
	{
		var oPrevLink = this._links[ this._currentTask ];
		oPrevLink.setPrevClass();
	}
	*/
	var oTask = this._tasks[ iNumber ];
	/*
	var iModes = TASK_BUTTON_ANSWER;
	if( 1 < this.mode )
	{
		iModes |= TASK_BUTTON_HELP;
		iModes |= TASK_BUTTON_RIGHT;
	}*/
	oTask.load( /*iModes*/ );
	oTask.render(this, true);
	
	//this._links[ iNumber ].setCurrent();
	
	//this._currentTask = iNumber;
	
	//this.showStat();
}

Task_Panel.prototype.checkAnswers = function ()
{
	/*debugger;*/
	this._buttonsDiv.style.display = 'none';
	var sum = 0;
	for (var i = 0; i < this._tasks.length; i++)
	{
		sum += this._tasks[i].checkAnswer();
	}
	alert('Результат выполнения теста: ' + Math.round(sum/this._tasks.length) + '%')
}

/*Task_Panel.prototype.showStat = function(ignoreTestMode)
{
	var numbers = {
		all: 0,
		answered: 0,
		unanswered: 0,
		percent: 0
	};
	
	for( var i = 0; i < this._links.length; i++ )
	{
		numbers.all++;
		numbers.percent += parseInt(this._links[i].right) || 0;
		if( this._links[i]._answered )
		{
			numbers.answered++;
		}
		else
		{
			numbers.unanswered++;
		}
	}
	/**
	 * @see header.js 
	 */ /*
	testInfoValues[0].innerHTML = numbers.all;
	testInfoValues[1].innerHTML = numbers.answered;
	testInfoValues[2].innerHTML = numbers.unanswered;
	
	if( 2 <= this.mode || ignoreTestMode )
	{
		var allPercent = parseInt(numbers.percent / numbers.all) || 0;
		var realPercent = numbers.answered ? (parseInt(numbers.percent / numbers.answered) || 0) : 100;
//		testInfoValues[3].innerHTML = allPercent + " %";
		testInfoValues[3].innerHTML = allPercent;
		testInfoValues[3].className = "value " + StylesOfMastery.getStyleName(realPercent);
		if (ignoreTestMode)
		{
			testInfoValues[3].style.display = 'inline';
			testInfoValues[3].previousSibling.style.display = 'inline';
		}
	}
}*/

/*Task_Panel.prototype.showAnswer = function( respXml )
{
    var aAnswer = respXml.getElementsByTagName('answer');
    var aError = respXml.getElementsByTagName('error');
    
    iRight = undefined;
    if( aAnswer.length )
    {
    	iRight = aAnswer[0].getAttribute('right');
    }
    
    var oTask = this._tasks[ this._currentTask ];
    
    oTask.showButtons( oTask.buttons & (~TASK_BUTTON_ANSWER) & (~TASK_BUTTON_RIGHT) );
    
    if( this.mode < 2 )
    {
    	iRight = undefined;
    }
    
    this._links[ this._currentTask ].setAnswered(iRight);
	
	var lastTask = !this.hasUnansweredLinks();
	
	if (lastTask) 
	{
		var aResult = respXml.getElementsByTagName('result');
		if( aResult.length )
		{
			var oDiv = Rup.create('div');
			this._removeChildsSafe();
			
			var reshtml = '<table id="resulttable"><tr><th>№</th><th>Название задания</th><th>Результат</th></tr>';
			var resultnodes = aResult[0].childNodes;
			var j = 1;
			for (var i = 0; i < resultnodes.length; i++)
			{
				if (resultnodes[i].nodeType == _NodeTypes.ELEMENT_NODE & resultnodes[i].nodeName == 'task')
				{
					var res = resultnodes[i].getAttribute('result');
					var rans = resultnodes[i].getAttribute('answer');
					var par = resultnodes[i].getAttribute('params');
					reshtml += '<tr><td>' + (j) + '</td><td>' + resultnodes[i].getAttribute('task') + '<br /><span class="taskshort">' + resultnodes	[i].getAttribute('name') + '</span>' + '</td><td>' + res + '</td></tr>';
					this._links[j-1].right = res;
					this._links[j-1].setAnswered(res);
					if (this._tasks[j-1].compareAnswers) 
						this._tasks[j-1].compareAnswers(rans, par);
					j++;
				}
			}
			
			reshtml += '</table>';
			reshtml += expiredPostTestMsg;
			oDiv.innerHTML = reshtml;
			
			var btndiv = Rup.create('div');
			oDiv.appendChild(btndiv);
			btndiv.className = 'EduTaskButtons';
			btndiv.appendChild(Rup.GetButton("Перейти к курсу", initCourseView));
			
			this.appendChild(oDiv);
		}
	
		this.hideButtons();
		this._links[ this._currentTask ].setCurrent();
		if( testInfoInterval )
		{
			window.clearInterval(testInfoInterval);
		}
		this.showStat(lastTask);
	}
	else
	{
		this.showStat(lastTask);
		this.nextTask();
	}
}*/

Task_Panel.prototype.showError = function( errorXml )
{
    var oTitle = Rup.create('div');
    oTitle.className = 'EduTaskTitle';
    oTitle.innerHTML = errorXml.getAttribute('title');
    
    var oText = Rup.create('div');
    oText.className = 'EduTaskText';
    oText.innerHTML = errorXml.getAttribute('content');
    
    this._containerElement.appendChild(oTitle);
    this._containerElement.appendChild(oText);
}