var WaveSwfAds = {
    "Ads" : new Object,
    "NewFloatAd" : function(swfUrl, swfWidth, swfHeight)
    {
        var ad = document.createElement("div");
        ad.DirV = true;
        ad.DirH = true;
        ad.AutoMove = true;
        ad.Seed = Math.random();
        ad.Timer = setInterval("WaveSwfAds.Float(" + ad.Seed + ")", 20);
        this.Ads[ad.Seed] = ad;
        ad.style.cssText="z-index:99999;";
        ad.style.position = "absolute";
        ad.style.left = 0;
        ad.style.top = 0;
        
        ad.onmouseover = function(){this.AutoMove = false;}
        ad.onmouseout = function(){this.AutoMove = true;}

        //var so_0 = new SWFObject(swfUrl, "", swfWidth, swfHeight, "8", "");
        //so_0.addParam("wmode","transparent");
        //so_0.write(ad);

        reval  = "";
        reval += "<embed type=\"application/x-shockwave-flash\" src=\""+swfUrl+"\" style=\"\" id=\"undefined\" name=\"undefined\" quality=\"high\" wmode=\"transparent\" width=\""+swfWidth+"\" height=\""+ swfHeight +"\">";

        ad.innerHTML=reval;
        
        document.body.appendChild(ad);
        return ad;
    },
    "Float" : function(floatId)
    {
        var ad = this.Ads[floatId];
        if(ad.AutoMove)
        {
            var curLeft = parseInt(ad.style.left);
            var curTop = parseInt(ad.style.top);
            if(ad.offsetWidth + curLeft > document.body.clientWidth + document.body.scrollLeft - 1)
            {
                curLeft = document.body.scrollLeft + document.body.clientWidth - ad.offsetWidth;
                ad.DirH = false;
            }
            if(ad.offsetHeight + curTop > document.body.clientHeight + document.body.scrollTop - 1)
            {
                curTop = document.body.scrollTop + document.body.clientHeight - ad.offsetHeight;
                ad.DirV = false;
            }
            if(curLeft < document.body.scrollLeft)
            {
                curLeft = document.body.scrollLeft;
                ad.DirH = true;
            }
            if(curTop < document.body.scrollTop)
            {
                curTop = document.body.scrollTop;
                ad.DirV = true;
            }
            ad.style.left = curLeft + (ad.DirH ? 1 : -1) + "px";
            ad.style.top = curTop + (ad.DirV ? 1 : -1) + "px";
        }
    }
}
