﻿//ouvre une fenetre fille retaillable    	
function new_browser(src,name,w,h)
{
	size=",width="+w+",height="+h
	browser=window.open(src,name,"resizable=yes,scrollbars=yes,toolbar=no,status=no,menubar=no,location=0,directories=no"+size)
}


//ouvre une fenetre fille de taille fixe   
function new_browser3(src,name,w,h)
{
	size=",width="+w+",height="+h;
	browser=window.open(src,name,"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no"+size);
}	


//ouvre une photo dans une fenetre fille à la taille de la photo
function fenetrephoto2 (repimages, lo, ha, nomimage,id)
{	
	browser=window.open("visualisation.asp?image="+repimages+"&id="+id, nomimage,"resizable=no,scrollbars=auto,toolbar=no,status=no,menubar=no,location=0,directories=no,width="+lo+",height="+ha)
}

function initListBox(l) {
	while (l.childNodes[0]) { l.removeChild(l.childNodes[0]); }
}

function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
		xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function hide_Map()
{
	var objBody = document.getElementsByTagName('body').item(0);

	var objClose = document.getElementById('close');
	objBody.removeChild(objClose);

	var objLayer = document.getElementById('map');
	objBody.removeChild(objLayer);

	var objOverlay = document.getElementById('overlay');
	objBody.removeChild(objOverlay);

	selects = document.getElementsByTagName('select');
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = 'visible';
	}
}

function show_Map(u, n, w, h) {
	if (window.pageXOffset) { window.pageXOffset = 0; window.pageYOffset = 0; }
	if (document.documentElement) { document.documentElement.scrollLeft = 0; document.documentElement.scrollTop = 0; }
	if (document.body) { document.body.scrollLeft = 0; document.body.scrollTop = 0; }

	var objBody = document.getElementsByTagName('body').item(0);

	selects = document.getElementsByTagName('select');
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = 'hidden';
	}

	var objOverlay = document.createElement('div');
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {hide_Map(); return false;}
	objOverlay.style.height = (getPageSize()[1] + 'px');
	objBody.insertBefore(objOverlay, objBody.firstChild);

	var objClose = document.createElement('div');
	objClose.setAttribute('id','close');
	objClose.innerHTML = '<a href="#" onclick="hide_Map(); return false;"><img src="/img/design/g_close.gif" border="0" /></a>'
	objClose.style.marginTop = '-' + h/2-1 + 'px';
	objClose.style.marginLeft = '+' + w-315 + 'px';
	objBody.insertBefore(objClose, objBody.firstChild);

	var objLayer = document.createElement('iframe');
	objLayer.setAttribute('id','map');
	objLayer.src = u;
	objLayer.frameBorder = 0;
	objLayer.scrolling = 'auto';
	objLayer.style.width = w + 'px';
	objLayer.style.height = h + 'px';
	objLayer.style.marginTop = '-' + h/2 + 'px';
	objLayer.style.marginLeft = '-' + w/2 + 'px';
	objBody.insertBefore(objLayer, objBody.firstChild);
}