function open_center_layer(element,x,y,mode){
	/*
	mode : 0; absolut középre, x és y a div fele
	mode : 1; a toppos = y;
	mode : 2; a leftpos = x; toppos = y;
	*/
	document.getElementById(element).style.display = "none";
	leftpos = 0 ;
	toppos = 0 ;

	if(mode==0){
		/* TOP */
		if(self.pageYOffset){
			yScroll = self.pageYOffset;
		}else if(document.documentElement && document.documentElement.scrollTop){
			yScroll = document.documentElement.scrollTop;
		}else if(document.body){
			yScroll = document.body.scrollTop;
		}
		if (self.innerHeight) {
			inheight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			inheight = document.documentElement.clientHeight;
		} else if (document.body) {
			inheight = document.body.clientHeight;
		}
		toppos = (yScroll + (inheight/2)) - y;
	}else{
		toppos = y;
	}

	if(mode==0){
		/* LEFT */
		if (screen){
			leftpos = (document.body.clientWidth/2) - x ;
		}

		if (leftpos<0)
			leftpos = 10 ;
	}else if(mode==2){
		leftpos = x;
	}

	document.getElementById(element).style.left = leftpos+'px';
	document.getElementById(element).style.top = toppos+'px';
}

function showmessagebox(mode){
	var elem = '';
	if(mode==0){
		elem = 'error_message';
	}else if(mode==1){
		elem = 'success_message';
	}else{
		elem = 'messagebox';
	}

	document.getElementById(elem).style.display = "block" ;
	window.focus() ;

	document.onclick = function(){
		document.getElementById(elem).style.display = "none" ;
		window.focus() ;
		document.onclick = empty ;
	}
}
function empty(){
}

function popup(){
	xajax_popup(0);
}
// FLASH MEGJELENÍTÉS

function showflash(file,width,height,bgcolor) {
	document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"'+width+'\" height=\"'+height+'\">');
	document.write('<param name=\"allowScriptAccess\" value=\"always\" />');
	document.write('<param name=\"movie\" value=\"'+file+'\" />');
	document.write('<param name=\"quality\" value=\"high\" />');
	document.write('<param name=\"wmode\" value=\"opaque\" />');
	document.write('<param name=\"bgcolor\" value=\"'+bgcolor+'\" />');
	document.write('<param name=\"swliveconnect\" value=\"true\" />');
	document.write('<param name=\"menu\" value=\"false\" />');
	document.write('<embed src=\"'+file+'\" quality=\"high\" bgcolor=\"'+bgcolor+'\" width=\"'+width+'\" height=\"'+height+'\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"opaque\"  swliveconnect=\"true\" menu=\"false\"/>');
	document.write('</object>');
}

// RADIO BUTTONOK MEGJELÖLT ÉRTÉKÉNEK VISSZAADÁSA
function getradiovalue(radioObj)
	{
	if (!radioObj)
		return "" ;
	var radioLength = radioObj.length ;
	if (radioLength == undefined)
		if (radioObj.checked)
			return radioObj.value ;
		else
			return "" ;
	for (var i = 0; i < radioLength; i++)
			{
		if (radioObj[i].checked)
			{
			return radioObj[i].value ;
			}
		}
	return "" ;
	}

function showelement(element)
	{
	document.getElementById(element).style.display = "block" ;
	window.focus() ;
	}

function hideelement(element)
	{
	document.getElementById(element).style.display = "none" ;
	window.focus() ;
	}
function hideall(elements){
	var element = elements.split(',');
	for(i=0; i<element.length; i++)	{
		e = element[i];
		if(document.getElementById(e)){
			document.getElementById(e).style.display = "none" ;
		}
	}
	window.focus() ;
}
function showhideelement(element)
	{
	if (document.getElementById(element).style.display=='none')
	showelement(element) ;
	else
	hideelement(element) ;
	window.focus() ;
	}
	
