/* -------------------------------------------------------------------------- */
/* --- OBJECTPARAMETERS                                                   --- */
/* --- Html objektumok paramétereinek lekéréséhez, beállításához          --- */
/* --- vagy kiiratásához kellő függvények.                                --- */
/* -------------------------------------------------------------------------- */
function getElement(obj) {return document.getElementById(obj);}

/* Lekérés */
function getObjectTop(obj) {return getElement(obj).offsetTop;}
function getObjectLeft(obj) {return getElement(obj).offsetLeft;}
function getObjectWidth(obj) {return getElement(obj).offsetWidth;}
function getObjectHeight(obj) {return getElement(obj).offsetHeight;}

/* Beállítás */
function setObjectTop(obj,position) {getElement(obj).style.top = position+"px";}
function setObjectLeft(obj,position) {getElement(obj).style.left = position+"px";}
function setObjectWidth(obj,value) {getElement(obj).style.width = value+"px";}
function setObjectHeight(obj,value) {getElement(obj).style.height = value+"px";}

/* Kiiratás */
function printObjectTop(obj) {document.write(getObjectTop(obj));}
function printObjectLeft(obj) {document.write(getObjectLeft(obj));}
function printObjectWidth(obj) {document.write(getObjectWidth(obj));}
function printObjectHeight(obj) {document.write(getObjectHeight(obj));}
/* -------------------------------------------------------------------------- */
/* --- OBJECTPARAMETERS                                                   --- */
/* -------------------------------------------------------------------------- */




/* -------------------------------------------------------------------------- */
/* --- USEFUL 1                                                           --- */
/* --- Hasznos függvények 1: képcsere, színcsere, popuplink stb...        --- */
/* -------------------------------------------------------------------------- */
/* képcsere */
function changeSrc(obj,ujpic) {obj.src=ujpic;}
function changeSrc_id(obj,ujpic) {getElement(obj).src=ujpic;}
function preLoad(imgObj,imgSrc)
	{
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "../g/ep/"+imgSrc')
	}
function preLoadWithActive(imgObj,imgSrc) 
	{
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "../g/ep/"+imgSrc+".gif"')
		eval(imgObj+'_active = new Image()')
		eval(imgObj+'_active.src = "../g/ep/"+imgSrc+"_active.gif"')
	}
function changeSrcPreLoad_id(imgName, imgObj) {document.images[imgName].src = eval(imgObj+".src");}

/* clip csere */
function changeClip(obj,top,right,bottom,left) {obj.style.clip = 'rect(' + top + 'px, ' + right + 'px, ' + bottom + 'px, ' + left + 'px)';}
function changeClip_id(obj,top,right,bottom,left) {getElement(obj).style.clip = 'rect(' + top + 'px, ' + right + 'px, ' + bottom + 'px, ' + left + 'px)';}

/* háttérképcsere */
function changeBg(obj,ujpic) {obj.style.backgroundImage = 'url(' + ujpic + ')';}
function changeBg_id(obj,ujpic) {getElement(obj).style.backgroundImage = 'url(' + ujpic + ')';}

/* háttérszíncsere */
function changeBgColor(obj,ujcolor) {obj.style.backgroundColor = ujcolor;}
function changeBgColor_id(obj,ujcolor) {getElement(obj).style.backgroundColor = ujcolor;}

/* betűszínszíncsere */
function changeColor(obj,ujcolor) {obj.style.color = ujcolor;}
function changeColor_id(obj,ujcolor) {getElement(obj).style.color = ujcolor;}

/* betű-dekoráció csere */
function changeDecoration(obj,ujdecoration) {obj.style.textDecoration = ujdecoration;}
function changeDecoration_id(obj,ujdecoration) {getElement(obj).style.textDecoration = ujdecoration;}

/* class lekérés és csere */
function getClassById(id)
	{
		var element = document.getElementById(id);
		if (element == null) 
			{return null;}
		else
			{return element.className;}
	}
function setClass(id, newclass) {return id.className = newclass;}
function setClassById(id, newclass)
	{
		var element = document.getElementById(id);
		if (element == null) 
			{return;}
		else
			{return element.className = newclass;}
	}

/* alt lekérés és csere */
function getAlt(id) {return id.alt;}
function getAltById(id)
	{
		var element = document.getElementById(id);
		if (element == null) 
			{return null;}
		else
			{return element.alt;}
	}
function setAlt(id) {return id.alt = newalt;}
function setAltById(id, newalt)
	{
		var element = document.getElementById(id);
		if (element == null) 
			{return;}
		else
			{return element.alt = newalt;}
	}

