function strstr (haystack, needle, bool) {
	// Finds first occurrence of a string within another  
	// 
	// version: 1109.2015
	// discuss at: http://phpjs.org/functions/strstr    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   bugfixed by: Onno Marsman
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// *     example 1: strstr('Kevin van Zonneveld', 'van');
	// *     returns 1: 'van Zonneveld'    // *     example 2: strstr('Kevin van Zonneveld', 'van', true);
	// *     returns 2: 'Kevin '
	// *     example 3: strstr('name@example.com', '@');
	// *     returns 3: '@example.com'
	// *     example 4: strstr('name@example.com', '@', true);    // *     returns 4: 'name'
	var pos = 0;

	haystack += '';
	pos = haystack.indexOf(needle);
	if (pos == -1) {
		return false;
	}
	else {
		if (bool) {
			return haystack.substr(0, pos);
		}
		else {
			return haystack.slice(pos);
		}
	}
}

function csomagnevMegado(p_this){
	// html_tag.childNodes[j].options[html_tag.childNodes[j].selectedIndex].text
	var exam_value = document.getElementById('select_exam').value;
	var exam_text = document.getElementById('select_exam').options[document.getElementById('select_exam').selectedIndex].text;
	var hova_value = document.getElementById('select_hova').value;
	var hova_text = document.getElementById('select_hova').options[document.getElementById('select_hova').selectedIndex].text;
	
	var csomag_szoveg = '';
	var kar = '';
	var nyelv = '';
	if(exam_value != ''){
		kar = strstr(exam_text, 'GYTK');
		if(kar != false) kar = kar.substr(0,4);
		else{
			kar = strstr(exam_text, 'ÁOK');
			if(kar != false) kar = kar.substr(0,3);
			else kar = '';
		}
		
		nyelv = strstr(exam_text, 'HU');
		if(nyelv != false) nyelv = nyelv.substr(0,2);
		else{
			nyelv = strstr(exam_text, 'EN');
			if(nyelv != false) nyelv = nyelv.substr(0,2);
			else nyelv = '';
		}
		
		// alert(kar+','+nyelv);
		// alert('exam'+exam_value+', '+exam_text);
		// csomag_szoveg += exam_text;
		csomag_szoveg += kar;
		if(csomag_szoveg != '') csomag_szoveg += '_';
		csomag_szoveg += nyelv;
		
		if(csomag_szoveg != '') csomag_szoveg += '_';
		csomag_szoveg += exam_value;
	}
	if(hova_value != ''){
		// alert('hova'+hova_value+', '+hova_text);
		if(csomag_szoveg != '') csomag_szoveg += '_';
		csomag_szoveg += hova_text;
	}
	
	// alert(csomag_szoveg);
	
	document.getElementById('upload_csomag_eleje_hidden').value = csomag_szoveg;
	document.getElementById('upload_csomag_eleje').innerHTML = csomag_szoveg;
	//alert(exam_value+', '+exam_text+', '+hova_value+', '+hova_text);
}

function formSubmit2() {
  document.getElementById('look_exam_result').submit();
}

function formSubmit(e,form) {
  var key=e.keyCode || e.which;
  if (key==13){
    form.submit();
    return false;
  } else {
    return true;
  }
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function mOver(cell) {
	cell.style.cursor = 'pointer';
}

function mOut(cell) {
	cell.style.cursor = 'default';
}

function over_btn(p_this,p_url,p_file,p_ext){
	var kep_ball = p_url+'_application/images/'+p_file+'_left_selected.'+p_ext;
	var kep_kozep = p_url+'_application/images/'+p_file+'_middle_selected.'+p_ext;
	var kep_jobb = p_url+'_application/images/'+p_file+'_right_selected.'+p_ext;
	document.getElementById(p_this+'_btn_ball').style.backgroundImage="url(" + kep_ball + ")";
	document.getElementById(p_this+'_btn_kozep').style.backgroundImage="url(" + kep_kozep + ")";
	document.getElementById(p_this+'_btn_jobb').style.backgroundImage="url(" + kep_jobb + ")";
}

function out_btn(p_this,p_url,p_file,p_ext){
	var kep_ball = p_url+'_application/images/'+p_file+'_left.'+p_ext;
	var kep_kozep = p_url+'_application/images/'+p_file+'_middle.'+p_ext;
	var kep_jobb = p_url+'_application/images/'+p_file+'_right.'+p_ext;
	document.getElementById(p_this+'_btn_ball').style.backgroundImage="url(" + kep_ball + ")";
	document.getElementById(p_this+'_btn_kozep').style.backgroundImage="url(" + kep_kozep + ")";
	document.getElementById(p_this+'_btn_jobb').style.backgroundImage="url(" + kep_jobb + ")";
}

function popupCenteredWindow(p_url){
	var top=screen.availHeight/2-280;
	var left=screen.availWidth/2-300;
	window.open(p_url, '_blank', 'width=600, height=560, scrollbars=yes, resizable=yes, top='+top.toString()+', left='+left.toString());
}

function popupCustomCenteredWindow(p_url,p_width,p_height){
	var top=(screen.availHeight/2-p_height/2)|0;
	var left=(screen.availWidth/2-p_width/2)|0;
	window.open(p_url, '_blank', 'width='+p_width.toString()+', height='+p_height.toString()+', scrollbars=yes, resizable=yes, top='+top.toString()+', left='+left.toString());
}

function menuIconOver(p_id){
	document.getElementById(p_id).style.display = 'inline';
}

function menuIconOut(p_id){
	document.getElementById(p_id).style.display = 'none';
}

function pairingChangeSymbol(p_container_id, p_id){
	var hidden_value = document.getElementById(p_container_id).value;
	if(hidden_value != ''){
		document.getElementById(document.getElementById(p_container_id).value).style.color="#000000";
		document.getElementById(document.getElementById(p_container_id).value + '_namelist').style.color="#000000";
	}
		
	document.getElementById(p_id).style.color="#FF0000";
	document.getElementById(p_id + '_namelist').style.color="#FF0000";
	document.getElementById(p_container_id).value = p_id;
}

//--------------------------------------------------------------------------------------------------------------------------------------------
//Egy már meglévő választ törlök ki vele, átállítom a display-t és adok egy új hidden mezőt. Azért a display-vel játszok, mert removeChild elrontja a CKEDITOR-t működését.
function valaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_id, p_sorszam, p_elemi, p_custom_id){
	//document.getElementById(p_container_id).removeChild(document.getElementById(p_block_id));
	document.getElementById(p_block_id).style.display = 'none';
	
	//Az ellenőrzésnél ennek az értkét nézem, hogy a törölt elemet ne ellenőrizzem.
	document.getElementById(p_elemi+'kerdes_id_'+p_sorszam).value = 0;
	
	hidden_elem = document.createElement("INPUT");
  hidden_elem.type = 'hidden';
  hidden_elem.value = p_id;
  hidden_elem.name = 'custom_edit_kerdes_'+p_custom_id+'['+p_tagname+'][deleted]';
  document.getElementById(p_container_id).appendChild(hidden_elem);
	
	div = document.createElement("DIV");
  div.className = 'deleted_valasz';
  div.innerHTML = p_sorszam + '. TÖRÖLVE';
  document.getElementById(p_container_id).appendChild(div);
}

