﻿        var isClose=false;
        var  isOnlineClose=false;
        function OnShowAD(){
            if(!isClose){
                ShowAD();
            }
            if(!isOnlineClose){
                ShowOnline();
            }
            var div1 = document.getElementById("divAD1");
            var div2 = document.getElementById("divAD2");
            var online = document.getElementById("online");
            
            var bodyHeight=document.documentElement.clientHeight; 
            if(bodyHeight==0){
                bodyHeight=document.body.clientHeight; 
            }
            var bodyWidth=document.documentElement.clientWidth;  
             if(bodyWidth==0){
                bodyWidth=document.body.clientWidth; 
            }
            var bodyTop=document.documentElement.scrollTop;
             if(bodyTop==0){
                bodyTop=document.body.scrollTop; 
            }
            var div1width;
            //设置广告层1位置
            if(div1){
                div1.style.top= bodyTop+bodyHeight*2/3;
                div1.style.left= "0";
                div1width=div1.offsetWidth;
            }else{
                div1width=0;
            }
            //设置广告层2位置
            if(div2){
                div2.style.top= bodyTop+bodyHeight*2/3;
                div2.style.left= bodyWidth-div1width;
                //保证层位置正常，再赋值一次
                div2.style.top= bodyTop+bodyHeight*2/3;
                div2.style.left= bodyWidth-div1width;
            }
            //设置客服层位置
             if(online){
                online.style.top= bodyTop+50;
                online.style.left= bodyWidth-online.offsetWidth;
            }
       }
       
       function CloseAD(){
            var div1 = document.getElementById("divAD1");
            var div2 = document.getElementById("divAD2");
            if(div1){
                div1.style.visibility="hidden";
            }
            if(div2){
                div2.style.visibility="hidden";
            }
            isClose=true;
       }

       function ShowAD(){
            var div1 = document.getElementById("divAD1");
            var div2 = document.getElementById("divAD2");
            if(div1){
                div1.style.visibility="";
            }
            if(div2){
                div2.style.visibility="";
            }
       }
       
        function CloseOnline(){
              var online = document.getElementById("online");
             if(online){
                online.style.visibility="hidden";
            }
            isOnlineClose=true;
       }
       
        function ShowOnline(){
            var online = document.getElementById("online");
            if(online){
                online.style.visibility="";
            }            
       }
       
      window.onscroll= OnShowAD;
      window.onresize= OnShowAD;
      window.onload= OnShowAD;