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

componentWordsSet = function(name) 
{
	this.__componentText = __componentText;
	this.__componentText(name);
	
	this.spaceBetween = 0;
	this.inArea = null;
	this.baskets = new Array();	
	this.collsNames = new Array();	
	this.texts = new Array();	
	this.groupsID = new Array();	
	this.maxRows = 0;
	this.dropAudioComp = null;
	
	this.interactions = true;
	this.interactionsType = "matching";		
};

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

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

componentWordsSet.prototype.onCreate = function(obj)
{
	if ( PageInterface.GetValue("state") != psDesigning && lms && this.disableOnlineOfflineMix != false ) 
	{
		this.resourcesStatus 	= lms.resourcesStatus();
		this.resourcesURL 		= lms.resourcesURL();
	} else this.resourcesURL = resourcesURL;

	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 = "";//"playIdx=0&autoStart=true";
		this.dropAudioComp = page.addChild(e);
	}else{
		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);		
		audioElement.allowNextStep = true;
	}
	
	var groupsArr = this.groupsName.split('|');
	var contentArr = this.content.split('||');
	
	this.spaceBetween = parseInt((this.w-6)/(groupsArr.length-1));
	
	var sizeDiv = '<div id="'+this.id+'sizeDiv" style="border: 2px solid #000000; visibility:hidden; left:0px; top:0px; position: absolute;"></div>';
	
	var ob = document.getElementById(this.id);
	ob.innerHTML += sizeDiv;	
	
	var ddelementHeight = 0;
	var ddelementWidth = 0;
	var beginTag = '';
	var endTag = '';
	
	if (this.titleBold) {
		beginTag = '<b>';
		endTag = '</b>';
	};	
	if (this.titleItalic) {
		beginTag += '<i>';
		endTag = '</i>' + endTag;
	};
	
	for(var i=0; i < contentArr.length; i++){
		var groupWord = contentArr[i].split('#!#');
		var span = document.getElementById(this.id+"sizeDiv");
		if (span) {
			span.innerHTML = beginTag+groupWord[1]+endTag;
			span.style.width = this.spaceBetween;
			span.style.fontFamily = this.fontFamily;
			span.style.fontWeight = (this.titleBold) ? "bold" : "normal";
			span.style.fontStyle = (this.titleItalic) ? "italic" : "normal";
			span.style.fontSize = this.getFontSize(this.fontSize, 'px');
			height = span.offsetHeight;
		};
		if ( height > ddelementHeight ) ddelementHeight = height;		
	};
	
	var titleHeight = 0;
	var titleWidth = 0;
	
	for(var i=0; i < groupsArr.length-1; i++){
		if (span) {
			span.innerHTML = groupsArr[i];
			span.style.width = this.spaceBetween-10;
			span.style.whiteSpace = 'normal';
			span.style.fontFamily = this.fontFamily;
			span.style.fontSize = this.getFontSize(this.fontSize, 'px');
			if ( titleHeight < span.offsetHeight ) titleHeight = span.offsetHeight;		
			if ( titleWidth < span.offsetWidth ) titleWidth = span.offsetWidth;		
		};
	};	
	titleHeight += 10;
	titleWidth += 10;
	
	ddelementHeight += 3;
	
	var tempX = this.x + 3;
	var tempY = this.y + 3;	
	var text = '';

	for(var i=0; i < groupsArr.length-1; i++){
		text += '<div id="'+this.id+'_groupName_'+i+'" style="top: 0px; left: '+i*this.spaceBetween+'; background: '+this.headerBckColor+';border: 1px solid '+this.tableBorderColor+'; width:'+this.spaceBetween+'px; height:'+titleHeight+'px;  position: absolute;"><table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td style="font-size: '+this.getFontSize(this.fontSize, 'px')+'; font-family: '+this.fontFamily+'; text-align:center; vertical-align:middle; color: '+this.fontColor+';">'+beginTag+groupsArr[i]+endTag+'</td></tr></table></div>';
		
		var groupID = this.ClearHTMLTags(groupsArr[i]);
		groupID = groupID.replace(/ /g, '');		
		this.groupsID[groupID] = i;
	};
	tempX = this.x;
	tempY += ddelementHeight;
	
	this.maxRows = this.getmaxRowsToColl(contentArr);
	
	var index = -1;
	for(var i=0; i < this.maxRows; i++){
		for(var j=0; j < groupsArr.length-1; j++){
			var result = j % (contentArr.length-1);
			var groupArr = groupsArr[result].split('#!#');
			var groupID = this.ClearHTMLTags(groupArr[0]);
			groupID = groupID.replace(/ /g, '');
			text += '<div id="'+this.id+'_DDB_'+groupID+'#'+i+';'+j+'" style="top: '+eval(i*ddelementHeight+titleHeight)+'px; left: '+j*this.spaceBetween+'px; border: 1px solid '+this.tableBorderColor+'; width:'+eval(this.spaceBetween+1)+'px; height:'+ddelementHeight+'px; font-size: 0pt; position: absolute;">.</div>';
		};
	};
	
	tempX = this.x + 3;
	tempY = this.y + 3;	
	tempY += titleHeight;
	for(var i=0; i < contentArr.length; i++){
		var collNr = i % (groupsArr.length-1);
		var groupWord = contentArr[i].split('#!#');
		
		var groupID = this.ClearHTMLTags(groupWord[0]);
		groupID = groupID.replace(/ /g, '');			
		
		var ddelementText = new __componentText;
		ddelementText.myParent = this; 
		ddelementText.id = this.id+'_DDE_'+i; 
		ddelementText.x = tempX;
		ddelementText.y = tempY;
		ddelementText.x_backup = ddelementText.x;
		ddelementText.y_backup = ddelementText.y;
		ddelementText.startX = ddelementText.x;
		ddelementText.startY = ddelementText.y;		
		ddelementText.w = this.spaceBetween;
		ddelementText.h = ddelementHeight;
		ddelementText.destinationBasketId = this.id+'_DDB_'+groupID;
		ddelementText.insideBasketId = "";
		ddelementText.text = groupWord[1];
		ddelementText.font.family = this.fontFamily;
		ddelementText.font.size = this.fontSize;
		ddelementText.font.color = this.fontColor;
		ddelementText.group = groupID;
		ddelementText.align = "center";
		ddelementText.valign = 'middle';		
		ddelementText.borderWidth = 1;
		ddelementText.borderColor = this.elementBorderColor;
		ddelementText.padding = 0;
		ddelementText.bgColor = this.elementBckColor;		
		ddelementText.cursor = this.elementCursor;		
		ddelementText.canDragging = true;
		ddelementText.solved = false;
		ddelementText.orgZ = ddelementText.z = this.z+i;
		ddelementText.dropAudio = groupWord[2];
		
		ddelementText.onCreate = this.onCreateText;
		ddelementText.beginDrag = this.beginDragText;
		ddelementText.endDrag = this.endDragText;
		ddelementText.onMove = this.mouseMoveText;	
		ddelementText.baseOnPaint = ddelementText.onPaint;
		ddelementText.onPaint = this._onPaint;						
		
		page.addChild(ddelementText);		
		this.texts.push( ddelementText );
		
		tempX += this.spaceBetween;	
		
		var result = (i+1) % (groupsArr.length-1);
		var div = parseInt((i+1)/(groupsArr.length-1));
		
		if (result == 0) {
			tempX = this.x + 3;
			tempY = (this.y+3) + titleHeight + div*ddelementHeight;
		};
	};
	this.text = text;
	//this.randomDDElements(this.texts);
};