//Egy már meglévő elemi választ törlök ki vele, átállítom a display-t és adok egy új hidden mezőt. Azért a display-vel játszok, mert removeChild elrontja a CKEDITOR-t működését.
function elemiValaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_id, p_sorszam, p_custom_id){
	valaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_id, p_sorszam, 'elemi_', p_custom_id);
}

//Egy már meglévő asszociációs választ törlök ki vele, átállítom a display-t és adok egy új hidden mezőt. Azért a display-vel játszok, mert removeChild elrontja a CKEDITOR-t működését.
function asszocKerdesBlokkTorlese(p_container_id, p_block_id, p_tagname, p_id, p_sorszam, p_custom_id){
	valaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_id, p_sorszam, 'asszoc_', p_custom_id);
}

//Egy újonnan hozzáadott választ törlök ki vele, átállítom a display-t és adok egy új hidden mezőt. Azért a display-vel játszok, mert removeChild elrontja a CKEDITOR-t működését.
function ujValaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_valaszok_szama_id, p_elemi, p_custom_id){
	document.getElementById(p_block_id).style.display = 'none';
	
	//Az ellenőrzésnél ennek az értkét nézem, hogy a törölt elemet ne ellenőrizzem.
	document.getElementById(p_elemi+'kerdes_id_'+p_valaszok_szama_id).value = 0;
	
	hidden_elem = document.createElement("INPUT");
  hidden_elem.type = 'hidden';
  hidden_elem.value = 0;
  hidden_elem.name = 'custom_edit_kerdes_'+p_custom_id+'['+p_tagname+'][deleted_new]';
  document.getElementById(p_container_id).appendChild(hidden_elem);
}

//Egy újonnan hozzáadott elemi választ törlök ki vele, átállítom a display-t és adok egy új hidden mezőt. Azért a display-vel játszok, mert removeChild elrontja a CKEDITOR-t működését.
function ujElemiValaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_valaszok_szama_id, p_custom_id){
	ujValaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_valaszok_szama_id, 'elemi_', p_custom_id);
}

//Egy újonnan hozzáadott asszociációs választ törlök ki vele, átállítom a display-t és adok egy új hidden mezőt. Azért a display-vel játszok, mert removeChild elrontja a CKEDITOR-t működését.
function ujAsszocKerdesBlokkTorlese(p_container_id, p_block_id, p_tagname, p_valaszok_szama_id, p_custom_id){
	ujValaszBlokkTorlese(p_container_id, p_block_id, p_tagname, p_valaszok_szama_id, 'asszoc_', p_custom_id);
}

var new_id = 1;
var elemi_new_id = 1;
var asszoc_tetel_new_id = 1;
var asszoc_kerdes_new_id = 1;

function szerkesztoKirakasa(p_editor_id){
	var editor, html = '';
	if ( editor )
		return;
	editor = CKEDITOR.replace( p_editor_id, { toolbar : [ [ 'Bold', 'Italic', 'Underline', 'Strike', '-', 'Link', 'Image', '-', 'MyButton' ] ] }, html );
}

/*AZ ALATTA LEVŐ FV MÁSOLATA, TARTALÉKANK!!!!!!!!!!!!*/
/*function ujValaszBlokkHozzaadasa(p_container_id, p_kerdes_id, p_feladat_tipus){
	valaszok_szama = valaszok_szama + 1;
	var new_answer_block = '<table class="valasz_container" id="valasz_block_new__replace_new_id_" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2"><div class="asszoc_tarol_btn"><span style="font-weight:bold; float:left;">ÚJ</span><span class="torles_btn" onclick="var answer = confirm(\'Biztos vagy benne?\'); if(answer) ujValaszBlokkTorlese(\'valasz_blocks\',\'valasz_container_new__replace_new_id_\',\'valasz_new__replace_new_id_\',\''+valaszok_szama+'\',\'\',\''+p_feladat_tipus+'\');"></span></td></tr><tr><td colspan="2"><input type="hidden" id="kerdes_id_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][kerdes_id]" value="_replace_kerdes_id_" />Betűjel: <input class="admin_betujel_input" type="edit" id="betujel_id_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][betujel]" value="" /><span class="admin_helyes">Helyes: <input type="checkbox" id="helyes_id_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][helyes]" value="0" /></span></td></tr><tr><td colspan="2"><div class="margin_top_8_bottom_4">Szöveg</div></td></tr><tr><td colspan="2"><div class="cke_valasz_szoveg"><textarea cols="60" id="szoveg'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][szoveg]" rows="3"></textarea></div></td></tr><tr><td colspan="2"><div class="margin_top_8_bottom_4">Magyarazat</div></td></tr><tr><td colspan="2"><div class="cke_valasz_magyarazat"><textarea cols="60" id="magyarazat'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][magyarazat]" rows="3"></textarea></div></td></tr><tr><td class="admin_valasz_separator_sor" colspan="2"><div></div></td></tr></table>';
	
	div = document.createElement("DIV");
  div.id = 'valasz_container_new_' + new_id;
	var innner_context = new_answer_block.replace(/_replace_new_id_/gi, new_id);
	innner_context = innner_context.replace(/_replace_kerdes_id_/gi, p_kerdes_id);
  div.innerHTML = innner_context;
  document.getElementById(p_container_id).appendChild(div);
	szerkesztoKirakasa('szoveg'+valaszok_szama);
	szerkesztoKirakasa('magyarazat'+valaszok_szama);
	new_id = new_id + 1;
}*/

function szerkesztoKirakasaXINHA(p_editor_id, p_hash, p_sessID, p_user_id){
	var user_id_len = p_user_id.length;
	var ser_len1 = 50 + user_id_len;
	var ser_len2 = 38 + user_id_len;
	xinha_editors_js = null; xinha_init_js = null; xinha_config_js = null; xinha_plugins_js = null;
	xinha_init_js = xinha_init_js ? xinha_init_js : function()
	{
		xinha_plugins_js = xinha_plugins_js ? xinha_plugins_js : ['CharacterMap', 'SpellChecker', 'Linker', 'ContextMenu', 'ImageManager', 'ExtendedFileManager'];
		if(!Xinha.loadPlugins(xinha_plugins_js, xinha_init_js)) return;
		xinha_editors_js = xinha_editors_js ? xinha_editors_js : [p_editor_id];
		xinha_config_js = xinha_config_js ? xinha_config_js : new Xinha.Config();with(xinha_config_js.ImageManager){
		backend_data = {
			'backend_data[data]': 'a:2:\x7Bs:10:\x22images_dir\x22;s:'+ser_len1+':\x22../../../../../_userfiles/kerdes_kepek/new_userid_'+p_user_id+'\x22;s:10:\x22images_url\x22;s:'+ser_len2+':\x22../_userfiles/kerdes_kepek/new_userid_'+p_user_id+'\x22;\x7D',
			'backend_data[session_name]': 'PHPSESSID',
			'backend_data[key_location]': 'Xinha:BackendKey',
			'backend_data[hash]': '\'' + p_hash + '\'',
			PHPSESSID: '\'' + p_sessID + '\''
			};
		}
		xinha_config_js.fullPage = false;
		xinha_config_js.CharacterMap.mode = 'panel';
		xinha_config_js.ContextMenu.customHooks = { 'a': [ ['Label', function() { alert('Action'); }, 'Tooltip', '../_framework/thirdparty/xinha/images/ed_copy.gif' ] ] }
		xinha_config_js.pageStyleSheets = [""];
		xinha_editors_js = Xinha.makeEditors(xinha_editors_js, xinha_config_js, xinha_plugins_js);
		Xinha.startEditors(xinha_editors_js);
	}
	xinha_init_js();
}

