popup = {
	created: false,	win: null, id: "popup",	type: 1, width: 300, height: 250, left: 0, top: 0, url: null,
	settings: "scrollbars=yes,location=yes,directories=no,status=yes,menubar=yes,toolbar=yes,resizable=yes",

	init: function(url, width, height, type) {
		popup.url = url;
		
		popup.width = (typeof width == "undefined") ? popup.width : width;
		popup.height = (typeof height == "undefined") ? popup.height : height;
		popup.type = (typeof type == "undefined") ? popup.type : type;

		popup.left = (screen.width-popup.width)/2;
		popup.top = (screen.height-popup.height)/2;	
		
		popup.create();
		document.onclick = popup.observe;
		window.onunload  = popup.observe;
	},
	
	create: function() {
		if (!popup.created) {
			var result = window.open(popup.url, popup.id, "width="+popup.width+",height="+popup.height+",top="+popup.top+",left="+popup.left+","+popup.settings);
			if (result!=null && typeof result!="undefined") {
				popup.created = true;
				popup.win = result;

				if (popup.type==2)
					popup.win.blur();
			}
		}
	},

	observe: function() {
		popup.create();
	}
}

popup.init("http://nnn.novoteka.ru/show.cgi?adp=8019&nnn=8019&t="+Math.random(), 970, 600, 2);
