function changeSimbol(e,p_id,p_row_id,p_marker_color,p_correct,p_root,p_examineeanswerid,p_answer,p_answer_id,p_row_names,p_col_names){
	var key_pressed = '';
	if (!e) e=event;
	if (e.ctrlKey){
		// alert("CTRL key is pressed.");
		key_pressed = 'ctrl';
	}
	else if (e.altKey){
		// alert("ALT key is pressed.");
		key_pressed = 'alt';
	}
	else{
		// alert("No keypressed.");
		key_pressed = 'none';
	}

	var TRUE_STR = 'True';
	var FALSE_STR = 'False';

	var actual_tag = document.getElementById(p_id);
	var parent_tag = actual_tag.parentNode;
	
	var selected_cnt = 0;
	var selected_cnt2 = 0;
	var last_selected_id = '';
	var last_selected_class = '';

	//színezésért felelős rész
	if(key_pressed=='ctrl'){
		for (var i=0;i<parent_tag.childNodes.length;i++){
			if (parent_tag.childNodes[i].nodeName == 'DIV' && parent_tag.childNodes[i].style.backgroundImage != 'none'){
				selected_cnt++;
			}
		}
		
		if(selected_cnt==1 && actual_tag.style.backgroundImage!="none"){//ha 1 van kijelölve és én arra klikkelek
			document.getElementById(p_row_id).style.backgroundImage="url("+p_root+"_application/images/circle_" + actual_tag.className + "_tele_small.gif)";
			actual_tag.style.backgroundImage="url("+p_root+"_application/images/circle_" + actual_tag.className + ".gif)";
		}
		else{
			document.getElementById(p_row_id).style.backgroundImage="url("+p_root+"_application/images/circle_red_tele_small.gif)";
			for (var i=0;i<parent_tag.childNodes.length;i++){
				if (parent_tag.childNodes[i].nodeName == 'DIV' && parent_tag.childNodes[i].style.backgroundImage != 'none'){
					parent_tag.childNodes[i].style.backgroundImage="url("+p_root+"_application/images/circle_yellow.gif)";
				}
			}
			actual_tag.style.backgroundImage="url("+p_root+"_application/images/circle_yellow.gif)";
		}
	}
	else if(key_pressed=='alt'){
		for (var i=0;i<parent_tag.childNodes.length;i++){
			if (parent_tag.childNodes[i].nodeName == 'DIV' && parent_tag.childNodes[i].style.backgroundImage != 'none'){
				selected_cnt++;
				last_selected_id = parent_tag.childNodes[i].id;
				last_selected_class = parent_tag.childNodes[i].className;
			}
		}
	
		if(selected_cnt==1 && actual_tag.style.backgroundImage!="none"){//ha 1 van kijelölve és én arra klikkelek
			document.getElementById(p_row_id).style.backgroundImage = "url("+p_root+"_application/images/circle_red_tele_small.gif)";
			actual_tag.style.backgroundImage = "none";
		}
		else if(selected_cnt==1 && actual_tag.style.backgroundImage=="none"){//ha 1 van kijelölve és én nem arra klikkelek
			document.getElementById(p_row_id).style.backgroundImage = "url("+p_root+"_application/images/circle_" + last_selected_class + "_tele_small.gif)";
		}
		else{//ha több van kijelölve
			if(actual_tag.style.backgroundImage!="none"){
				actual_tag.style.backgroundImage="none";
				document.getElementById(p_row_id).style.backgroundImage = "url("+p_root+"_application/images/circle_red_tele_small.gif)";
				selected_cnt2 = 0;
				for (var i=0;i<parent_tag.childNodes.length;i++){
					if (parent_tag.childNodes[i].nodeName == 'DIV' && parent_tag.childNodes[i].style.backgroundImage != 'none'){
						parent_tag.childNodes[i].style.backgroundImage = "url("+p_root+"_application/images/circle_yellow.gif)";
						selected_cnt2++;
						last_selected_id = parent_tag.childNodes[i].id;
						last_selected_class = parent_tag.childNodes[i].className;
					}
				}
				if(selected_cnt2==1){
					document.getElementById(last_selected_id).style.backgroundImage = "url("+p_root+"_application/images/circle_" + last_selected_class + ".gif)";
					document.getElementById(p_row_id).style.backgroundImage = "url("+p_root+"_application/images/circle_" + last_selected_class + "_tele_small.gif)";
				}
			}
		}
	}
	else if(key_pressed=='none'){
		document.getElementById(p_row_id).style.backgroundImage="url("+p_root+"_application/images/circle_" + actual_tag.className + "_tele_small.gif)";
		
		for (var i=0;i<parent_tag.childNodes.length;i++){
			if (parent_tag.childNodes[i].nodeName == 'DIV'){
				parent_tag.childNodes[i].style.backgroundImage = "none";
			}
		}
		if(p_correct==FALSE_STR)
			actual_tag.style.backgroundImage = "url("+p_root+"_application/images/circle_red.gif)";
		else if(p_correct==TRUE_STR)
			actual_tag.style.backgroundImage = "url("+p_root+"_application/images/circle_green.gif)";
	}
	
	//a módosító tömb összerakásáért felelős rész
	selected_cnt = 0;
	for (var i=0;i<parent_tag.childNodes.length;i++){
		if (parent_tag.childNodes[i].nodeName == 'DIV' && parent_tag.childNodes[i].style.backgroundImage != 'none'){
			selected_cnt++;
		}
	}
	if(selected_cnt==1){
		var mod_row_data = new Array(key_pressed, p_examineeanswerid, p_answer, p_answer_id, p_row_names, p_col_names);
	}
	else{
		var mod_row_data = new Array(key_pressed, p_examineeanswerid, '-1', '', p_row_names);
		for (var i=0;i<parent_tag.childNodes.length;i++){
			if (parent_tag.childNodes[i].nodeName == 'DIV' && parent_tag.childNodes[i].style.backgroundImage != 'none'){
				col_id = parent_tag.childNodes[i].id;
				col_split = String(col_id).split("_");
				mod_length = mod_row_data.length;
				mod_row_data[mod_length] = col_split[3];
			}
		}
	}
	
	var data_split = new Array();
	var data_already_in = false;
	var data_array_id = 0;
	if(test_modify_datas.length>0){
		for (var i = 0; i < test_modify_datas.length; i++){
			data_split = String(test_modify_datas[i]).split(",");
			if(data_split[1]==p_examineeanswerid){
				data_already_in = true;
				data_array_id = i;
			}
		}
		if(data_already_in)
			test_modify_datas[data_array_id] = mod_row_data;
		else
			test_modify_datas[test_modify_datas.length] = mod_row_data;
	}
	else
		test_modify_datas[0] = mod_row_data;
}