function ujValaszBlokkHozzaadasa(p_container_id, p_kerdes_id, p_feladat_tipus, p_hash, p_sessID, p_user_id){
	valaszok_szama = valaszok_szama + 1;
	var new_answer_block = '<table class="valasz_container" id="valasz_block_new__replace_new_id_" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2"><div class="asszoc_tarol_btn"><span style="font-weight:bold; float:left;">ÚJ</span><span class="torles_btn" onclick="var answer = confirm(\'Biztos vagy benne?\'); if(answer) ujValaszBlokkTorlese(\'valasz_blocks\',\'valasz_container_new__replace_new_id_\',\'valasz_new__replace_new_id_\',\''+valaszok_szama+'\',\'\',\''+p_feladat_tipus+'\');"></span></td></tr><tr><td colspan="2"><input type="hidden" id="kerdes_id_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][kerdes_id]" value="_replace_kerdes_id_" />Betűjel: <input class="admin_betujel_input" type="edit" id="betujel_id_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][betujel]" value="" /><span class="admin_helyes">Helyes: <input type="checkbox" id="helyes_id_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][helyes]" value="0" /></span></td></tr><tr><td colspan="2"><div class="margin_top_8_bottom_4">Szöveg</div></td></tr><tr><td colspan="2"><div class="cke_valasz_szoveg"><textarea id="szoveg_sz_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][szoveg]" style="width:685px; height:60px;"></textarea></div></td></tr><tr><td colspan="2"><div class="margin_top_8_bottom_4">Magyarazat</div></td></tr><tr><td colspan="2"><div class="cke_valasz_magyarazat"><textarea id="magyarazat_m_'+valaszok_szama+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_new_id_][magyarazat]" style="width:685px; height:60px;"></textarea></div></td></tr><tr><td class="admin_valasz_separator_sor" colspan="2"><div></div></td></tr></table>';
	
	div = document.createElement("DIV");
  div.id = 'valasz_container_new_' + new_id;
	var innner_context = new_answer_block.replace(/_replace_new_id_/gi, new_id);
	innner_context = innner_context.replace(/_replace_kerdes_id_/gi, p_kerdes_id);
  div.innerHTML = innner_context;
  document.getElementById(p_container_id).appendChild(div);
	//szerkesztoKirakasa('szoveg'+valaszok_szama);
	szerkesztoKirakasaXINHA('szoveg_sz_'+valaszok_szama, p_hash, p_sessID, p_user_id);
	szerkesztoKirakasaXINHA('magyarazat_m_'+valaszok_szama, p_hash, p_sessID, p_user_id);
	new_id = new_id + 1;
}

function ujElemiValaszBlokkHozzaadasa(p_container_id, p_kerdes_id, p_feladat_tipus, p_hash, p_sessID, p_user_id){
	elemi_valaszok_szama = elemi_valaszok_szama + 1;
	var uj_elemi_valasz_block = '<table class="valasz_container" id="elemi_valasz_block_new__replace_elemi_new_id_" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2"><div class="asszoc_tarol_btn"><span style="font-weight:bold; float:left;">ÚJ</span><input type="hidden" id="elemi_kerdes_id_'+elemi_valaszok_szama+'" name="custom_edit_kerdes_2[elemi_valasz_new__replace_elemi_new_id_][kerdes_id]" value="_replace_elemi_kerdes_id_" /><span class="torles_btn" onclick="var answer = confirm(\'Biztos vagy benne?\'); if(answer) ujElemiValaszBlokkTorlese(\'elemi_valasz_blocks\',\'elemi_valasz_container_new__replace_elemi_new_id_\',\'elemi_valasz_new__replace_elemi_new_id_\',\''+elemi_valaszok_szama+'\',\''+p_feladat_tipus+'\');"></span></div></td></tr><tr><td>Szám: <input class="admin_sorszam_input" type="edit" id="szam_'+elemi_valaszok_szama+'" name="custom_edit_kerdes_2[elemi_valasz_new__replace_elemi_new_id_][szam]" value="" /></td></tr><tr><td colspan="2"><div class="margin_top_8_bottom_4">Szöveg</div></td></tr><tr><td colspan="2"><div class="cke_elemi_valasz_szoveg"><textarea id="elemi_szoveg'+elemi_valaszok_szama+'" name="custom_edit_kerdes_2[elemi_valasz_new__replace_elemi_new_id_][szoveg]" style="width:685px; height:60px;"></textarea></div></td></tr><tr><td class="admin_valasz_separator_sor" colspan="2"><div></div></td></tr></table>';
	
	div = document.createElement("DIV");
  div.id = 'elemi_valasz_container_new_' + elemi_new_id;
	var innner_context = uj_elemi_valasz_block.replace(/_replace_elemi_new_id_/gi, elemi_new_id);
	innner_context = innner_context.replace(/_replace_elemi_kerdes_id_/gi, p_kerdes_id);
  div.innerHTML = innner_context;
  document.getElementById(p_container_id).appendChild(div);
	szerkesztoKirakasaXINHA('elemi_szoveg'+elemi_valaszok_szama, p_hash, p_sessID, p_user_id);
	elemi_new_id = elemi_new_id + 1;
}

