function showList() {
	for(i=0; i<document.getElementsByTagName('select').length; i++)
		document.getElementsByTagName('select')[i].style.visibility = 'visible';
}
function hideList() {
	for(i=0; i<document.getElementsByTagName('select').length; i++)
		document.getElementsByTagName('select')[i].style.visibility = 'hidden';
}

/********************* XMLHTTP REQUEST *********************/
// Variables
var liveReq = false;
var liveReqLayer = 'results';
var IE5MAC = (OS == "Mac" && browser == "Internet Explorer");
var XMLHttpRequestEnabled = (window.XMLHttpRequest) || (window.ActiveXObject);
var XMLHttpRequestCompatible = XMLHttpRequestEnabled && !IE5MAC;
// on !IE we only have to initialize it once
if (window.XMLHttpRequest) {
	liveReq = new XMLHttpRequest();
}
function liveReqDoReq(strRequestUrl) {
	if ( strRequestUrl != "" ) {
		if (liveReq && liveReq.readyState < 4) {
			liveReq.abort();
		}
		if (window.XMLHttpRequest) {
		} else if (window.ActiveXObject) {
			liveReq = new ActiveXObject("Microsoft.XMLHTTP");
		}

		liveReq.onreadystatechange = liveReqProcessReqChange;

		liveReq.open("POST", strRequestUrl);
		liveReq.setRequestHeader('Content-Type','charset=iso-8859-1');
		liveReq.send(null);
	}
  else {
  			if (XMLHttpRequestCompatible) {
	  		document.getElementById(liveReqLayer).innerHTML = '';
	  		document.getElementById(liveReqLayer).style.display = "none";
				}
				else {
				self.close();
				}
	  }
}

function liveReqProcessReqChange() {
	if (liveReq.readyState == 4) {
		document.getElementById(liveReqLayer).innerHTML = liveReq.responseText;
		document.getElementById(liveReqLayer).style.display = "block";
		}
}

function getWindowDim() {
	var x,y;
	if (self.innerHeight) {
		// all except Explorer
		x = self.innerWidth;
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
			// Explorer 6 Strict Mode
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) {
				// other Explorers 
				x = document.body.clientWidth;
				y = document.body.clientHeight;
			}
	return [x,y];
}

function getScrollDim() {
	var x,y;
	if (self.pageYOffset) {
		// all except Explorer
		x = self.pageXOffset;
		y = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
			// Explorer 6 Strict
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		} else if (document.body) {
				// all other Explorers
				x = document.body.scrollLeft;
				y = document.body.scrollTop;
			}
	return [x,y];
}

function getPageDim() {
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) {
		// all but Explorer Mac
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	} else {
		// Explorer Mac;
		//would also work in Explorer 6 Strict, Mozilla and Safari
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	return [x,y];
}

function popupDiv(strURL, intWidth, intHeight) {
	if (XMLHttpRequestCompatible) {
		// pour chaque variable / tableau : 0 -> largeur , 1 -> hauteur
		var WindowDim = getWindowDim();
		var ScrollDim = getScrollDim();
		var PageDim = getPageDim();
	
		//var hauteurVisible = (browser == 'Safari') ? window.innerHeight : document.body.clientHeight;
		//var hauteurCachee = (document.documentElement) ? document.documentElement.scrollTop : document.body.scrollTop;
		//hauteurVisible = (document.documentElement) ? document.documentElement.clientHeight : hauteurVisible;
		//hauteurVisible = window.innerHeight;
		// old	modif yvan prat var layerTop = ((WindowDim[1]/2) + ScrollDim[1]) - (intHeight/2);
		 // modif yvan layer top et layer lift -64   
		var layerTop = ((WindowDim[1]/2) + ScrollDim[1]) - (intHeight) +100;
		var layerLeft = (WindowDim[0]/2) - (intWidth/2)-150 ;
		document.getElementById(liveReqLayer).style.left = layerLeft + 'px';
		if (WindowDim[1] <= intHeight) {
			document.getElementById(liveReqLayer).style.top = 200 + 'px';
		}
		else {
			document.getElementById(liveReqLayer).style.top = layerTop +'px';
		}
		
		document.getElementById(liveReqLayer).style.width= intWidth +'px';
		//document.getElementById(liveReqLayer).style.height= intHeight +'px';
		
		hideList();
		
		liveReqDoReq(strURL);
	}
	else {
	 	doPopUp(strURL, 'popUpDiv', intWidth, intHeight, 'no');
	}
}

/********************* LIEN PAGE OUVRANTE *********************/

function goToURL(strURL) {
	if (XMLHttpRequestCompatible) {
	top.location.href=strURL;
	}
	else {
	opener.location.href=strURL;
	self.close();
	}
}


/********************* SCRIPTS DRAG *********************/

//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine dragbrowser and version.

function DragBrowser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" dragbrowser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var dragbrowser = new DragBrowser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (dragbrowser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (dragbrowser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (dragbrowser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (dragbrowser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (dragbrowser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (dragbrowser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (dragbrowser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (dragbrowser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (dragbrowser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (dragbrowser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (dragbrowser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (dragbrowser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