/* style érték lekérés és csere */
function getStyle(id, property) {return id.style[property];}
function getStyleById(id, property)
	{
		var element = document.getElementById(id);
		if (element == null) 
			{return null;}
		else
			{return element.style[property];}
	}
function setStyle(id, property, newvalue) {return id.style[property] = newvalue;}
function setStyleById(id, property, newvalue)
	{
		var element = document.getElementById(id);
		if (element == null) 
			{return;}
		else
			{return element.style[property] = newvalue;}
	}
/* -------------------------------------------------------------------------- */
/* --- USEFUL 1                                                           --- */
/* -------------------------------------------------------------------------- */




/* -------------------------------------------------------------------------- */
/* --- USEFUL 2                                                           --- */
/* --- Hasznos függvények 2: objektum eltűntetés-megjelenítés, kukaccsere --- */
/* --- popup-os link megnyitás, form+select link url átírás stb...        --- */
/* -------------------------------------------------------------------------- */
/* objektum eltűntetés és megjelenítés */
function show(obj) {obj.style.visibility='visible';}
function show_id(obj) {getElement(obj).style.visibility='visible';}
function hide(obj) {obj.style.visibility='hidden';}
function hide_id(obj) {getElement(obj).style.visibility='hidden';}

function show_display(obj) {obj.style.display='block';}
function show_display_id(obj) {getElement(obj).style.display='block';}
function hide_display(obj) {obj.style.display='none';}
function hide_display_id(obj) {getElement(obj).style.display='none';}

function show_all(obj)
	{
		obj.style.visibility='visible';
		obj.style.display='block';
	}
function show_all_id(obj)
	{
		document.getElementById(obj).style.visibility='visible';
		document.getElementById(obj).style.display='block';
	}
function hide_all(obj)
	{
		obj.style.visibility='hidden';
		obj.style.display='none';
	}
function hide_all_id(obj)
	{
		document.getElementById(obj).style.visibility='hidden';
		document.getElementById(obj).style.display='none';
	}


/* link popup megnyitás */
function popupWindow(linkHref, linkTarget, winWidth, winHeight) {window.open(linkHref, linkTarget, "toolbar=0,location=0,directories=0,status=0,scrollbars=0,width=" + winWidth + ",height=" + winHeight + ",left=" + (screen.width - winWidth) / 2 + ",top=" + (screen.height - winHeight) / 2);}
function openWindow(linkHref) {if (linkHref != '') {window.open(linkHref);}}

/* kukac string feloldás */
function atCharReplace(){
	var a_tags = document.getElementsByTagName("a");
	for (var i=0; i<a_tags.length; i++) {
		if (a_tags[i].href.indexOf("#e-mail-kukac#") != -1){
			a_tags[i].href = a_tags[i].href.replace("#e-mail-kukac#", String.fromCharCode(64));
			a_tags[i].innerHTML = a_tags[i].innerHTML.replace("#e-mail-kukac#", String.fromCharCode(64));
		}
	}
}

/* szám string konvertálás (XSLT-vel való kapcsolathoz kell) */
function numberToString(n)
	{
		var res = n;
		if (n < 10)  res = '0' + n;
		return res;
	}
/* -------------------------------------------------------------------------- */
/* --- USEFUL 2                                                           --- */
/* -------------------------------------------------------------------------- */




/* -------------------------------------------------------------------------- */
/* --- USEFUL 3                                                           --- */
/* --- Hasznos függvények 3: Középső hasáb méretének 100%-ra állítása,    --- */
/* --- Lastmodifydate doboz alulra beállítás, popupmenü pozicionálás      --- */
/* -------------------------------------------------------------------------- */
function setAreasHeight()
	{
		var body_height                = document.body.clientHeight;
		var header_height              = getObjectHeight("header");
		var footer_height              = getObjectHeight("footer");
		var minus_sum                  = header_height + footer_height + 1;
		var areas_height               = body_height - minus_sum;

		getElement("areas_td").style.height = areas_height+"px";
		getElement("areas_table").style.height = areas_height+"px";
	}
function setLastModifyDateHeight()
	{
		var lastmodifydate_div_exist = document.getElementById("lastmodifydate_div") != null;
		if (lastmodifydate_div_exist == true)
			{
				var areas_height_new = getObjectHeight("areas_td");
				var lastmodifydate_top = getObjectTop("lastmodifydate_div");
				var lastmodifydate_height = 30;
				var lastmodifydate_height_calculated = areas_height_new - lastmodifydate_top -16;

				getElement("lastmodifydate_div").style.height = eval(lastmodifydate_height_calculated) + "px";
				getElement("lastmodifydate_td").style.height = eval(lastmodifydate_height_calculated) + "px";
			}
	}