function ujAsszocTetelBlokkHozzaadasa(p_container_id, p_asszoc_leiras_id, p_feladat_tipus, p_hash, p_sessID, p_user_id){
	asszociacios_leiras_tetel = asszociacios_leiras_tetel + 1;
	var new_answer_block = '<table class="valasz_container" id="valasz_block_new__replace_asszoc_leiras_new_id_" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2"><div class="asszoc_tarol_btn"><span style="font-weight:bold; float:left;">ÚJ</span><span class="torles_btn" onclick="var answer = confirm(\'Biztos vagy benne?\'); if(answer) ujValaszBlokkTorlese(\'valasz_blocks\',\'valasz_container_new__replace_asszoc_leiras_new_id_\',\'valasz_new__replace_asszoc_leiras_new_id_\',\''+asszociacios_leiras_tetel+'\',\'\',\''+p_feladat_tipus+'\');"></span></div></td></tr><tr><td><div class="admin_betujel"><input type="hidden" id="kerdes_id_'+asszociacios_leiras_tetel+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_asszoc_leiras_new_id_][asszociacios_leiras_id]" value="_replace_asszoc_leiras_id_" />Betűjel: <input type="edit" id="betujel_id_'+asszociacios_leiras_tetel+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_asszoc_leiras_new_id_][betujel]" value="" /></div></td></tr><tr><td colspan="2"><div class="margin_top_8_bottom_4">Szöveg</div></td></tr><tr><td colspan="2"><div class="valaszok_ckeditor cke_tetel_szoveg"><textarea id="szoveg'+asszociacios_leiras_tetel+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[valasz_new__replace_asszoc_leiras_new_id_][szoveg]" style="width:685px; height:60px;"></textarea></div></td></tr><tr><td class="admin_valasz_separator_sor" colspan="2"><div></div></td></tr></table>';
	
	div = document.createElement("DIV");
  div.id = 'valasz_container_new_' + asszoc_tetel_new_id;
	var innner_context = new_answer_block.replace(/_replace_asszoc_leiras_new_id_/gi, asszoc_tetel_new_id);
	innner_context = innner_context.replace(/_replace_asszoc_leiras_id_/gi, p_asszoc_leiras_id);
  div.innerHTML = innner_context;
  document.getElementById(p_container_id).appendChild(div);
	szerkesztoKirakasaXINHA('szoveg'+asszociacios_leiras_tetel, p_hash, p_sessID, p_user_id);
	asszoc_tetel_new_id = asszoc_tetel_new_id + 1;
}

function ujAsszocKerdesBlokkHozzaadasa(p_container_id, p_asszoc_kerdes_id, p_feladat_tipus, p_hash, p_sessID, p_user_id){
	asszociacios_kerdes = asszociacios_kerdes + 1;
	var new_answer_block = '<table class="valasz_container" id="asszoc_kerdes_block_new__replace_asszoc_kerdes_new_id_" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2"><div class="asszoc_tarol_btn"><span style="font-weight:bold; float:left;">ÚJ</span><span class="torles_btn" onclick="var answer = confirm(\'Biztos vagy benne?\'); if(answer) ujAsszocKerdesBlokkTorlese(\'asszoc_kerdes_blocks\',\'asszoc_kerdes_container_new__replace_asszoc_kerdes_new_id_\',\'asszoc_kerdes_new__replace_asszoc_kerdes_new_id_\',\''+asszociacios_kerdes+'\',\''+p_feladat_tipus+'\');"></span></div></td></tr><tr><td><input type="hidden" id="asszoc_kerdes_id_'+asszociacios_kerdes+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][asszociacios_leiras_id]" value="_replace_asszoc_kerdes_id_" /><div class="admin_kerdes asszoc_feladatcsoport_id" id="feladatcsoport_id_'+asszociacios_kerdes+'"><label>Feladatcsoport*</label><span class="cppeditcombocontrol_left"></span><select id="feladatcsoport_id_'+asszociacios_kerdes+'_select" size="1" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][feladatcsoport_id]" title="Feladatcsoport" class="cppeditcombocontrol">_feladat_tipus_option_</select><span class="cppeditcombocontrol_right"></span></div></td><td><div class="admin_kerdes" id="feladat_tipus_id"><input type="hidden" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][feladat_tipus_id]" value="3" /></div></td></tr><tr><td colspan="2"><table class="sorszam_mezok" border="0" cellspacing="0" cellpadding="0"><tr><td><div class="admin_kerdes" id="sorszam_'+asszociacios_kerdes+'"><label>Sorszám<span>*</span></label><span class="cppeditcontrol_left"></span><input type="text" align="left" title="Sorszám" class="cppeditcontrol" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][sorszam]" value="" /><span class="cppeditcontrol_right"></span></div></td><td>&nbsp;</td><td><div class="admin_kerdes" id="alsorszam_'+asszociacios_kerdes+'"><label>Alsorszám<span>*</span></label><span class="cppeditcontrol_left"></span><input type="text" align="left" title="Al sorszám" class="cppeditcontrol" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][alsorszam]" value="" /><span class="cppeditcontrol_right"></span></div></td><td>&nbsp;</td><td><div class="admin_kerdes"><label>Sub sorszám</label><span class="cppeditcontrol_left"></span><input type="text" align="left" title="Sub sorszám" class="cppeditcontrol" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][subsorszam]" value="" /><span class="cppeditcontrol_right"></span></div></td></tr></table></td></tr><tr><td colspan="2"><div class="admin_kerdes cke_kerdes_leiras"><label>Kérdés leírása<span>*</span></label><textarea id="asszoc_kerdes'+asszociacios_kerdes+'" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][leiras]" style="width:685px; height:60px;"></textarea></div></td></tr><tr><td colspan="2"><table class="nehezseg_aktiv_nemperm" border="0" cellspacing="0" cellpadding="0"><tr><td><div class="admin_kerdes admin_nehezseg" id="nehezseg_'+asszociacios_kerdes+'"><label>Nehézség</label><span class="cppeditcombocontrol_left"></span><select id="nehezseg_'+asszociacios_kerdes+'_select" size="1" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][nehezseg]" title="Nehézség" class="cppeditcombocontrol">_nehezseg_option_</select><span class="cppeditcombocontrol_right"></span></div></td><td><div class="admin_kerdes"><label>Aktív</label><span><input class="cppcheckeditcontrol" type="checkbox" align="left" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][aktiv]" value="" title="Aktív" /></span></div></td><td><div class="admin_kerdes"><label>Nem permutált</label><span><input class="cppcheckeditcontrol" type="checkbox" align="left" name="custom_edit_kerdes_'+p_feladat_tipus+'[asszoc_kerdes_new__replace_asszoc_kerdes_new_id_][nemperm]" value="" title="Nem permutált" /></span></div></td></tr></table></td></tr><tr><td class="admin_valasz_separator_sor" colspan="2"><div></div></td></tr></table>';
	
	new_answer_block = new_answer_block.replace(/_feladat_tipus_option_/gi, document.getElementById('feladatcsoport_combo').innerHTML);
	new_answer_block = new_answer_block.replace(/_nehezseg_option_/gi, document.getElementById('nehezseg_combo').innerHTML);
	
	div = document.createElement("DIV");
  div.id = 'asszoc_kerdes_container_new_' + asszoc_kerdes_new_id;
	var innner_context = new_answer_block.replace(/_replace_asszoc_kerdes_new_id_/gi, asszoc_kerdes_new_id);
	innner_context = innner_context.replace(/_replace_asszoc_kerdes_id_/gi, p_asszoc_kerdes_id);
  div.innerHTML = innner_context;
  document.getElementById(p_container_id).appendChild(div);
	szerkesztoKirakasaXINHA('asszoc_kerdes'+asszociacios_kerdes, p_hash, p_sessID, p_user_id);
	asszoc_kerdes_new_id = asszoc_kerdes_new_id + 1;
}

function strip_tags(input, allowed) {
	/*http://phpjs.org/functions/strip_tags:535*/
	allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('');
	var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi, commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
	return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';});
}

