
var hmax;
var vmax;
var pos_h;
var pos_v;
var vit;
var fl_h=true;
var fl_v=true;
var sourisx=0;
var sourisy=0;
var imgheight;
var imgwidth;
var special;


function souris()
{ 
 sourisx=event.x;
 sourisy=event.y;
}

function bouge_div(nom_obj,nom_img,vitesse)
{
imgwidth = document.all[nom_img].width;
imgheight = document.all[nom_img].height;
vmax=screen.height - 130 - imgheight;
hmax=screen.width  - imgwidth;

vit=vitesse;

if (navigator.appName=="Netscape")
 {
   objet1=document.layers[nom_obj];
 }
else
 {
   objet1=document.all[nom_obj].style;
 }

pos_h=parseInt(objet1.left);
pos_v=parseInt(objet1.top);

bouge()
}

function bouge()
{

 special=false;
 if ((sourisx > parseInt(objet1.left)) && (sourisx < parseInt(objet1.left) + imgwidth))
 {
    if ((sourisy>parseInt(objet1.top)) && (sourisy<parseInt(objet1.top) + imgheight))
    {
	special=true;
    }
 }


 if (special==false)
 {
    if ((pos_h>hmax) || (pos_h<1)) fl_h = !fl_h;
    if ((pos_v>vmax) || (pos_v<1)) fl_v = !fl_v;
    if (fl_h) pos_h+=vit;else pos_h-=vit;
    if (fl_v) pos_v+=vit;else pos_v-=vit;
 }

 objet1.left=pos_h;
 objet1.top=pos_v;

 setTimeout('bouge()',20);
}
