$(document).ready(function(){
	   setInterval('changepos()',50);
	   $("#close").click(function(){
          $("#imgbox").hide();
	  });
});
    var xPos = 20,  //左边距离
	    y_Pos = window.screen.height, //向上距离
		yon = 0,
        xon = 0;

function changepos(){
    var obj=document.getElementById("imgbox");
	    obj.style.position="absolute";
    var 
       
        Cwidth = window.screen.width,
        Cheight = window.screen.height,
	    offsetW=obj.offsetWidth,
	    offsetH=obj.offsetHeight;
		
	obj.style.left = xPos + document.body.scrollLeft+"px";
    obj.style.top = y_Pos + document.body.scrollTop+"px";
	
   if(yon){  y_Pos++;  } 
	else{  y_Pos--  }
	
	if(y_Pos<0){
		yon=1;
		y_Pos=0;
		}
		
	if(y_Pos>=(Cheight-offsetH)){
		yon=0;
		y_Pos=Cheight-offsetH;
		
		}
		
	if(xon){  xPos++  }
	
	else {   xPos--   }	
	 
	if(xPos<0){   xon=1;
	              xPos=0;
	        } 
	if(xPos>=(Cwidth-offsetW)){
		xon=0;
		xPos=Cwidth-offsetW;
		}		
	}
 
