// JavaScript Document
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var dobj;

var LIDduDIV;

var LEFT;
var TOP;
function Teste_Navigateur()
{

		Nom_Browser = navigator.appName;
		Version_Browser = navigator.appVersion;
		if ( Nom_Browser == "Netscape" )
		{
			return 1;
		}
		if ( Nom_Browser == "Microsoft Internet Explorer" )
		{
			return 2;
		}
		return 2;
}
//// recuperation de position d'objets dans la page
function getOffsetPosition(inID, inTYPE)
{
 var iVal = 0;
 var oObj = document.getElementById(inID);
 var sType = 'oObj.offset' + inTYPE;
 while (oObj && oObj.tagName != 'BODY') {
  iVal += eval(sType);
  oObj = oObj.offsetParent;
 }
 return iVal;
}

/////////////////////////////////   DEBUT DES FONCTIONS DRAG UTILISANT LES FONCTIONS CI-DESSUS
function movemouse(e)
{
  if (isdrag)
  {
    LEFT = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
	TOP = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
	
	var iNav = Teste_Navigateur();
	if( iNav == 1)
	{
		dobj.setAttribute('style' ,  'position:absolute; visibility:visible; width:280px; height:280px; z-index:500; left:'+LEFT+'px; top:'+TOP+'px;' );
		return false;
	}
	if( iNav == 2)
	{
		dobj.style.left = LEFT;
   		dobj.style.top  = TOP;
		dobj.style.visibility  = 'visible';
	}
  }
}

function selectmouse(e)
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";
  while (fobj.tagName != topelement && fobj.id != "supportZoom" && fobj.id != "supportZoom")
  {
	LIDduDIV = nn6 ? fobj.parentNode : fobj.parentElement;
	fobj = LIDduDIV;
  }
  //// pour la fenetre de rappel
  if (fobj.id=="supportZoom" || fobj.id=="FENETRE_VIDEO" )
  {
	/// releve de la position du div en question 
	var myTOP =  Number(getOffsetPosition(fobj.id, 'Top'));
	var myLEFT = Number(getOffsetPosition(fobj.id, 'Left'));
	 
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+myLEFT,10);
    ty = parseInt(dobj.style.top+myTOP,10);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }  
}
//window.document.onmousedown=selectmouse;
//window.document.onmouseup=new Function("isdrag=false");

function ActiveEcouteurDrag()
{
	LIDduDIV = 'FENETRE_RAPPEL';
}

function DesactiveDrag()
{
	window.document.onmousemove=new Function("isdrag=false");
	isdrag=false;
}

function Affiche_zoom(image)
{
	var iNav = Teste_Navigateur();
	
	if( iNav == 1)// SAFARI
		{
			//taille = document.getElementById('cadre').innerHeight;
			var obj = document.getElementById('supportZoom');
			if( obj != null ) obj.setAttribute('style', 'display:block; position:absolute; top:150px; left:200px; background:#000000; visibility:visible; border:2px solid #000000;' );
			//alert(image);
			var obj2 = document.getElementById('imageZoom');
			if( obj2 != null ) obj2.setAttribute('src' , '../images/manoir/'+image ); 
		}
	if( iNav == 2)//ie
		{
			//alert(document.getElementById('cadre').clientHeight);
			var obj = document.getElementById('supportZoom');
			if( obj != null ) obj.style.visibility = 'visible' ;
			
			var obj = document.getElementById('imageZoom');
			if( obj != null ) obj.src = '../images/manoir/'+image ;
		}
}
function Masque_zoom()
{
	//alert('Masque_rappel');
	var iNav = Teste_Navigateur();
	
	if( iNav == 1)// SAFARI
		{
			
			//taille = document.getElementById('cadre').innerHeight;
			var obj = document.getElementById('supportZoom');
			if( obj != null ) obj.setAttribute('style' ,  'display:block; position:absolute; top:50px; left:50px; width:200; background:#00CC66; visibility:hidden;' );
			
		}
	if( iNav == 2)//ie
		{
			//alert(document.getElementById('cadre').clientHeight);
			var obj = document.getElementById('supportZoom');
			if( obj != null ) obj.style.visibility = 'hidden' ;	
		}
	
}