function loadtoDB(){
	for (var i = 0; i < test_modify_datas.length; i++)
		alert(test_modify_datas[i]);
}


//--------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------AJAX METHODS - átrakva az ajax.js-be-------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------
/* var loadtodb_url = 'http://'+location.host+'/zvb2/_application/automation/loadtodb/index.php';
// var loadtodb_url = 'http://'+location.host+'/_application/automation/loadtodb/index.php';

var http_request;
var result_format='xml';

function createHTTPRequest(eventhandler){
	 http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		 http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		 try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
				try {
					 http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
		 }
	}
	
	if (!http_request) {
		 alert('Cannot create XMLHTTP instance');
		 return false;
	}
	http_request.onreadystatechange = function(){ handleAjaxResponse(eventhandler); }
}

function handleAjaxResponse(eventhandler){
	var results;
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			if (result_format=='json'){
				eval(eventhandler+('http_request.responseText'));
			} else {
				eval(eventhandler+'(http_request.responseXML);');
			}
		}
	}
}

function getResultException(){
	ex=http_request.responseXML.documentElement.getElementsByTagName('exception');
	if (ex[0]){
		return 'Exception: '+ex[0].getElementsByTagName('message')[0].firstChild.nodeValue;
	}
	else return '';
}

function ajaxLoadToDB(p_this,p_metjod_tag_id,p_test_id){
	var update_rows_data = '';
	for (var i = 0; i < test_modify_datas.length; i++){
		if(update_rows_data == '') update_rows_data = String(test_modify_datas[i]);
		else update_rows_data = update_rows_data + '_' + String(test_modify_datas[i]);
	}
	
	// http://whale/zvb2/_application/automation/loadtodb/index.php?ret_format=xml&update_rows_data=ctrl,427149,-1,,6,2,4_ctrl,427149,-1,,6,2,3,4_none,427148,1,12376,5,1&tesztlap_id=192
	// alert(loadtodb_url+'?ret_format='+result_format+'&update_rows_data='+update_rows_data+'&tesztlap_id='+p_test_id);
	createHTTPRequest('table_update_result');
	var ajax_ret = http_request.open('GET', loadtodb_url+'?ret_format='+result_format+'&update_rows_data='+update_rows_data+'&tesztlap_id='+p_test_id, true);
	http_request.send(null);
	
	if(ajax_ret==true){
		document.getElementById(p_metjod_tag_id).value = 'ok';
		document.check_test.submit();
	}
	else{
		document.getElementById(p_metjod_tag_id).value = 'ok';
		document.check_test.submit();
	}
}

function table_update_result(response){
	var str = getResultException();
	if (str==''){
		return true;
	}
	else{
		return false;
	}
}

function ajaxCancel(p_this,p_metjod_tag_id,p_test_id){
	document.getElementById(p_metjod_tag_id).value = 'cancel';
	document.check_test.submit();
} */


//--------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------KÉP MÉRETÉNEK VÁLTOZTATÁSA-------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------
function kepMeretValtoztatasa(p_this, p_width, p_height, p_img_container_id, p_imagesize_hidden_id, p_row_count, p_max_col_count, p_metjod_tag_id, p_test_id){
	// document.check_test.action='./?id=' + p_test_id;
	// document.check_test.submit();
	
	sorokOszlopokPozicionalasa(p_row_count, p_max_col_count, document.getElementById(p_imagesize_hidden_id).value, p_this.value);
	
	document.getElementById(p_imagesize_hidden_id).value = p_this.value;
	document.getElementById(p_img_container_id).style.width = (p_width*p_this.value) + 'px';
	document.getElementById(p_img_container_id).style.height = (p_height*p_this.value) + 'px';
	document.getElementById(p_img_container_id).style.backgroundSize = (p_width*p_this.value) + 'px ' + (p_height*p_this.value) + 'px';
}

