var step = 2; var flyDelay = 14; var height = 0; var Hoffset = 0; var Woffset = 0; var yon = 0; var xon = 0; var flyInterval; var flyTimeout; var startPos = 0; var sleft, stop; var xPos = 20; var yPos; var flyObj; var flyFlying = false; var flyPaused = false; var swapImg = null; var flyImg = null; if (typeof(fly['CookieName']) == 'undefined') { fly['CookieName'] = 'FLY'; } else { fly['CookieName'] = 'FLY'+ fly['CookieName']; } if (typeof(fly['Times']) == 'undefined') { fly['Times'] = 2; } if (typeof(fly['ExpiresIn']) == 'undefined') { fly['ExpiresIn'] = 24 * 60; // in minutes } // Used when one image is for going to the left side and other for going back if (fly['Name_back']) { swapImg = new Image(); // FIXME: should rather use image url here, because we don't alter click // target and this way banner statistics go weird swapImg.src = 'http://www.vara.ee/cgi-bin/click.cgi?action=jump&URL=http://www.vararate.com' } function flyGetObj(id) { if (document.getElementById) { return document.getElementById(id); } if (document.all) { return document.all[id]; } if (document.layers) { return document.layers[id]; } return null; } function flyGetDim() { if ((window.innerWidth && (typeof(document.body) == 'undefined')) || (document.body.clientHeight > window.innerHeight) || (document.innerWidth < document.body.clientWidth)) { pwidth = window.innerWidth; pheight = window.innerHeight; sleft = window.pageXOffset; stop = window.pageYOffset; } else { pwidth = document.body.clientWidth; pheight = document.body.clientHeight; sleft = document.body.scrollLeft; stop = document.body.scrollTop; } stop -= 2; yPos = pheight; } function flyChangePos() { if (yPos >= (pheight - Hoffset)) { yon = 0; yPos = (pheight - Hoffset); } if (flyObj.style) { flyObj.style.left = xPos + sleft; flyObj.style.top = yPos + stop; } else { flyObj.pageY = yPos + stop; flyObj.pageX = xPos + sleft; } if (xon) { xPos = xPos + step; } else { xPos = xPos - step; } if (xPos < 0) { xon = 1; xPos = 0; // reached left border if (swapImg) { flySwapImg(); } } if (xPos >= (pwidth - startPos - Woffset)) { xon = 0; xPos = (pwidth - startPos - Woffset); // reached right border if (swapImg) { flySwapImg(); } } flyGetDim(); } // luckily swapping images like this it will not make another request to webserver function flySwapImg() { var img = new Image(); if (!flyImg) { flyImg = flyGetObj('fly_img'); // this fails for ns4 if (!flyImg) { return; } } img.src = flyImg.src; flyImg.src = swapImg.src; swapImg.src = img.src; } function flyEndFloat() { if (flyObj.style) { flyObj.style.visibility = 'hidden'; flyObj.style.display = 'none'; } else { flyObj.visibility = 'hidden'; } clearInterval(flyInterval); } function flyPrepare() { flyInterval = setInterval('flyChangePos()', flyDelay); flyTimeout = setTimeout('flyEndFloat()', fly['Timeout'] * 2000); flyPaused = false; } function flyLaunch() { flyObj = flyGetObj('flyThing'); if (flyObj) { flyGetDim(); Hoffset = (flyObj.offsetHeight ? flyObj.offsetHeight : flyObj.clip.height); Woffset = (flyObj.offsetWidth ? flyObj.offsetWidth : flyObj.clip.width); if (pwidth > 770) { startPos = (pwidth - 770) / 2; } if (flyObj.style) { flyObj.style.visibility = 'visible'; } else { flyObj.visibility = 'visible'; } flyFlying = true; flyPrepare(); } } function flyMouseOver() { if (flyFlying) { clearInterval(flyInterval); clearTimeout(flyTimeout); flyPaused = true; } } function flyMouseOut() { if (flyFlying && flyPaused) { flyPrepare(); } } function FLYcheckRef() { newDomain = dhtmlTheDomain.replace(/\./gi, '\\.'); re = new RegExp("^http:\/\/\\w+\."+ newDomain, "i"); if (re.test(document.referrer)) { return true; } else { return false; } } function flySetup() { var cookie = dhtmlGetCook(fly['CookieName']); var overTimes = 0; if (fly['Times'] != DHTML_IGNORE_COOKIES) { if (cookie == DHTML_NO_COOKIES) { overTimes = 1; } else { if (cookie != false) { var count = dhtmlGetCount(cookie); var FLYs = dhtmlGetCook(fly['CookieName'] + 's'); if ((count >= fly['Times']) || (FLYs == '1') || FLYcheckRef()) { overTimes = 1; } else { dhtmlSetCook(fly['CookieName'], ++count, fly['ExpiresIn']); } } else { dhtmlSetCook(fly['CookieName'], 1, fly['ExpiresIn']); } } } if (!overTimes && typeof(dhtmlPush) != 'undefined') { dhtmlPush('flyLaunch'); } } flySetup();