function ar_d(p,d){return window[p]||d}
function ar_v(p,d){window[p]=ar_d(p,d)}
function ar_e(p,d,e){return(e?escape(ar_d(p,d)):ar_d(p,d))+'&'}

ar_v('ar_width',300);
ar_v('ar_height',250);
ar_v('Mirror','');
ar_v('ar_logo',0);
ar_v('ar_pp_settings', 'scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
ar_v('ar_pass','');
ar_v('ar_place',0);
ar_pass = unescape(ar_pass);

ar_tryPU();


function ar_tryPU(){
	var ClickPop = {		
		url: Mirror+'/popup.html?'
		+ar_e('ar_place',0)
		+ar_e('CompPath','',1) 
		+ar_e('CgiHref','',1)  
		+ar_e('ar_width')
		+ar_e('ar_height')
		+ar_e('ar_img','',1) 
		+ar_e('ar_alt','',1) 
		+ar_e('ar_swf','',1) 
		+ar_e('ar_pp_left',100) 
		+ar_e('ar_pp_top',100) 
		+ar_e('ar_pp_timeout',400)
		+ar_e('ar_flashver',5)
		+ar_e('ar_logo',0)
		+ar_e('ar_adid',0)
		+ar_e('ar_ntype',0)
		+ar_e('bid',0)
		+ar_e('sliceid',0)
		+ar_e('ar_nid',0)
		+ar_e('ar_siteid',0)
		+ar_e('ar_img_click','',1)
		+ar_e('ar_rhost','ad.adriver.ru')
		+ar_e('RndNum4NoCash',Math.round(Math.random()*10000000))
		+ar_e('ar_pass','',1),
		PopFocus: ar_place,
		PopWidth: ar_width,
		PopHeight: ar_height,
		_Top: null,
		PopWin: null,
		PopLoaded: false,			
		CreatePop: function (e) {
			var popURL = "about:blank";								
			this.PopWin = this._Top.window.open(popURL, 'ar_'+ar_width+'x'+ar_height, ar_pp_settings+",width="+ this.PopWidth+",height="+this.PopHeight+",top="+4000+",left="+4000);
			if (this.PopWin) {
				this.PopLoaded = true;
				if (this.PopFocus == 0){
					 this.PopWin.blur();
					if (navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1) {
						this._Top.window.blur();
						this._Top.window.focus();
					}	
				}
				this.PopWin.Init = function (e) {
					with(e) {
						this.Params = e.Params;
						this.Main = function () {
							if (typeof window.mozPaintCount != "undefined") { var x = this.window.open("about:blank"); x.close(); } 
							var popURL = this.Params.url;
							try { opener.window.focus(); } catch (err) {}
							window.location = popURL;
						};
						this.Main();
					}
				};	
				this.PopWin.Params = { url: this.url };
				this.PopWin.Init(this.PopWin);
			}
			return true;
		}	
	}	
	function AddEvent(target, eventName, handlerName) {
						if (target.addEventListener) { target.addEventListener(eventName, eval(handlerName), false); } else if (target.attachEvent) {
							target.attachEvent("on" + eventName, eval(handlerName));
						} else { var originalHandler = target["on" + eventName];
							if (originalHandler) { target["on" + eventName] = eval(handlerName); } else { target["on" + eventName] = eval(handlerName); }
						}
	} 
	function Init() {
		ClickPop._Top = self; 
		if (top != self) { try { if (top.document.location.toString()) { this._Top = top; } } catch (err) {} }
		AddEvent(ClickPop._Top.document, "click", function (e) { if (!InitPop(e)) { if (e.preventDefault) { e.preventDefault(); } e.returnValue = false; }});
		AddEvent(ClickPop._Top.window, "scroll", function (e) { if (arguments.callee.scroll) { return; } arguments.callee.scroll = true; });
	}
	function InitPop(e) {
		if (ClickPop.PopLoaded || arguments.callee.init) { return true; }
		var status = ClickPop.CreatePop(e); return status;					
	}	
	Init();
}