function popupmenu_positioner(menuitems, nameextension)
	{
		//A MAINMENU DIV adatainak meghatározása
		var mainmenu_name										= 'mainmenu';
		var mainmenu_all_number									= menuitems;
		var mainmenu_nameextension								= nameextension;
		var mainmenu_top_position								= getObjectTop(mainmenu_name);
		var mainmenu_left_position								= getObjectLeft(mainmenu_name);
		var mainmenu_width										= getObjectWidth(mainmenu_name);
		var mainmenu_height										= getObjectHeight(mainmenu_name);
		var mainmenu_right_position								= mainmenu_left_position + mainmenu_width;
		//A MAINMENU DIV adatainak meghatározása
	
		//A MAINMENU DIV adatainak kiírása
/*		alert_str =  'ELEM POZÍCIÓ MEGHATÁROZÁS: MAINMENU'										+ '\n';
		alert_str += 'mainmenu_name: '							+ mainmenu_name					+ '\n';
		alert_str += 'mainmenu_all_number: '					+ mainmenu_all_number			+ '\n';
		alert_str += 'mainmenu_top_position: '					+ mainmenu_top_position 		+ '\n';
		alert_str += 'mainmenu_left_position: '					+ mainmenu_left_position		+ '\n';
		alert_str += 'mainmenu_width: '							+ mainmenu_width				+ '\n';
		alert_str += 'mainmenu_height: '						+ mainmenu_height				+ '\n';
		alert_str += 'mainmenu_right_position: '				+ mainmenu_right_position		+ '\n';
		alert(alert_str);*/
		//A MAINMENU DIV adatainak kiírása

		//Ciklus a MAINMENU DIV "menuitem_0X_div"-nevű gyermekelemein
		for (var i = 1; i<=mainmenu_all_number; i++) 
			{
				//A "menuitem_0X_div"-nevű gyermekelemek adatainak meghatározása
				var mainmenu_item_name							= 'menuitem_' + mainmenu_nameextension + '0' + i + '_div';
				var mainmenu_item_number						= i;
				if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Windows") != -1)
					{
						var mainmenu_item_top_position			= mainmenu_top_position + getObjectTop(mainmenu_item_name);
						var mainmenu_item_left_position			= mainmenu_left_position + getObjectLeft(mainmenu_item_name);
					}
				else
					{
						var mainmenu_item_top_position			= getObjectTop(mainmenu_item_name);
						var mainmenu_item_left_position			= getObjectLeft(mainmenu_item_name);
					}
				var mainmenu_item_width							= getObjectWidth(mainmenu_item_name);
				var mainmenu_item_height						= getObjectHeight(mainmenu_item_name);
				var mainmenu_item_right_position				= mainmenu_item_left_position + mainmenu_item_width;
				var mainmenu_item_leftspace						= mainmenu_item_right_position - mainmenu_left_position;
				var mainmenu_item_rightspace					= mainmenu_right_position - mainmenu_item_left_position;
				//A "menuitem_0X_div"-nevű gyermekelemek adatainak meghatározása
			
				//A "menuitem_0X_div"-nevű gyermekelemek adatainak kiírása
/*				alert_str =  'ELEM POZÍCIÓ MEGHATÁROZÁS: MAINMENU_ITEM'							+ '\n';
				alert_str += 'mainmenu_item_name: '				+ mainmenu_item_name			+ '\n';
				alert_str += 'mainmenu_item_number: '			+ mainmenu_item_number			+ '\n';
				alert_str += 'mainmenu_item_top_position: '		+ mainmenu_item_top_position	+ '\n';
				alert_str += 'mainmenu_item_left_position: '	+ mainmenu_item_left_position	+ '\n';
				alert_str += 'mainmenu_item_width: '			+ mainmenu_item_width			+ '\n';
				alert_str += 'mainmenu_item_height: '			+ mainmenu_item_height			+ '\n';
				alert_str += 'mainmenu_item_right_position: '	+ mainmenu_item_right_position	+ '\n';
				alert_str += 'mainmenu_item_leftspace: '		+ mainmenu_item_leftspace		+ '\n';
				alert_str += 'mainmenu_item_rightspace: '		+ mainmenu_item_rightspace		+ '\n';
				alert(alert_str);*/
				//A "menuitem_0X_div"-nevű gyermekelemek adatainak kiírása

				//A "popupmenu_0X_div"-nevű POPUP menük kezdeti adatainak meghatározása
				var popupmenu_name								= 'popupmenu_' + mainmenu_nameextension + '0' + i + '_div';
				var popupmenu_number							= i;
				var popupmenu_top_position						= getObjectTop(popupmenu_name);
				var popupmenu_left_position						= getObjectLeft(popupmenu_name);
				var popupmenu_width								= getObjectWidth(popupmenu_name);
				var popupmenu_height							= getObjectHeight(popupmenu_name);
				var popupmenu_right_position					= popupmenu_left_position + popupmenu_width;
				var popupmenu_comment							= '';
				//A "popupmenu_0X_div"-nevű POPUP menük kezdeti adatainak meghatározása

				//A "popupmenu_0X_div"-nevű POPUP menük kezdeti adatainak kiírása
/*				alert_str =  'ELEM KEZDETI POZÍCIÓ MEGHATÁROZÁS: POPUPMENU'						+ '\n';
				alert_str += 'popupmenu_name: '					+ popupmenu_name				+ '\n';
				alert_str += 'popupmenu_number: '				+ popupmenu_number				+ '\n';
				alert_str += 'popupmenu_top_position: '			+ popupmenu_top_position		+ '\n';
				alert_str += 'popupmenu_left_position: '		+ popupmenu_left_position		+ '\n';
				alert_str += 'popupmenu_width: '				+ popupmenu_width				+ '\n';
				alert_str += 'popupmenu_height: '				+ popupmenu_height				+ '\n';
				alert_str += 'popupmenu_right_position: '		+ popupmenu_right_position		+ '\n';
				alert_str += 'popupmenu_comment: '				+ popupmenu_comment				+ '\n';
				alert(alert_str);*/
				//A "popupmenu_0X_div"-nevű POPUP menük kezdeti adatainak kiírása

				//A "popupmenu_0X_div"-nevű POPUP menük "left_position" adatának meghatározása
				if (popupmenu_width >= mainmenu_width)
					{
						popupmenu_comment		= '1. A POPUPMENU szélesebb mint a MAINMENU               MAINMENU_LEFT_POSITION-tól';
						popupmenu_left_position = mainmenu_left_position - 1;
						setObjectLeft(popupmenu_name,popupmenu_left_position);
					}
				if (popupmenu_width < mainmenu_width && popupmenu_width >= mainmenu_item_leftspace && popupmenu_width >= mainmenu_item_rightspace)
					{
						popupmenu_comment		= '2. A POPUPMENU keskenyebb mint a MAINMENU, szélesebb mint LEFTSPACE és szélesebb mint a RIGHTSPACE             MAINMENU_LEFT_POSITION-tól';
						popupmenu_left_position = mainmenu_left_position - 1;
						setObjectLeft(popupmenu_name,popupmenu_left_position);
					}
				if (popupmenu_width < mainmenu_width && popupmenu_width < mainmenu_item_leftspace && popupmenu_width >= mainmenu_item_rightspace)
					{
						popupmenu_comment		= '3. A POPUPMENU keskenyebb mint a MAINMENU, keskenyebb mint LEFTSPACE és szélesebb mint a RIGHTSPACE             MAINMENU_ITEM_RIGHT_POSITION-ig';
						popupmenu_left_position = (mainmenu_item_right_position - popupmenu_width) + 1;
						setObjectLeft(popupmenu_name,popupmenu_left_position);
					}
				if (popupmenu_width < mainmenu_width && popupmenu_width >= mainmenu_item_leftspace && popupmenu_width < mainmenu_item_rightspace)
					{
						popupmenu_comment		= '4. A POPUPMENU keskenyebb mint a MAINMENU, szélesebb mint LEFTSPACE és keskenyebb mint a RIGHTSPACE              MAINMENU_ITEM_LEFT_POSITION-tól';
						popupmenu_left_position = mainmenu_item_left_position - 1;
						setObjectLeft(popupmenu_name,popupmenu_left_position);
					}
				if (popupmenu_width < mainmenu_width && popupmenu_width < mainmenu_item_leftspace && popupmenu_width < mainmenu_item_rightspace)
					{
						popupmenu_comment		= '5. A POPUPMENU keskenyebb mint a MAINMENU, keskenyebb mint LEFTSPACE és keskenyebb mint a RIGHTSPACE              MAINMENU_ITEM_LEFT_POSITION-tól';
						popupmenu_left_position = mainmenu_item_left_position - 1;
						setObjectLeft(popupmenu_name,popupmenu_left_position);
					}
				//A "popupmenu_0X_div"-nevű POPUP menük "left_position" adatának meghatározása

				//A "popupmenu_0X_div"-nevű POPUP menük új adatainak kiírása
/*				alert_str =  'ELEM ÚJ POZÍCIÓ MEGHATÁROZÁS: POPUPMENU'							+ '\n';
				alert_str += 'popupmenu_name: '					+ popupmenu_name 				+ '\n';
				alert_str += 'popupmenu_number: '				+ popupmenu_number 				+ '\n';
				alert_str += 'popupmenu_left_position: '		+ popupmenu_left_position 		+ '\n';
				alert_str += 'popupmenu_right_position: '		+ popupmenu_right_position 		+ '\n';
				alert_str += '----------------------------------'								+ '\n';
				alert_str += 'mainmenu_width: '					+ mainmenu_width 				+ '\n';
				alert_str += 'popupmenu_width: '				+ popupmenu_width 				+ '\n';
				alert_str += 'mainmenu_item_leftspace: '		+ mainmenu_item_leftspace 		+ '\n';
				alert_str += 'mainmenu_item_rightspace: '		+ mainmenu_item_rightspace 		+ '\n';
				alert_str += 'popupmenu_comment: '				+ popupmenu_comment 			+ '\n';
				alert(alert_str);*/
				//A "popupmenu_0X_div"-nevű POPUP menük új adatainak kiírása
			}
		//Ciklus a MAINMENU DIV "menuitem_0X_div"-nevű gyermekelemein
	}
