var Float_AD = {

    "Ads" : new Object,

    "NewFloatAd" : function(imgUrl, strLink,IsClose)
    {
        var ad = document.createElement("div");
				ad.step = 1;
        ad.DirV = true;
        ad.DirH = true;
        ad.AutoMove = true;
				ad.style.position = "absolute";
        ad.style.left = 0;
        ad.style.top = 0;
        ad.style.zIndex=8888;
        ad.Seed = Math.random();
        ad.Timer = setInterval("Float_AD.Float(" + ad.Seed + ")", 50);
        this.Ads[ad.Seed] = ad;
				var imgads = document.createElement("a");
        imgads.Image = new Image;
        imgads.Image.Parent = imgads;
        imgads.Image.src = imgUrl;
				imgads.onfocus = function(){this.blur();}
        ad.onmouseover = function(){this.AutoMove = false;}
        ad.onmouseout = function(){this.AutoMove = true;}
        if(strLink)
        {
            imgads.href = strLink;
            imgads.Image.border = 0;
           // imgads.Image.width=120;
            //imgads.Image.height=120;
            imgads.target = "_blank";
        }
        imgads.appendChild(imgads.Image);
				var close = document.createElement("span");
				close.style.cursor="hand";
				close.title="点击关闭";
				close.innerHTML ="关闭";
				close.style.position="absolute";
				close.style.left=97;
				close.style.top=107;
				close.onclick = function(){document.body.removeChild(ad);}
				ad.appendChild(imgads);
				if(IsClose)	ad.appendChild(close);
		        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.documentElement.clientWidth + document.documentElement.scrollLeft - ad.step)
            {
                curLeft = document.documentElement.scrollLeft + document.documentElement.clientWidth - ad.offsetWidth;
				ad.DirH = false;
            }
            if(ad.offsetHeight + curTop > document.documentElement.clientHeight + document.documentElement.scrollTop - ad.step)
            {
                curTop = document.documentElement.scrollTop + document.documentElement.clientHeight - ad.offsetHeight;
                ad.DirV = false;
            }
            if(curLeft < document.documentElement.scrollLeft)
            {
                curLeft = document.documentElement.scrollLeft;
                ad.DirH = true;
            }
            if(curTop < document.documentElement.scrollTop)
            {
                curTop = document.documentElement.scrollTop;
                ad.DirV = true;
            }
            ad.style.left = curLeft + (ad.DirH ? ad.step : -ad.step) + "px";
            ad.style.top = curTop + (ad.DirV ? ad.step : -ad.step) + "px";
        }
    }
}