var oBAO;

var largeurFenetre = 45;	
var topFenetre = 50;			
var leftFenetre= 500;	

var topFenetreResult = 300;			
var leftFenetreResult = 300;	

var topFenetreInfo = 300;			
var leftFenetreInfo = 300;	
var largeurFenetreInfo = 240;

var BAOActif = true;//ToolBox
var zoomActif = true;//Zoom
var visuActif = true;//Visibility
var coordActif = false;//Coord
var valActif = true;//Value
var motCleActif = false;//Search

if (BAOActif){visu="visible"}else{visu="hidden"}
if (zoomActif) largeurFenetre+=40;
if (visuActif) largeurFenetre+=40;
if (coordActif) largeurFenetre+=40;
if (valActif) largeurFenetre+=40;
if (motCleActif) largeurFenetre+=40;

var hauteurBarretitre = 13; 
var couleurHaut = "#7392C6";	
var couleurBas = "#FFFFFF";

var texteBarretitre = "<b>Outils</b>";
var policeBarretitre = "Arial";
var taillePoliceBarretitre = "12";
var couleurPoliceBarretitre = "#FFFFFF";

var policeCorps = "Arial";
var taillePoliceCorps = "12";
var couleurPoliceCorps = "#000000";

var policeListe = "Arial";
var taillePoliceListe = "10";
var couleurPoliceListe = "#000000";

var texteBarretitreInfo = "<b>Informations</b>";

var clic = false;
var clicZoom = false;
var clicVisu = false;
var clicCoord = false;
var clicVal = false;
var clicResult = false;
var clicInfo = false;
var clicRech = false;

function clicDownBAO(tab) {
	abscisse = abs-leftFenetre;
	ordonne = ord-topFenetre;
	clic=true;
}
function clicUpBAO() {
		clic=false;
}
function fermerPopupBAO() {
	oBAO.style.visibility="hidden";
}

function clicDownResult(tab) {
	abscisse = abs-leftFenetreResult;
	ordonne = ord-topFenetreResult;
	clicResult=true;
}
function clicUpResult() {
		clicResult=false;
}


function clicDownInfo(tab) {
	abscisse = abs-leftFenetreInfo;
	ordonne = ord-topFenetreInfo;
	clicInfo=true;
}
function clicUpInfo() {
	clicInfo=false;
}
function fermerPopupInfo() {
	oINFO.style.visibility="hidden";
}

function get_mouse(e){
	if (document.getElementById && document.all) {
		// Internet explorer
		abs = event.x+document.body.scrollLeft;
		ord = event.y+document.body.scrollTop;
	} else if (document.getElementById) {
		// Netscape 6+
		abs = e.pageX
		ord = e.pageY
	} 
	if(clic && document.getElementById){
		leftFenetre = abs-abscisse;
		topFenetre = ord-ordonne;
		oBAO.style.left = leftFenetre;
  		oBAO.style.top = topFenetre;
	}
	if(clicZoom && document.getElementById){
		leftFenetreZoom = abs-abscisse;
		topFenetreZoom = ord-ordonne;
		oZOOM.style.left = leftFenetreZoom;
  		oZOOM.style.top = topFenetreZoom;
	}
	if(clicVisu && document.getElementById){
		leftFenetreVisu = abs-abscisse;
		topFenetreVisu = ord-ordonne;
		oVISU.style.left = leftFenetreVisu;
  		oVISU.style.top = topFenetreVisu;
	}
	if(clicCoord && document.getElementById){
		leftFenetreCoord = abs-abscisse;
		topFenetreCoord = ord-ordonne;
		oCOORD.style.left = leftFenetreCoord;
  		oCOORD.style.top = topFenetreCoord;
	}
	if(clicVal && document.getElementById){
		leftFenetreVal = abs-abscisse;
		topFenetreVal = ord-ordonne;
		oVALCHP.style.left = leftFenetreVal;
  		oVALCHP.style.top = topFenetreVal;
	}
	if(clicResult && document.getElementById){
		leftFenetreResult = abs-abscisse;
		topFenetreResult = ord-ordonne;
		oFIND.style.left = leftFenetreResult;
  		oFIND.style.top = topFenetreResult;
	}
	if(clicInfo && document.getElementById){
		leftFenetreInfo = abs-abscisse;
		topFenetreInfo = ord-ordonne;
		oINFO.style.left = leftFenetreInfo;
  		oINFO.style.top = topFenetreInfo;
	}
	if(clicRech && document.getElementById){
		leftFenetreRech = abs-abscisse;
		topFenetreRech = ord-ordonne;
		oRECHCHP.style.left = leftFenetreRech;
  		oRECHCHP.style.top = topFenetreRech;
	}
}