componentWordsSet.prototype.ClearHTMLTags = function(inHTML) 
{ 
	var regEx
	var outText
	regEx = /<[^>]*>/g 
	outText = inHTML.replace(regEx, "")
	regEx = /&nbsp;/g
	outText = outText.replace(regEx, "")
	
	return outText;
};

componentWordsSet.prototype.editorPaint = function() 
{
	return "";
}

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

componentWordsSet.prototype.getmaxRowsToColl = function(arr)
{
	var maxR = 0;
	var groupNamesArr = new Array();
	
	for (var i=0; i < arr.length; i++){
		var wordsArr = arr[i].split("#!#");
		if (!groupNamesArr[wordsArr[0]]) groupNamesArr[wordsArr[0]] = new Array();
		groupNamesArr[wordsArr[0]].push(wordsArr[1]);
		if (groupNamesArr[wordsArr[0]].length > maxR) maxR = groupNamesArr[wordsArr[0]].length;
	};
	
	return maxR;
};

componentWordsSet.prototype.getFontSize = function(value, format)
{
	var fontSizesPX = new Array(0,10,13,16,18,24,32,48);
	var fontSizesPT = new Array(0, 8,10,12,14,18,24,36);
	var pxSize = fontSizesPT[parseInt(value)];
	if (format == "px") {
		pxSize = fontSizesPX[parseInt(value)];
	};	
	return pxSize;
};

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

