/* Creating new mlInline object (if not already exists) */ (function(){ if (typeof class_mlBase === 'undefined') { setTimeout(arguments.callee, 50); return; } if (typeof class_mlInline !== 'undefined') { return; } /* Defining mlInlne class methods */ var ext_mlInline = { main : function(b){ /*validate*/ b.w = b.w.toString(); b.production = /https?(:|%3A)\/\/[^\/]+\/reference(\?|%3F)/.test(b.link); if(this._useReferer) { b.place_dir = ((typeof(b.place_dir) != 'undefined' && b.place_dir.length) ? escape(b.place_dir) : this._defaultPlaceDir); b.link = this._clickServerUrl + b.place_dir + '/?' + escape(b.link); } b.ph = this.inject(b); if (null != b.ph) { b.ph.pixels = b.ph.document.createElement('div'); b.ph.pixels.id = "pixels_" + b.pid; b.ph.pixels.style.display = "none"; b.ph.placeholder.appendChild(b.ph.pixels); //set site background if needed if(typeof(b.banner_background) != "undefined" && typeof(b.banner_background.image) != "undefined" && b.banner_background.image.length > 0) { //var change_bg = new Function('inline.set_site_background_image('+b.name+')'); //this.addEvent(b.ph.window, 'load', change_bg); this.set_site_background_image(b); } if (b.eshows) { b.listener = this.proxy(this, this.listener, [b]); this.addEvent(b.ph.window, 'scroll', b.listener); this.addEvent(b.ph.window, 'resize', b.listener); b.listener(); // forse check, banner maight be already visible } else { if (b.iframe && b.iframe_src) { b.iframe.src = b.iframe_src; } this.callEvent(b.zeropixel, b.rand_url, b.ph); } if (b.show_when_ph_visible) { b.ph.placeholder.style.visibility = 'hidden'; b.vis_listener = this.proxy(this, this.vis_listener, [b]); this.addEvent(b.ph.window, 'scroll', b.vis_listener); this.addEvent(b.ph.window, 'resize', b.vis_listener); b.vis_listener(); } } }, inject : function(banner) { var ua = navigator.userAgent; var checkAndroid = /Android(?=.*?(Mobile))/i.test(ua); //var androidDefaultBrowser = /Android.+AppleWebKit.+Version\/[^\s]+( Mobile)?\s+Safari/.test(ua); var checkAndroidTablet = /(Android(?=.*?tab)|Android 3|Android(?!.*?(phone|Mobile)))/i.test(ua); var checkIphone = /iphone/i.test(ua); var checkIpad = /ipad/i.test(ua); var checkWinPhone = /Windows Phone|WPDesktop|IEMobile|WP7/i.test(ua); var isMobile = (checkAndroid || checkIphone || checkWinPhone); var isTablet = (checkAndroidTablet || checkIpad); var p = this.codeVariant(banner.pid); var o, computed_height; var canvas = document.createElement('canvas'); var isDevice = isMobile || isTablet; var isBannerStretch = typeof banner.gif_w != 'undefined'; var isHtml5_enable = !isBannerStretch || !isDevice || (isDevice && banner.tablet_html5_enable); if (/Firefox/.test(ua)) { isHtml5_enable = isHtml5_enable && (typeof banner.firefox_html5_enable == 'undefined' || banner.firefox_html5_enable); } if (banner.show_close_button) { banner.close_button = p.document.createElement('div'); banner.close_button.id = 'close_button_' + banner.pid; banner.close_button.style.cssText = 'display : block; position : absolute; right : 5px; top : 5px; width : 50px; height : 50px; background : url(http://content.rbc.medialand.ru/templates_r/cross.png) top right no-repeat; background-size : 19px 19px;'; banner.close = this.proxy(this, this.close, [banner]); this.addEvent(banner.close_button, 'click', banner.close); if (!banner.div_style) { banner.div_style = {}; } banner.div_style.position = 'relative'; } if (canvas && typeof canvas.getContext == 'function' && /^https?:\/\/.+/i.test(banner.html5) && isHtml5_enable) { o = p.document.createElement('iframe'); o.id = 'html5_' + banner.pid; o.frameBorder = 0; o.scrolling = 'no'; o.marginWidth = 0; o.marginHeight = 0; o.width = (typeof banner.gif_w != 'undefined')? banner.gif_w : banner.w; //o.height = (typeof banner.gif_h != 'undefined')? banner.gif_h : banner.h; o.height = (banner.h.indexOf('%') > -1) ? "100%" : ((typeof banner.gif_h != 'undefined') ? banner.gif_h : banner.h); if (banner.w) o.style.width = '' + banner.w + ((banner.w.indexOf('%') > -1) ? '' : 'px'); //if (banner.h) o.style.height = '' + banner.h + ((banner.h.indexOf('%') > -1) ? '' : 'px'); if (banner.h) o.style.height = (banner.h.indexOf('%') > -1) ? "100%" : banner.h + 'px'; computed_height = banner.h; o.style.display = 'inline-block'; o.style.border = '0'; o.style.margin = '0'; var rnd = Math.round(Math.random()*100000); banner.iframe = o; banner.iframe_src = banner.html5 + ((banner.html5.indexOf('?') == -1) ? '?' : '&') + 'r' + rnd + '=' + rnd; for (i=0; i -1) ? '' : 'px'))); //height = (typeof banner.gif_h != 'undefined') ? (banner.gif_h + 'px') : (banner.h + ((banner.h.indexOf('%') > -1) ? '' : 'px')); height = computed_height ? (computed_height + (computed_height.toString().indexOf('%') == -1 ? 'px' : '')) : (banner.gif_h + 'px'); } if (banner.dfp_iframe) { try { if (p.placeholder.style.height.indexOf('%') < 0 && banner.dfp_iframe.parentNode.style.height != p.placeholder.style.height) { banner.dfp_iframe.parentNode.style.height = p.placeholder.style.height; } } catch (e) {} } if(typeof(banner.div_style) == "object") { banner.div_style.width = (banner.div_style.width == "" || banner.div_style.width == "100%") ? "100%" : (banner.div_style.width.indexOf('%') == -1 ? banner.div_style.width + 'px' : banner.div_style.width); for(prop in banner.div_style) { with(p.placeholder.style) { try{ eval(prop + '="' + banner.div_style[prop] + '"'); }catch(e){} } } } if (p.placeholder.style.display == 'inline-block') { try { p.placeholder.parentNode.style.textAlign = 'center'; } catch (e) {} } banner.destroy = this.destroy; if (p.type == 'async') setTimeout('document.close()', 1000); return p; }, close : function (b) { b.ph.placeholder.style.display = "none"; this.removeEvent(b.close_button, 'click', b.close); }, destroy : function (b) { //remove events if banner wasn't shown in visible area if (b.eshows) { try { this.removeEvent(b.ph.window, 'scroll', b.listener); this.removeEvent(b.ph.window, 'resize', b.listener); } catch (e) {} } if (b.show_when_ph_visible) { try { this.removeEvent(b.ph.window, 'scroll', b.vis_listener); this.removeEvent(b.ph.window, 'resize', b.vis_listener); } catch(e) {} } this._super(b); }, listener : function(b) { //var isElementVisible = this.isVisible(b, b.ph.window); var g = this.winSize(b.ph.window, b.ph.document); var h = this.findPos(b.ph.placeholder).top+b.h/4; // 25% visiblee //if (isElementVisible) { // if (b.dfp_iframe) { // b.dfp_iframe.style.display = 'block'; // } if (Math.abs(g.scrollY+g.height/2-h)<=g.height/2) { if (b.iframe && b.iframe_src) { b.iframe.src = b.iframe_src; } this.callEvent(b.zeropixel, b.rand_url, b.ph); this.removeEvent(b.ph.window, 'scroll', b.listener); this.removeEvent(b.ph.window, 'resize', b.listener); } //} }, vis_listener : function(b) { var g = this.winSize(b.ph.window, b.ph.document); var h = this.findPos(b.ph.placeholder).top + parseInt(b.h*(4/10)); if (Math.abs(g.scrollY + g.height) > h) { //25% visible b.ph.placeholder.style.visibility = 'visible'; this.removeEvent(b.ph.window, 'scroll', b.vis_listener); this.removeEvent(b.ph.window, 'resize', b.vis_listener); } }, set_site_background_image : function(b){ var page_height = b.ph.document.body.scrollHeight; //get options var screen_width = screen.width; var screen_height = screen.height; var body_width = b.ph.document.body.clientWidth; if(screen_width < 1280) { return; } var left_bg_a = b.ph.document.createElement('a'); left_bg_a.href = b.link; left_bg_a.innerHtml = "_"; left_bg_a.target = "_blank"; var diff = (b.w.indexOf('%') > -1) ? 0: body_width - b.banner_background.content_width -2*b.banner_background.width; with(left_bg_a.style) { height = page_height + "px"; position = "absolute"; left = diff? Math.ceil(diff/2) + "px" : "0px"; top = (b.h.indexOf('%') > -1) ? "0px" : b.h + "px"; width = b.banner_background.width + "px"; height = b.banner_background.height + "px"; zIndex = 1; backgroundImage = "url('" + b.banner_background.image + "')"; backgroundRepeat = "no-repeat"; display = "block"; textIndent = "-9999px"; cursor = "pointer"; padding = "0px"; margin = "0px"; border = "0px none black"; } var right_bg_a = b.ph.document.createElement('a'); right_bg_a.href = b.link; right_bg_a.innerHtml = "_"; right_bg_a.target = "_blank"; with(right_bg_a.style) { height = page_height + "px"; position = "absolute"; right = diff? Math.ceil(diff/2) + "px" : "0px"; top = (b.h.indexOf('%') > -1) ? "0px" : b.h + "px"; width = b.banner_background.width + "px"; height = b.banner_background.height + "px"; zIndex = 1; backgroundImage = "url('" + b.banner_background.image_r + "')"; backgroundRepeat = "no-repeat"; display = "block"; textIndent = "-9999px"; cursor = "pointer"; padding = "0px"; margin = "0px"; border = "0px none black"; } var s = b.ph.document.getElementsByTagName('div')[0]; s.parentNode.insertBefore(left_bg_a, s); s.parentNode.insertBefore(right_bg_a, s); } }; /* Initializing mlInline object */ window.class_mlInline = class_mlBase.extend(ext_mlInline); window.obj_mlInline = new class_mlInline(); })();