function clicMenu(elmt_menu){
	switch (elmt_menu) {
		case "zoom":
			if (oZOOM){
			if(oZOOM.style.visibility=="hidden"){
				oZOOM.style.visibility="visible"}else{
				oZOOM.style.visibility="hidden"}
			}
			break;
		case "visu":
			if (oVISU){
			if(oVISU.style.visibility=="hidden"){
				oVISU.style.visibility="visible"}else{
				oVISU.style.visibility="hidden"}
			}
			break;
		case "coord":
			if (oCOORD){
			if(oCOORD.style.visibility=="hidden"){
				oCOORD.style.visibility="visible"}else{
				oCOORD.style.visibility="hidden"}
			}
			break;
		case "valeur":
			if (oVALCHP){
			if(oVALCHP.style.visibility=="hidden"){
				if(!loadedVal){typeFeed();sTypeFeed();loadedVal=true}					
				oVALCHP.style.visibility="visible"}else{
				oVALCHP.style.visibility="hidden"}
			}
			break;
		case "mot_cle":
			if (oRECHCHP){
			if(oRECHCHP.style.visibility=="hidden"){
				if(!loadedRech){typeFeedRech();sTypeFeedRech();loadedRech=true}					
				oRECHCHP.style.visibility="visible"}else{
				oRECHCHP.style.visibility="hidden"}
			}
			break;
		case "info":
			if (oINFO){
			if(oINFO.style.visibility=="hidden"){					
				oINFO.style.visibility="visible"}else{
				oINFO.style.visibility="hidden"}
			}
			break;
	}
}

function showResult(){
	oFIND.style.visibility="visible";
}

function showHideResult(){
	if(oFIND.style.visibility=="hidden"){
		oFIND.style.visibility="visible"}else{
		oFIND.style.visibility="hidden"}
}

if (document.getElementById && !document.all) {
	document.captureEvents(Event.MOUSEMOVE);
}	

document.onmousemove = get_mouse;

