<!--

/**
 * function  getBrowser - renvoie des informations sur le navigateur
 *
 * Renvoie un tableau contenant (browser, version, OS)
 *
 */
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

function getBrowser() {
	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari'))	browser = "Safari";
	else if (checkIt('omniweb'))browser = "OmniWeb";
	else if (checkIt('opera'))	browser = "Opera";
	else if (checkIt('webtv'))	browser = "WebTV";
	else if (checkIt('icab'))	browser = "iCab";
	else if (checkIt('msie'))	browser = "Internet Explorer";
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux'))	 OS = "Linux";
		else if (checkIt('x11')) OS = "Unix";
		else if (checkIt('mac')) OS = "Mac"
		else if (checkIt('win')) OS = "Windows"
		else OS = "an unknown operating system";
	}
	tab = Array();
	tab["Name"] = browser;
	tab["Version"] = version;
	tab["OS"] = OS;

	return tab;
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}




/**
 * function  popUpWindow - opens a new pop up window
 *
 * Order: The function opens a new pop up window with the given size.
 * According to the OS and the browser, it returns HTML code
 *
 * @param   adresse : page uri to disply in the window;
 * @param   nom : name of the window
 * @param   largeur : width of the window
 * @param   hauteur : height of the window
 * @param   redim : "yes" to set the window resizable, "no" to set the window not resizable
 * @param       scrollin : "yes" to force scrolling, "no" to disable scrolling, "auto" to enable scrolling
 */
function popUpWindow (adresse, nom, largeur, hauteur, redim, scrolling){
    win = window.open(adresse, nom, 'toolbar=no,location=no,status=no,menubar=no,width='+largeur+',height='+hauteur+',resizable='+redim+',scrollbars='+scrolling);
    win.focus();
}

/**
 * function  openPdf - opens pdf document in a new pop up window
 * Order: The function opens a new pop up window with the given path.
 * @param   chemin : page uri to display in the window;
 */
function openPdf(chemin){
    viewpdf = window.open(chemin,"VIEW_PDF","height=550,width=640,resizable=yes,scrollbars=yes");
    viewpdf.focus();
}


function popPDF(file)
{
  if (window.pdfWindow)
  {
     pdfWindow.focus();
  }
  else
  {
     pdfWindow = window.open(file);
  }
}

function popFig (url){
	window.open('/figure.php?illus='+url, 'Websurg', 'menubar=0,toolbar=0,status=0,width=545,height=545,resizable=1,scrollbars=0');
}


/**
 * function  rollover - replace the image uri by a other one
 * 
 * Order : replace the image specified by the attibute "name" 
 * or the index of the image in the page images table.
 *
 * @param   index : index of the image in the page images table or the image name
 * @param   imageName : name of the image object created below
 */

function rollover(index, imageName) {
    if (document.images) {
        document.images[index].src = eval(imageName+".src");
    }
}

/**
 * function  replace - Replaces text with by in string
 * 
 * Order : replace the substring "text"by the sybstring "by" in the string "string"
 *
 * @param   string : the string containing the text
 * @param   text : the substring to replace
 * @param       by : the new substring
 *
 * @return      newstr : the string after to replace.
 */
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
        return newstr;
}

/**
 * function  newImage - create an image object with a specified uri.
 * 
 * Order : returns a Image object with a given src property 
 *
 * @param   arg : the uri of the image
 *
 * @return      rslt : the Image object .
 */

function newImage(arg) {
        if (document.images) {
            rslt = new Image();
            rslt.src = arg;
            return rslt;
        }
		return false;
    }

/**
 * function  changeImages - replace the images uri by a other ones 
 * 
 * Order : this function can replace simultaneously the several images.
 * The goal is to get rollover effects. 
 * It replace the images specified by the attibutes "name" 
 * or the indexes of the images in the page images table.
 *
 * Example :  onmouseover="changeImages(3, 'Image/texteOver_home.gif', 4, 'Image/home_over.gif'); return true;" 
 *
 * @param   argument n : index of the image in the page images table or the image name
 * @param   argument n+1 : the image uri
 */
function changeImages() {
    if (document.images) {
            for (var i=0; i<changeImages.arguments.length; i+=2) {
                document.images[changeImages.arguments[i]].src = changeImages.arguments[i+1];
            }
    }
}

function reloadParent() {
	if (window.opener.name == 'ws') {
            window.opener.location = window.opener.location;
        }
    }

function fullscreen() {
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
}

function reduce() {
	window.resizeTo(760,420);
	window.moveTo((screen.availWidth-760)/2, (screen.availHeight-420)/2);
}









