//-----------------------------------------------------------------------------

// Detection navigateur M-tech Industries

//-----------------------------------------------------------------------------

// HJ : 01/06/01



/*

4.7 [fr] (WinNT; I)

4.7 [fr] (WinNT; I)

4.0 (compatible; MSIE 5.01; Windows NT 5.0)

4.0 (compatible; MSIE 5.01; Windows NT)

4.0 (compatible; MSIE 5.0; Macintosh; I; PPC) 		-> IE 5.01 Mac

4.5 [fr] (Macintosh; I; PPC)

4.08 (Macintosh; I; PPC, Nav)						-> Netscape 4.08 Mac

*/



NavName = navigator.appName;

NavVers = navigator.appVersion; 

NavCode = navigator.appCodeName; 

NavAgent  = navigator.userAgent;

NavJSOK = navigator.javaEnabled();



// Detection de l'OS

//-----------------------------------------------------------------------------

if (NavVers.indexOf('Mac') > -1) {

	NavOS = "Mac OS";

	Win=0;

} else {

	if (NavVers.indexOf('Win') > -1) {

		if (NavVers.indexOf('NT 5') > -1)  NavOS = "Windows 2000";

		else if (NavVers.indexOf('NT') > -1)  NavOS = "Windows NT";

		else if (NavVers.indexOf('95') > -1)  NavOS = "Windows 95";

		else if (NavVers.indexOf('98') > -1)  NavOS = "Windows 98";		

		else NavOS = "Windows";

		Win=1;

	} else {

		NavOS = "Inconnu"

		Win=-1;

	}

}



// Detection du nro de version

//-----------------------------------------------------------------------------

NavVersNum=NavVers.substr(0, 3);

if (NavVers.indexOf('MSIE') > -1) {

	NavVersNum=NavVers.substr(NavVers.indexOf('MSIE')+5, 3);

}



if (NavName == 'Netscape')

	var IE = 0;

else

	var IE = 1;



var IE4 = (document.all && !document.getElementById) ? true : false;

var NS4 = (document.layers) ? true : false;

var IE5 = (document.all && document.getElementById) ? true : false;

var NS6 = (document.getElementById && !document.all) ? true : false;



// Detection de la langue

//-----------------------------------------------------------------------------

if (IE4 || IE5)

	var NavLang =  navigator.browserLanguage;

else

	var NavLang = navigator.language;



if (NavLang.indexOf('fr') > -1) NavLangFR = 'Fran&ccedil;ais';

else if (NavLang.indexOf('nl') > -1) NavLangFR = 'Neerlandais';

else if (NavLang.indexOf('en') > -1) NavLangFR = 'Anglais';

else if (NavLang.indexOf('de') > -1) NavLangFR = 'Allemand';

else if (NavLang.indexOf('ja') > -1) NavLangFR = 'Japonais';

else if (NavLang.indexOf('it') > -1) NavLangFR = 'Italien';

else if (NavLang.indexOf('pt') > -1) NavLangFR = 'Portugais';

else if (NavLang.indexOf('es') > -1) NavLangFR = 'Espagnol';

else if (NavLang.indexOf('sv') > -1) NavLangFR = 'Suedois';

else if (NavLang.indexOf('zh') > -1) NavLangFR = 'Chinois';

// Pour rediriger selon la langue :

//if (NavLang.indexOf('zh') > -1) document.location.href = NavLangFR +'.html';



//Ici la page par defaut si la langue n'est pas dans la liste 

else 

NavLangFR = 'Inconnu...';





// Affichage des infos

//-----------------------------------------------------------------------------

function AlertNavInfos() {

	alert("Navigateur : " + NavName + "\nVersion : " + NavVers + "\nNro : " + NavVersNum + "\nCode : " + NavCode + "\nAgent : " + NavAgent  + "\nOS : " + NavOS +  "\nLangue : " + NavLang + "\nIE4, IE5, NS4, NS6 : " + IE4 + "," + IE5 + ","  + NS4 + "," + NS6 );

}



function DisplayNavInfos() {

	document.write("Nom du navigateur : <B>" + NavName + "</b><BR>");

	document.write("Version du navigateur : <B>" + NavVersNum + "</b><BR>");

	document.write("Agent du navigateur : <B>" + NavAgent + "</b><BR>");

	document.write("D&eacute;tails du navigateur : <B>" + NavVers + "</b><BR>");

	document.write("Code du navigateur : <B>" + NavCode + "</b><BR>");

	document.write("Javascript actif : <B>" + NavJSOK + "</b><BR>");

	document.write("OS du navigateur : <B>" + NavOS + "</b><BR>");

	document.write("Type Windows ?   : <B>" + Win + "</b><BR>");

	document.write("Langue du navigateur : <B>" + NavLangFR + "</b><BR>");

}







//-----------------------------------------------------------------------------

// Gestion de fenetres

//-----------------------------------------------------------------------------





function LanceSite() {

	//alert(document.URL + "\n" + document.SitesForm.listeSites.value);

	//document.URL=document.SitesForm.listeSites.value;

	window.location=document.FormEdit.listeData.value

	return false;

}