function popup_BAO(){
	if (document.getElementById) {
		document.write('<style type="text/css">')
		document.write('table.popup {')
		document.write('	border: 1px solid #000000;}')
		document.write('td.titre {')
		document.write('	font-family: '+policeBarretitre+';')
		document.write('	font-size: '+taillePoliceBarretitre+'px;')
		document.write('	color: '+couleurPoliceBarretitre+';}')
		document.write('td.corps {')
		document.write('	font-family: '+policeCorps+';')
		document.write('	font-size: '+taillePoliceCorps+'px;')
		document.write('	color: '+couleurPoliceCorps+';}')
		document.write('td.liste {')
		document.write('	font-family: '+policeListe+';')
		document.write('	font-size: '+taillePoliceListe+'px;')
		document.write('	color: '+couleurPoliceListe+';}')		
		document.write('</style>')
		document.write('<div id=BAO STYLE="position:absolute; z-index:10; top:'+topFenetre+'px; left:'+leftFenetre+'px;visibility:'+ visu +';filter:alpha(opacity=90)">')       
		document.write('<table width="'+largeurFenetre+'"  height="60" border="1" cellspacing="0" cellpadding="0" class="popup">')		
		document.write('<tr onmousedown="clicDownBAO()" onmouseup="clicUpBAO()">')
		document.write('<td bgcolor="'+couleurHaut+'" class="titre" width="'+largeurFenetre+'" height="13" style="cursor: move">' + texteBarretitre +'</td>')
		document.write('<td bgcolor="'+couleurHaut+'"><!--<img src="fonctions/img/b_fermer.gif" width="13" height="13" onclick="fermerPopupBAO()">--></td>')
		document.write('</tr>')
		document.write('<tr valign="center">') 
		document.write('<td bgcolor="'+couleurBas+'" width="'+largeurFenetre+'" colspan="2" class="corps">')
		if (zoomActif) {document.write('<img src="fonctions/img/b_zoom.gif" alt="Zoom" width="30" height="30" hspace="5" vspace"5" onClick="clicMenu(\'zoom\')">')}
		if (visuActif) {document.write('<img src="fonctions/img/b_visu.gif" alt="Visibilits" width="30" height="30" hspace="5" vspace"5" onClick="clicMenu(\'visu\')">')}
		if (coordActif) {document.write('<img src="fonctions/img/b_rech_coord.gif" alt="Recherche coordonnes" width="30" height="30" hspace="5" vspace"5" onClick="clicMenu(\'coord\')">')}
		if (valActif) {document.write('<img src="fonctions/img/b_rech_val.gif" alt="Recherche par valeur" width="30" height="30" hspace="5" vspace"5" onClick="clicMenu(\'valeur\')">')}
		if (motCleActif) {document.write('<img src="fonctions/img/b_rech_motCle.gif" alt="Recherche par mot-cl" width="30" height="30" hspace="5" vspace"5" onClick="clicMenu(\'mot_cle\')">')}
		if (valActif || motCleActif) {document.write('<img src="fonctions/img/b_liste.gif" alt="Liste" width="30" height="30" hspace="5" vspace"5" onClick="showHideResult()">')}
		document.write('<img src="fonctions/img/b_info.gif" alt="Informations" width="30" height="30" hspace="5" vspace"5" onClick="clicMenu(\'info\')">')		
		document.write('</td>')
		document.write('</tr>')
		document.write('</table>')
		document.write('</div>')
		
		document.write('<div id="objectFind" style="position:absolute; top:'+topFenetreResult+'px;left:'+leftFenetreResult+'px;height:300px;width:500px;visibility:hidden;overflow:scroll;background-color:#FFFFFF;filter:alpha(opacity=90);border:1px solid #000000">')
		document.write('<table border="1" cellspacing="0" cellpadding="0" class="popup">')
		document.write('<tr><td width="13" bgcolor="'+couleurHaut+'" class="titre" style="cursor: move" onmousedown="clicDownResult()" onmouseup="clicUpResult()"><img src="fonctions/img/pix_trans.gif" width="13"></td><td id="content"></td></tr>')
		document.write('</table>')
		document.write('</div>')
		
		document.write('<div id=BINFO STYLE="position:absolute;top:'+topFenetreInfo+'px;left:'+leftFenetreInfo+'px;visibility:hidden;filter:alpha(opacity=90)">')       
		document.write('<table width="'+largeurFenetreInfo+'" border="1" cellspacing="0" cellpadding="0" class="popup">')
		document.write('<tr onmousedown="clicDownInfo()" onmouseup="clicUpInfo()">')
		document.write('<td bgcolor="'+couleurHaut+'" class="titre" width="'+largeurFenetre+'" height="13" style="cursor: move">' + texteBarretitreInfo +'</td>')
		document.write('<td bgcolor="'+couleurHaut+'" class="titre" width="13" height="13"><img src="fonctions/img/b_fermer.gif" width="13" height="13" onclick="fermerPopupInfo()"></td>')
		document.write('</tr>')
		document.write('<tr valign="top">') 
		document.write('<td id="infoValue" bgcolor="'+couleurBas+'" width="'+largeurFenetre+'" colspan="2" class="corps">')
		document.write('</td>')
		document.write('</tr>')			
		document.write('</table>')
		document.write('</div>')
	}
	oBAO = document.getElementById("BAO");
	oFIND = document.getElementById("objectFind");
	oINFO = document.getElementById("BINFO");
}


