function cintPopup() { this.mainEl = false; this.status = false; this.maxviews = 2; this.target = 'http://www.start.no/panelet/'; this.campaign = 564; this.zone = 87; this.media = 1195; } cintPopup.prototype.init = function() { if(typeof(jQuery) != 'undefined') { var status = this.getStatus(); if(status >= 0 && status < this.maxviews) { jQuery(document).load(this.generate()); } } } cintPopup.prototype.generate = function() { var a = document.createElement("div"); a.style.position = 'fixed'; a.style.display = 'none'; a.style.bottom = '0px'; a.style.right = '10px'; a.style.height = '170px'; a.style.width = '300px'; a.id = 'cintPopup'; a.style.zIndex = 99; var b = document.createElement("div"); b.style.height = '170px'; b.style.width = '300px'; b.style.position = 'absolute'; b.style.top = 0; b.style.left = 0; b.style.backgroundColor = '#7A9625'; var br = '5px'; b.style.MozBorderRadius = br; b.style.WebkitBorderRadius = br; b.style.borderRadius = br; b.style.zIndex = 103; a.appendChild(b); var c = document.createElement("iframe"); c.style.height = '160px'; c.style.width = '290px'; c.style.position = 'absolute'; c.style.top = '5px'; c.style.left = '5px'; c.style.border = '0px none'; c.style.backgroundColor = '#FFFFFF'; c.scrolling = 'no'; c.src = 'http://www.start.no/includes/ads/cint/cintPopup.php'; c.style.zIndex = 104; c.style.overflow = 'hidden'; a.appendChild(c); var d = document.createElement("img"); d.style.height = '18px'; d.style.width = '17px'; d.style.zIndex = 105; d.style.cursor = 'pointer'; d.src = 'http://g2.start.no/ads/cint/x.gif'; d.style.top = '4px'; d.style.right = '6px'; d.style.position = 'absolute'; a.appendChild(d); jQuery(d).click(function(){ cintPop.close(); }); var e = document.createElement("a"); e.target = '_blank'; var randomnumber=Math.floor(Math.random()*99999999); var now = new Date(); var timestamp = now.getFullYear() + this.dtns(now.getMonth() + 1) + this.dtns(now.getDate()) + this.dtns(now.getHours()) + this.dtns(now.getMinutes()) + this.dtns(now.getSeconds()); e.href = 'http://ad.start.no/advertpro/servlet/click/campaign?cid=' + this.campaign + '&zid=' + this.zone + '&mid=' + this.media + '&pid=0&default=false&random=' + randomnumber + '×tamp=' + timestamp + '&test=false&referrer=' + encodeURIComponent(location.href) + '&redirect=' + encodeURIComponent(this.target); e.style.width = '290px'; e.style.height = '140px'; e.style.position = 'absolute'; e.style.top = '25px'; e.style.left = '5px'; e.style.backgroundImage = "url('http://g2.start.no/ads/cint/pixel.gif')"; var vcUrl = 'http://ad.start.no/advertpro/servlet/view/banner/image/campaign?cid=' + this.campaign + '&pid=0&position=1&random=' + randomnumber + '×tamp=' + timestamp; e.style.backgroundImage = "url('" + vcUrl + "')"; e.style.zIndex = 110; a.appendChild(e); jQuery(e).click(function(){ cintPop.clicked(); }); document.getElementsByTagName('body')[0].appendChild(a); this.mainEl = a; var status = this.getStatus(); status++; this.setStatus(status); setTimeout(function(){cintPop.pop()}, 5000); } cintPopup.prototype.pop = function() { jQuery(this.mainEl).slideToggle(1000); } cintPopup.prototype.getStatus = function() { // Status: // 0 - no cookie // 1 - user has seen ad once // 2 - user has seen ad twice // 12 - user has clicked the ad // 13 - user has closed the ad if(this.status == false) { var co = new String(document.cookie); var cm = co.match(/cintboxstatus=([0-9]*)(; |$)/); if(cm != null && !isNaN(cm[1])) { this.status = cm[1]; } else { this.status = 0; } } return this.status; } cintPopup.prototype.setStatus = function(status) { var days_expiry = 30; var expiry=new Date(); expiry.setDate(expiry.getDate() + days_expiry); document.cookie = "cintboxstatus=" + escape(status) + "; expires=" + expiry.toUTCString() + '; path=/; domain=.start.no'; this.status = status; } cintPopup.prototype.clicked = function() { this.setStatus(12); this.hide(); } cintPopup.prototype.close = function() { this.setStatus(13); this.hide(); } cintPopup.prototype.hide = function() { jQuery(this.mainEl).slideToggle(400); } cintPopup.prototype.dtns = function(num) { if(num > 10) { return num; } else return '0' + num; } var cintPop = new cintPopup(); cintPop.init();