function newWindow(wUrl,wName,wParams) {

//* url, name, width, height, resizable, scrollbars, menubar, toolbar, directories, location, status

	//url='calend.asp?champ='+field;

	//alert(wName);

	if (wName == "") {

		wName="theWin";

	}

	if (wParams == "") {

		wParams="width=300,height=200,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no";

	}

	theWindow=window.open(wUrl,wName,wParams);

	theWindow.focus();

}





function remLink() {

  if (window.theWindow && window.theWindow.open && !window.theWindow.closed)

    window.theWindow.opener = null;

}





// Impression de la fenetre

function PrintWindow() {

    if (window.print) {

        if (confirm("Imprimer cette page ?")) {

            window.print();

        }

    } else {

		alert("Utilisez l'article 'Imprimer...' du menu 'Fichier' de " + NavName + ".\n" + NavName + " " + NavVersNum + " (" + NavOS + ") ne supporte pas la fonction 'window.print()'");

    }

}



// Positionnement de la fenetre a l'ecran

function LocateWindow(theMode,deltaX,deltaY) {

// theMode : "M" = centre, "P" = par rapport au parent, "HG" = haut gauche, "HD", "BG", "BD"

	if (self.innerWidth)

	{

		frameWidth = self.innerWidth;

		frameHeight = self.innerHeight;

	}

	else if (document.body)

	{

		frameWidth = document.body.clientWidth;

		frameHeight = document.body.clientHeight;

	}

	else return;

	

if (theMode=="M") {

	// Centre

	posX=(self.screen.width-frameWidth)/2+deltaX;

	posY=(self.screen.height-frameHeight)/2+deltaY;

} else {

	if (theMode=="P") {

		// Par rapport au parent

		if (self.innerWidth) {

			parentX = window.opener.self.screenX;

			parentY = window.opener.self.screenY;

		} else if (window.screenTop) { // document.body

			parentX = window.opener.screenLeft;

			parentY = window.opener.screenTop;

			} else {

				parentX = 0;

				parentY = 0;

			}

		posX=parentX+deltaX;

		posY=parentY+deltaY;

	} else {

		if (theMode=="HG") {

			// Haut gauche

			posX=0+deltaX;

			posY=0+deltaY;

		} else {

			if (theMode=="HD") {

				// Haut droit

				posX=self.screen.width-deltaX-frameWidth;

				posY=0+deltaY;

			} else {

				if (theMode=="BG") {

					// Haut droit

					posX=0+deltaX;

					posY=self.screen.height-deltaY-frameHeight;

				} else {

					if (theMode=="BD") {

						// Haut droit

						posX=self.screen.width-deltaX-frameWidth;

						posY=self.screen.height-deltaY-frameHeight;

					} else {

						// On ne touche a rien

					}

				}

			}

		}

	}

}



	if ((frameWidth+posX)<self.screen.width && (frameHeight+posY)<self.screen.height) {

		parent.window.moveTo(posX,posY);

	}



}





//-----------------------------------------------------------------------------

// Gestion des images

//-----------------------------------------------------------------------------





// Cree ou met a jour une image en adaptant la taille

function ChangePict(thePict, theWidth, theHeight, theName, theOptions, theMode) {

// theMode : 0 = creation (document.write) 1 = update (document.src)

// ViewWidth : Largeur maxi d'affichage en pixels (0 sinon). Var globale.

// ViewHeight : Hauteur maxi d'affichage en pixels (0 sinon). Var globale.



	if (theName=="")  { theName="thePictName"; }



	if (ViewWidth>0 && theWidth>ViewWidth) {

		dispWidth=ViewWidth

		dispHeight=Math.round(ViewWidth*theHeight/theWidth)

	} else {

		dispWidth=theWidth

		dispHeight=theHeight	

	}

	if (ViewHeight>0  && theHeight>ViewHeight)  {

		dispWidth=Math.round(dispWidth*ViewHeight/dispHeight)

		dispHeight=ViewHeight			

	}

	

	if (theMode) {

		document.images[theName].src=thePict;

		document.images[theName].width=dispWidth;

		document.images[theName].height=dispHeight;

	} else {

		document.write("<img height=" + dispHeight + " width=" + dispWidth + " ")	

		document.write("src='" + thePict + "' " )

		document.write("name='" + theName + "' " + theOptions + ">")

	}

}





function DelPict(theImgObj,theField) {

	//alert(document.thePict.src);

	//tmp=theImgObj.src

	if (theImgObj.src.indexOf('common/nopict.gif') < 1) {

		if (validerSuppr()==true) {

			theImgObj.src='common/nopict.gif';

			theImgObj.border=0;

			theImgObj.width=100;

			//alert(document.thePict.height);

			theImgObj.height=54;

			tmp=eval("document.FormEdit." + theField);

			tmp.value='';

		}

	} else {

		alert("Rien a supprimer !");

	}

}





// Ouvre une image en adaptant la taille de la fenetre