function kerdesEllenorzese(){
	var ures_szoveg_ell = true;
	var ellenorizendo_combo = new Array('feladatcsoport_id');//, 'feladat_tipus_id'
	var ellenorizendo_edit = new Array('sorszam', 'alsorszam');
	
	for(var i=0;i<ellenorizendo_combo.length;i++){
		html_tag = document.getElementById(ellenorizendo_combo[i]);
		for (var j=0;j<html_tag.childNodes.length;j++){
			if (html_tag.childNodes[j].nodeName == 'SELECT'){
				if(html_tag.childNodes[j].options[html_tag.childNodes[j].selectedIndex].text == '---'){
					ures_szoveg_ell = false;
				}
			}
		}
	}
	
	for(var i=0;i<ellenorizendo_edit.length;i++){
		html_tag = document.getElementById(ellenorizendo_edit[i]);
		for (var j=0;j<html_tag.childNodes.length;j++){
			if (html_tag.childNodes[j].nodeName == 'INPUT'){
				if(html_tag.childNodes[j].value == ''){
					ures_szoveg_ell = false;
				}
			}
		}
	}
	
	var td_tag =  document.getElementById('cke_contents_leiras_editor');
	for (var k=0;k<td_tag.childNodes.length;k++){
		if (td_tag.childNodes[k].nodeName == 'IFRAME'){
			if ( td_tag.childNodes[k].contentDocument ) { // FF
				iFrameBody = td_tag.childNodes[k].contentDocument.getElementsByTagName('body')[0];
			}
			else if ( td_tag.childNodes[k].contentWindow ) { // IE
				iFrameBody = td_tag.childNodes[k].contentWindow.document.getElementsByTagName('body')[0];
			}
		}
	}
	szoveg_pucolt = strip_tags(iFrameBody.innerHTML);
	if(szoveg_pucolt=='') ures_szoveg_ell = false;
	
	if(ures_szoveg_ell) return true;
	else{
		hibauzenet = 'Üres kötelező mezők a kérdés leírása részben!';
		alert(hibauzenet);
		return false;
	}
}

function valaszokEllenorzese(){
	var betuk = new Array();
	var betujel_egyezes_ell = true;
	var betujel_ures_ell = true;
	var helyes_ell = false;
	var ures_szoveg_ell = true;
	
	for (var i=1; i<=valaszok_szama; i++){
		if(document.getElementById('kerdes_id_' + i).value!=0){
			var td_tag =  document.getElementById('cke_contents_szoveg' + i);
			for (var k=0;k<td_tag.childNodes.length;k++){
				if (td_tag.childNodes[k].nodeName == 'IFRAME'){
					if ( td_tag.childNodes[k].contentDocument ) { // FF
						iFrameBody = td_tag.childNodes[k].contentDocument.getElementsByTagName('body')[0];
					}
					else if ( td_tag.childNodes[k].contentWindow ) { // IE
						iFrameBody = td_tag.childNodes[k].contentWindow.document.getElementsByTagName('body')[0];
					}
				}
			}
			
			szoveg_pucolt = strip_tags(iFrameBody.innerHTML);
			betuk_length = betuk.length;
			for (var j = 0; j < betuk.length; j++){
				if(betuk[j]==document.getElementById('betujel_id_' + i).value.toUpperCase()) betujel_egyezes_ell = false;
				//alert(betuk[j]);
			}
			betuk[betuk_length] = document.getElementById('betujel_id_' + i).value.toUpperCase();
			
			// alert(document.getElementById('betujel_id_' + i).value+', '+document.getElementById('helyes_id_' + i).value+', '+iFrameBody.innerHTML+', '+szoveg_pucolt);
			// alert(document.getElementById('helyes_id_' + i).value + ', ' + document.getElementById('helyes_id_' + i).checked);
			if(document.getElementById('helyes_id_' + i).value==1 || document.getElementById('helyes_id_' + i).checked) helyes_ell = true;
			if(szoveg_pucolt=='') ures_szoveg_ell = false;
			if(document.getElementById('betujel_id_' + i).value=='') betujel_ures_ell = false;
		}
	}
	// alert(betujel_egyezes_ell+','+betujel_ures_ell+','+helyes_ell+','+ures_szoveg_ell+', '+valaszok_szama);
	if(valaszok_szama==0) return true;
	else if(betujel_egyezes_ell && betujel_ures_ell && helyes_ell && ures_szoveg_ell) return true;
	else{
		hibauzenet = '';
		if(betujel_egyezes_ell===false) hibauzenet = 'A betűjelek nem egyediek!';
		if(betujel_ures_ell===false) hibauzenet = hibauzenet + ' Üres betűjel mező!';
		if(helyes_ell===false) hibauzenet = hibauzenet + ' Nincs legalább egy helyesnek bejelölve!';
		if(ures_szoveg_ell===false) hibauzenet = hibauzenet + ' Üres szövegmező hiba!';
		alert(hibauzenet);
		return false;
	}
}

function elemiValaszokEllenorzese(){
	var szamok = new Array();
	var szamok_egyezes_ell = true;
	var szamok_ures_ell = true;
	var ures_szoveg_ell = true;
	
	for (var i=1; i<=elemi_valaszok_szama; i++){
		if(document.getElementById('elemi_kerdes_id_' + i).value!=0){
			var td_tag =  document.getElementById('cke_contents_elemi_szoveg' + i);
			for (var k=0;k<td_tag.childNodes.length;k++){
				if (td_tag.childNodes[k].nodeName == 'IFRAME'){
					if ( td_tag.childNodes[k].contentDocument ) { // FF
						iFrameBody = td_tag.childNodes[k].contentDocument.getElementsByTagName('body')[0];
					}
					else if ( td_tag.childNodes[k].contentWindow ) { // IE
						iFrameBody = td_tag.childNodes[k].contentWindow.document.getElementsByTagName('body')[0];
					}
				}
			}
			
			szoveg_pucolt = strip_tags(iFrameBody.innerHTML);
			szamok_length = szamok.length;
			for (var j = 0; j < szamok.length; j++){
				if(szamok[j]==document.getElementById('szam_' + i).value.toUpperCase()) szamok_egyezes_ell = false;
			}
			szamok[szamok_length] = document.getElementById('szam_' + i).value.toUpperCase();
			
			if(szoveg_pucolt=='') ures_szoveg_ell = false;
			if(document.getElementById('szam_' + i).value=='') szamok_ures_ell = false;
		}
	}
	//alert(szamok_egyezes_ell+','+szamok_ures_ell+','+ures_szoveg_ell+', '+elemi_valaszok_szama);
	if(elemi_valaszok_szama==0) return true;
	else if(szamok_egyezes_ell && szamok_ures_ell && ures_szoveg_ell) return true;
	else{
		hibauzenet = '';
		if(szamok_egyezes_ell===false) hibauzenet = 'A számok nem egyediek!';
		if(szamok_ures_ell===false) hibauzenet = hibauzenet + ' Üres szám mező!';
		if(ures_szoveg_ell===false) hibauzenet = hibauzenet + ' Üres szövegmező hiba!';
		alert(hibauzenet);
		return false;
	}
}