function gmload()
	{
	if (GBrowserIsCompatible())
		{
		var bounds = new GLatLngBounds();
		var icon = new GIcon(G_DEFAULT_ICON); 
		icon.image = "frame/google_marker.png";
		icon.transparent = "frame/google_marker.png"; 
		
		function gmarker_object(infohtml,point,icon)
			{
			this.infohtml = infohtml ;
			this.point = point ;
			this.icon = icon ;
			}
		var gmarkers = new Array() ;
		gmarkers[0] = new gmarker_object(
			'',
			new GLatLng(48.102960, 20.781580, true),
			icon
			) ;

		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.setCenter(gmarkers[0].point, 16);
		
		var opts = {maxWidth : 200};
		
		var marker1 = new GMarker(gmarkers[0].point,gmarkers[0].icon);
		map.addOverlay(marker1);
		bounds.extend(marker1.getPoint()) ;

		/*map.setZoom(map.getBoundsZoomLevel(bounds)); 
		map.setCenter(bounds.getCenter());*/   
		}
	}

	var bt_Widget = 0;
function bt_Window(){
	var Setting;
	var Coords = {mouse:null, mouseOffset:null};
	var dragableObject = null;

	this.open = function(set){
		Setting = set;
		o = this;
		bt_Widget++;

		Number.prototype.NaN0 = function(){ return isNaN(this) ? 0 : this; }
		var objBody = document.getElementsByTagName("body").item(0);
		var zIndex = (bt_Widget) ? bt_Widget * 1000 : 1000;
		var pageSize = o.getPageSize();
		var objOverlay = document.createElement("div");

		objOverlay.setAttribute('id','bt_layer_' + bt_Widget );
		objOverlay.style.display = 'none';
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = '0';
		objOverlay.style.left = '0';
		objOverlay.style.zIndex = zIndex;
		objOverlay.style.width = (pageSize.pw + 'px');
		objOverlay.style.minWidth = '100%';
		objOverlay.style.height = (pageSize.ph + 'px');
		objOverlay.style.minHeight = '100%';
		if(Setting.background)
			objOverlay.style.backgroundColor = Setting.background;
		else
			objOverlay.style.backgroundColor = '#000000';
		if(Setting.transparent){
			objOverlay.style.filter = 'alpha(opacity=' + Setting.transparent + ')';
			objOverlay.style.opacity = ( Setting.transparent / 100 );
		}else{
			objOverlay.style.filter = 'alpha(opacity=80)';
			objOverlay.style.opacity = 0.80;
		}
		objBody.appendChild(objOverlay);

		var objContent = document.createElement("div");
		objContent.setAttribute('id','bt_content_' + bt_Widget );
		objContent.style.visibility	= 'hidden';
		objContent.style.position = 'absolute';
		objContent.style.top = '0';
		objContent.style.left = '0';
		objContent.style.zIndex = zIndex + 1;
		objBody.appendChild(objContent);

		Setting.winid = 'bt_win_' + bt_Widget;
		var objBox = document.createElement("div");
		objBox.setAttribute('id', Setting.winid);
		if(Setting.winclass) objBox.className = Setting.winclass;
		objContent.appendChild(objBox);
		if(Setting.html) objBox.innerHTML = Setting.html;

		if(!Setting.width) Setting.width = objBox.offsetWidth;
		if(!Setting.height) Setting.height = objBox.offsetHeight;

		var scroll = o.getPageScroll(0);
		if(Setting.fixtop)
			toppos   = scroll.y + Setting.fixtop;
		else
			toppos   = scroll.y + (pageSize.wh - Setting.height) / 2;
		leftpos	= scroll.x + (pageSize.pw - Setting.width) / 2;

		objBox.style.top  = (toppos < 0) ? '0px' : toppos + 'px';
		objBox.style.left = (leftpos < 0) ? '0px' : leftpos + 'px';

		objOverlay.style.display = '';
		objContent.style.visibility	= '';

		if(Setting.drag){
			var root = document.getElementById(Setting.winid);
			for(var i=0; i<root.childNodes.length; i++){
				var handle = root.childNodes[i];
				if(handle.className == Setting.drag){
					handle.onmousedown = function(e){
						o.mouseDown(this.parentNode, e);
					}
				}
			} // end for
		}
	};

	this.reposition = function(){
		var target = document.getElementById('bt_win_' + bt_Widget);
		var pageSize = o.getPageSize();
		var scroll = o.getPageScroll(0);

		toppos   = (scroll.y + (pageSize.wh - target.offsetHeight) / 2 )-200;
		leftpos	= scroll.x + (pageSize.pw - target.offsetWidth) / 2;
		target.style.top  = (toppos < 0) ? '0px' : toppos + 'px';
		target.style.left = (leftpos < 0) ? '0px' : leftpos + 'px';
	};

	this.mouseDown = function(root, e){
		e = event(e);
		Coords.mouse = getMouseCoords(e);
		Coords.mouseOffset = getMouseOffset(root,e);
		dragableObject = root;

		document.onmousemove = o.mouseMove;
		document.onmouseup = o.mouseUp;

		return false;
	};

	this.mouseUp = function(){
		dragableObject = null;
	};

	this.mouseMove = function(e){
		e = event(e);
		Coords.mouse = getMouseCoords(e);

		if(dragableObject){
			dragableObject.style.top  = Coords.mouse.y - Coords.mouseOffset.y + 'px';
			dragableObject.style.left = Coords.mouse.x - Coords.mouseOffset.x + 'px';
		}
		return false;
	};

	this.close = function(){

		var activeWidget = bt_Widget;

		layerID = 'bt_content_' + activeWidget;
		objElement = document.getElementById(layerID);
		if (objElement && objElement.parentNode && objElement.parentNode.removeChild){
			objElement.parentNode.removeChild(objElement);
		}

		layerID = 'bt_layer_' + activeWidget;
		objElement = document.getElementById(layerID);
		if (objElement && objElement.parentNode && objElement.parentNode.removeChild){
			objElement.parentNode.removeChild(objElement);
			bt_Widget--;
		}
	};

	this.getPageSize = function(){
		var scroll = o.getPageScroll(1);

		var windowWidth, windowHeight;
		if(self.innerHeight) {	// all except
			windowWidth = self.innerWidth; windowHeight = self.innerHeight;
		}else if(document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict
			windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight;
		}else if(document.body) { // other
			windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight;
		}

		pageHeight = (scroll.y < windowHeight) ? windowHeight : scroll.y ;
		pageWidth = (scroll.x < windowWidth) ? windowWidth : scroll.x ;

		return {pw:pageWidth, ph:pageHeight, ww:windowWidth, wh:windowHeight};
	};

	this.getPageScroll = function(mode){
		var xScroll, yScroll;
		if(mode==1){
			if(window.innerHeight && window.scrollMaxY) {
				xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY;
			}else if(document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight;
			}else{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight;
			}
		}else{
			if(self.pageYOffset){
				xScroll = self.pageXOffset; yScroll = self.pageYOffset;
			}else if(document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
				xScroll = document.documentElement.scrollLeft; yScroll = document.documentElement.scrollTop;
			}else if(document.body){ // other
				xScroll = document.body.scrollLeft; yScroll = document.body.scrollTop;
			}
		}
		return {x:xScroll,y:yScroll};
	};

	function getMouseOffset(target, e){
		e = event(e);
		var targPos =  getPosition(target);
		var mousePos = getMouseCoords(e);
		return {x:mousePos.x - targPos.x, y:mousePos.y - targPos.y};
	};

	function getMouseCoords(e){
		e = event(e);

		var sL = (document.body.scrollLeft) ? document.body.scrollLeft : 0 ;
		var sT = (document.body.scrollTop) ? document.body.scrollTop : 0 ;
		var cL = (document.body.clientLeft) ? document.body.clientLeft : 0 ;
		var cT = (document.body.clientTop) ? document.body.clientTop : 0 ;

		var mouseX = e.clientX + sL - cL;
		var mouseY = e.clientY + sT - cT;
		return {x:mouseX, y:mouseY};
	};

	function getPosition(target){
		var left = 0;
		var top  = 0;
		do{
			left += target.offsetLeft + (target.currentStyle ? (parseInt(target.currentStyle.borderLeftWidth)).NaN0() : 0);
			top += target.offsetTop + (target.currentStyle ? (parseInt(target.currentStyle.borderTopWidth)).NaN0() : 0);
		}while(target = target.offsetParent);
		return {x:left, y:top};
	};

	function event(e){
		if (typeof e == 'undefined') e = window.event;
		return e;
	};
}