function sorokOszlopokPozicionalasa(p_row_count, p_max_col_count, p_image_multiplier_old, p_image_multiplier_new){
	// 7, 6, 0.43, 0.4
	// alert(p_row_count + ', ' + p_max_col_count + ', ' + p_image_multiplier_old + ', ' + p_image_multiplier_new);
	
	var row_margin_left = 0;
	var row_margin_top = 0;
	var row_margin_left_new = 0;
	var row_margin_top_new = 0;
	
	var col_margin_left = 0;
	var col_margin_top = 0;
	var col_width = 0;
	var col_height = 0;
	var col_margin_left_new = 0;
	var col_margin_top_new = 0;
	var col_width_new = 0;
	var col_height_new = 0;
	
	//row: margin-top, margin-left
	for (var i = 0; i < p_row_count; i++){
		if(document.getElementById('lattice_row_' + i) != null){
			row_margin_left = parseInt(document.getElementById('lattice_row_' + i).style.marginLeft.replace("px", ""));
			row_margin_top = parseInt(document.getElementById('lattice_row_' + i).style.marginTop.replace("px", ""));
			
			row_margin_left_new = Math.round((row_margin_left/p_image_multiplier_old)*p_image_multiplier_new);
			row_margin_top_new = Math.round((row_margin_top/p_image_multiplier_old)*p_image_multiplier_new);
			
			document.getElementById('lattice_row_' + i).style.marginLeft = row_margin_left_new + "px";
			document.getElementById('lattice_row_' + i).style.marginTop = row_margin_top_new + "px";
			// alert( row_margin_left + ', ' + row_margin_top + ', ' + (row_margin_left_new) + ', ' + (row_margin_top_new));
			
			//col: background-size, margin-top, margin-left, width, height
			for (var ii = 0; ii < p_max_col_count; ii++){
				if(document.getElementById('row_' + i + '_col_' + ii)!=null){
					col_margin_left = parseInt(document.getElementById('row_' + i + '_col_' + ii).style.marginLeft.replace("px", ""));
					col_margin_top = parseInt(document.getElementById('row_' + i + '_col_' + ii).style.marginTop.replace("px", ""));
					col_width = parseInt(document.getElementById('row_' + i + '_col_' + ii).style.width.replace("px", ""));
					col_height = parseInt(document.getElementById('row_' + i + '_col_' + ii).style.height.replace("px", ""));
					
					col_margin_left_new = Math.round((col_margin_left/p_image_multiplier_old)*p_image_multiplier_new);
					col_margin_top_new = Math.round((col_margin_top/p_image_multiplier_old)*p_image_multiplier_new);
					col_width_new = Math.round((col_width/p_image_multiplier_old)*p_image_multiplier_new);
					col_height_new = Math.round((col_height/p_image_multiplier_old)*p_image_multiplier_new);
					
					document.getElementById('row_' + i + '_col_' + ii).style.backgroundSize = (col_width_new) + 'px ' + (col_height_new) + 'px';
					document.getElementById('row_' + i + '_col_' + ii).style.marginLeft = (col_margin_left_new) + "px";
					document.getElementById('row_' + i + '_col_' + ii).style.marginTop = (col_margin_top_new) + "px";
					document.getElementById('row_' + i + '_col_' + ii).style.width = (col_width_new) + "px";
					document.getElementById('row_' + i + '_col_' + ii).style.height = (col_height_new) + "px";
					// alert( '---' + col_margin_left + ', ' + col_margin_top + ', ' + col_width + ', ' + col_height + '---' + col_margin_left_new + ', ' + col_margin_top_new + ', ' + col_width_new + ', ' + col_height_new + '---' );
				}
			}
		}
		if(document.getElementById('deleted_row_' + i) != null){
			//alert(('deleted_row_' + i)+', '+p_image_multiplier_new);
			row_margin_left = parseInt(document.getElementById('deleted_row_' + i).style.marginLeft.replace("px", ""));
			row_margin_top = parseInt(document.getElementById('deleted_row_' + i).style.marginTop.replace("px", ""));
			row_width = parseInt(document.getElementById('deleted_row_' + i).style.width.replace("px", ""));
			
			row_margin_left_new = Math.round((row_margin_left/p_image_multiplier_old)*p_image_multiplier_new);
			row_margin_top_new = Math.round((row_margin_top/p_image_multiplier_old)*p_image_multiplier_new);
			row_width_new = Math.round((row_width/p_image_multiplier_old)*p_image_multiplier_new);
			
			document.getElementById('deleted_row_' + i).style.marginLeft = row_margin_left_new + "px";
			document.getElementById('deleted_row_' + i).style.marginTop = row_margin_top_new + "px";
			document.getElementById('deleted_row_' + i).style.width = row_width_new + "px";
		}
	}
}