function asszociaciosLeirasEllenorzese(){
	var ures_szoveg_ell = true;
	var ellenorizendo_combo = new Array('feladatcsoport_id');
	
	for(var i=0;i<ellenorizendo_combo.length;i++){
		html_tag = document.getElementById(ellenorizendo_combo[i]);
		for (var j=0;j<html_tag.childNodes.length;j++){
			if (html_tag.childNodes[j].nodeName == 'SELECT'){
				if(html_tag.childNodes[j].options[html_tag.childNodes[j].selectedIndex].text == '---'){
					ures_szoveg_ell = false;
				}
			}
		}
	}
	
	var td_tag =  document.getElementById('cke_contents_leiras_editor');
	for (var k=0;k<td_tag.childNodes.length;k++){
		if (td_tag.childNodes[k].nodeName == 'IFRAME'){
			if ( td_tag.childNodes[k].contentDocument ) { // FF
				iFrameBody = td_tag.childNodes[k].contentDocument.getElementsByTagName('body')[0];
			}
			else if ( td_tag.childNodes[k].contentWindow ) { // IE
				iFrameBody = td_tag.childNodes[k].contentWindow.document.getElementsByTagName('body')[0];
			}
		}
	}
	szoveg_pucolt = strip_tags(iFrameBody.innerHTML);
	if(szoveg_pucolt=='') ures_szoveg_ell = false;
	
	if(ures_szoveg_ell) return true;
	else{
		hibauzenet = 'Üres kötelező mezők a kérdés leírása részben!';
		alert(hibauzenet);
		return false;
	}
}

function asszociaciosTetelekEllenorzese(){
	var betuk = new Array();
	var betujel_egyezes_ell = true;
	var betujel_ures_ell = true;
	var ures_szoveg_ell = true;
	
	for (var i=1; i<=asszociacios_leiras_tetel; i++){
		if(document.getElementById('kerdes_id_' + i).value!=0){
			var td_tag =  document.getElementById('cke_contents_szoveg' + i);
			for (var k=0;k<td_tag.childNodes.length;k++){
				if (td_tag.childNodes[k].nodeName == 'IFRAME'){
					if ( td_tag.childNodes[k].contentDocument ) { // FF
						iFrameBody = td_tag.childNodes[k].contentDocument.getElementsByTagName('body')[0];
					}
					else if ( td_tag.childNodes[k].contentWindow ) { // IE
						iFrameBody = td_tag.childNodes[k].contentWindow.document.getElementsByTagName('body')[0];
					}
				}
			}
			
			szoveg_pucolt = strip_tags(iFrameBody.innerHTML);
			betuk_length = betuk.length;
			for (var j = 0; j < betuk.length; j++){
				if(betuk[j]==document.getElementById('betujel_id_' + i).value.toUpperCase()) betujel_egyezes_ell = false;
			}
			betuk[betuk_length] = document.getElementById('betujel_id_' + i).value.toUpperCase();
			
			if(szoveg_pucolt=='') ures_szoveg_ell = false;
			if(document.getElementById('betujel_id_' + i).value=='') betujel_ures_ell = false;
		}
	}
	if(asszociacios_leiras_tetel==0) return true;
	else if(betujel_egyezes_ell && betujel_ures_ell && ures_szoveg_ell) return true;
	else{
		hibauzenet = '';
		if(betujel_egyezes_ell===false) hibauzenet = 'A betűjelek nem egyediek!';
		if(betujel_ures_ell===false) hibauzenet = hibauzenet + ' Üres betűjel mező!';
		if(ures_szoveg_ell===false) hibauzenet = hibauzenet + ' Üres szövegmező hiba!';
		alert(hibauzenet);
		return false;
	}
}

function asszociaciosKerdesekEllenorzese(){
	var ures_szoveg_ell = true;
	var ellenorizendo_combo = new Array('feladatcsoport_id');
	var ellenorizendo_edit = new Array('sorszam', 'alsorszam');
	
	for (var g=1; g<=asszociacios_kerdes; g++){
		if(document.getElementById('asszoc_kerdes_id_' + g).value!=0){
			for(var i=0;i<ellenorizendo_combo.length;i++){
				html_tag = document.getElementById(ellenorizendo_combo[i]+'_'+g);
				for (var j=0;j<html_tag.childNodes.length;j++){
					if (html_tag.childNodes[j].nodeName == 'SELECT'){
						if(html_tag.childNodes[j].options[html_tag.childNodes[j].selectedIndex].text == '---'){
							ures_szoveg_ell = false;
						}
					}
				}
			}
			
			for(var i=0;i<ellenorizendo_edit.length;i++){
				html_tag = document.getElementById(ellenorizendo_edit[i]+'_'+g);
				for (var j=0;j<html_tag.childNodes.length;j++){
					if (html_tag.childNodes[j].nodeName == 'INPUT'){
						if(html_tag.childNodes[j].value == ''){
							ures_szoveg_ell = false;
						}
					}
				}
			}
			
			var td_tag =  document.getElementById('cke_contents_asszoc_kerdes'+g);
			for (var k=0;k<td_tag.childNodes.length;k++){
				if (td_tag.childNodes[k].nodeName == 'IFRAME'){
					if ( td_tag.childNodes[k].contentDocument ) { // FF
						iFrameBody = td_tag.childNodes[k].contentDocument.getElementsByTagName('body')[0];
					}
					else if ( td_tag.childNodes[k].contentWindow ) { // IE
						iFrameBody = td_tag.childNodes[k].contentWindow.document.getElementsByTagName('body')[0];
					}
				}
			}
			szoveg_pucolt = strip_tags(iFrameBody.innerHTML);
			if(szoveg_pucolt=='') ures_szoveg_ell = false;
		}
	}
	
	if(ures_szoveg_ell) return true;
	else{
		hibauzenet = 'Üres kötelező mező kérdés megadásban!';
		alert(hibauzenet);
		return false;
	}
}

function comboTartalomEllenorzes(p_combo_id){
	if(document.getElementById(p_combo_id).value==0) return false;
	else return true;
}

//---------------------------------------------------------SAROKPONT---------------------------------------------------------
var sarok_x1 = 0; var sarok_y1 = 0;
var sarok_x2 = 0; var sarok_y2 = 0;
var sarok_x3 = 0; var sarok_y3 = 0;
var sarok_x4 = 0; var sarok_y4 = 0;

function kepAtmeretezese(p_doboz_id, p_width, p_height, p_this){
	imagesize = p_this.value;
	document.getElementById(p_doboz_id).style.width = (p_width*imagesize) + 'px';
	document.getElementById(p_doboz_id).style.height = (p_height*imagesize) + 'px';
	document.getElementById(p_doboz_id).style.backgroundSize = (p_width*imagesize) + 'px ' + (p_height*imagesize) + 'px';
	pontokTorlese();
}

