function BannerInterface(map) {
this.map = map; // map interface object
this.elBanner = null;
this.bannerWidth = 300
this.bannerHeight = 60;
this.bannerSet = new Array();
this.currentPage = -1;
this.bannerFirstRun = true;
this.defaultPageTimeout = 30000;// TODO: set to 3000
this.defaultPageMoveInTime = 700;
this.defaultPageMoveOutTime = 700;
this.pageTimeout = 3000;
this.pageCaptionMoveInTime = 800;
this.pagePriceDelay = 400;
this.pagePriceMoveInTime = 700;
this.pageMoveOutTime = 700;
this.elBannerPageDefault = null;
this.elBannerPageCaption = null;
this.elBannerPageCaptionValue = null;
this.elBannerPageDescValue = null;
this.elBannerPagePrice = null;
this.elBannerPagePriceValue = null;
this.urlShop = 'http://www.shocart.cz/';
this.cbBannerShown = null;
this.cbBannerEnd = null;
this.cbBannerHidden = null;
this.cbBannerClick = null;
this._create = function() {
this.cbBannerShown = jQuery.proxy(this.onBannerShown, this);
this.cbBannerEnd = jQuery.proxy(this.onBannerEnd, this);
this.cbBannerHidden = jQuery.proxy(this.onBannerHidden, this);
this.cbBannerClick = jQuery.proxy(this.onBannerClick, this);
this.elBanner = document.getElementById('r-box');
$(this.elBanner).empty();
this.elBanner.style.width = this.bannerWidth + 'px';
this.elBanner.style.height = this.bannerHeight + 'px';
this.elBanner.style.overflow = 'hidden';
this.elBanner.style.backgroundColor = '#BE0022';
this.elBannerPageDefault = document.createElement('div');
this.elBannerPageDefault.style.position = 'absolute';
this.elBannerPageDefault.style.width = this.bannerWidth + 'px';
this.elBannerPageDefault.style.height = this.bannerHeight + 'px';
this.elBannerPageDefault.style.right = this.bannerWidth + 'px';
this.elBannerPageDefault.style.overflow = 'hidden';
this.elBannerPageDefault.style.backgroundImage = 'url("https://www.cykloserver.cz/img/sh_banner_idnes_300x60.jpg")';
this.elBanner.appendChild(this.elBannerPageDefault);
var elBuy = document.createElement('div');
elBuy.style.color = '#FFC003';
elBuy.style.padding = '7px 4px 0px 10px';
elBuy.style.fontWeight = 'bold';
//elBuy.innerHTML = 'Kupte si mapu SHOCart
této oblasti do Vašeho
mobilního telefonu.';
this.elBannerPageDefault.appendChild(elBuy);
this.elBannerPageCaption = document.createElement('div');
this.elBannerPageCaption.style.position = 'absolute';
this.elBannerPageCaption.style.width = this.bannerWidth + 'px';
this.elBannerPageCaption.style.height = this.bannerHeight + 'px';
this.elBannerPageCaption.style.right = this.bannerWidth + 'px';
this.elBannerPageCaption.style.overflow = 'hidden';
this.elBanner.appendChild(this.elBannerPageCaption);
this.elBannerPageCaptionValue = document.createElement('div');
this.elBannerPageCaptionValue.style.color = '#FFC003';
this.elBannerPageCaptionValue.style.padding = '9px 4px 0px 24px';
this.elBannerPageCaptionValue.style.fontWeight = 'bold';
this.elBannerPageCaptionValue.innerHTML = '';
this.elBannerPageCaption.appendChild(this.elBannerPageCaptionValue);
this.elBannerPageDescValue = document.createElement('div');
this.elBannerPageDescValue.style.color = '#FFC003';
this.elBannerPageDescValue.style.padding = '2px 0px 0px 24px';
this.elBannerPageDescValue.style.fontSize = '10px';
this.elBannerPageDescValue.style.fontWeight = 'normal';
this.elBannerPageDescValue.innerHTML = '';
this.elBannerPageCaption.appendChild(this.elBannerPageDescValue);
this.elBannerPagePrice = document.createElement('div');
this.elBannerPagePrice.style.position = 'absolute';
this.elBannerPagePrice.style.width = this.bannerWidth + 'px';
this.elBannerPagePrice.style.height = this.bannerHeight + 'px';
this.elBannerPagePrice.style.right = this.bannerWidth + 'px';
this.elBannerPagePrice.style.overflow = 'hidden';
this.elBanner.appendChild(this.elBannerPagePrice);
this.elBannerPagePriceValue = document.createElement('div');
this.elBannerPagePriceValue.style.color = '#FFFFFF';
this.elBannerPagePriceValue.style.padding = '37px 4px 0px 230px';
this.elBannerPagePriceValue.style.fontWeight = 'bold';
this.elBannerPagePriceValue.innerHTML = '';
this.elBannerPagePrice.appendChild(this.elBannerPagePriceValue);
this.elBannerCatcher = document.createElement('div');
this.elBannerCatcher.style.position = 'absolute';
this.elBannerCatcher.style.width = this.bannerWidth + 'px';
this.elBannerCatcher.style.height = this.bannerHeight + 'px';
this.elBannerCatcher.style.cursor = 'pointer';
this.elBanner.appendChild(this.elBannerCatcher);
$(this.elBannerCatcher).bind('click', jQuery.proxy(this.onClick, this));
this.prepareAreaDef();
this.attachEvents();
this.updateBennerView();
this.updateBannerSet();
}
this.prepareAreaDef = function() {
if (ShcAreasDef) {
for (var ti = 0; ti < ShcAreasDef.length; ti++) {
ShcAreasDef[ti]['bnds'] = new OpenLayers.Bounds(ShcAreasDef[ti].minlon, ShcAreasDef[ti].minlat, ShcAreasDef[ti].maxlon, ShcAreasDef[ti].maxlat);
}
}
}
this.attachEvents = function() {
this.map.map.events.register('moveend', this, this.onMapUpdate);
}
this.onMapUpdate = function() {
this.updateBannerSet();
}
this.updateBannerSet = function() {
// TODO: remove
return false;
var bnds = this.map.getBoundsObj();
var newAreaSet = new Array();
if (ShcAreasDef) for (var ti = 0; ti < ShcAreasDef.length; ti++) {
if (bnds.intersectsBounds(ShcAreasDef[ti].bnds)) {
newAreaSet.push(ShcAreasDef[ti]);
}
}
this.bannerSet = newAreaSet;
}
this.updateBennerView = function() {
if (this.bannerFirstRun) {
this.showBannerPage(-1);
this.bannerFirstRun = false;
} else {
}
}
this.showBannerPage = function(page) {
if (page == -1) {
this.elBannerPageDefault.style.bottom = this.bannerHeight + 'px';
this.elBannerPageDefault.style.right = '0px';
$(this.elBannerPageDefault).animate({bottom: '0px'}, this.defaultPageMoveInTime, this.cbBannerShown);
this.currentPage = page;
} else {
if (page >= this.bannerSet.length) page = -1;
this.elBannerPageCaptionValue.innerHTML = this.bannerSet[page].nazev;
this.elBannerPagePriceValue.innerHTML = this.bannerSet[page].cena;
if (ShcAreaTypesDef) {
if (ShcAreaTypesDef[this.bannerSet[page].typ]) {
this.elBannerPageDescValue.innerHTML = ShcAreaTypesDef[this.bannerSet[page].typ].nazev;
}
}
this.elBannerPageCaption.style.bottom = this.bannerHeight + 'px';
this.elBannerPageCaption.style.right = '0px';
this.elBannerPagePrice.style.top = this.bannerHeight + 'px';
this.elBannerPagePrice.style.right = '0px';
$(this.elBannerPageCaption).animate({bottom: '0px'}, this.pageCaptionMoveInTime);
$(this.elBannerPagePrice).delay(this.pagePriceDelay).animate({top: '0px'}, this.pagePriceMoveInTime, this.cbBannerShown);
this.currentPage = page;
}
}
this.onBannerShown = function() {
if (this.currentPage == -1) {
window.setTimeout(this.cbBannerEnd, this.defaultPageTimeout);
} else {
window.setTimeout(this.cbBannerEnd, this.pageTimeout);
}
}
this.onBannerEnd = function() {
if (this.currentPage == -1) {
//if (this.bannerSet.length) {
$(this.elBannerPageDefault).animate({right: this.bannerWidth + 'px'}, this.defaultPageMoveOutTime, this.cbBannerHidden);
//}
} else {
$(this.elBannerPageCaption).animate({right: this.bannerWidth + 'px'}, this.pageMoveOutTime);
$(this.elBannerPagePrice).animate({right: this.bannerWidth + 'px'}, this.pageMoveOutTime, this.cbBannerHidden);
}
}
this.onBannerHidden = function() {
if (!this.bannerSet.length) {
this.showBannerPage(-1);
} else {
if (this.bannerSet.length - 1 > this.currentPage) {
this.showBannerPage(this.currentPage + 1);
} else {
this.showBannerPage(-1);
}
}
}
this.onClick = function() {
window.open(this.urlShop);
}
this._create();
}