﻿
    var time = 500;
    var h = 0;
    
    
    function addCount()
    {
        if(time>0)
        {
            time--;
            h = h+5;
        }
        else
        {
            return;
        }
        if(h>385)  //高度
        {
            return;
        }
        document.getElementById("ads").style.display = "";
        document.getElementById("ads").style.height = h+"px";
        setTimeout("addCount()",30); 
    }
    function showAds_ok(obj)
    {
		if(getcookie("door"))
        {
        var doorAd=document.createElement("div");
        doorAd.id="ads";
        doorAd.style.cssText="display:none;background-Image:url("+obj.src+"); width:962px; margin:auto; top:0px; height:0px; border:solid 1px #666666;  overflow:hidden; text-align:left;clear:both "
        document.body.insertBefore(doorAd,document.body.firstChild);
      
        addCount();
        setTimeout("noneAds()",7000); //停留时间自己适当调整
        setcookie("door","dd");
        }
    }
    
    
    var T = 385;
    var N = 385; //高度
    function noneAds()
    {
        if(T>0)
        {
            T--;
            N = N-5;
        }
        else
        {
            return;
        }
        if(N<0)
        {
            document.getElementById("ads").style.display = "none";
            return;
        }
        document.getElementById("ads").style.height = N+"px";
        setTimeout("noneAds()",30); 
    }
   
   function getcookie(name)
   {
       if(unescape(document.cookie)=="") return true;
       var cookies=unescape(document.cookie).split(";");
       var s=cookies[0].split('=');
        var datenow=new Date();
        var exp=cookies[1].split('=');
        if(s[0]==name&&datenow.toLocaleString()<exp[1])//cookie名字是当前功能的cookie，且时间间隔5分钟
        return false;
       else
       return true;
   }  
   
   function setcookie(name,value)
   {
   var hour=new Date();
   hour.setMinutes(hour.getMinutes()+5);
   var expiretime="expire="+hour.toLocaleString();
   document.cookie=escape(name+"="+value+";"+expiretime);
   }
   
   //2月8号
   function showAds()
{
    var img = new Image();
    img.src="images/dq2.jpg";
    var appname = navigator.appName.toLowerCase();
    if (appname.indexOf("netscape") == -1)
    {
       //ie
        img.onreadystatechange = function () {
            if (img.readyState == "complete")
            {
			   showAds_ok(img);
            }
        };
    } else {
       //firefox
        img.onload = function () {
            if (img.complete == true)
            {
				  showAds_ok(img);
            }
        }
    }
	 
}




