
function cBrowser() {
	var ua = navigator.userAgent;
	var bName = function () {
		if (ua.search(/MSIE/) > -1) return "ie";
		}();
		
	var version = function (bName) {
		switch (bName) {
			case "ie" : return (ua.split("MSIE ")[1]).split(";")[0];break;
	}}(bName);
	return [bName];
}
function loadScript_5i8(url, callback,id_script)
{
	
		// adding the script tag to the head as suggested before
		var head = document.getElementsByTagName('head')[0];
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = url;
		script.id = id_script;
		
		if(cBrowser()=='ie'){
			setTimeout(callback, 300);
		}else{
			script.onreadystatechange = callback;
			script.onload = callback;
		
		}
		head.appendChild(script);
}

loadScript_5i8('http://advertising.tech.mos.ru//bitrix/templates/.default/static/js/postmessage.js',init_event_banner_5i8,'script_postmessage');


function init_event_banner_5i8(){

	pm.bind("resaiz_frame_banner_5i8", function(data) {
			if(data['param_h']>0){
				var frameElement = document.getElementById('banner_frame_5i8'); 
				frameElement.style.height = data['param_h'] + 'px'; 
				var frameElement = document.getElementById('banner_block_5i8'); 
				frameElement.style.height = data['param_h'] + 'px'; 
			}
			
			if(data['param_w']>0){
				var frameElement = document.getElementById('banner_frame_5i8'); 
				frameElement.style.width = data['param_w'] + 'px'; 
				var frameElement = document.getElementById('banner_block_5i8'); 
				frameElement.style.width = data['param_w'] + 'px'; 
			}
			return data;
	}); 

	pm.bind("add_new_from_5i8", function(data){
		var el = document.createElement("iframe");
		
		el.id = 'iframe_';
		el.src = data['param_url']+'&rand_id=5i8';
		el.style.top = '0';
		el.style.left = '0';
		el.style.width = '100%';
		el.style.height = $(window).height()+'px';
		el.style.border = 'medium none';
		el.style.zIndex = 9999;
		el.style.overflow = 'hidden';
		el.style.position = 'fixed';
		el.style.backgroundColor = 'transparent';
		document.body.appendChild(el);
	});

	pm.bind('remove_adver_frame_5i8', function(){
		document.body.removeChild(document.getElementById("iframe_"));
	});
}


document.write('<div style="display: inline-block; height: 400px; width: 240px;" id="banner_block_5i8"><iframe style="height: 400px; width: 240px; border: none; z-index: 1; overflow: hidden; position: absolute; background-color:transparent" scrolling="no" frameborder="0" allowtransparency="true"  name="banner_frame_5i8" id="banner_frame_5i8" src="http://advertising.tech.mos.ru/banner.php?site_id=vo&rand_id=5i8&type=left_banners_2&ref_url='+encodeURIComponent(document.location.href)+'"></iframe></div>');