componentWordsSet.prototype.componentWordsSetBaseOnPaint = componentWordsSet.prototype.onPaint;
componentWordsSet.prototype.onPaint = function() 
{
	if (this.locked) return;

	this.randomDDElements(this.texts);
	this.componentWordsSetBaseOnPaint();
	this.setElementIntoBasketsAtRandom(this.texts);
}

componentWordsSet.prototype.componentWordsSetBaseResetElement = componentWordsSet.prototype.resetElement;
componentWordsSet.prototype.resetElement = function() 
{
	this.componentWordsSetBaseResetElement();
	
	for (var i=0; i < this.texts.length; i++) {
		this.texts[i].setBorder(this.elementBorderColor, 1);
		this.texts[i].setBgColor(this.elementBckColor);
	}
}

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

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

componentWordsSet.prototype.randomDDElements = function(arr) 
{
	var indexes = new Array();
	var sizes = new Array();
	
	for (var i=0; i<arr.length; i++) {
		indexes.push(i);
		sizes.push( 
			{ 
				x: arr[i].x, 
				y: arr[i].y,
				x_backup: arr[i].x_backup,
				y_backup: arr[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<arr.length; i++) {
		arr[i].x = sizes[ randomIndexes[i] ].x;
		arr[i].y = sizes[ randomIndexes[i] ].y;
		arr[i].x_backup = sizes[ randomIndexes[i] ].x_backup;
		arr[i].y_backup = sizes[ randomIndexes[i] ].y_backup;
		arr[i].startX = arr[i].x_backup;
		arr[i].startY = arr[i].y_backup;
	};
};

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

componentWordsSet.prototype.setElementIntoBasketsAtRandom = function(elemArr) 
{
	var contentArr = this.content.split('||');
	var groupsArr  = this.groupsName.split('|');
	var found = false;
	var groupID = '';
	
	for (var i=0; i < elemArr.length; i++) {
		found = false;
		elemArr[i].show();
		var ddelement = document.getElementById(elemArr[i].id);
		var middlePoint = { 
			x: (ddelement.offsetLeft + ddelement.offsetWidth/2), 
			y: (ddelement.offsetTop + ddelement.offsetHeight/2)
		};		
		for(var l=0; l < groupsArr.length-1; l++){
			var groupWord = groupsArr[l].split('#!#');
			for(var k=0; k < this.maxRows; k++){
				groupID = this.ClearHTMLTags(groupWord[0]);
				groupID = groupID.replace(/ /g, '');
			
				var ddbasket = document.getElementById(this.id+'_DDB_'+groupID+'#'+k+';'+l);
				var left = this.findPosX(ddbasket);
				var right = left + ddbasket.offsetWidth;
				var top = this.findPosY(ddbasket);
				var bottom = top + ddbasket.offsetHeight;				
				
				if ( middlePoint.x > left && middlePoint.x < right && middlePoint.y > top && middlePoint.y < bottom ) {
					this.setIntoBasket(this.texts[i], ddelement, ddbasket)
					found = true;
					break;
				};
			};
			if (found) break;
		};
	};
};

componentWordsSet.prototype.getDropAudioIndex = function(audioFile)
{
	var result = -1;
	var contentArr = unescape(this.content).split('||');
	
	for(var i=0; i < contentArr.length; i++){
		var oneArr = contentArr[i].split('#!#');
		if (oneArr[2] == audioFile) {
			result = i;// + 1;
			break;
		}
	}
	return result;
};

componentWordsSet.prototype.playDropAudio = function(audioFile) 
{
	if (audioFile == '' || audioFile == 'undefined' || typeof(audioFile) == 'undefined')
		return;		
	
	if (this.enableFlashPlayer) {
		this.dropAudioComp.flashVars = "playIdx="
			+ this.getDropAudioIndex(audioFile) + "&autoStart=true&playOnce=true";
		this.dropAudioComp.show();
	} else {
		this.dropAudioComp.setUrl(this.resourcesURL + audioFile);
		this.dropAudioComp.actionMediaPlay();
	}
};	

componentWordsSet.prototype.mouseMoveText = function(e) 
{
	return;
};

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

componentWordsSet.prototype.endDragText = function(e) {
	this.setZIndex(this.orgZ);
	
	var ddbasket = document.getElementById(this.destinationBasketId);
	var ddelement = document.getElementById(this.id);
	/** ddbasket.style.borderColor = "black"; */
	
	this.myParent.playDropAudio(this.dropAudio);	
	
	var middlePoint = { 
		x: (ddelement.offsetLeft + ddelement.offsetWidth/2), 
		y: (ddelement.offsetTop + ddelement.offsetHeight/2)
	};
	
	var contentArr = this.myParent.content.split('||');
	var groupsArr  = this.myParent.groupsName.split('|');
	var found = false;
	var groupID = '';
	
	for(var j=0; j < groupsArr.length-1; j++){
		for(var i=0; i < this.myParent.maxRows; i++){
			var groupWord = groupsArr[j].split('#!#');
			groupID = this.myParent.ClearHTMLTags(groupWord[0]);
			groupID = groupID.replace(/ /g, '');			
			
			var ddbasket = document.getElementById(this.myParent.id+'_DDB_'+groupID+'#'+i+';'+j);
			
			var left = this.myParent.findPosX(ddbasket);
			var right = left + ddbasket.offsetWidth;
			var top = this.myParent.findPosY(ddbasket);
			var bottom = top + ddbasket.offsetHeight;
			
			if ( middlePoint.x > left && middlePoint.x < right && middlePoint.y > top && middlePoint.y < bottom ) {
				this.inArea = ddbasket;
				found = true;
				break;
			}else this.inArea = null; 
		};
		if (found) break;
	};
	
	if (this.inArea){
		var otherElem = this.myParent.checkIsFilled(this, this.inArea.id);
		if (otherElem){
			this.myParent.replaceElements(this, otherElem);
		}else{
			this.myParent.setIntoBasket(this, ddelement, this.inArea)
		};
	}else {
		this.myParent.moveToStart(this, ddelement);
	};
};

componentWordsSet.prototype.replaceElements = function (first, second) 
{
	var tempElem = {
		x 				: first.x,
		y 				: first.y,
		x_backup 		: first.x_backup,
		y_backup 		: first.y_backup,
		startX			: first.startX,
		startY 			: first.startY,
		insideBasketId 	: first.insideBasketId
	};
	
	var ddb = document.getElementById(second.insideBasketId);
	var dde = document.getElementById(first.id);
	var shift = 0;
	if (is.moz) shift = 1;	
	
	var x = this.findPosX(ddb) + shift;
	var y = this.findPosY(ddb) + shift;
	
	dde.style.left = x;
	dde.style.top = y;	
	
	first.x = x;
	first.y = y;
	first.x_backup = second.x_backup;
	first.y_backup = second.y_backup;
	first.startX = second.startX;
	first.startY = second.startY;
	first.insideBasketId = second.insideBasketId;
	var nameArr = first.insideBasketId.split('#');
	first.solved = (nameArr[0] == first.destinationBasketId);	
	
	var ddb = document.getElementById(tempElem.insideBasketId);
	var dde = document.getElementById(second.id);
	var x = this.findPosX(ddb) + shift;
	var y = this.findPosY(ddb) + shift;	
	
	dde.style.left = x;
	dde.style.top = y;

	second.x = x;
	second.y = y;
	second.x_backup = tempElem.x_backup;
	second.y_backup = tempElem.y_backup;
	second.startX = tempElem.startX;
	second.startY = tempElem.startY;
	second.insideBasketId = tempElem.insideBasketId;
	var nameArr = second.insideBasketId.split('#');
	second.solved = (nameArr[0] == second.destinationBasketId);
	
	if (first.myParent.showAnswerIndicatorAnyTime && first.myParent.showCorrectAnswerIndicator){
		first.setBorder(first.myParent.elementBorderColor, 1);
		first.obj.style.background = first.myParent.elementBckColor;
	};	
	if (second.myParent.showAnswerIndicatorAnyTime && first.myParent.showCorrectAnswerIndicator){
		second.setBorder(second.myParent.elementBorderColor, 1);
		second.obj.style.background = second.myParent.elementBckColor;
	};		
};

componentWordsSet.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;
};

componentWordsSet.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;
};

componentWordsSet.prototype.moveToStart = function(sender, elem) 
{
	sender.solved = false;
	sender.x = sender.startX;
	sender.y = sender.startY;
	//sender.insideBasketId = '';
	elem.style.left = sender.startX;
	elem.style.top = sender.startY;
};

componentWordsSet.prototype.setIntoBasket = function(sender, dde, obj) 
{
	if (sender.myParent.showAnswerIndicatorAnyTime && sender.insideBasketId != obj.id){
		sender.setBorder(sender.myParent.elementBorderColor, 1);
		sender.obj.style.background = sender.myParent.elementBckColor;
	};
	var shift = 0;
	if (is.moz) shift = 1;
	var x = sender.myParent.findPosX(obj) + shift;
	var y = sender.myParent.findPosY(obj) + shift;

	dde.style.left = x;
	dde.style.top = y;
	sender.x = x;
	sender.y = y;
	sender.startX = x;
	sender.startY = y;
	sender.insideBasketId = obj.id;
	var nameArr = obj.id.split('#');
	sender.solved = (nameArr[0] == sender.destinationBasketId);
};

componentWordsSet.prototype.checkIsFilled = function(obj, destBasket) 
{
	for (var i=0; i < this.texts.length; i++) {
		if (this.texts[i].id != obj.id && this.texts[i].insideBasketId == destBasket){
			//this.moveToStart(obj, obj);	
			return this.texts[i];
		}
	}	
	return null;
};

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

componentWordsSet.prototype.setAnswer = function(valStr, showCorrect)
{
	if ((typeof(valStr) == 'undefined' || valStr == '') && !showCorrect) return;
	if (valStr == '' && (typeof(showCorrect) == 'undefined' || showCorrect.toString() == '')) showCorrect = true;
	
	if (!showCorrect){
		var splited = valStr.split('#!#');
		for (var i=0; i < splited.length; i++){
			var elem = splited[i].split('||');
			var ddelement = document.getElementById(elem[0]);
			var ddbasket = document.getElementById(elem[1]);
			
			var j=-1;
			do{
				j++;
			}while (this.texts[j].id != elem[0] && j < this.texts.length)
			
			if (ddbasket) {
				this.setIntoBasket(this.texts[j], ddelement, ddbasket);		
				this.texts[j].setBorder(this.texts[j].myParent.elementBorderColor, 1);
			}
		};
	}else{
		var tempArr = new Array();
		for (var i=0; i < this.texts.length; i++) {
			var coll = this.groupsID[this.texts[i].group];
			
			if (tempArr[this.texts[i].destinationBasketId])
				var row = tempArr[this.texts[i].destinationBasketId].length;
			else var row = 0;
			
			var ddelement = document.getElementById(this.texts[i].id);
			var ddbasket = document.getElementById(this.texts[i].destinationBasketId+'#'+row+';'+coll);
			this.setIntoBasket(this.texts[i], ddelement, ddbasket);
			this.texts[i].setBorder(this.texts[i].myParent.elementBorderColor, 1);
			
			if (tempArr[this.texts[i].destinationBasketId]){
				var length = tempArr[this.texts[i].destinationBasketId].length;
				tempArr[this.texts[i].destinationBasketId][length] = 'filled';
			}else{
				tempArr[this.texts[i].destinationBasketId] = new Array();
				tempArr[this.texts[i].destinationBasketId][0] = 'filled';
			};
		};
	};
	this.onRepaint();	
};

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

componentWordsSet.prototype.parseCheckAnswer = function(index)
{
	var result = true;
	for (var i=0; i < this.texts.length; i++) {
		if (!this.texts[i].solved) {
			result = false;
		};
		if (this.showAnswerIndicatorAnyTime && this.showCorrectAnswerIndicator){
			if (this.texts[i].solved) {
				this.texts[i].setBorder(this.elementCorrectBorderColor, 1);
				this.texts[i].obj.style.background = this.elementCorrectBckColor;
			}else{
				this.texts[i].setBorder(this.elementInCorrectBorderColor, 1);
				this.texts[i].obj.style.background = this.elementInCorrectBckColor;
			}
		}
	};
	return result;
};

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

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

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

componentWordsSet.prototype.interactionsCorrectResponses = function(index)
{
	var result = '';
	var sep = '';

	var tempArr = new Array();
	for (var i=0; i < this.texts.length; i++) {
		var coll = this.groupsID[this.texts[i].group];
		
		if (tempArr[this.texts[i].destinationBasketId])
			var row = tempArr[this.texts[i].destinationBasketId].length;
		else var row = 0;
		
		var ddelement = document.getElementById(this.texts[i].id);
		var ddbasket = document.getElementById(this.texts[i].destinationBasketId+'#'+row+';'+coll);
		this.texts[i].insideBasketId = ddbasket.id;
		
		if (result != '') sep = '#!#';
		result += sep + this.texts[i].id +'||'+this.texts[i].insideBasketId;

		if (tempArr[this.texts[i].destinationBasketId]){
			var length = tempArr[this.texts[i].destinationBasketId].length;
			tempArr[this.texts[i].destinationBasketId][length] = 'filled';
		}else{
			tempArr[this.texts[i].destinationBasketId] = new Array();
			tempArr[this.texts[i].destinationBasketId][0] = 'filled';
		};
	};
	return(result);
};

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

componentWordsSet.prototype.interactionsCorrectResponsesAsText = function(index)
{
	var result = '';
	var sep = '';

	var tempArr = new Array();
	for (var i=0; i < this.texts.length; i++) {
		var coll = this.groupsID[this.texts[i].group];
		
		if (tempArr[this.texts[i].destinationBasketId])
			var row = tempArr[this.texts[i].destinationBasketId].length;
		else var row = 0;
		
		var ddelement = document.getElementById(this.texts[i].id);
		var ddbasket = document.getElementById(this.texts[i].destinationBasketId+'#'+row+';'+coll);
		this.texts[i].insideBasketId = ddbasket.id;
		
		if (result != '') sep = '#!#';
		result += sep + this.texts[i].id +'||'+this.texts[i].insideBasketId;

		if (tempArr[this.texts[i].destinationBasketId]){
			var length = tempArr[this.texts[i].destinationBasketId].length;
			tempArr[this.texts[i].destinationBasketId][length] = 'filled';
		}else{
			tempArr[this.texts[i].destinationBasketId] = new Array();
			tempArr[this.texts[i].destinationBasketId][0] = 'filled';
		};
	};
	return(result);
};

componentWordsSet.prototype.interactionsStudentResponseAsText = function()
{
	return this.getAnswer();
};
