/* 3e test template
 * sort items in 3 columns
 * requires:
 * jquery.js
 * player_test_template.js
 * iliustraData.js
 */

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

function template3escript() {
	console.log("function template3escript(); sectionName=" +sectionName + "; slideName=" +slideName);	
	
         tObj = getObject();
    
        var mainVars = initMainVars(tObj,sectionName,slideName);
	var tO = mainVars.tO;
        var items = tO['items'];  	
	//var captions = tO['captions'];    
    
    // count items
	var itemsCount = tO['items_count']; 	console.log('items count: ' +itemsCount);

	if (tO['background']) {
		loadSlideBackground();
	}
    
    var p = {	// properties for 3 captions
		end :{
			min:{
				x:500,
				y:10
			},
			max:{
				x:650,
				y:600
			},
		},
		left:{
			caption_1 : 60,
			caption_2 : 414,
			caption_3 : 768
		},
		caption :{
			"position":"absolute",
			'width':'334px',
			'height':'50px',
			'top':'165px',
			"z-index": "10",
			"background":"rgb(26,188,156)",
			'color' : '#ffffff',
			'text-indent':'0px',
			'font-family':'Arial',
			'font-size': '24px',
			'text-align':'center',
			'line-height': '50px'
		},
		container :{
			"position":"absolute",
			'width':'334px',
			'height':'283px',
			'top':'217px',
			"background":"rgb(241,242,242)",
			"z-index": "7"
		},
		text:{
			css	:{
				main	:{
					"position":"absolute",
					'width':'331px',
					'height': 'auto',
					'top':'350px',
					'left':'200px',
					"cursor": "move",
					"z-index": "10",
					"border": "1px solid rgb(252,235,143)",
					//'opacity':'0.5',
					"background":"rgb(254,255,188)"
				},
				text:{
					"position":"absolute",
					'width':'311px',
					'margin-top' : '4px',
					'margin-bottom':'4px',
					'margin-right':'10px',
					'margin-left':'10px',
					"z-index": "7",
					'text-indent':'0px',
					'font-family':'Arial',
					'font-size': '24px',
					'text-align':'left',
					'line-height': '33px'
				},
				hover_on:{
					"background":"rgb(255,255,239)"
				},
				hover_out:{
					"background":"rgb(254,255,188)"
				},
			}
		}
	}	
	

	var p2 = {	// properties for 2 captions
		end :{
			min:{
				x:500,
				y:10
			},
			max:{
				x:650,
				y:600
			},
		},
		left:{
			caption_1 : 60,
			caption_2 : 590
		},
		caption :{
			"position":"absolute",
			'width':'510px',
			'height':'50px',
			'top':'165px',
			"z-index": "10",
			"background":"rgb(26,188,156)",
			'color' : '#ffffff',
			'text-indent':'0px',
			'font-family':'Arial',
			'font-size': '24px',
			'text-align':'center',
			'line-height': '50px'
		},
		container :{
			"position":"absolute",
			'width':'510px',
			'height':'283px',
			'top':'217px',
			"background":"rgb(241,242,242)",
			"z-index": "7"
		},
		text:{
			css	:{
				main	:{
					"position":"absolute",
					'width':'508px',
					'height': 'auto',
					'top':'350px',
					'left':'200px',
					"cursor": "move",
					"z-index": "10",
					"border": "1px solid rgb(252,235,143)",
					//'opacity':'0.5',
					"background":"rgb(254,255,188)"
				},
				text:{
					"position":"absolute",
					'width':'488px',
					'margin-top' : '4px',
					'margin-bottom':'4px',
					'margin-right':'10px',
					'margin-left':'10px',
					"z-index": "7",
					'text-indent':'0px',
					'font-family':'Arial',
					'font-size': '24px',
					'text-align':'left',
					'line-height': '33px'
				},
				hover_on:{
					"background":"rgb(255,255,239)"
				},
				hover_out:{
					"background":"rgb(254,255,188)"
				},
			}
		}
	}	
	
	var captions_count = tO['captions_count'];
	
	if (captions_count == 2) {
		p =p2;
	}
	
	var zIndexChange=20;
	
	var drop_in = {
		text:{},
		order:{
			caption_1 :[],
			caption_2 :[],
			caption_3 :[]
			},
		height:{},
		items :{},
		caption: {},
		caption_1 :{},
		caption_2 :{},
		caption_3 :{}
	}
	
	// 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_3e;
	// check buttton and function to check
	checkTestButton(this.checkAnswer,tO,null,randPlaces,drop_in);

	loadSlideBackground();
	
	appendQuestion(ssId, ss, tO, 3);
	
	append_captions(tO.captions,p,drop_in);
	
	//append_items(items);
        append_items(items,p,4,null,ss,ssId,drop_in);
	
	image_mDraggable(".items",ssId,zIndexChange,3);

	console.log('drop_in:');
	console.log(drop_in);	
}