function selectNav(ID) {
	
	args = selectNav.arguments;
	doSelectNavSt2 = (args[1]==null || args[1]!=null && args[1]==true);

	if(headerMenuStyle==3) {
		selectNavSt2(ID);
		return;
	}

	if(doSelectNavSt2 && headerMenuStyle==2)
		selectNavSt2('');


	isDefaultID = (ID==defaultID);

	if(currID == null || currID != null && currID != ID) {
		if(currID != null) {
			if(document.getElementById("nav2_" + currID))
				document.getElementById("nav2_" + currID).style.display = "none";
			if(document.getElementById("link_" + currID)) {
//				if(currID!=defaultID)
//					document.getElementById("link_" + currID).className = "";
			}
		}
		currID = ID;

		if(document.getElementById("nav2_" + ID))
			document.getElementById("nav2_" + ID).style.display = "block";
		else if(ID != "DEF")
			selectNav("DEF");
	}
}




function selectNavSt2(ID) {
	isDefaultID = (ID==defaultID);

	if(ID!="" && currID != defaultID)
		selectNav(defaultID, false);

	if(ID=="" && currIDst2 == "")
		return;


	if(currIDst2 == null || currIDst2 != null && currIDst2 != ID) {
		if(currIDst2 != null) {
			if(document.getElementById("nav2_st2_" + currIDst2))
				document.getElementById("nav2_st2_" + currIDst2).style.display = "none";
			if(document.getElementById("link_" + currIDst2)) {
//				if(currIDst2!=defaultID)
//					document.getElementById("link_" + currIDst2).className = (currIDst2==defaultID ? "hi" : "");
			}
		}
		currIDst2 = ID;


			if(document.getElementById("nav2_st2_" + ID)) {
				document.getElementById("nav2_st2_" + ID).style.display = "block";
				if(document.getElementById("link_" + ID)) {
//					if(ID!=defaultID)
//						document.getElementById("link_" + ID).className = "over" + (ID==defaultID ? " hi" : "");
				}
			}
	}
}









function placeMenu(IDmenu, elementToPlace) {
	if(document.getElementById(elementToPlace) && document.getElementById(IDmenu)) {
		args = placeMenu.arguments;

		//var align	= (args[2]!=null ? args[2] : "left");
		var offsetX	=  0 + (args[2]!=null ? args[2] : 0);
		var offsetY	= 34 + (args[3]!=null ? args[3] : 0);
		var a = new Object();
		a = getPosition(document.getElementById(elementToPlace));
		document.getElementById(IDmenu).style.left = eval(a.x) + offsetX;
		document.getElementById(IDmenu).style.top = eval(a.y) + offsetY;
	}
}



function getPosition(element)
{
	var elem=element, tagname="", x=0, y=0;
  
	while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
	{
		y+=elem.offsetTop;
		x+=elem.offsetLeft;
		tagname=elem.tagName.toUpperCase();

		if(tagname=="BODY")
			elem=0;

		if(typeof(elem)=="object")
			if (typeof(elem.offsetParent)=="object")
				elem=elem.offsetParent;
	}

	position = new Object();
	position.x = x;
	position.y = y;
	return position;
}

function getSize(element)
{
	var elem=element, tagname="", w=0, h=0;
  
	while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
	{
//		alert(elem);
		h+=elem.height;
		w+=elem.width;
		tagname=elem.tagName.toUpperCase();

		if(tagname=="BODY")
			elem=0;

		if(typeof(elem)=="object")
			if (typeof(elem.offsetParent)=="object")
				elem=elem.offsetParent;
	}

	var position = new Object();
	position.w = w;
	position.h = h;
	return position;
}






function swapImage(id, src) {
	if(document.getElementById(id))
		document.getElementById(id).src = src;
}

function zoom(z) {
	currentZoom = z;
	document.getElementById('WeBSurg').style.zoom = z;
//	document.getElementById('q').value = z;
}

function zoom_in() {
	val = Math.round((currentZoom+pasZoom)*100)/100;
	if(val < 10)
		zoom(val);
	else
		alert("Unable to zoom in again !");
}

function zoom_out() {
	val = Math.round((currentZoom-pasZoom)*100)/100;
	if(val > 0.2)
		zoom(val);
	else
		alert("Unable to zoom out again !");
}

//-->




function show(id) {
	if(document.getElementById(id))
		document.getElementById(id).style.display = "block";
}

function mask(id) {
	if(document.getElementById(id))
		document.getElementById(id).style.display = "none";
}












/****** NEWS ALTERNEES	*/

/*
var cntNews = 3;	// Nombre total de News
*/
var tmrSec  = 5;	// Intervalle entre chaque changement de News (en secondes)

var idxNews = 1;
var timer = null;

