/* JS - AUTEUR: tapaj.net (c) 2007 */

var moveM="";

//****************************************************************************************************
//function bgMenu(destY) { } ds entete GAEC


//****************************************************************************************************
function moveDiv(e) {
//Récupération de la position de la souris    
  if (ie) {
     window.lastX=event.clientX;
     window.lastY=event.clientY;
     }
  else {                   //firefox
     window.lastX=e.clientX;
     window.lastY=e.clientY;
     }

  document.onmousemove=doDrag;
  document.onmouseup=endDrag;                                       
  // alert (document.getElementById(moveM).style.left) ;
  }

//****************************************************************************************************
function doDrag(e) {
  if (moveM=='planPup') document.getElementById('z_modif').style.visibility="hidden" ;
  if (document.getElementById(moveM).style.right) var typePlan='nordEst' ;
  else  var typePlan='nordOuest' ;
  if (ie) {
     // Calcul de l'écart de position de la souris
     var difX=event.clientX-window.lastX;
     var difY=event.clientY-window.lastY;
     //Récupération de la position du div et ajout de l'écart de position de la souris   
     var newX1 ; typePlan=='nordEst' ? newX1 = parseInt(document.getElementById(moveM).style.right)-difX : newX1 = parseInt(document.getElementById(moveM).style.left)+difX;
     var newY1 = parseInt(document.getElementById(moveM).style.top)+difY;
     // Assignation des nouvelles coordonnées au div  
     typePlan=='nordEst' ? document.getElementById(moveM).style.right=newX1+"px" : document.getElementById(moveM).style.left=newX1+"px";
     document.getElementById(moveM).style.top=newY1+"px";
     //Assignation de l'anciènne position de la souris
     if (window.lastX>0) window.lastX=event.clientX;    
     else document.onmousemove=null;
     if (window.lastY>0) window.lastY=event.clientY;  
     else document.onmousemove=null;

     }
  else {
     // Calcul de l'écart de position de la souris
     var difX=e.clientX-window.lastX;
     var difY=e.clientY-window.lastY;
     //Récupération de la position du div et ajout de l'écart de position de la souris
     var newX1 ;  typePlan=='nordEst' ? newX1 = parseInt(document.getElementById(moveM).style.right)-difX : newX1 = parseInt(document.getElementById(moveM).style.left)+difX
     var newY1 = parseInt(document.getElementById(moveM).style.top)+difY;
     // Assignation des nouvelles coordonnées au div              
     if (!isNaN(newY1)) document.getElementById(moveM).style.top=newY1+"px";
     if (!isNaN(newX1)&&( typePlan!='nordEst')) document.getElementById(moveM).style.left=newX1+"px";
     else if (!isNaN(newX1)&&( typePlan=='nordEst')) document.getElementById(moveM).style.right=newX1+"px";
     //Assignation de l'ancienne position de la souris
     if (window.lastX>0) window.lastX=e.clientX;    
     else document.onmousemove=null;
     if (window.lastY>0) window.lastY=e.clientY;
     else document.onmousemove=null;
     }
}

//****************************************************************************************************
function endDrag(e) {
  if (moveM=='planPup') document.getElementById('z_modif').style.visibility="inherit" ;
  moveM="" ;
  //Réinitialisation du onmousemove
  document.onmousemove=null;   
  document.onmouseup=null; 
}

//****************************************************************************************************
function centre(divId,aff) {      //centre l'image en largeur et hauteur : pose des pbs
var offsetX ;
var offsetY ;
var dimX ;
var dimY ;
if (document.getElementById(divId)) {
   dimX = parseInt(document.getElementById(divId).style.width) ;
   dimY = parseInt(document.getElementById(divId).style.height) ;   
   if (!dimX) dimX=500 ;
   if (!dimY) dimY=500 ;
   //alert (dimX + ' - ' + dimY) ;
   if (ie) {
      offsetX=document.body.clientWidth ;
      offsetY=document.body.clientHeight ;
      }
   else {
      offsetX=window.innerWidth ;
      offsetY=window.innerHeight ;
      }
   offsetY=(offsetY-dimY)/2 ;
   offsetX=(offsetX-dimX)/2 ;                                      
   //alert (offsetX + ' - ' + offsetY) ;
   offsetX=Math.max(offsetX,0)+document.body.scrollLeft ;
   offsetX=''+offsetX+'px' ;
   offsetY=Math.max(offsetY,0)+document.body.scrollTop ;
   offsetY=''+offsetY+'px' ;
   document.getElementById(divId).style.left=offsetX;
   document.getElementById(divId).style.top=offsetY;
   affPlan(divId,aff);
   }
return 1 ;
}



