(function(){
if (typeof _montblanc != 'undefined') {
var _mon = true;
}else{
var _mon = false;
console.log('_montblanc doesnt included');
}
var Adf = {};
Adf.dom = {};
Adf.counter = 1;
Adf.util = {
debug: true,
DOC_READY: false,
CRTG_CONTENT: '',
getBodyScrollTop: function(opt_win){
var _window = opt_win || window;
return _window.pageYOffset || (_window.document.documentElement && _window.document.documentElement.scrollTop) || (_window.document.body && _window.document.body.scrollTop);
},
getBodyScrollLeft: function(opt_win){
var _window = opt_win || window;
return _window.pageXOffset || (_window.document.documentElement && _window.document.documentElement.scrollLeft) || (_window.document.body && _window.document.body.scrollLeft);
},
getElementPosition: function(id, opt_doc){
var _document = opt_doc || document,
elem = _document.getElementById(id),
elemPos = {};
elemPos['width'] = elem.offsetWidth;
elemPos['height'] = elem.offsetHeight;
elemPos['left'] = 0;
elemPos['top'] = 0;
while (elem) {
elemPos['left'] += elem.offsetLeft;
elemPos['top'] += elem.offsetTop;
elem = elem.offsetParent;
}
return elemPos;
},
createScript: function(src, is_async, opt_doc) {
var _document = opt_doc || document,
el = _document.createElement('script');
el.src = src;
el.type = 'text/javascript';
el.async = !! is_async;
return el;
},
insertScript: function(script, opt_doc) {
var _document = opt_doc || document,
f = _document.getElementsByTagName('script')[0];
f.parentNode.insertBefore(script, f);
},
getProtocol: function(opt_doc){
var _document = opt_doc || document;
return _document.location.protocol == 'https:' ? 'https:' : 'http:';
},
getScreenSize: function(){
var scrheight = '',
scrwidth = '';
if (self.screen) {
scrwidth = screen.width;
scrheight = screen.height;
} else if (self.java) {
var jkit = java.awt.Toolkit.getDefaultToolkit(),
scrsize = jkit.getScreenSize();
scrwidth = scrsize.width;
scrheight = scrsize.height;
}
if(scrwidth && scrheight) {
return [scrwidth, scrheight]
} else {
return ['', '']
}
},
getWindowSize: function(opt_win){
var width,
height,
_window = opt_win || window;
if (typeof(_window.innerWidth) == 'number') {
width = _window.innerWidth;
height = _window.innerHeight;
} else if (_window.document.documentElement && (_window.document.documentElement.clientWidth || _window.document.documentElement.clientHeight)) {
width = _window.document.documentElement.clientWidth;
height = _window.document.documentElement.clientHeight;
} else if (_window.document.body && (_window.document.body.clientWidth || _window.document.body.clientHeight)) {
width = _window.document.body.clientWidth;
height = _window.document.body.clientHeight;
}
return {
"width": width,
"height": height
};
},
getDate: function(){
var addate = new Date();
return {
'date': addate.getDate(),
'day': addate.getDay(),
'hour': addate.getHours()
}
},
wrapScript: function(source){
return '' + source + '';
},
createElement: function(elem, opt_id, opt_class, opt_doc){
var _document = opt_doc || document,
elm = _document.createElement(elem);
if(typeof opt_id == 'string') elm.setAttribute('id', opt_id);
if(typeof opt_class == 'string') elm.className += opt_class;
return elm;
},
getFrameWindow: function(frameElement, opt_win){
var _window = opt_win || window;
return frameElement.contentWindow
? frameElement.contentWindow
: _window.frames[frameElement.name];
},
getFrameDocument: function(frameElement, opt_win){
var _window = opt_win || window;
if(!_window.safari){
return (_window.document.all && !_window.opera)
? frameElement.document
: frameElement.contentDocument;
}else{
var y = (frameElement.contentWindow || frameElement.contentDocument);
return (y.document)? y.document : y;
}
},
isIe: function(opt_win){
var _window = opt_win || window,
ua = _window.navigator.userAgent;
return -1 != ua.indexOf('MSIE ');
},
getIeVersion: function(){
var ua = navigator.userAgent;
var pos = ua.indexOf('MSIE ');
return parseFloat(ua.substring(pos + 5, ua.indexOf(';', pos)));
},
ieSetFrameBody: function(frameElement, frameWindow, body){
var ieVersion = Adf.util.getIeVersion(), _script;
frameWindow["contents"] = body;
if (6 < parseInt(ieVersion, 10)) {
_script = 'document.write(window["contents"]);';
} else {
_script = 'window["contents"]';
}
frameElement.src = 'javascript:' + _script;
},
w3cSetFrameBody: function(frameWindow, body){
var frameDocument = frameWindow.document;
frameDocument.write(body);
},
getCodeScript: function(i, src, id, banner_place, opt_callback){
var frameDocument;
if (i < 10) {
try {
if (document.all && !window.opera) {
frameDocument = window.frames[id].document;
} else if (document.getElementById) {
frameDocument = document.getElementById(id).contentDocument;
}
} catch (e) {}
if (frameDocument) {
frameDocument.write('<\/scr' + 'ipt>');
} else {
setTimeout(function(){ Adf.util.getCodeScript(++i , src, id) }, 100);
}
} else if(i == 10){
window.console.log('Can not access to frameDocument && frameWindow; id = ' + id);
}
Adf.inner.checkBannerLoaded(banner_place, opt_callback);
},
createAdIframe: function(id, opt_doc){
var _document = opt_doc || document,
ifr = _document.createElement('iframe');
ifr.setAttribute('id', id);
ifr.setAttribute('marginwidth', '0');
ifr.setAttribute('marginheight', '0');
ifr.setAttribute('scrolling', 'no');
ifr.setAttribute('frameBorder', '0');
ifr.setAttribute('width', '1');
ifr.setAttribute('height', '1');
ifr.style.position = 'absolute';
return ifr;
},
getReferrer: function(){
if (typeof(document.referrer) != 'undefined') {
if (typeof(afReferrer) == 'undefined') {
var afReferrer = escape(document.referrer);
}
} else {
var afReferrer = '';
}
return afReferrer;
}
};
Adf.init = {
criteo: function(site_id){
var crtg_nid = site_id,
crtg_cookiename = 'crtg_rta',
crtg_varname = 'crtg_content';
function crtg_getCookie(c_name){
var i,x,y,ARRCookies=document.cookie.split(";");
for(i=0;i 50) {
clearInterval(checkInterval);
if( typeof opt_callback === 'function' ) opt_callback(banner_place.scrollWidth, banner_place.scrollHeight, true);
return true;
}
}, 100);
},
getMonblanc: function(key){
if(_mon){
return _montblanc.get(key, '');
}else{
return '';
}
}
};
Adf.banner = {
needReload: false,
account_id: 171817,
pr: Math.floor(Math.random() * 1000000),
dl: escape(document.location),
montblanc: {
'puid3' : Adf.inner.getMonblanc('4i'),
'puid4' : Adf.inner.getMonblanc('c6'),
'puid11' : Adf.inner.getMonblanc('dd'),
'puid22' : Adf.inner.getMonblanc('y1'),
'puid33' : Adf.inner.getMonblanc('bj'),
'puid37' : Adf.inner.getMonblanc('k4'),
'puid38' : Adf.inner.getMonblanc('x3')
},
show: function(div_id, options, opt_class, opt_callback){
var divIdType = typeof div_id;
if(typeof opt_class === 'function') opt_callback = opt_class;
if ( divIdType == 'string') {
var banner_place = document.getElementById(div_id);
} else if ( divIdType == 'object' ) {
var banner_place = div_id;
};
var pr1 = Math.floor(Math.random() * 1000000),
pr2 = Math.floor(Math.random() * 1000000),
criteo = 0,
ban_block = Adf.util.createElement('div', 'AdFox_banner_' + pr1, opt_class),
ifr = Adf.util.createAdIframe('AdFox_iframe_' + pr1),
reloadPr = !Adf.banner.needReload ? Adf.banner.pr : Math.floor(Math.random() * 1000000),
url = Adf.util.getProtocol() +'//ads.adfox.ru/' + ( options['account_id'] ? options['account_id'] : Adf.banner.account_id ) + '/prepareCode?pfc=a&pfb=a&pt=b' +
'&pd=' + Adf.util.getDate()['date'] +
'&pw=' + Adf.util.getDate()['day'] +
'&pv=' + Adf.util.getDate()['hour'] +
'&prr=' + Adf.util.getReferrer() +
'&pdw=' + Adf.util.getScreenSize()[0] +
'&pdh=' + Adf.util.getScreenSize()[1] +
'&dl=' + Adf.banner.dl +
'&pr1=' + pr1 +
'&random=' + pr2 +
'&pr=' + reloadPr;
//include montblanc params
for(var prop in Adf.banner.montblanc){
url += '&' + prop + '=' + Adf.banner.montblanc[prop]
}
//check banner params
if (typeof options == 'object') {
for(var prop in options){
if (prop == 'criteo') {
if (Adf.util.CRTG_CONTENT){criteo = ((Adf.util.CRTG_CONTENT.indexOf(options[prop]) != -1))?(options[prop]):("0");}
url += '&puid23=' + criteo;
} else {
url += '&' + prop + '=' + options[prop]
}
}
} else { console.log('options =' + typeof options) };
//insert banner
if (banner_place) {
banner_place.appendChild(ban_block);
banner_place.appendChild(ifr);
} else {
console.log('adfox can not access banner_place');
};
if(Adf.util.debug) console.log('div_id = ' + div_id);
if(Adf.util.debug) console.log(options);
Adf.util.getCodeScript(1, url, 'AdFox_iframe_' + pr1, banner_place, opt_callback);
},
reload: function(div_id, options, opt_class, opt_callback){
Adf.banner.needReload = true;
document.getElementById(div_id).innerHTML = '';
Adf.banner.show(div_id, options, opt_class, opt_callback);
Adf.banner.needReload = false;
},
showScroll: function(div_id, options, opt_class, opt_callback){
var winPos = Adf.util.getWindowSize(),
winWidth = winPos.width,
winHeight = winPos.height,
scrollY = Adf.util.getBodyScrollTop(),
scrollX = Adf.util.getBodyScrollLeft(),
ltwhPos = Adf.util.getElementPosition(div_id),
lPos = ltwhPos.left,
tPos = ltwhPos.top;
if (scrollY + winHeight + 5 >= tPos && scrollX + winWidth + 5 >= lPos) {
Adf.banner.show(div_id, options, opt_class, opt_callback);
} else {
setTimeout(function(){
Adf.banner.showScroll(div_id, options, opt_class, opt_callback);
}, 100);
}
},
showScroll_b: function(div_id, options, options_b, opt_class, opt_win){
var winPos = Adf.util.getWindowSize(),
winWidth = winPos.width,
winHeight = winPos.height,
scrollY = Adf.util.getBodyScrollTop(),
scrollX = Adf.util.getBodyScrollLeft(),
ltwhPos = Adf.util.getElementPosition(div_id),
lPos = ltwhPos.left,
tPos = ltwhPos.top;
if (scrollY + winHeight + 5 >= tPos && scrollX + winWidth + 5 >= lPos) {
Adf.banner.show_b(div_id, options, options_b, opt_class, opt_win);
} else {
setTimeout(function(){
Adf.banner.showScroll_b(div_id, options, options_b, opt_class, opt_win);
}, 100);
}
},
show_b: function(div_id, options, options_b, opt_class, opt_win){
var _window = opt_win || window;
Adf.inner.show_b(Adf.counter, 1, div_id, options, options_b, opt_class, _window);
Adf.counter = Adf.counter + 1;
},
reload_b: function(div_id, options, options_b){
Adf.banner.needReload = true;
document.getElementById(div_id).innerHTML = '';
Adf.banner.show_b(div_id, options, options_b);
Adf.banner.needReload = false;
}
};
//api
window['Adf'] = {};
window['Adf']['util'] = Adf.util;
window['Adf']['init'] = Adf.init;
window['Adf']['banner'] = Adf.banner;
})();
function AdFox_SetLayerVis(spritename, state) {
document.getElementById(spritename).style.visibility = state;
}
function AdFox_Open(AF_id) {
AdFox_SetLayerVis('AdFox_DivBaseFlash_' + AF_id, "hidden");
AdFox_SetLayerVis('AdFox_DivOverFlash_' + AF_id, "visible");
}
function AdFox_Close(AF_id) {
AdFox_SetLayerVis('AdFox_DivOverFlash_' + AF_id, "hidden");
AdFox_SetLayerVis('AdFox_DivBaseFlash_' + AF_id, "visible");
}
function adfoxSdvigContent(banID, flashWidth, flashHeight) {
var obj = document.getElementById('adfoxBanner' + banID).style;
if (flashWidth == '100%') obj.width = flashWidth;
else obj.width = flashWidth + "px";
if (flashHeight == '100%') obj.height = flashHeight;
else obj.height = flashHeight + "px";
}
function adfoxVisibilityFlash(banName, flashWidth, flashHeight) {
var obj = document.getElementById(banName).style;
if (flashWidth == '100%') obj.width = flashWidth;
else obj.width = flashWidth + "px";
if (flashHeight == '100%') obj.height = flashHeight;
else obj.height = flashHeight + "px";
}
function adfoxStart(banID, FirShowFlNum, constVisFlashFir, sdvigContent, flash1Width, flash1Height, flash2Width, flash2Height) {
if (FirShowFlNum == 1) adfoxVisibilityFlash('adfoxFlash1' + banID, flash1Width, flash1Height);
else if (FirShowFlNum == 2) {
adfoxVisibilityFlash('adfoxFlash2' + banID, flash2Width, flash2Height);
if (constVisFlashFir == 'yes') adfoxVisibilityFlash('adfoxFlash1' + banID, flash1Width, flash1Height);
if (sdvigContent == 'yes') adfoxSdvigContent(banID, flash2Width, flash2Height);
else adfoxSdvigContent(banID, flash1Width, flash1Height);
}
}
function adfoxOpen(banID, constVisFlashFir, sdvigContent, flash2Width, flash2Height) {
var aEventOpenClose = new Image();
var obj = document.getElementById("aEventOpen" + banID);
if (obj) aEventOpenClose.src = obj.title + '&rand=' + Math.random() * 1000000 + '&prb=' + Math.random() * 1000000;
adfoxVisibilityFlash('adfoxFlash2' + banID, flash2Width, flash2Height);
if (constVisFlashFir != 'yes') adfoxVisibilityFlash('adfoxFlash1' + banID, 1, 1);
if (sdvigContent == 'yes') adfoxSdvigContent(banID, flash2Width, flash2Height);
}
function adfoxClose(banID, constVisFlashFir, sdvigContent, flash1Width, flash1Height) {
var aEventOpenClose = new Image();
var obj = document.getElementById("aEventClose" + banID);
if (obj) aEventOpenClose.src = obj.title + '&rand=' + Math.random() * 1000000 + '&prb=' + Math.random() * 1000000;
adfoxVisibilityFlash('adfoxFlash2' + banID, 1, 1);
if (constVisFlashFir != 'yes') adfoxVisibilityFlash('adfoxFlash1' + banID, flash1Width, flash1Height);
if (sdvigContent == 'yes') adfoxSdvigContent(banID, flash1Width, flash1Height);
}