function autoNews() {
	// Avancement automatique des News
	nextNews(true);
	timer = setTimeout('autoNews()', tmrSec * 1000);
}
//timer = setTimeout('autoNews()', tmrSec * 1000);


function prevNews(isTimer) {
	// Passe à la News précédente

	if(isTimer) {
		if(idxNews < 1)
			idxNews = cntNews + 1;
	}
	else if(timer!=null)
		clearTimeout(timer);

	if(idxNews > 1)
		idxNews --;

	chgNews();
}


function nextNews(isTimer) {
	// Passe à la News suivante

	if(isTimer) {
		if(idxNews >= cntNews)
			idxNews = 0;
	}
	else if(timer!=null)
		clearTimeout(timer);

	if(idxNews < cntNews)
		idxNews ++;

	chgNews();
}


function goNews(idx, isTimer) {
	if(isTimer==false && timer!=null)
		clearTimeout(timer);

	idxNews = idx;
	chgNews();
}


function chgNews() {
	for(i=1; i<=cntNews; i++) {
		if(document.getElementById('News'+i))
			document.getElementById('News'+i).style.display = 'none';
	}

	if(document.getElementById('News'+idxNews))
		document.getElementById('News'+idxNews).style.display = 'block';
	
	toggleNewsBar();
}


function toggleNewsBar() {
	for(i=1; i<=cntNews; i++) {
		if(document.getElementById('NewsTitle'+i)) {
			document.getElementById('NewsTitle'+i).style.textDecoration = 'underline';
		}
	}
	if(document.getElementById('NewsTitle'+idxNews)) {
		document.getElementById('NewsTitle'+idxNews).style.textDecoration = 'none';
	}
}


/*	NEWS ALTERNEES	******/








/******	DIV ALTERNEES */

function startAlternateDiv(prefixe, cntDiv, intervale) {
	eval("tmr_"+ prefixe +" = setTimeout(\"alternateDiv('"+ prefixe +"', 1, "+ cntDiv +", "+ intervale +")\", "+ intervale + ");");
}

function stopAlternateDiv(prefixe) {
	eval("stop_"+ prefixe +" = true; clearTimeout(tmr_"+ prefixe +");");
	
}

function alternateDiv(prefixe, idxDiv, cntDiv, intervale) {
//	alert(prefixe +" - "+ idxDiv +" - "+ cntDiv +" - "+ intervale);
	stop_that = false;
	eval("if(stop_"+ prefixe +") stop_that=true;");
	if(stop_that)
		return;

	if(document.getElementById(prefixe+idxDiv))
		document.getElementById(prefixe+idxDiv).style.display = "none";

	idxDiv++;
	if(idxDiv > cntDiv)
		idxDiv = 1;
	
	if(document.getElementById(prefixe+idxDiv))
		document.getElementById(prefixe+idxDiv).style.display = "block";

	setTimeout("alternateDiv('"+ prefixe +"', "+ idxDiv +", "+ cntDiv +", "+ intervale +")", intervale);
}

/*	DIV ALTERNEES ******/







/******	DETECTION FLASH */

var flashActualVersion = 0;			// version the user really has
var flashOK = false;			// boolean. true if it's safe to embed the flash movie in the page

function detectFlash(flashRequiredVersion) {

	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;				// true if we're on ie
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;	// true if we're on windows

	if(isIE && isWin) {
		// Write vbscript detection on ie win. IE on Windows doesn't support regular JavaScript plugins array detection.
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		for(i=2; i<=9; i++) {
			document.write('isObj = false\n');
			document.write('isObj = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'")))\n');
			document.write('if(isObj) Then flashActualVersion = '+i+'\n');
		}
		document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
	}
	
	if(navigator.plugins && (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) ) {
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

		var flashVersion = parseInt(flashDescription.substring(16));
		if(flashVersion == 2) flashActualVersion = 2;
		if(flashVersion == 3) flashActualVersion = 3;
		if(flashVersion == 4) flashActualVersion = 4;
		if(flashVersion == 5) flashActualVersion = 5;
		if(flashVersion == 6) flashActualVersion = 6;
		if(flashVersion == 7) flashActualVersion = 7;
		if(flashVersion == 8) flashActualVersion = 8;
		if(flashVersion >= 9) flashActualVersion = 9;
	}
  
	// If we're on msntv (formerly webtv), the version supported is 4 (as of January 1, 2004).
	// Note that we don't bother sniffing varieties of msntv. You could if you were sadistic...
	if(navigator.userAgent.indexOf("WebTV") != -1)
		flashActualVersion = 4;
  
	return flashActualVersion >= flashRequiredVersion;
}

/*	DETECTION FLASH ******/

// -->