function mouseClick(p_url, evt){
	document.getElementById('detektalas_eredmeny').style.display = 'none';
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null );
	evt = (evt) ? evt : ((event) ? event : null);

	xpo = evt.clientX;
	ypo = evt.clientY;

	var posx = document.getElementById('kep_tarto').offsetLeft;
	var posy = document.getElementById('kep_tarto').offsetTop;
	var scrollLeft = f_scrollLeft();
	var scrollTop = f_scrollTop();
	var pont_id = 0;
	//alert("X-coord: " + xpo + " Y-coord: " + ypo + " Left: " + posx + " Top: " + posy);
	
	if(sarok_x1==0 && sarok_y1==0 && sarok_x2==0 && sarok_y2==0){
		sarok_x1 = Math.floor(((xpo+scrollLeft)-posx)/imagesize);
		sarok_y1 = Math.floor(((ypo+scrollTop)-posy)/imagesize);
		pont_id = 1;
	}
	else if(sarok_x1 > 0 && sarok_y1 > 0 && sarok_x2==0 && sarok_y2==0){
		sarok_x2 = Math.floor(((xpo+scrollLeft)-posx)/imagesize);
		sarok_y2 = Math.floor(((ypo+scrollTop)-posy)/imagesize);
		pont_id = 2;
	}
	else if(sarok_x3==0 && sarok_y3==0 && sarok_x4==0 && sarok_y4==0){
		sarok_x3 = Math.floor(((xpo+scrollLeft)-posx)/imagesize);
		sarok_y3 = Math.floor(((ypo+scrollTop)-posy)/imagesize);
		pont_id = 3;
	}
	else if(sarok_x3 > 0 && sarok_y3 > 0 && sarok_x4==0 && sarok_y4==0){
		sarok_x4 = Math.floor(((xpo+scrollLeft)-posx)/imagesize);
		sarok_y4 = Math.floor(((ypo+scrollTop)-posy)/imagesize);
		pont_id = 4;
	}
	else{
		pontokTorlese();
		sarok_x1 = Math.floor(((xpo+scrollLeft)-posx)/imagesize);
		sarok_y1 = Math.floor(((ypo+scrollTop)-posy)/imagesize);
		pont_id = 1;
	}
	
	var piros_potty = p_url+'_application/images/piros_potty_8x8.png';
	div = document.createElement("DIV");
	div.id = pont_id+'_sarokpont';
	div.className = pont_id+'_sarokpont';
	div.style.backgroundImage = "url(" + piros_potty + ")";
	div.style.position = "absolute";
	div.style.top = (ypo+scrollTop-5)+"px";
	div.style.left = (xpo+scrollLeft-5)+"px";
	div.style.width = "8px";
	div.style.height = "8px";
	document.getElementById('kep_doboz').appendChild(div);
}

function pontokTorleseBal(){
	if(document.getElementById('1_sarokpont') != null) document.getElementById('kep_doboz').removeChild(document.getElementById('1_sarokpont'));
	if(document.getElementById('2_sarokpont') != null) document.getElementById('kep_doboz').removeChild(document.getElementById('2_sarokpont'));
	sarok_x1 = 0; sarok_y1 = 0;
	sarok_x2 = 0; sarok_y2 = 0;
}

function pontokTorleseJobb(){
	if(document.getElementById('3_sarokpont') != null) document.getElementById('kep_doboz').removeChild(document.getElementById('3_sarokpont'));
	if(document.getElementById('4_sarokpont') != null) document.getElementById('kep_doboz').removeChild(document.getElementById('4_sarokpont'));
	sarok_x3 = 0; sarok_y3 = 0;
	sarok_x4 = 0; sarok_y4 = 0;
}

function pontokTorlese(){
	pontokTorleseBal();
	pontokTorleseJobb();
}

function koordinatakKuldese(p_url,p_tesztlap_id){
	if((sarok_x1 > 0 && sarok_y1 > 0 && sarok_x2 > 0 && sarok_y2 > 0 && sarok_x3 > 0 && sarok_y3 > 0 && sarok_x4 > 0 && sarok_y4 > 0) || (sarok_x1 > 0 && sarok_y1 > 0 && sarok_x2 > 0 && sarok_y2 > 0 && sarok_x3 == 0 && sarok_y3 == 0 && sarok_x4 == 0 && sarok_y4 == 0)){
		sarokpontFeldolgozas(p_tesztlap_id,sarok_x1,sarok_y1,sarok_x2,sarok_y2,sarok_x3,sarok_y3,sarok_x4,sarok_y4);
		return true;
		//window.location = p_url+"admin/?tesztlap_sarokpont[okbutton]=Ok";
	}
	else{
		alert('Nincs meg minden koordináta! ('+sarok_x1+','+sarok_y1+'), ('+sarok_x2+','+sarok_y2+'), ('+sarok_x3+','+sarok_y3+'), ('+sarok_x4+','+sarok_y4+')');
		return false;
	}
}

