/*
 * Copyright (C) 1995-2011 by 4system Polska Sp. z o.o.
 * All Rights Reserved. v4
 */

componentFillTextBottom = function(name) {
	this.__componentText = __componentText;
	this.__componentText(name);
	
	this.passed = false;
	this.basketsCount = 0;
	this.componentX = 0;
	this.componentY = 0;	
	
	this.corrSeqArr = new Array();
	this.userSeqArr = new Array();	
	this.elementsUsed = new Array();
	this.elementsByText = new Array();
	this.elementsCorrect = new Array();	
	
	this.compAudio = null;	
	this.dropAudioComp = null;
	
	this.interactions = true;
	this.interactionsType = "matching";		
};

componentFillTextBottom.prototype = new __componentText;
componentFillTextBottom.prototype.type = "componentFillTextBottom";

componentFillTextBottom.prototype.onBaseCreate = function(obj) {
	this.captureMouseEvents();
};

componentFillTextBottom.prototype.componentFillTextBottomBaseOnCreate = componentFillTextBottom.prototype.onCreate;
componentFillTextBottom.prototype.onCreate = function(obj) {
	this.componentFillTextBottomBaseOnCreate();
	
	if ( PageInterface.GetValue("state") != psDesigning && lms && this.disableOnlineOfflineMix != false ) 
	{
		this.resourcesStatus 	= lms.resourcesStatus();
		this.resourcesURL 		= lms.resourcesURL();
	} else this.resourcesURL = resourcesURL;
	
	var sizeDiv = '<span id="'+this.id+'sizeDiv" style="visibility: hidden; position: absolute; font-family:' + this.font.family
	+ '; font-size:' + getFontSize(this.font.size, "px") + ';"></span>';
	
	var ob = document.getElementById(this.id);
	ob.innerHTML += sizeDiv;

	var width = 0;
	var height = 0;
	var tempX = this.x+this.borderWidth+1;
	var tempY = this.y + this.h - 1;
	var tempWidth = 0;
	var onlyText = '';
	
	this.texts = new Array();

	var match = this.text.match(/\{[^\{]+\}/gi);
	var badElem = this.text.match(/\[[^\[]+\]/gi);	
	
	this.basketsCount = match.length;
	this.dynamicWidth = false;
	this.maxWidth = 0;
	
	if (this.enableFlashPlayer) {
		var e = new componentFlashAudioPlayer;
		e.myParent = this;
		e.id = this.id + 'Audio';
		e.step = -1;
		e.src = this.flashAudioPlayerSrc;
		e.x = 0;
		e.y = 0;
		e.w = 1;
		e.h = 1;
		e.loop = false;
		e.flashVars = "";
		this.compAudio = page.addChild(e);
		
		var e = new componentFlashAudioPlayer;
		e.myParent = this;
		e.id = this.id + 'dropAudioComp';
		e.step = -1;
		e.src = this.flashAudioPlayerSrc;
		e.x = 0;
		e.y = 0;
		e.w = 1;
		e.h = 1;
		e.loop = false;
		e.flashVars = "";
		this.dropAudioComp = page.addChild(e);
	} else {
		var audioElement = new componentAudio;
		audioElement.myParent = this;
		audioElement.id = this.id+'Audio'; 
		audioElement.src = this.src;
		audioElement.pvWMP64 = false;
		audioElement.pvWMP7up = false;
		audioElement.step = -1;
		audioElement.editorPaint = this.editorPaint;
		this.compAudio = page.addChild(audioElement);
		
		var audioElement = new componentAudio;
		audioElement.myParent = this;
		audioElement.id = this.id+'dropAudioComp'; 
		audioElement.src = this.audioDrop;
		audioElement.pvWMP64 = false;
		audioElement.pvWMP7up = false;
		audioElement.step = -1;
		audioElement.editorPaint = this.editorPaint;
		this.dropAudioComp = page.addChild(audioElement);	
	}
	
	var allBaskets = match;
	if (badElem){
		allBaskets = match.concat(badElem);
	}
	var obj = null;	
	
	if (!this.dynamicWidth) 
	{
		for (var i=0; i<allBaskets.length; i++) {
			// Czysty tekst bez nawiasow
			onlyText = allBaskets[i].substr(1,allBaskets[i].length-2);
			
			// tymczasowy element do ustalania szerokosci i wysokosci ddelementow
			var sizeDiv = document.getElementById(this.id+"sizeDiv");
			if (sizeDiv) {
				sizeDiv.innerHTML = onlyText;
				width = sizeDiv.offsetWidth;
			}
			if ( width > this.maxWidth ) this.maxWidth = width;
		}
		width = this.maxWidth + this.elementPadding;
	}
	
	var baskets = this.text;
	var lastTopX = tempX;
	var lastBottomX = tempX;
	var pos = [0, 0];
	var elemIndex = 0;	
	
	for (var i=0; i<this.basketsCount; i++) {
		// Czysty tekst bez nawiasow
		var ddeText = match[i].substr(1,match[i].length-2);
		onlyText = this.getTextOnly(ddeText);
		
		// tymczasowy element do ustalania szerokosci i wysokosci ddelementow
		if (document.getElementById(this.id+"sizeDiv")) {
			document.getElementById(this.id+"sizeDiv").innerHTML = ddeText;
			height = document.getElementById(this.id+"sizeDiv").offsetHeight;// + this.elementPadding;
			if (this.dynamicWidth) width = document.getElementById(this.id+"sizeDiv").offsetWidth;
		};
		
		if (this.basketBorderColor == 'transparent'){
			var borderStyle = '0px';
		}else{
			var borderStyle = '1px solid '+this.basketBorderColor;
		};
		var ddeText = match[i].substr(1,match[i].length-2);		
		
		baskets = baskets.replace(match[i], "<textarea name='"+this.id+"_"+onlyText+"' id='_"+this.id+"_"+i+"_basket' style='background: "+this.basketBgColor+"; border: "+borderStyle+"; width: " + eval(width+this.elementPadding) + "px; height: " + eval(height+2)+ "px; margin: 0px; padding-right: "+eval(width)+"px; overflow: hidden;' disabled></textarea>");
		
		pos = this.getElemXY(i != 0, tempX, tempY, tempWidth, width, height);		
		tempX = pos[0];
		tempY = pos[1];
		
		this.createDDEElement(elemIndex, ddeText, tempX, tempY, width, height, false, onlyText);
		tempWidth = width;
		elemIndex++;		
		this.corrSeqArr.push(onlyText);
		
		this.setElementIntoArray(onlyText, elemIndex);		
	};
	
	if (badElem){	
		for (var i=0; i<badElem.length; i++) {
			var ddeText = badElem[i].substr(1,badElem[i].length-2);
			var onlyText = this.getTextOnly(ddeText);
		
			baskets = baskets.replace(badElem[i], "");
		
			pos = this.getElemXY(true, tempX, tempY, tempWidth, width, height);		
			tempX = pos[0];
			tempY = pos[1];
			
			this.createDDEElement(elemIndex, ddeText, tempX, tempY, width, height, true, onlyText);	
			tempWidth = width;
			elemIndex++;
		}		
	}		
	
	this.valign = 'bottom';
	
	this.text = baskets;
	if (PageInterface.GetValue("state") != psDesigning) this.randomDDElements();	
	
	this.componentX = this.x;
	this.componentY = this.y;
};
		
componentFillTextBottom.prototype.getTextOnly = function(text) 
{
	var onlyText = text.replace(/'/ig, '');
	onlyText = onlyText.replace(/"/ig, '');
	onlyText = onlyText.replace(/ /ig, '');
	
	return onlyText;
}

componentFillTextBottom.prototype.getElemXY = function(firstElem, tempX, tempY, tempWidth, width, height) 
{
	if (firstElem){	
		if ( (tempX + tempWidth + width + 2) >  (this.x + this.w) ) {
			tempX = this.x + this.borderWidth + 1;
			tempY += height + 8;//+ (this.elementPadding-3);
		}else {
			//tempY = this.y + 2 + this.borderWidth;
			tempX += tempWidth + 8 + (this.elementPadding-3);
		}
	}else{ 
		tempY = this.y + 2 + this.borderWidth;//+ (this.elementPadding-3);
		tempX += tempWidth + this.borderWidth;
	};
		
	return [tempX, tempY];
}

componentFillTextBottom.prototype.createDDEElement = function(elemIndex, ddeText, tempX, tempY, width, height, solved, onlyText) 
{
	var textTemp = new __componentText;
	textTemp.parentText = this; 
	textTemp.id = this.id+'_DDE_'+elemIndex; 
	textTemp.text = ddeText;// match[i].substr(1,match[i].length-2);
	textTemp.x = tempX;
	textTemp.y = tempY;
	textTemp.x_backup = tempX;
	textTemp.y_backup = tempY;
	textTemp.startX = tempX;
	textTemp.startY = tempY;
	if (!this.dynamicWidth) {
		textTemp.w = width+this.elementPadding;
		textTemp.h = height+2;//+this.elementPadding;
	};
	textTemp.canDragging = true;
	textTemp.borderWidth = 1;
	textTemp.borderColor = this.elementBorderColor;
	textTemp.padding = 0;
	textTemp.bgColor = this.elementBckColor;
	textTemp.step = 0;
	textTemp.align = "center";
	textTemp.valign = 'middle';
	textTemp.font.family = this.font.family;
	textTemp.font.size = this.font.size;
	textTemp.font.color = this.elementTextColor;
	textTemp.onCreate = this.onCreateText;
	textTemp.beginDrag = this.beginDragText;
	textTemp.endDrag = this.endDragText;
	textTemp.onMove = this.mouseMoveText;
	//textTemp.hide = this.__hide;
	textTemp.basketsCount = this.basketsCount; 
	textTemp.destinationBasketId = "_"+this.id+"_"+elemIndex+"_basket";
	textTemp.basketName = this.id+"_"+onlyText;
	textTemp.onlyText = onlyText;	
	textTemp.solved = solved;
	textTemp.orgZ = textTemp.z = this.z+elemIndex;
	textTemp.insideBasketId = "";
	textTemp.cursor = this.ddelementCursor;
	textTemp.baseOnPaint = textTemp.onPaint;
	textTemp.onPaint = this._onPaint;				
	
	tempWidth = width;
	page.addChild(textTemp);
	this.texts.push( textTemp );	
	
	var onlyText = this.getTextOnly(textTemp.text);
	
	this.setAllElementIntoArray(onlyText, elemIndex)	
}

componentFillTextBottom.prototype.setAllElementIntoArray = function(elemText, objID) 
{
	if (!this.elementsByText[elemText]){
		this.elementsByText[elemText] = new Array();
	}
	this.elementsByText[elemText].push(objID);		
};

componentFillTextBottom.prototype.setElementIntoArray = function(elemText, objID) 
{
	if (!this.elementsCorrect[elemText]){
		this.elementsCorrect[elemText] = new Array();
	}
	this.elementsCorrect[elemText].push(objID);		
};

componentFillTextBottom.prototype.__hide = function() 
{
	return;
}

componentFillTextBottom.prototype.onCreateText = function(text) 
{
	this.captureMouseEvents();
};

componentFillTextBottom.prototype._onPaint = function() 
{
	if (this.locked) {
		if (this.solved) {
			this.setBgColor(this.parentText.elementCorrectBckColor);
		}else { 
			this.setBgColor(this.parentText.elementInCorrectBckColor);
		}
		return;
	}
	this.baseOnPaint();
}

componentFillTextBottom.prototype.onLoad = function() {
}

componentFillTextBottom.prototype.editorPaint = function()
{
	return '';
}
	
componentFillTextBottom.prototype.componentFillTextBottomBaseOnPaint = componentFillTextBottom.prototype.onPaint;
componentFillTextBottom.prototype.onPaint = function() 
{
	if (this.locked) return;

	this.componentFillTextBottomBaseOnPaint();
	
	var newX = this.componentX - this.x;
	var newY = this.componentY - this.y; 
	// var newX = 0;
	// var newY = 0;
	
	
	this.componentX = this.x;
	this.componentY = this.y;
	
	for (var i=0; i<this.texts.length; i++) {
		this.texts[i].x = this.texts[i].x_backup;
		this.texts[i].y = this.texts[i].y_backup;
		this.texts[i].startX = this.texts[i].x_backup;
		this.texts[i].startY = this.texts[i].y_backup;
		
		this.texts[i].insideBasketId = '';
		this.texts[i].solved = false;
		
		this.texts[i].startX -= newX;
		this.texts[i].startY -= newY;
		
		this.texts[i].x -= newX;
		this.texts[i].y -= newY;
		
		this.texts[i].setX(this.texts[i].x);
		this.texts[i].setY(this.texts[i].y);	
		
		this.texts[i].setBorder(this.elementBorderColor, 1);
		this.texts[i].setBgColor(this.elementBckColor);			
	};
}

componentFillTextBottom.prototype.onShow = function() {
	for (var i=0; i < this.texts.length; i++) {
		this.texts[i].show();
	}
}

componentFillTextBottom.prototype.findPosX = function (obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

componentFillTextBottom.prototype.findPosY = function(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

componentFillTextBottom.prototype.mouseMoveText = function(e) {
};

componentFillTextBottom.prototype.get_random = function(from, to) {
    var ranNum = Math.floor( Math.random() * (to-from+1) ) + from;
    return ranNum;
}

componentFillTextBottom.prototype.randomDDElements = function() {
	var indexes = new Array();
	var sizes = new Array();
	//for (var i=0; i<this.basketsCount; i++) {
	for (var i=0; i<this.texts.length; i++) { //pg2
		indexes.push(i);
		sizes.push( 
			{ 
				x: this.texts[i].x, 
				y: this.texts[i].y,
				x_backup: this.texts[i].x_backup,
				y_backup: this.texts[i].y_backup				
			}
		);
	}
	var randomIndexes = new Array();
	while( indexes.length != 0 ) {
		randomIndexes.push( indexes.splice( this.get_random(0, indexes.length-1),1 ) );
	};
	//for (var i=0; i<this.basketsCount; i++) {
	for (var i=0; i<this.texts.length; i++) { //pg2
		this.texts[i].x = sizes[ randomIndexes[i] ].x;
		this.texts[i].y = sizes[ randomIndexes[i] ].y;
		this.texts[i].x_backup = sizes[ randomIndexes[i] ].x_backup;
		this.texts[i].y_backup = sizes[ randomIndexes[i] ].y_backup;

		this.texts[i].startX = this.texts[i].x;
		this.texts[i].startY = this.texts[i].y;
		this.texts[i].startY = this.texts[i].x_backup;
		this.texts[i].startY = this.texts[i].y_backup;
	};
};

componentFillTextBottom.prototype.playDropAudio = function(audioFile) 
{
	if (this.enableFlashPlayer) {
		this.dropAudioComp.flashVars = "playIdx=0&autoStart=true&playOnce=true";
		this.dropAudioComp.show();
	} else {
		this.dropAudioComp.actionMediaPlay();
	}
};	

componentFillTextBottom.prototype.beginDragText = function() {
	/**
	var obj = document.getElementById(this.destinationBasketId);
	obj.style.borderColor = "red";
	*/
	this.setZIndex(1000);
};

componentFillTextBottom.prototype.endDragText = function(e)
{
	this.setZIndex(this.orgZ);
	//pg2
	var bckI = -1;
	var bckUserSeqArr = "";
	
	var ddbasket = document.getElementById(this.destinationBasketId);
	var ddelement = document.getElementById(this.id);
	/** ddbasket.style.borderColor = "black"; */
	
	this.parentText.playDropAudio();
	
	var middlePoint = { 
		x: (ddelement.offsetLeft + ddelement.offsetWidth/2), 
		y: (ddelement.offsetTop + ddelement.offsetHeight/2)
	};
	
	for (var i=0; i < this.basketsCount; i++){
		var ddbasket = document.getElementById("_"+this.parentText.id+"_"+i+"_basket");
		
		var left = this.parentText.findPosX(ddbasket);
		var right = this.parentText.findPosX(ddbasket) + ddbasket.offsetWidth;
		var top = this.parentText.findPosY(ddbasket);
		var bottom = this.parentText.findPosY(ddbasket) + ddbasket.offsetHeight;
		
		if ( middlePoint.x > left && middlePoint.x < right && middlePoint.y > top && middlePoint.y < bottom ) {
			this.inArea = ddbasket;
			//pg2
			bckI = i;
			bckUserSeqArr = this.parentText.userSeqArr[i];
			
			this.parentText.userSeqArr[i] = this.parentText.getTextOnly(this.text);
			break;
		}else this.inArea = false; 
	};
	
	if (this.inArea && !this.parentText.checkIsFilled(this, this.inArea.id)){
		this.parentText.setIntoBasket(this, ddelement, this.inArea)
	}else {
		this.parentText.moveToStart(this, ddelement);
		if (bckI > -1) { //pg2
			try {
				this.parentText.userSeqArr[bckI] = bckUserSeqArr;
			} catch(e) {};
		}
	};
};

componentFillTextBottom.prototype.moveToStart = function(obj, elem) 
{
	if (obj.parentText.showAnswerIndicatorAnyTime){
		obj.setBorder(obj.parentText.elementBorderColor, 1);
		obj.setBgColor(obj.parentText.elementBckColor);			
	};
	
	obj.solved = (obj.basketName == "")?true:false;
	
	obj.x = obj.startX;
	obj.y = obj.startY;
	obj.insideBasketId = '';
	elem.style.left = obj.startX;
	elem.style.top = obj.startY;
};

componentFillTextBottom.prototype.setIntoBasket = function(sender, dde, obj) 
{
	var x = sender.parentText.findPosX(obj)+sender.parentText.borderWidth;
	var y = sender.parentText.findPosY(obj)+sender.parentText.borderWidth;

	dde.style.left = x;
	dde.style.top = y;
	
	sender.x = x;
	sender.y = y;
	sender.insideBasketId = obj.id;
	sender.insideBasketName = obj.name.replace(this.id+"_", "");
	//sender.solved = (obj.name == sender.text);
	//sender.solved = (obj.id == sender.destinationBasketId);
	sender.solved = (obj.name == sender.basketName);
};

componentFillTextBottom.prototype.checkIsFilled = function(obj, destBasket) 
{
	//for (var i=0; i < this.basketsCount; i++) {
	for (var i=0; i<this.texts.length; i++) { //pg2
		if (this.texts[i].id != obj.id && this.texts[i].insideBasketId == destBasket){
			if (this.replaceElements){
				this.moveToStart(this.texts[i], this.texts[i]);	
				return false;
			}else{
				this.moveToStart(obj, obj);	
				return true;
			}
		}
	}	
	return false;
};

componentFillTextBottom.prototype.onRepaint = function() 
{
	if (PageInterface.GetValue("allowCAI") && this.showCorrectAnswerIndicator) 
	{
		for (var i=0; i < this.texts.length; i++) {
			if (!this.texts[i].solved) {
				if (this.showCorrectAnswerIndicator == true) {
					this.texts[i].setBorder(this.elementInCorrectBorderColor, 1);
					this.texts[i].setBgColor(this.elementInCorrectBckColor);						
				}
			}
			else if (this.showCorrectAnswerIndicator == true) { 
				this.texts[i].setBorder(this.elementCorrectBorderColor, 1);
				this.texts[i].setBgColor(this.elementCorrectBckColor);				
			}
		}
	}
}

componentFillTextBottom.prototype.getAnswer = function(obj)
{
	var result = '';
	var sep = '';
	for (var i=0; i < this.texts.length; i++) {
		if (result != '') sep = '[,]';
		result += sep + this.texts[i].insideBasketId +'[.]'+this.texts[i].id; 
	}
	return(result);
};

componentFillTextBottom.prototype.setAnswer = function(valStr, showCorrect)
{
	if ((typeof(valStr) == 'undefined' || valStr == '') && !showCorrect) return;
	if (valStr == '' && (typeof(showCorrect) == 'undefined' || showCorrect.toString() == '')) showCorrect = true;
	
	if (valStr != '' && !showCorrect){
		var splited = valStr.split('[,]');
		for (var i=0; i < splited.length; i++){
			var elem = splited[i].split('[.]');
			var ddbasket = document.getElementById(elem[0]);
			var ddelement = document.getElementById(elem[1]);
			var j=-1;
			do{
				j++;
			}while (this.texts[j].id != elem[1] && j < this.texts.length)
			
			if (ddbasket) this.setIntoBasket(this.texts[j], ddelement, ddbasket);		
		};
		var correct = this.checkSequence();		
		if (correct){
			this.setAllCorrect();
		};
	}else{
		for (var i=0; i<this.texts.length; i++) { //pg2
			this.moveToStart(this.texts[i], this.texts[i]);
		}
		for (var i=0; i < this.basketsCount; i++) {
			var ddelement = document.getElementById(this.texts[i].id);
			var ddbasket = document.getElementById(this.texts[i].destinationBasketId);
			
			if (ddbasket && ddelement){			
				this.setIntoBasket(this.texts[i], ddelement, ddbasket);
				this.userSeqArr[i] = this.texts[i].text;
			}
		};
	};
	this.onRepaint();	
};

componentFillTextBottom.prototype.getUsedElements = function()
{
	for (var i=0; i < this.userSeqArr.length; i++)
	{
		if (!this.elementsUsed[this.userSeqArr[i]]){
			this.elementsUsed[this.userSeqArr[i]] = new Array();
		};
		this.elementsUsed[this.userSeqArr[i]].push('used');
	};
}

componentFillTextBottom.prototype.componentFillTextBottomBaseResetElement = componentFillTextBottom.prototype.resetElement;
componentFillTextBottom.prototype.resetElement = function() 
{
	this.componentFillTextBottomBaseResetElement();
	
	this.userSeqArr = [];
	this.elementsUsed = [];	
}

componentFillTextBottom.prototype.checkAnswer = function() 
{
	this.getUsedElements();
	
	return(this.parseCheckAnswer(this));
};

componentFillTextBottom.prototype.checkSequence = function()
{
	var result = true;
	for (var i=0; i < this.corrSeqArr.length; i++) {
		if (this.corrSeqArr[i] != this.userSeqArr[i])
		{
			result = false;
			break;
		};
	};
	return result;
}

componentFillTextBottom.prototype.setAllCorrect = function()
{
		for (var i=0; i < this.texts.length; i++) 
		{
			this.texts[i].solved = true;
		};
}

componentFillTextBottom.prototype.parseCheckAnswer = function(index)
{
	var correct = this.checkSequence();
	
	if (correct){
		this.setAllCorrect();
	}else{
		if (this.notCorrectOutBasketWrong){
			this.setAllOutBasketsWrong();			
	}else{
		this.setSolveToElements();
		}
	};

	for (var i=0; i < this.texts.length; i++) {
		if (!this.texts[i].solved) {
			if (this.returnWhenIncorrect && page.countAnswers != 0){
				this.moveToStart(this.texts[i], this.texts[i]);	
			};
		};
		if (this.showAnswerIndicatorAnyTime && this.showCorrectAnswerIndicator){
			if (this.texts[i].solved){
				this.texts[i].setBorder(this.elementCorrectBorderColor, 1);
				this.texts[i].setBgColor(this.elementCorrectBckColor);
			}else{
				this.texts[i].setBorder(this.elementInCorrectBorderColor, 1);
				this.texts[i].setBgColor(this.elementInCorrectBckColor);
			};
		};		
	}
	return correct;
};

componentFillTextBottom.prototype.setAllOutBasketsWrong = function() 
{
	for (var i=0; i < this.texts.length; i++) 
	{
		if (this.texts[i].insideBasketId == ""){
			this.texts[i].solved = false;
		}
};
}

componentFillTextBottom.prototype.setSolveToElements = function() 
{
	for (var k in this.elementsCorrect)
	{		
		if (this.elementsUsed[k]){
			if (this.elementsCorrect[k].length == this.elementsUsed[k].length)
			{
				if (this.wereUsedInTheSamePlace(k))
				{
					for (var i=0; i < this.elementsByText[k].length; i++)
					{	
						this.texts[this.elementsByText[k][i]].solved = true;
					};
				}else{
					for (var i=0; i < this.elementsByText[k].length; i++)
					{	
						if (this.texts[this.elementsByText[k][i]].basketName == ""){
							this.texts[this.elementsByText[k][i]].solved = true;
						};
					};
				};
			};
		};
	};		
}

componentFillTextBottom.prototype.wereUsedInTheSamePlace = function(elemText) 
{
	var result = true;
	
	for (var i=0; i < this.corrSeqArr.length; i++) 
	{
		if (this.corrSeqArr[i] == elemText){
			if (this.corrSeqArr[i] != this.userSeqArr[i])
			{
				result = false;
				break;
			};		
		};
	};
	return result;
};

componentFillTextBottom.prototype.onLock = function() {
	for (var i=0; i < this.texts.length; i++) {
		this.texts[i].canDragging = false;
		this.texts[i].locked = true;
	}
};

componentFillTextBottom.prototype.onUnLock = function() {
	for (var i=0; i < this.texts.length; i++) {
		this.texts[i].canDragging = true;
		this.texts[i].locked = false;
	}
};

componentFillTextBottom.prototype.interactionsCorrectResponsesCount = function()
{
	return 1;
};

componentFillTextBottom.prototype.interactionsCorrectResponses = function(index)
{
	var result = '';
	var sep = '';
	for (var i=0; i < this.texts.length; i++) {
		if (result != '') sep = '[,]';
		result += sep + this.texts[i].destinationBasketId +'[.]'+this.texts[i].id 
	}
	return(result);
};

componentFillTextBottom.prototype.interactionsStudentResponse = function()
{
	return this.getAnswer();
};

componentFillTextBottom.prototype.interactionsCorrectResponsesAsText = function(index)
{
	var result = '';
	var sep = '';
	for (var i=0; i < this.basketsCount; i++) {
		if (result != '') sep = '[,]';
		result += sep + this.texts[i].onlyText+'[.]'+this.texts[i].text;
	}
	return(result);
};

componentFillTextBottom.prototype.interactionsStudentResponseAsText = function()
{
	var result = '';
	var sep = '';
	for (var i=0; i < this.texts.length; i++) {	
		if (result != '') sep = '[,]';
		result += sep + this.texts[i].insideBasketName+'[.]'+this.texts[i].text;
	}
	return(result);
};
