if ("undefined"==typeof(c8BannerLoaderList))
{
     var c8BannerLoaderList = new Array();
};

function c8_setcode(site_id,page_id,format_id,width,height,div_id)
{
    if (undefined===this.c8_sa) 
    {
	var c8_sa='';
    }
    else
    {
	var c8_sa=this.c8_sa;
    };
    
    if (undefined===width) width='';
    if (undefined===height) height='';
    if (undefined===div_id) div_id='';
    
    var c8_pid = Math.round(Math.random() * 1000000000);
    
    c8_sa=c8_sa.replace("'", "");
    c8_sa=c8_sa.replace('"', '');
    
    if (0 && ('f49'!=site_id)&&(typeof(hitua)=='undefined') && (""==div_id)) {
    document.write("<sc"+"ript src='http://c.hit.ua/hit?i=15&g=2&x=3&nc=1&"+Math.round(Math.random()*1000000000)+"'></sc"+"ript>");};
    if (''==c8_sa){c8_sa=typeof(hitua)=='undefined'?'':hitua.poll_sex+';'+hitua.poll_age+';';};
    
    if (''==c8_sa)
    {
        var iMa=0;
        if (null!=navigator.userAgent.match(/Android/i))
        {
            iMa=2;
        };
        if (null!=navigator.userAgent.match(/(iOS|iPhone|iPod|iPad|iTouch|Mac|WebKit)/i)) 
        {
            iMa=4;
        };
        if (null!=navigator.userAgent.match(/(Nokia|Samsung|HTC|LG|Mobile|NEC|Sony|BlackBerry|Palm|Opera mini)/i)) 
        {
            iMa=8+iMa;
        };
        if (0!=iMa)
        {
            c8_sa='0;0;'+(1+iMa);
        };
    };
    
    if (""==div_id)
    document.write('<scr' + 'ipt language="JavaScript" charset="utf-8" src="http://b.c8.net.ua/show?'+site_id+'&' + c8_pid + '&'+page_id+'&'+format_id+'&'+width+'&'+height+'&'+c8_sa+'&'+div_id+'&'+(document.referrer ? escape(document.referrer) : '')+'"></scr' + 'ipt>');
    else
    c8_load_script('http://b.c8.net.ua/show?'+site_id+'&' + c8_pid + '&'+page_id+'&'+format_id+'&'+width+'&'+height+'&'+c8_sa+'&'+div_id+'&'+(document.referrer ? escape(document.referrer) : '')+'');

    if (""!=div_id)
    return;
    
    if ("f1108"==site_id)
    {
    show_code('f49','14','6','0','0','');
    };
    
    if (("f1611"==site_id)||("f1767"==site_id)||("f491"==site_id)||("f412"==site_id)||("f549"==site_id))
    {
    show_code('f49','14','6','0','0','');
    };
    

    if (("f1701"==site_id)||("f969"==site_id)||("f1592"==site_id)||("f132"==site_id)||("f1594"==site_id))
    {
    show_code('f49','16','6','0','0','');
    };

    if (("f892"==site_id)||("f616"==site_id)||("f1253"==site_id)||("f1260"==site_id))
    {
    show_code('f49','25','6','0','0','');
    };

    if (("f1577"==site_id)||("f1092"==site_id)||("f735"==site_id)||("f362"==site_id) || ("f1686"==site_id)||("f1703"==site_id)||("f1356"==site_id)||("f444"==site_id) ||("f607"==site_id)||("f1182"==site_id)||("f664"==site_id))
    {
    show_code('f49','13','6','0','0','');
    };
    
    if (("f1575"==site_id)||("f550"==site_id)||("f1740"==site_id)||("f1225"==site_id) || ("f753"==site_id)||("f1576"==site_id)||("f1699"==site_id))
    {
    show_code('f49','22','6','0','0','');
    };

    if ("f1428"==site_id)
    {
    show_code('f49','11','6','0','0','');
    };    
    
    if ((''!=c8_sa) && ('f49'!=site_id))
    {
    var m = c8_sa.split(';');
    if (29<m[1])
    {
         show_code('f49','12','6','0','0','');
    };
    if (1==m[0])
    {
         show_code('f49','10','6','0','0','');
    };
    if (2==m[0])
    {
         show_code('f49','9','6','0','0','');
    }; 
    };
    
    if ((typeof(hitua)!='undefined'))
    if (("f49"!=site_id) && (0!=hitua.favor_mask) && (typeof(wbl_behav)=='undefined'))
    {
    //show_code('f49','27','5','0','0','');
    wbl_behav=1;
    var c;var ar=[[6,14],[27,13],[29,15],[30,15],[12,16],[14,17],[19,17],[4,25],[7,22],[8,23],[9,23],[10,23],[25,23],[15,24],[16,24],[21,24],[20,20],[24,19],[28,21],[35,26]];
    
    if(0!=hitua.favor_mask)
    for(c in ar)
    {c=ar[c];if(hitua.favor_mask&(1<<c[0])&&c[1])
    document.write('<scr'+'ipt language="JavaScript" charset="utf-8" src="http://b.c8.net.ua/show?f49&'+Math.round(Math.random()*1000000000)+'&'+c[1]+'&6&1&_1&'+'"></scr'+'ipt>');
    };
    
    };
}

if ("undefined"==typeof(c8_tns_already))
{
    var c8_tns_already = 0;
};
    

