﻿// JScript 文件

FloatAd = { 
    "Ads" : new Object, 
    "NewFloatAd" : function(imgUrl, strLink) { 
        var ad = document.createElement("a"); 
        ad.DirV = true; 
        ad.DirH = true; 
        ad.AutoMove = true; 
        ad.Image = new Image; 
        ad.Seed = Math.random(); 
        ad.Timer = setInterval("FloatAd.Float(" + ad.Seed + ")", 50); 
        this.Ads[ad.Seed] = ad; 
        ad.Image.Parent = ad; 
        ad.style.position = "absolute"; 
        ad.style.left = 0; 
        ad.style.top = 0; 
        ad.Image.src = imgUrl; 
        ad.Image.onmouseover = function(){this.Parent.AutoMove = false;} 
        ad.Image.onmouseout = function(){this.Parent.AutoMove = true;} 
        if(strLink) { 
            ad.href = strLink; 
            ad.Image.border = 0; 
            ad.target = "_blank"; 
        } 		
        ad.appendChild(ad.Image); 
        document.body.appendChild(ad); 
        return ad; 
    }, 
    "NewFloatAd1" : function(imgUrl, strLink) { 
   var ad = document.createElement("div"); 
        ad.id="adDiv";
        ad.DirV = true; 
        ad.DirH = true; 
        ad.AutoMove = true; 
        ad.Image = new Image; 
        ad.Seed = Math.random(); 
        ad.Timer = setInterval("FloatAd.Float(" + ad.Seed + ")", 50); 
        this.Ads[ad.Seed] = ad; 
        ad.Image.Parent = ad; 
        ad.style.position = "absolute"; 
        ad.style.left = 0; 
        ad.style.top = 0; 
        //ad.style.backgroundImage = "url("+imgUrl+")"; 
        var timedate= new Date("11/8/2011");
        var now = new Date();    
　　    var date = timedate.getTime() - now.getTime();    
　　    var time = Math.floor(date / (1000 * 60 * 60 * 24));   
        var Html1="<div class=\"divClose\" onclick='document.getElementById(\"adDiv\").style.display=\"none\";'>关闭</div>";
        var Html2="<div class=\"divAd\"onclick=\"window.open('/')\"><div style='padding-top:140px;padding-left:160px;' >"+time+"</div></div>";
        ad.style.height="206px";
        ad.style.width="319px";
        ad.style.cursor="pointer";
        ad.innerHTML=Html1+Html2;
        ad.onmouseover = function(){this.AutoMove = false;}
        
        ad.onmouseout = function(){this.AutoMove = true;}  
       
        document.body.appendChild(ad); 
        return ad; 
         
    }, 
    "NewFloatAd_2" : function(imgUrl, strLink) { 
        var ad = document.createElement("a"); 
        ad.DirV = true; 
        ad.DirH = true; 
        ad.AutoMove = true; 
        ad.Image = new Image; 
        ad.Seed = Math.random(); 
        ad.Timer = setInterval("FloatAd.Float_2(" + ad.Seed + ")", 120); 
        this.Ads[ad.Seed] = ad; 
        ad.Image.Parent = ad; 
        ad.style.position = "absolute"; 
        ad.style.left = 0; 
        ad.style.top = 0; 
        ad.Image.src = imgUrl; 
        ad.Image.onmouseover = function(){this.Parent.AutoMove = false;} 
        ad.Image.onmouseout = function(){this.Parent.AutoMove = true;} 
        if(strLink) { 
            ad.href = strLink; 
            ad.Image.border = 0; 
            ad.target = "_blank"; 
        } 		
        ad.appendChild(ad.Image); 
        document.body.appendChild(ad); 
        return ad; 
    }, 
    "Float_2" : 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"; 
        } 
    },
    "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"; 
           
        } 
    } 
   
} 