/* -------------------------------------------------------------------------- */
/* --- USEFUL 3                                                           --- */
/* -------------------------------------------------------------------------- */




/* -------------------------------------------------------------------------- */
/* --- INITIALIZATION                                                     --- */
/* --- Onload, onresize automatikus függvények                            --- */
/* -------------------------------------------------------------------------- */
function DocumentInit()
	{
		atCharReplace();
		setAreasHeight();
		setLastModifyDateHeight();
	}
if (window.addEventListener)
	{
		window.addEventListener("load",DocumentInit,false);
		window.addEventListener("resize",DocumentInit,false);
	}
else if (window.attachEvent)
	{
		window.attachEvent("onload",DocumentInit);
	}
/* -------------------------------------------------------------------------- */
/* --- INITIALIZATION                                                     --- */
/* -------------------------------------------------------------------------- */


/*
 * BEGIN --- Belépési nyilatkozat JS tools
 * 
 * @param
 */	

function selectClear(selectO) {
	selectO.options.length = 0;
}

function zipCodeSearch(zipCodeO,cityO,selected){
	var cityFound = false;
	selectClear(cityO);
	for ( var zipCodeId in zipCodes) {
		if( zipCodes[zipCodeId][zipCodeO.value] != null ) {
			cityFound = true;
			var newCity = document.createElement('option');
			newCity.text = zipCodes[zipCodeId][zipCodeO.value];
			newCity.value = zipCodes[zipCodeId][zipCodeO.value];
			if (selected == newCity.value) {
				newCity.selected = true;
			}
			try{
				cityO.add(newCity, null);
			}
			catch (ex) {
				cityO.add(newCity );	// in IE
			}
		}
	}
	if ( !cityFound ) {
		var newCity = document.createElement('option');
		newCity.text = 'Település nem található!';
		newCity.value = '';
		try{
			cityO.add(newCity, null);
		}
		catch (ex) {
			cityO.add(newCity );	// in IE
		}
	}
}

function copyFields(fields, copy){
	if (copy) {
		for (var ind in fields) {
			switch (document.getElementById(fields[ind]).type) {
				case 'select-one':
					var toSelect = document.getElementById(fields[ind]);
					selectClear(toSelect);
					var newOption = document.createElement('option');
					newOption.text = document.getElementById(ind)[document.getElementById(ind).selectedIndex].text;
					newOption.value = document.getElementById(ind)[document.getElementById(ind).selectedIndex].value;
					try{
						toSelect.add(newOption, null);
					}
					catch (ex) {
						toSelect.add(newOption );	// in IE
					}
					
					break;
				default:
					document.getElementById(fields[ind]).value = document.getElementById(ind).value;
					document.getElementById(fields[ind]).readOnly = true;
					break;
			}
		}		
	}
	else {
		for (var ind in fields) {
			switch (document.getElementById(fields[ind]).type) {
			case 'select-one':
				selectClear(document.getElementById(fields[ind]));
				break;
			default:
				document.getElementById(fields[ind]).value = '';
				document.getElementById(fields[ind]).readOnly = false;
				break;
			}
		}				
	}
}	
	
/*
 * END --- Belépési nyilatkozat JS tools 
 */	
