var dirX = 1;
var dirY = 1;
function fly(){

var t = document.getElementById("floatAdv");
t.style.display = "block";
var x=y=1;
var time = 10;
var step = 1;				
step = step || 1;time = time || 30;
var timer = setInterval(function(){
    var st = document.documentElement.scrollTop || document.body.scrollTop,
        sl = document.documentElement.scrollLeft || document.body.scrollLeft;
        ch =  document.documentElement.clientHeight,
        cw = document.documentElement.clientWidth,
        tp = parseInt(t.style.top || 0),
        left = parseInt(t.style.left || 0);					
    if(tp <= st){
        y = 1;
        t.style.top = st + "px";
    }
    if (tp  >= st + ch - t.offsetHeight){
        y = -1;
        t.style.top = st + ch - t.offsetHeight + "px";
    }
    if(left <=  sl){
        x = 1;
        t.style.left = sl + 'px';
    }
    if(left >= sl + cw - t.offsetWidth){
        x = -1;
        t.style.left = sl + cw - t.offsetWidth + "px";
    }
    t.style.top = parseInt(t.style.top || 0)+(step*y)+"px";
    t.style.left = parseInt(t.style.left || 0) + (step*x) + "px";
    },time);
    t.onmouseover=function(){
    clearInterval(timer);
    }
    t.onmouseout=function(){
    fly();
    }
}

function flashadv(u,p,w,h)
{   
   // setTimeout('qz_adv()',0);
   //fly();
}

function qz_adv(){	
    u = "zx.html";
    p = "images/ad_b.jpg";
    w = 800;
    h = 356;			
    var adv = document.getElementById('qz_adv');
   
    var body = /CSS1Compat/.test(document.compatMode)?document.documentElement:document.body;				
    if(!adv){
        adv = document.createElement('div');				
        var img = document.createElement('img');
        var a = document.createElement('a');
        a.href=u;	
        a.target="_blank";	
        img.src = p;	
        img.width = w;
        img.height = h;	
        a.appendChild(img);
        adv.appendChild(a);
        document.body.appendChild(adv);	
        
                                
    }	
    var ch = ((body.clientHeight-h)+document.documentElement.scrollTop+150)/2,cw = (body.clientWidth-w)/2;	
    img.style.border='0';
    adv.style.cssText="position:absolute;left:"+cw+"px;top:"+ch+"px;";		
    var t = 100;		
    var  timer = setInterval(function(){
    if(t<=30){
        clearInterval(timer);
        document.body.removeChild(adv);		
        fly();	}
    adv.style.cssText="position:absolute;filter:alpha(opacity="+t+");opacity:"+(t/100)+";left:"+cw+"px;top:"+ch+"px";
    t --;
    },60);
        
}

function floatAdv(t,w,d)
{
		    
	d = d || 0;			
	t.style.top = (document.documentElement.scrollTop || document.body.scrollTop) + (document.documentElement.clientHeight-t.offsetHeight)/2+"px";
	t.style.left = (document.documentElement.clientWidth > w ?
							   d ? (w + (document.documentElement.clientWidth - w)/2)>document.documentElement.clientWidth ? document.documentElement.clientWidth-t.offsetWidth :  w + (document.documentElement.clientWidth - w)/2
							   :(document.documentElement.clientWidth - w)/2-t.offsetWidth
							   : d ? document.documentElement.clientWidth - t.offsetWidth : 0) + 'px';
	t.onclick=function(){
	document.getElementById('leftDiv').style.display = "none";
    document.getElementById('rightDiv').style.display = "none";
	};			
}
function floatAll()
{        
	floatAdv(document.getElementById('leftDiv'),900);	
	floatAdv(document.getElementById('rightDiv'),900,1);	
}

function floatInit()
{
	//document.getElementById('leftDiv').style.display ="block";
	//document.getElementById('rightDiv').style.display ="block";	
	//floatAdv(document.getElementById('leftDiv'),900);	
	//floatAdv(document.getElementById('rightDiv'),900,1);
}			
  
window.onscroll=floatAll ;  //窗口的滚动事件，当页面滚动时调用move( )函数