var LP_banner = {
el: null, position: null, posHdlr: null, animHndlr: null, offset: null,
isIE: /MSIE/.test(navigator.userAgent),
isIElt7: /MSIE (\d+\.\d+);/.test(navigator.userAgent) && parseInt(RegExp.$1) < 7,
rid
: Math
.floor(Math
.random
()*1000000), /* Declare user variables */
timeout: 3000,
step: 5,
interval: 3, /* in minutes */
messages: [
["http://vgospode.ru/img/s_img2.jpg", "Здесь вы сможете быстро найти себе пару. Бесплатные знакомства соединяют людей со всего мира. Посетителям доступны поиск по разным параметрам, а также просмотр фото и анкет без регистрации."]
],
style: {
msg_popup: "font:normal 11px Tahoma;color:#333;width: 200px; background: #fff url(http://vgospode.ru/img/bg_bookmarks.gif) no-repeat right top;dislay:none;z-index:1000;",
header: "font-weight:bold;background: url(http://vgospode.ru/img/bg_bookmarks.gif) no-repeat left top; padding:7px 10px 7px 15px; color:#0879b1; margin-right: 5px;", close: "float: right; margin-top: 4px; margin-right: -5px;cursor:pointer;",
box: "border: 1px solid #d0d0d0; padding: 6px;",
photo: "width: 66px; height: 90px; float: left; margin-right: 6px;"
},
calcPosition: function(){
if(this.isIE){
return({
left: document.documentElement.clientWidth + document.documentElement.scrollLeft - this.offset.left,
top: document.documentElement.clientHeight + document.documentElement.scrollTop
});
}else{
return({
left: window.innerWidth - this.el.offsetWidth - 20,
top: window.innerHeight
});
}
},
setWasShowed: function() {
date.setTime
((now
+this
.interval
*60)*1000); document
.cookie
= "lp_banner="+now
+"; expires="+date.toUTCString
()+"; path=/"; },
getWasShowed: function() {
var cookie
=null, cookies
= document
.cookie
.split("; "), length
= cookies
.length
; for (var i = 0; i < length; i++){
cookie
= cookies
[i
].split("="); if (cookie[0]=="lp_banner") return true;
}
return false;
},
init: function(){
if(this.getWasShowed()){
return true;
}
else{
this.setWasShowed();
}
var template
= '<div id="lp_banner_'+this
.rid
+'" style="'+this
.style
.msg_popup
+'"><div style="'+this
.style
.header+'"><img src="http://vgospode.ru/img/bg_exit.gif" title="Закрыть" style="'+this
.style
.close
+'" onclick="LP_banner.close()">Новое сообщение</div><a href="http://vgospode.ru/clubs/18" style="text-decoration: none;"><div style="'+this
.style
.box
+'"><img src="%src%" style="'+this
.style
.photo
+'">%text%<div style="clear:both;"></div></div></a></div>', msg
= this
.messages
[Math
.floor(Math
.random
()*this
.messages
.length
)]; document.write(template.replace("%src%", msg[0]).replace("%text%", msg[1]));
this.el = document.getElementById("lp_banner_"+this.rid);
this.el.style.position = (this.isIElt7)?"absolute":"fixed";
this.offset = {left: this.el.offsetWidth, top: 0};
this.position = this.calcPosition();
this.el.style.left = this.position.left+"px";
this.el.style.top = this.position.top+"px";
this.posHdlr = window.setInterval (function(){
LP_banner.position = LP_banner.calcPosition();
if(LP_banner.position.left != parseInt(LP_banner.el.style.left) || LP_banner.position.top - LP_banner.offset.top != parseInt(LP_banner.el.style.top)){
LP_banner.el.style.left = (LP_banner.position.left) + "px";
LP_banner.el.style.top = (LP_banner.position.top - LP_banner.offset.top) + "px";
}
}, 50);
window.setTimeout(this.open, this.timeout);
},
open: function(){
LP_banner.el.style.display = "block";
LP_banner.animHdlr = window.setInterval(function(){
LP_banner.offset.top+=LP_banner.step;
if (LP_banner.offset.top > LP_banner.el.offsetHeight){
LP_banner.offset.top = LP_banner.el.offsetHeight;
window.clearInterval(LP_banner.animHdlr);
}
LP_banner.el.style.top=LP_banner.position.top - LP_banner.offset.top + "px";
}, 25)
},
close: function(){
LP_banner.animHdlr = window.setInterval(function(){
LP_banner.offset.top-=LP_banner.step;
if (LP_banner.offset.top < 0){
LP_banner.offset.top = 0;
window.clearInterval(LP_banner.animHdlr);
window.clearInterval(LP_banner.posHdlr);
LP_banner.el.style.display = "none";
var root = LP_banner.el.parentNode;
try {root.removeChild(root.childNodes[0])}
catch(e) {/*alert(e)*/}
}
LP_banner.el.style.top=LP_banner.position.top - LP_banner.offset.top + "px";
}, 25)
}
}
LP_banner.init();