/* 4b test template
 * requires:
 * jquery.js
 * player_test_template.js
 * iliustraData.js
 */

console.log('> template4b.js is iniciated;');

function template4bscript() {
	console.log("function template4bscript(); sectionName=" +sectionName + "; slideName=" +slideName);	
	
         tObj = getObject();
    
        var mainVars = initMainVars(tObj,sectionName,slideName);
	var tO = mainVars.tO;
        var items = tO['items'];
        
        
	// count items
	var itemsCount = tO['items_count']; 	console.log('items count: ' +itemsCount);
	
	if (tO['background']) {
		loadSlideBackground();
	}
    
    var p = {	// properties
		end :{
			min:{
				x:570,
				y:5
			},
			max:{
				x:680,
				y:700
			},
		},
		text:{
			css	:{
				main	:{
					"position":"absolute",
					'width':'247px',
					'height':'34px',
					'top':'350px',
					'left':'200px',
					"cursor": "move",
					"z-index": "10",
					"border": "1px solid rgb(190,190,190)",
					"background":"rgb(254,255,188)"
				},
				text:{
					"position":"absolute",
					'width':'247px',
					'height':'34px',
					'top':'0px',
					'left':'0px',
					"z-index": "7",
					'text-indent':'0px',
					'font-family':'Arial',
					'font-size': '22px',
					'text-align':'center',
					'line-height': '34px'
				}
			}
		}
	}	
	
	var zIndexChange=20;
	
	var answered ={};
	
	// generate random end points for items x and y ;
	randomise_items_end_XY(itemsCount,p);
	
	// randomise items order
	var randPlaces = randomArray(itemsCount);
	
	items = change_items_to_random(items, randPlaces);
	
	//  get true - correct ; or falls - incorrect
	this.checkAnswer = checkTestAnswer_4b;
	// check buttton and function to check
	checkTestButton(this.checkAnswer,tO,null,randPlaces,null,null,answered);

	appendQuestion(ssId, ss, tO, 4);
	
	append_caption_text_4b(tO,p,answered);
	
	append_items(items,p,5,null,ss,ssId);
        
        var clname = "."+sectionName+slideName + "items_4b";	
	image_mDraggable(clname,ssId,zIndexChange,4);	
}