function OpenPict(theImgObj,W,H) {

	//theImgObj.src.indexOf('common/nopict.gif') < 1

	if (W > 0 && H > 0) {

		if (!IE) {

			W += 15;

			H += 15;

		} else

		{

			W += 5;

			H += 5;

		}

		newWindow(theImgObj.src,'wPict','width=' + W + ',height=' + H + ',resizable=yes,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no');

	}

}





// FiberSTONE dev

theWindowCont="francais/showpict.html";



function OpenPictInWindow(pictName) {

	theWindow=window.open("../../picts/" + pictName,'wPict','width=' + '640' + ',height=' + '400' + ',resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no');	

//	theWindow=window.open(homePath+theWindowCont,'wPict','width=' + '320' + ',height=' + '240' + ',resizable=yes,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no');	

/*	n=1;

	while( n < 10000 ) {

		n ++

	}

	alert(theWindow.onLoad);

	alert(theWindow.document.images.length + "\n" + theWindow.document.url);*/

	//alert(theWindow.innerHeight + "\n" + theWindow.document.thePict.width);

	//theWindow.resizeTo(theWindow.document.theCustPict.width + 40,theWindow.document.theCustPict.height + 60);

//	theWindow.document.theCustPict.src=homePath+ pictPath + pictName;

	theWindow.focus();

}







// Interdiction clic droit

function disableClick(e) {

	if (IE4) { // IE

		if (event.button==2||event.button==3) {

			if (event.srcElement.tagName=="IMG"){

				alert(theCopyRight);

				return false; } } }

	else if (NS4) { // NS 4

		if (e.which == 3) {

			alert(theCopyRight);

			return false; } }

	else if (NS6){ // NS 6

		if (e.which==3&&e.target.tagName=="IMG"){

			alert(theCopyRight)

			return false } }

}



function imageEvents() {

	for(i=0;i<document.images.length;i++)

		document.images[i].onmousedown=disableClick; // Event !

}



function noClick() { // Pour declencher, mettre dans BODY onload=noClick()

if (IE4)

	document.onmousedown=disableClick

else if (NS6)

	document.onmouseup=disableClick

else if (NS4)

	imageEvents()

}





//-----------------------------------------------------------------------------

// Debug

//-----------------------------------------------------------------------------

// Pour debug mettre dans la page:

// var DebugOn=false;

function DisplayDebug(theString) {	

	if ( DebugOn ) alert(theString); }





// Affichage des propriete de l'ecran

function PrintScreenProperties() {



var props = new Array(

	'self.pageXOffset',

	'self.pageYOffset',

	'self.screenX',

	'self.screenY',

	'self.innerHeight',

	'self.innerWidth',

	'self.outerHeight',

	'self.outerWidth',

	'self.screen.height',

	'self.screen.width',

	'self.screen.availHeight',

	'self.screen.availWidth',

	'self.screen.availTop',

	'self.screen.availLeft',

	'self.screen.Top',

	'self.screen.Left',

	'self.screenTop',

	'self.screenLeft',

	'self.screen.colorDepth',

	'self.screen.pixelDepth',

	'document.body.clientHeight',

	'document.body.clientWidth',

	'document.body.scrollHeight',

	'document.body.scrollWidth',

	'document.body.scrollLeft',

	'document.body.scrollTop',

	'document.body.offsetHeight',

	'document.body.offsetWidth',

	'document.body.offsetTop',

	'document.body.offsetLeft');



	for (var i=0;i<props.length;i++)

	{

		if (!self.screen && props[i].indexOf('self.screen') != -1) continue;

		if (!document.body && props[i].indexOf('document.body') != -1) continue;

		if (eval(props[i])) document.write('<BR>' + props[i] + ': ' + eval(props[i]));

	}

}



// Affichage des propriete de l'ecran

function PrintScreenProperties() {



var props = new Array(

	'self.pageXOffset',

	'self.pageYOffset',

	'self.screenX',

	'self.screenY',

	'self.innerHeight',

	'self.innerWidth',

	'self.outerHeight',

	'self.outerWidth',

	'self.screen.height',

	'self.screen.width',

	'self.screen.availHeight',

	'self.screen.availWidth',

	'self.screen.availTop',

	'self.screen.availLeft',

	'self.screen.Top',

	'self.screen.Left',

	'self.screenTop',

	'self.screenLeft',

	'self.screen.colorDepth',

	'self.screen.pixelDepth',

	'document.body.clientHeight',

	'document.body.clientWidth',

	'document.body.scrollHeight',

	'document.body.scrollWidth',

	'document.body.scrollLeft',

	'document.body.scrollTop',

	'document.body.offsetHeight',

	'document.body.offsetWidth',

	'document.body.offsetTop',

	'document.body.offsetLeft');



	for (var i=0;i<props.length;i++)

	{

		if (!self.screen && props[i].indexOf('self.screen') != -1) continue;

		if (!document.body && props[i].indexOf('document.body') != -1) continue;

		if (eval(props[i])) document.write('<BR>' + props[i] + ': ' + eval(props[i]));

	}

}