nav = navigator.appName.indexOf("Microsoft")!= -1 ? 1 : 2;

function popup(url, name, width, height, scroll, modal, resizable) {
	width=Math.min(screen.availWidth,width);
	height=Math.min(screen.availHeight-40,height);
	var poz_x=(screen.availWidth-width)/2;
	var poz_y=(screen.availHeight-height-30)/2;
	newwin=window.open(url, name, 'scrollbars='+scroll+', menubar=no, width='+width+', height='+height+', resizable=no,toolbar=no, left='+poz_x+', top='+poz_y+', location=no, status=no');
	if(modal){
		popInt=setInterval(function(n){
			if(typeof(newwin.name)=="string"){
				if(newwin.document.body){
					openerfocus=function(){
						if(typeof(newwin.name)=="string"){
							newwin.focus();
						}else{
							document.body.onfocus=null;
						}
					}
					document.body.onfocus=openerfocus;
					newwin.window.document.body.onunload=function(){alert(66)}
					newwin.focus();
					/*with(newwin){
						self.focus()
						opener.document.body.onfocus=function(){self.focus();opener.alert(4);}
						self.document.body.onunload=function(){opener.document.body.onfocus=null}
					}*/
					clearInterval(popInt);
				}
			}else{
				clearInterval(popInt)
			}
		},1)
	}
}
