prev_moveevent = null; 
if(window.top.selfpopupwindow!=true)
	var popupwin = null;
var currentfocus = this.window;
var focusonce=true;	
function popup(url,name,width,height) {	
	if(url!=''){
		if(isNaN(width))
			width=100;
		if(isNaN(height))
			height=100;
	
		var isBrowswerIE = true;	
		
		///alert(navigator.userAgent);
		
		if (navigator.appName=='Netscape') {
			isBrowswerIE = false;
			winW = window.innerWidth;
			winH = window.innerHeight;
			
			winl = (screen.width - width) / 2;
			wint = (screen.height - height) / 2;
		}
		else {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
			
			winl = (screen.width - width) / 2;
			wint = (screen.height - height) / 2;	
		}		
		
		//wint=5000;
		//winl=0;
				
		if (window.top.popupwin != null)
			window.top.popupwin.close();
			
		window.top.popupwin = window.open(url, name,'status=yes,resizable=no,scroll=no,width=' + width + ',height='+ height+',left='+winl+',top='+wint);		
	}
	
	// modalwindow szimuláló események			
	window.onbeforeunload = function() {
		try{
			if (window.top.popupwin != null && !window.top.popupwin.closed && window.top.popupwin.refreshopenerwindowevent!=true) { 
				window.top.popupwin.close();	
			}
		}
		catch(e){error=e.description;}		
	}	

	//ha van korábbi move event figyelés(nyitoconfig, moduladmin), megőrizzük 
	if(window.document.onmousemove) prev_moveevent=document.onmousemove;
	
	document.onmousemove = function() {
		try{
			if(window.top.popupwin.closed){
				if(prev_moveevent==null)
					document.onmousemove=null;
				if(prev_moveevent!=null){
					document.onmousemove=prev_moveevent;
					prev_moveevent=null;
				}
			}
			if (window.top.popupwin != null && !window.top.popupwin.closed){
				if(focusonce){
					focuschildwindow();
					focusonce=false;
					setTimeout('focusonce=true;',1000);
				}
			}	
		}
		catch(e){error=e.description;}		
	}

	document.onclick = function() {
		focuschildwindow();
	}		
		
}

function focuschildwindow(){
	try{
		if(window.top.popupwin!=null){
			topwin=window.top.popupwin;
			topwin.focus();
			topwin.dialogframe.focuschildwindow();
		}
		else
			window.focus();
	}
	catch(e){error=e.description;}			
}
