if (typeof Begun == 'undefined') {
	var Begun = {};
}
if (typeof Begun.loaderCallbacks === "undefined") {
	Begun.loaderCallbacks = [];
}

Begun.loaderCallbacks.push(begun_loader_ppcall);
function begun_loader_ppcall() {

Begun.Scripts.importAllScripts({"acp/begun_utils.53784.js": true}); 

Begun.Scripts.Callbacks['ppcall'] = function(fileName) {
	if (!Begun.Ppcall && Begun.Scripts.isLastRequired(fileName)) {
		Begun.Ppcall = function() {
			this.element = false;
			this.isHide = true;
			this.REVISION = '$LastChangedRevision: 54679 $';
			this.WIDTH = 342;
			this.HEIGHT = 260;

			var css_text = (new Begun.Template(this.tpls.css)).evaluate({width:this.WIDTH, height:this.HEIGHT});
			Begun.Utils.includeStyle(css_text, 'append', 'begun-ppcall-css');
		};
		Begun.Ppcall.prototype = {
			show: function(event, is_mobile) {
				if (!this.isHide) {
					this.hide();
				}
				if (this.isHide) {
					this.pos(event, is_mobile);
					this.element.innerHTML = '';
				}
				return true;
			},
			hide: function() {
				if (!this.isHide) {
					this.element.innerHTML = '';
					this.element.style.display = 'none';
					this.isHide = true;
				}
				return true;
			},
			pos: function(event, is_mobile) {
				if (is_mobile) {
					this.element.style.top = '50%';
					this.element.style.left = '50%';
					this.element.style.marginLeft = (this.WIDTH / -2) + 'px';
					this.element.style.marginTop = (this.HEIGHT / -2) + 'px';
					this.element.style.display = 'block';
					return;
				}
				var position = new Object();
				if (Begun.Browser.IE) {
					position.x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
					position.y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
				} else if (Begun.Browser.Opera)  {
					position.x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
					position.y = window.event.clientY + document.documentElement.scrollTop;
				} else {
					position.x = event.clientX + window.scrollX;
					position.y = event.clientY + window.scrollY;
				}
				var clientHeight = Begun.Utils.countWindowSize().height + Begun.Utils.getScrollXY().y;
				var clientWidth  = window.document.body.clientWidth;
				if (!clientWidth) {
					clientWidth  = window.innerWidth;
				}

				position.y = position.y + 5;
				position.x = position.x + 15;

				//width
				if ((clientWidth-position.x) < 350) {
					position.x = (clientWidth - 353);
				}

				//Height
				if ((clientHeight-position.y) < 260) {
					position.y = (position.y - 260);
				}

				if (position.y < 0) position.y = 5;
				if (position.x < 0) position.x = 5;

				this.element.style.top = position.y + 'px';
				this.element.style.left = position.x + 'px';
				this.element.style.display = 'block';
			},

			showEnterForm: function(i,a_obj,event, pad_id, iframe_link, is_mobile, url) {
				iframe_link = (function() {
					if (!iframe_link) {
						var _ppcall_iframe_link = (window.begun_urls && window.begun_urls.ppcall_iframe_link) || (Begun.Autocontext && Begun.Autocontext.Strings.urls.ppcall_iframe_link);
						if (_ppcall_iframe_link) {
							iframe_link = new Begun.Template(_ppcall_iframe_link).evaluate({ppcall_url: url});
						} else {
							iframe_link = Begun.Scripts.getConformProtocol() + '//ppcall.begun.ru/acont_xmlhttp.php?action=get_form&url=' + url;
						}
					}
					return iframe_link; 
				})();
				if (is_mobile) {
					window.location.href = iframe_link + (iframe_link.indexOf('is_mobile') != -1 ? '' : '&is_mobile=' + is_mobile);
					return;
				}
				if (!this.element){
					var a = document.createElement("div");
					document.body.appendChild(a);
					a.style.position = 'absolute';
					a.style.zIndex = '2147483647';
					a.style.display = 'none';
					a.style.background = "#0099CC";
					a.id = 'EF1';
					this.element = a;
				}
				if (!url) {
					if (typeof begunBanners != 'undefined' && begunBanners.length && begunBanners.length > 2) {
						url = begunBanners[i][2];
					} else if (typeof Begun != 'undefined' && Begun.Autocontext && Begun.Autocontext.getBanner) {
						url = Begun.Autocontext.getBanner('autocontext', i, pad_id)['url'];
					}
				} else {
					url = '';
				}
				this.show(event, is_mobile);
				this.element.innerHTML = this.tpls.html;
				this.isHide = false;
				Begun.$('begun_iframeid').src = iframe_link;
			},
			tpls: {
				css: '\
		#begun_ppcall {\
		width:{{width}}px;\
		height:{{height}}px;\
		position:absolute;\
		top:0;\
		left:0;\
		border:1px solid #666;\
		background-color:#fff;\
		z-index:2147483647;\
		}\
		#begun_ppcall * {\
		color:#000;\
		font-family:Arial, Helvetica, sans-serif;\
		font-size:12px;\
		margin:0;\
		padding:0;\
		}\
		#begun_ppcall .begun_ppcall_inner {height:245px;position:relative;margin:0 10px 10px;padding-top:2px;}\
		#begun_ppcall .begun_ppcall_inner .begun_ppcall_close {position:absolute;right:2px;top:6px;}\
		',
			html: '\
		<div id="begun_ppcall">\
		<div class="begun_ppcall_inner">\
		<iframe scrolling="no" frameborder="0" style="margin:0;padding:0;" width="100%" height="100%" src="#" id="begun_iframeid"></iframe>\
		<a class="begun_ppcall_close" href="javascript:void(0);" onclick="Begun.Ppcall.hide();return false;">&#1047;&#1072;&#1082;&#1088;&#1099;&#1090;&#1100;</a>\
		</div>\
		</div>\
		'
			}
		};
		Begun.Ppcall = new Begun.Ppcall();
		showEnterForm = function(i,a_obj,event, pad_id, link) {
			Begun.Ppcall.showEnterForm.apply(Begun.Ppcall, arguments);
		};
	}
}

Begun.Scripts.addStrictFunction(Begun.Scripts.Callbacks['ppcall']);
}

if (typeof Begun.Scripts !== "object") {
	(function() {
		var scripts = {
			"begun_scripts": "44517" //__COMPRESS_ACP_VERSION
		};
		var protocol = "http:";
		if (typeof Begun.Scripts != "undefined") {
			protocol = Begun.Scripts.getConformProtocol();
		}

		var baseUrl;
		if (window.begun_urls && window.begun_urls.base_scripts_url) {
			baseUrl = window.begun_urls.base_scripts_url;
		} else {
			baseUrl = protocol + "//autocontext.begun.ru/";
		}

		for (var scriptName in scripts) {
			if (scripts.hasOwnProperty(scriptName)) {
				document.write("<scr" + "ipt type=\"text/javascript\" src=\"" + baseUrl + "acp/" + scriptName + "." + scripts[scriptName] + ".js" + "\"></scr" + "ipt>");
			}
		}
	})();
} else {
	if (typeof Begun.Scripts.addStrictFunction !== "undefined") {
		begun_loader_ppcall();
	}
}