function XYKiirato(){
	alert('kép szorzó:'+imagesize+' ('+sarok_x1+','+sarok_y1+'), ('+sarok_x2+','+sarok_y2+'), ('+sarok_x3+','+sarok_y3+'), ('+sarok_x4+','+sarok_y4+')');
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

//---------------------------------------------------------WEBES TESZTVIZSGA---------------------------------------------------------
function get_checked_count(form_name) {
	var r = 0;
	var f;
	f = document.getElementsByName(form_name);
	if (f.length > 0) {
		f = f[0];
		for (var i=0;i<f.elements.length;i++) {
			if (f.elements[i].type == 'checkbox'
					&& f.elements[i].checked) r++;
		}
	}
	return r;
}

function refresh_sub_pager(tol) {
  var htmlstr, sub_pager, i;
  htmlstr = '';
  // alert(((Math.floor((tol-1)/10)*10)+1)+'-->>'+((Math.floor((tol-1)/10+1)*10)+1));
	for (i=(Math.floor((tol-1)/10)*10)+1;i<(Math.floor((tol-1)/10+1)*10)+1;i++) {
    if (i>(Math.floor((tol-1)/10)*10)+1) htmlstr += '&nbsp;';
    htmlstr += '<span';
    if (sel == i){
			htmlstr += ' style="color:#505005; font-weight:bold;';
		}
		else{
			htmlstr += ' style="color:' + colors[allapot[(i-1)]] + ';';
		}
    htmlstr += '">';
    htmlstr += '<a href="#" onclick="document.getElementById(\'webteszt_pg\').value=' + (i) + ';document.web_testexam.submit(); return false;"';
		if (sel == i){
			htmlstr += ' style="color:#505005; font-weight:bold;"';
		}
		else{
			htmlstr += ' style="color:' + colors[allapot[(i-1)]] + ';"';
		}
		htmlstr += '>';
    htmlstr += (i);
    htmlstr += '</a>';
    if (i<Math.floor((tol-1)/10+1)*10) htmlstr += '&nbsp;&nbsp;&nbsp;';
    htmlstr += '</span>';
  }
  sub_pager = document.getElementById('sub_pager');
  sub_pager.innerHTML = htmlstr;
}

function sugoMegmutatasa(p_id){
	if(document.getElementById(p_id).style.display == 'none') document.getElementById(p_id).style.display = 'inline';
	else document.getElementById(p_id).style.display = 'none';
}

var limit;
var timeleft;
// var save_url = 'http://'+location.host+'/zvb2/_application/automation/ajax_methods/save_timeleft/index.php';
var save_url = 'http://'+location.host+'/_application/automation/ajax_methods/save_timeleft/index.php';

function begintimer() {
  if (arguments.length > 0) {
    limit = arguments[0];
    timeleft = document.getElementById("timeleft");
  }
  if (limit == 0) {
    document.finish_form.submit();
  } else { 
    limit -= 1;
    curmin = Math.floor(limit/60);
    cursec = limit%60;
    if (cursec < 10) {
      cursec = '0' + cursec.toString();
    }
    timeleft.innerHTML = curmin + ":" + cursec;
    document.getElementById("webteszt_timeleft").value = limit;
    if (arguments.length == 0 && limit%5 == 0) {
      try {
        // Moz supports XMLHttpRequest. IE uses ActiveX. 
        // browser detction is bad. object detection works for any browser
        xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
				/*
				http://whale/zvb2/_application/automation/ajax_methods/save_timeleft/index.php/?timeleft=2695&felsor_id=13
				alert(save_url+'/?timeleft=' + limit + '&felsor_id=' + document.getElementById("webteszt_feladatsor_id").value);
				*/
				xmlhttp.open('GET', save_url+'/?timeleft=' + limit + '&felsor_id=' + document.getElementById("webteszt_feladatsor_id").value, false);
        xmlhttp.send(null);
        // if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) alert(unescape(xmlhttp.responseText));
      }
      catch (e) {
       // browser doesn't support ajax. handle however you want
      }
    }
    setTimeout("begintimer()",1000)
  }
}

//---------------------------------------------------------ISKOLÁK FILE FELTÖLTŐJÉHEZ A FV-EK---------------------------------------------------------
function implode (glue, pieces) {
	// Joins array elements placing glue string between items and return one string  
	// 
	// version: 1109.2015
	// discuss at: http://phpjs.org/functions/implode    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Waldo Malqui Silva
	// +   improved by: Itsacon (http://www.itsacon.net/)
	// +   bugfixed by: Brett Zamir (http://brett-zamir.me)
	// *     example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);    // *     returns 1: 'Kevin van Zonneveld'
	// *     example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'});
	// *     returns 2: 'Kevin van Zonneveld'
	var i = '', retVal = '', tGlue = '';
	if (arguments.length === 1) {
		pieces = glue;
		glue = '';
	}
	if (typeof(pieces) === 'object') {
		if (Object.prototype.toString.call(pieces) === '[object Array]') {
			return pieces.join(glue);
		} 
		for (i in pieces) {
			retVal += tGlue + pieces[i];
			tGlue = glue;
		}
		return retVal;
	}
	return pieces;
}

var flash_ID = "fel1Uploader";
var flash_Obj = null;
function getFlashObject(){
	if (flash_Obj == null){
		var flashObj;
		if (navigator.appName.indexOf( "Microsoft" ) != -1){
			//flashObj = window[flash_ID];
			flashObj = document.getElementById(flash_ID);
			// alert('EXP' + flashObj);
		}
		else{
			flashObj = window.document[flash_ID];
			// alert('Egyeb' + flashObj);
		}
		flash_Obj = flashObj;
	}
	return flash_Obj;
}

function vizsgaTipusCsomagnevEllenorzes(p_this){
	var hova_index = document.getElementById('select_hova').selectedIndex;
	var hove_ertek = document.getElementById('select_hova').options[document.getElementById('select_hova').selectedIndex].value;
	var exam_index = document.getElementById('select_exam').selectedIndex;
	var exam_ertek = document.getElementById('select_exam').options[document.getElementById('select_exam').selectedIndex].value;
	var csomag_part1 = document.getElementById('upload_csomag_eleje_hidden').value;
	var csomag_part2 = document.getElementById('upload_csomag').value;
	
	// document.getElementById("select_hova").setAttribute('disabled','disabled'); 
	// document.getElementById("select_hova").readOnly = true;
	// document.getElementById("select_exam").setAttribute('disabled','disabled'); 
	// document.getElementById("select_exam").readOnly = true;
	// document.getElementById("upload_csomag").readOnly = true;
	
	// var user_id_value = document.getElementById('user_id').value;
	
	// alert('('+document.getElementById('select_hova').selectedIndex+', '+hove_ertek+'), ('+document.getElementById('select_exam').selectedIndex+', '+exam_ertek+')');
	
	var hiba_uzenet = new Array();
	var hiba_teljes = '';
	var hiba_index = 0;
	if(hove_ertek==0){hiba_uzenet[hiba_index] = 'A típus nincs kiválasztva!'; hiba_index++;}
	if(exam_ertek==0){hiba_uzenet[hiba_index] = 'A vizsga nincs kiválasztva!'; hiba_index++;}
	// if(csomag_part1==''){hiba_uzenet[hiba_index] = 'Csomagnév hiba!'; hiba_index++;}
	if(csomag_part2==''){hiba_uzenet[hiba_index] = 'Csomagnév nincs megadva!'; hiba_index++;}
	
	hiba_teljes = implode("\n",hiba_uzenet);
	if(hiba_index>0){
		alert(hiba_teljes);
		// return 'hiba';
	}
	else{
		document.getElementById("select_hova").setAttribute('disabled','disabled'); 
		document.getElementById("select_exam").setAttribute('disabled','disabled'); 
		document.getElementById("upload_csomag").readOnly = true;
		
		/* p_this.style.display='none';
		document.getElementById('fel1').style.display='inline';
		
		uploadData.queueID = 'fel1cel';
		uploadData.scriptData.mezo = 'feltoltes1';
		uploadData.scriptData.user_id = user_id_value;
		uploadData.scriptData.upload_csomag = csomag_part1+csomag_part2;
		uploadData.scriptData.hova = hove_ertek;
		uploadData.scriptData.vizsga_id = exam_ertek;
		$("#fel1").uploadify(uploadData); */
		
		// alert('asd012');
		var flash = getFlashObject();
		// alert(flash);
		flash.setVariables('upload_csomag%3D'+(csomag_part1+csomag_part2)+'%26hova%3D'+(hove_ertek)+'%26vizsga_id%3D'+(exam_ertek));
		flash.uploadFiles();
		// return 'ok';
	}
}

//---------------------------------------------------------KEZDŐOLDALRA NYELVVÁLASZTÓ SEGÉD FV-E---------------------------------------------------------
function changeLngSelected(p_all_lng, p_act_lng){
	lng_array = String(p_all_lng).split(",");
	for (var i=0;i<lng_array.length;i++){
		if(lng_array[i]==p_act_lng) document.getElementById('lng_tag_'+lng_array[i]).className='lang_selected_middle';
		else document.getElementById('lng_tag_'+lng_array[i]).className='lang_nonselected_middle';
		//alert(lng_array[i]);
	}
	// alert(p_all_lng+', '+p_act_lng);
	document.getElementById('start_lng_hidden').value=p_act_lng;
}

function clickLngBtn(p_url){
	var lng_url_data;
	lng_url_data = strstr(p_url, '/?');
	if(lng_url_data == false)
		p_url = p_url+'?lang[lang]='+document.getElementById('start_lng_hidden').value;
	else
		p_url = p_url+'&lang[lang]='+document.getElementById('start_lng_hidden').value;
	window.open(p_url,'_self');
}
