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

componentCopyOutSentenceCounter = function(name) 
{
	this.componentCopyOutSentence = componentCopyOutSentence;
	this.componentCopyOutSentence(name);
	
	this.text = "";
	this.texts = new Array();
	this.textArea = new Array();
};

componentCopyOutSentenceCounter.prototype = new componentCopyOutSentence;
componentCopyOutSentenceCounter.prototype.type = "componentCopyOutSentenceCounter";

componentCopyOutSentenceCounter.prototype.onCreate = function(obj)
{
	this.correctAnswersList = this.correctAnswer.split("||");
	
	var splitedContent = this.content.split('|@|');
	
	var pairSentAreaHeight = (this.h - splitedContent.length-1)/splitedContent.length;
	
	var tempX = this.x;
	var tempY = this.y;
	
	for(var i=0; i < splitedContent.length; i++){
		var parirArr = splitedContent[i].split('#!#');
		if (parirArr[1] != '') var answersArr = parirArr[2].split('@!@');
		
		var textComp = new __componentText;
		textComp.myParent = this; 
		textComp.id = this.id+'_sent_'+i; 
		textComp.x = tempX;
		textComp.y = tempY;
		textComp.h = pairSentAreaHeight/2;
		textComp.w = this.w;
		textComp.text = parirArr[0]+'&nbsp;&nbsp;&nbsp;'+parirArr[1];
		textComp.font.family = this.font.family;
		textComp.font.size = this.font.size;
		textComp.font.color = this.font.color;		
		textComp.lineHeight = this.lineHeight;
		page.addChild(textComp);		
		this.texts.push( textComp );
		
		var areaComp = new componentTextarea;
		areaComp.myParent = this; 
		areaComp.id = this.id+'_area_'+i; 
		areaComp.x = tempX;
		areaComp.y = tempY + pairSentAreaHeight/2;
		areaComp.h = pairSentAreaHeight/2;
		areaComp.w = this.w;
		areaComp.correctAnswer = answersArr[0];
		areaComp.caseSensitive = (answersArr[1] == 'true')?true:false;
		areaComp.borderColor = this.borderColor;
		areaComp.ignoreWhiteChars = this.ignoreWhiteChars;
		areaComp.clearWhiteChars = this.__clearWhiteChars;		
		areaComp._setHTMLDef = this.__setHTMLDef;
		areaComp.onLock = this.__onLock;
		areaComp.onUnLock = this.__onUnLock;
		areaComp.getAnswer = this.__getAnswer;
		areaComp.parseCheckAnswer = this.__parseCheckAnswer;
		areaComp.setAnswer = this.__setAnswer;
			
		page.addChild(areaComp);		
		this.textAreaComponent.push( areaComp );
		
		tempY += pairSentAreaHeight + (i+1);
	};
};