/* wins */
var oneWin = new bt_Window();
function openWindow(){
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_wintitle" class="fps_windrag"></div><div id="x_winclose" onclick="closeWindow();" title="Close" class="fps_winclose"></div><div id="loader" class="fps_winloading"></div><div id="x_wincontent" class="fps_wincontent"></div>'
	});
}
function openWindow2(){
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_wintitle2" class="fps_windrag"></div><div id="x_winclose2" onclick="closeWindow();" title="Close" class="fps_winclose"></div><div id="loader2" class="fps_winloading"></div><div id="x_wincontent2" class="fps_wincontent"></div>'
	});
}
function returnWindow(title, str, type){
	var content = '';
	if(type==0){
		content += '<div class="fps_error">';
	}else if(type==1){
		content += '<div class="fps_success">';
	}else{
		content += '<div class="fps_notice">';
	}
	content += str + '</div>';
	content += '<div style="text-align:center;"><input onclick="closeWindow();" class="fps_button3" type="button" value="OK" /></div></div>';

	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_returntitle" class="fps_windrag">' + title + '</div><div id="x_returnclose" onclick="closeWindow();" title="Close" class="fps_winclose"></div>'+
		'<div id="returnloader" class="fps_winloading"></div><div id="x_returncontent" class="fps_wincontent">' + content + '</div>'
	});
}

