function sceneCrosswordsLoad(){
	
	var dataObjects=dataScene[sceneCurrent]['objects'];
	
	for(key in dataObjects){
		var dataObject=dataObjects[key];
		
		//group
		var object = new Konva.Group({
			id:key,
			name:dataObject['name'],
			x:dataObject['x'],
			y:dataObject['y'],
		});
		grpScene.add(object);
		object.setAttr("objectType",dataObject['objectType']);
		object.setAttr("target",dataObject['target']);
		object.setAttr("interaction",dataObject['interaction']);
		object.setAttr("limit",dataObject['limit']);
		object.setAttr("group",dataObject['group']);
		object.setAttr("rectFillOver",dataObject['rectFillOver']);
		object.setAttr("textFill",dataObject['textFill']);
		object.setAttr("textFillOver",dataObject['textFillOver']);
		
		//rect
		if(dataObject['interaction']){
			var rect = new Konva.Rect({
				id: "rect",
				x: 0,
				y: 0,
				width: dataObject['width'],
				height: dataObject['height'],
				opacity: .5,
			});
			object.add(rect);
		}
		
		//text
		fontSize=dataObject['width'] / 2;
		var text = new Konva.Text({
			id: "text",
			fontSize: fontSize,
			x: 0,
			y: (dataObject['height']- (fontSize - 5)) /2,
			width: dataObject['width'],
			fill: dataObject['textFill'],
			fontStyle: 'bold',
			fontFamily: 'Trebuchet MS, sans-serif',
			align: 'center',
		});
		object.add(text);
		
		
		
		
		//checkerTrue
		/*
			var checkerTrue=qcImage({
			name:"checkerTrue",
			src:dataScene[sceneCurrent]['checkerTrueSrc'],
			x:0,
			y:0,
			width:dataScene[sceneCurrent]['checkerWidth'],
			height:dataScene[sceneCurrent]['checkerHeight'],
			});
			checkerTrue.hide();
			object.add(checkerTrue);
		*/
		
		//checkerFalse
		/*
			var checkerFalse=qcImage({
			name:"checkerFalse",
			src:dataScene[sceneCurrent]['checkerFalseSrc'],
			x:0,
			y:0,
			width:dataScene[sceneCurrent]['checkerWidth'],
			height:dataScene[sceneCurrent]['checkerHeight'],
			});
			checkerFalse.hide();
			object.add(checkerFalse);
		*/
		
		//events
		object.on('pointerover', function (e) {
			object=e.currentTarget;
			if(object.getAttr('interaction')){
				stage.container().style.cursor = 'pointer';
				object.findOne("#rect").fill(object.getAttr('rectFillOver'));
				object.findOne("#text").fill(object.getAttr('textFillOver'));
			}
		});
		object.on('pointerout', function (e) {
			if(object.getAttr('interaction')){
				object=e.currentTarget;
				stage.container().style.cursor = 'default';		
				object.findOne("#rect").fill('');
				object.findOne("#text").fill(object.getAttr('textFill'));
			}
		});
		object.on('pointerclick ', function (e) {
			object=e.currentTarget;
			if(object.getAttr('interaction')){
				
				//inputBox dan gelen veri burada işleniyor
				object.input = function (value) {
					
					value = value.replace(/ /g, "");
					
					checkLock=false //btnCheck için checklock kapatıyoruz, artık sceneCheck yapilabilir
					
					if(object.getAttr('group')){
						//grup kutusu ve bu kutu lider kutu
						
						
						var letters = value.split('');
						
						for(key in object.getAttr('group')){
							boxId=object.getAttr('group')[key];
							box=grpScene.findOne('#'+boxId);
							text=box.findOne('#text');
							
							if(letters[key]){
								letter=letters[key].toLocaleUpperCase('tr-TR');
								text.text(letter);
								box.setAttr('targetted',letter);
							}
						}
						} else {
						//normal kutu
						text=object.findOne('#text');
						letter=value.substring(0,object.getAttr('limit')).toLocaleUpperCase('tr-TR');
						text.text(letter);
					}
				}
				
				popInputBox(object);
			}
		});
		
	}
	
}
function sceneCrosswordsChecker(obj,trueFalse){
	
	if(dataScene[sceneCurrent]['check']){
		
		checkerX=0;
		checkerY=0;
		
		if(dataScene[sceneCurrent]['checkerX']){ checkerX=dataScene[sceneCurrent]['checkerX'];}
		if(dataScene[sceneCurrent]['checkerY']){ checkerY=dataScene[sceneCurrent]['checkerY'];}
		
		
		var imageSrc = new Image();
		imageSrc.onload = function () {
			var checker = new Konva.Image({
				id:"checker",
				x:checkerX,
				y:checkerY,
				width:dataScene[sceneCurrent]['checkerWidth'],
				height:dataScene[sceneCurrent]['checkerHeight'],
				image: imageSrc,
			});
			obj.add(checker);
		};
		
		
		if(trueFalse){
			imageSrc.src = stagePath+dataScene[sceneCurrent]['checkerTrueSrc'];
			} else {
			imageSrc.src = stagePath+dataScene[sceneCurrent]['checkerFalseSrc'];
		}
	}
}
function sceneCrosswordsCheck(check=null){
	
	var objects = grpScene.getChildren();
	var countCorrect=0;
	var countTotal=0;
	
	for(key in objects){
		var obj = objects[key];
		
		if(check){
			obj.draggable(false);
			obj.off('pointerdown');
			obj.off('pointerup');
			obj.off('pointerover');
			obj.off('pointerout');
		}
		
		if(obj.getAttr('objectType')=='crosswordBox'){
			
			countTotal++;
			
			if(obj.getAttr('target')==obj.getAttr('targetted')){
				countCorrect++;
				if(check){ sceneCrosswordsChecker(obj,true); }
				} else {
				if(check){ sceneCrosswordsChecker(obj,false); }
			}
			
		}
	}
	if(check){
		if(countCorrect>=countTotal){
			btnSolve.hide();
		}
	}
	
	//*********************************************************
	//check if answer correct and save answer to answers array
	//*********************************************************
	sceneResults[sceneCurrent]={
		'scene':sceneCurrent,
		'type':'crosswords',
		'total':countTotal,
		'correct':countCorrect,
	};
	if(countCorrect>=countTotal){
		sceneResults[sceneCurrent]['success']=true;
	}
}

function sceneCrosswordsSolve(){
	
	var objects = grpScene.getChildren();
	
	for(key in objects){
		
		var obj = objects[key];
		
		if(obj.getAttr('objectType')=='crosswordBox'){
			
			text=obj.findOne('#text');
			text.text(obj.getAttr('target'));
			
			checker=obj.findOne('#checker');
		
			checker.hide();
			
			
			obj.draggable(false);
			obj.off('pointerdown');
			obj.off('pointerup');
			obj.off('pointerover');
			obj.off('pointerout');
			
			
		}
	}
}	