function show_code(site_id,page_id,format_id,width,height,div_id)
{
    if (undefined===c8_sa) var c8_sa='';
    if (undefined===width) width='';
    if (undefined===height) height='';
    if (undefined===div_id) div_id='';
    
    var loader_div_id_new = '';
    
    
    if (null!=navigator.userAgent.match(/Android/i))
        {
            //alert('an');
            return;
        };

    if (('f49'!=site_id) && (5!=format_id)) {
        
        if (""==div_id) 
        {
            loader_div_id_new='c8div_'+site_id+page_id+format_id+'_'+Math.round(Math.random() * 1000000000); 
            document.write("<div id='"+loader_div_id_new+"'></div>");
        }
        else
        {
            loader_div_id_new=div_id; 
        };
    };
    
    if (''!=loader_div_id_new)
    {
        var key=site_id+'_'+page_id+'_'+format_id;
        if ("undefined"==typeof(c8BannerLoaderList[key]))
        {
            c8BannerLoaderList[key] = new c8BannerLoader(site_id,page_id,format_id,width,height,loader_div_id_new);
            c8BannerLoaderList[key].init();
        };
    }
    else
    {
        c8_setcode(site_id,page_id,format_id,width,height,loader_div_id_new);  
    };
    
    
    if ("f902"==site_id && !c8_tns_already)
    {
    	c8_tns_already=1;
    	c8_tns("xorosho.com");
    };
    
    if (0 && "f1428"==site_id && !c8_tns_already)
    {
    	c8_tns_already=1;
    	c8_tns("connect.ua");
    };
    
}


function c8_load_script(src,txt)
{
try {
if (""==txt) txt="void(0);";
 var head = document.getElementsByTagName('head')[0],
  s = document.createElement('script');
   //s.async = "async";
   s.setAttribute('type', 'text/javascript');
    s.setAttribute('src', src);
     //s.onreadystatechange = function(){if(/loaded|complete/.test(this.readyState)) {eval(txt);head.removeChild(s);}};
      //s.onload = function(){eval(txt);head.removeChild(s);};
       head.insertBefore(s, head.firstChild);
        }catch(e){}
        }

function c8BannerLoader(ban_id,page_id,format_id,height,width,div_id) {
    this.ban_id=ban_id;
    this.page_id=page_id;
    this.format_id=format_id;
    this.div_id=div_id;
    this.height=height;
    this.width=width;
    this.name=this.ban_id+'_'+this.page_id+'_'+this.format_id; 
}
c8BannerLoader.prototype = {

    top: 0,
    ban_id:'',
    div_id:'',
    page_id:0,
    format_id:0,
    height:0,
    width:0,
    unload:0,
    name:'',
    
    cm: document.compatMode == "CSS1Compat",
    
    scroll: function (){
        var ch = self.innerHeight || this.cm && document.documentElement.clientHeight || document.body.clientHeight;
        var st = self.pageYOffset || this.cm && document.documentElement.scrollTop || document.body.scrollTop;
        
if (this.top >= st && st + ch >= this.top && 0==this.unload) {

            this.unload=1;
            this.removeEvent(window, 'scroll', this.sfunc);
            c8_setcode(this.ban_id,this.page_id,this.format_id,this.height,this.width,this.div_id);    
        }
    },
    
    
    sfunc: function () {},
    sfunc1: function () {},
    
    reinit: function(){
	if (0==this.unload)
	{
	    var t = this;
	    
	
	    var obj = document.getElementById(this.div_id);
	    if ('undefined'!=typeof(obj)){
	    t.top=0;    
    	    while(obj.offsetParent){t.top += obj.offsetTop; obj = obj.offsetParent}

    	    t.scroll();
        }
	}; 
    },
    
    init: function(){
        var t = this;
            
        eval('this.sfunc = function () {c8BannerLoaderList[\''+this.name+'\'].scroll()};');

	eval('this.sfunc1 = function () {c8BannerLoaderList[\''+this.name+'\'].reinit()};');

	

        var obj = document.getElementById(this.div_id);
        if ('undefined'!=typeof(obj)){
    
        while(obj.offsetParent){t.top += obj.offsetTop; obj = obj.offsetParent}

        this.addEvent(window, 'scroll',this.sfunc);
        t.scroll();
        setTimeout(this.sfunc1, 1000);
        }
    },

     addEvent: function(e,t,f){
            if (e.addEventListener) e.addEventListener(t, f, false);
            else if (e.attachEvent) e.attachEvent('on'+t, f)
         },
    
    removeEvent: function (e,t,f){
            if (e.removeEventListener) e.removeEventListener(t, f, false);
            else if (e.detachEvent) e.detachEvent('on'+t, f)
        }

};

function c8_tns(site_url){
var i=new Image();
i.src="http://istat.tns.bemobile.ua/bug/pic.gif?siteid="+site_url+"&j=1&"+Math.random();
//c8_load_script("http://source.tns.bemobile.ua/id/tns_id.js","");
//c8_load_script("http://source.tns.bemobile.ua/cm/cmeter.js","");


(function(){
var p=document.getElementsByTagName('head')[0];
var s=document.createElement("script");
s.type="text/javascript";
s.src="http://source.tns.bemobile.ua/id/tns_id.js";
s.onload=s.onreadystatechange=function(){
if(!("readyState" in s)||/loaded|complete/.test(s.readyState)){
s.onload=s.onreadystatechange=null;
var s2=document.createElement("script");
s2.type="text/javascript";
s2.src="http://source.tns.bemobile.ua/cm/cmeter.js";
p.appendChild(s2);
}}
p.appendChild(s);
})();

}