function fps_alert(str, type){
	var content = '';
	var myhref;

	if(!type) type='fps_caution';

	content = "<div class=\""+type+"\">"+str+"</div><div style=\"text-align: center\"><input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_ok+"\" onclick=\"oneWin.close();\" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winalert" class="fps_windrag"><img src="'+fps_globalurl+'image/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winalertclose" onclick="closeWindow();" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}

function fps_confirm(obj, str, yesscript, noscript){
	var content = '';
	var myhref;
	if(obj.href) {
		myhref = obj.href;
	}
	else myhref="";

	if(!yesscript) yesscript='';
	if(!noscript) noscript='';

	content = "<div class=\"fps_caution\">"+str+"</div><div style=\"text-align: center\"><input type=\"button\" class=\"fps_button2\" value=\""+fps_confirm_yes+"\" onclick=\"oneWin.close();"+yesscript+"window.location.href='"+myhref+"';\" /> <input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_no+"\" onclick=\"oneWin.close();"+noscript+"\" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winconfirm" class="fps_windrag"><img src="'+fps_globalurl+'image/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winconfirmclose" onclick="closeWindow();'+noscript+'" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}

function fps_confirm3(obj, str, yesscript, noscript, cancelscript){
	var content = '';
	var myhref;
	if(obj.href) {
		myhref = obj.href;
	}
	else myhref="";

	if(!yesscript) yesscript='';
	if(!noscript) noscript='';
	if(!cancelscript) cancelscript='';

	content = "<div class=\"fps_caution\">"+str+"</div>"+"<div style=\"text-align: center\">"+"<input type=\"button\" class=\"fps_button2\" value=\""+fps_confirm_yes+"\" onclick=\"oneWin.close();"+yesscript+" window.location.href='"+myhref+"';\" /> <input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_no+"\" onclick=\"oneWin.close();"+noscript+"\" /> <input type=\"button\" class=\"fps_button3\" value=\""+fps_confirm_cancel+"\" onclick=\"oneWin.close();"+cancelscript+"\" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winconfirm3" class="fps_windrag"><img src="'+fps_globalurl+'image/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winconfirm3close" onclick="closeWindow();'+cancelscript+'" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}


function closeWindow(){
	oneWin.close();
}
