//Ecriture simplifiée d'instruction conditionnelle//
//--opérateur ternaire : (document.body.clientWidth < 600) ? return '500px': return 'auto'//


loop = 0;
// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
//alert(navigator.appName+' | '+navigator.appVersion)
var isIE  = (navigator.appVersion.indexOf('MSIE') != -1) ? true : false;
var isFF = (navigator.appName.indexOf('Netscape') != -1 && navigator.appVersion.indexOf('Chrome') == -1 && navigator.appVersion.indexOf('Safari') == -1) ? true : false;
var isCH  = (navigator.appVersion.indexOf('Chrome') != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf('win') != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf('Opera') != -1) ? true : false;
//alert('isIE='+isIE+' |isFF='+isFF+' |isCH='+isCH)
var isPub = ( window.location.hostname == 'protopub' || window.location.hostname == '10.3.123.137' || window.location.hostname.substr(0,11) == 'www.actebis' ) ? true : false;
var isRvd = ( window.location.hostname == 'protorvd' || window.location.hostname == '10.3.123.136' || window.location.hostname == 'intranet' || window.location.hostname == '10.3.50.75' || window.location.hostname == 'a2.actebis.fr' ) ? true : false;
var urlActebisPanier;
var FormatPanier='none';

//--sauvegarde de la querystring
var query = location.search.substr(1, window.location.search.length);
query = query.slice(query.indexOf('?') - query.length);

//--page visitee
var pageActuelle = window.location.pathname
pageActuelle = pageActuelle.toLowerCase()
pageActuelle = pageActuelle.substr(1,pageActuelle.lastIndexOf('.')-1)


var userScreenWidth = window.screen.width;
var userScreenHeight = window.screen.height;
var userBodyWidth = 0;
var userBodyHeight = 0;

function affEnvUser() {		//--affichage sur le site public
	document.write('navigateur : '+navigator.appName.substr(0,navigator.appName.indexOf(' '))+' ('+navigator.appVersion.substr(0,navigator.appVersion.indexOf(' '))+') | ')
	document.write('resolution ecran : '+screen.width+' x '+screen.height+'px | ')
	document.write('taille fenetre : '+getBodyWidth()+' x '+getBodyHeight()+'px')
}


function getBodyWidth() {
	if (self.innerWidth) { // all except Explorer
		return userBodyWidth = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) { // Explorer 6 Strict Mode
		return userBodyWidth = document.documentElement.clientWidth;
	} else if (document.body) { // other Explorers
		return userBodyWidth = document.body.clientWidth;
	}
}


function getBodyHeight() {
	if (self.innerHeight) { // all except Explorer
		return userBodyHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		return userBodyHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		return userBodyHeight = document.body.clientHeight;
	}
}


function getScrollPosition(){
	//--retourne un tableau 1 dimension / 2 valeurs
	//--getScrollPosition(0)=abcisse(x) / getScrollPosition(1)=ordonnée(y)
	return Array( (document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft, (document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop );
}


function goResize(){
	setCol(100);
}


function goScroll(){
	if ( isPub ){
		//--site public
		affColGD(50);
	}
	if ( isRvd ){
		//--site revendeur
		if ( window.parent.document.getElementById('paniermobile') ){affPanierCorps(30, 'maxi');}
	}
}


function setCol(thisColGDwidth){
	//alert(window.location.hostname)
	var myBodyW = parseInt(getBodyWidth());
	var myBodyH = parseInt(getBodyHeight());
	//alert('myBodyW='+myBodyW+' |myBodyH='+myBodyH)
	if ( isPub ){
		//alert('window.parent.document.getElementById(pubColC)='+window.parent.document.getElementById('pubColC')+' |window.parent.document.getElementById(pubColG)='+window.parent.document.getElementById('pubColG'))
		//alert('window.parent.document.getElementById(pubColG).style.width='+window.parent.document.getElementById('pubColG').style.width+' |window.parent.document.getElementById(pubColC).style.width='+window.parent.document.getElementById('pubColC').style.width)
		var myEntete = window.parent.document.getElementById('pubentete');
		var myLogobar = window.parent.document.getElementById('divLogobar');
		var myCorps = window.parent.document.getElementById('pubcorps');
		var myTabCorps = window.parent.document.getElementById('tabPubCorps');
		var myTdColC = window.parent.document.getElementById('pubColC'); myTdColG = window.parent.document.getElementById('pubColG'); var myTdColD = window.parent.document.getElementById('pubColD');
		var myDivColG = window.parent.document.getElementById('divPubColG'); var myDivColD = window.parent.document.getElementById('divPubColD');
	}else{
		var myEntete = window.parent.document.getElementById('entete');
		var myLogobar = window.parent.document.getElementById('divLogobar');
		var myCorps = window.parent.document.getElementById('corps');
		var myTabCorps = window.parent.document.getElementById('tabCorps');
		var myTdColC = window.parent.document.getElementById('ColC'); myTdColG = window.parent.document.getElementById('ColG'); var myTdColD = window.parent.document.getElementById('ColD');
		var myDivColG = window.parent.document.getElementById('divColG'); var myDivColD = window.parent.document.getElementById('divColD');
	}
	var myWidth;
	var regul=0;
	//alert('BodyWidth='+myBodyW+' |myEnteteWidth='+myEntete.style.width+' |logobarLeft='+myLogobar.offsetLeft+' |logobarWidth='+myLogobar.style.width)
	
	if ( myCorps ) {
		myCorps.style.width = '100%';
		myTabCorps.style.height = String(myBodyH-110)+'px';
		//alert('myCorps.style.width='+myCorps.style.width)
	}
	if ( myLogobar ){
		//alert('myTdColG.style.width='+myTdColG.style.width+'\nmyTdColD.style.width='+myTdColD.style.width+'\nmyLogobar.offsetLeft='+myLogobar.offsetLeft)
		myWidth = parseInt(myLogobar.style.width);
		myTdColG.style.width = String(Math.max(0, parseInt(myLogobar.offsetLeft)))+'px';
		myTdColC.style.width = String(parseInt(myLogobar.style.width))+'px';
		myTdColD.style.width = String(parseInt(myLogobar.offsetLeft))+'px';	//--stricte égale largeur requise
		//myCorps.style.width = parseInt(myTdColG.style.width) + parseInt(myTdColC.style.width) + parseInt(myTdColD.style.width)
		//alert('myTdColG.style.width='+myTdColG.style.width+' |myTdColC.style.width='+myTdColC.style.width+' |myTdColD.style.width='+myTdColD.style.width)
	}
		
	if ( myDivColG && myDivColD ){
		//alert('BodyWidth='+myBodyW+' |myWidth='+myWidth+' |thisColGDwidth='+thisColGDwidth)
		if ( myBodyW <= (myWidth + (thisColGDwidth * 2)) ){
			myDivColG.style.display = 'none'; 
			myDivColD.style.display = 'none'; 
		}else{
			myDivColG.style.display = 'block';
			myDivColD.style.display = 'block';
			//affColGD(50);
		}
	}
	//alert('TdColGwidth='+myTdColG.style.width+' |TdColCwidth='+myTdColC.style.width+' |TdColDwidth='+myTdColD.style.width)
	
	//setTimeOut('window.onresize=setCol(myWidth)',500)
}


function affColGD(thisTopIni){
	var coor = getScrollPosition();
	//alert(coor[0]+' | '+coor[1]);
	if ( isPub ){
		var myDivColG = window.parent.document.getElementById('divPubColG');
		var myDivColD = window.parent.document.getElementById('divPubColD');
	}else{
		var myDivColG = window.parent.document.getElementById('divColG');
		var myDivColD = window.parent.document.getElementById('divColD');
	}
	if ( myDivColG ){
		myDivColG.style.top = String(parseInt(coor[1]) + thisTopIni)+'px';
	}
}


function ValidByEnter(thisEvent, thisForm, thisFctValid){
	//alert('thisEvent='+thisEvent+'\nthisForm='+thisForm+'\nthisFctValid='+thisFctValid)
	var myEvent;
	var isEvent = false;
	if ( window.event ){
		isEvent = true;
		myEvent = event;
	}else{
		if ( thisEvent ){
			//alert('event='+thisEvent);
			isEvent = true;
			myEvent = thisEvent;
		}
	}
	if ( isEvent ){
		//alert(myEvent.type + ' = ' + myEvent.keyCode)
		if ( myEvent.type == 'keyup' && myEvent.keyCode == 13 ){
			if ( thisFctValid ){		//--si l'argument thisFctValid est renseigné
				if( thisFctValid() ){document[thisForm].submit()}		//--je valide le formulaire si la fonction de contrôle thisFctValid() renvoie true
			}else{
				document[thisForm].submit();		//--je valide le formulaire sans fonction de contrôle
			}
		}else{
			return false;
		}
	}
}


function encodUrl(thisStr){
	//alert(thisStr)
	var myStr = thisStr;
	
	myStr = myStr.replace(/</g,'‹'); myStr = myStr.replace(/>/g,'›');
	/*
	var cote = decodeURIComponent('%27');
	var antislash = decodeURIComponent('%5C');
	myStr = myStr.replace(cote, antislash+cote);
	*/
	myStr = encodeURIComponent(myStr);
	myStr = myStr.replace(/%20/g,'+')
	
	return myStr
}


function decodUrl(thisStr){
	//alert(thisStr)
	var myStr = thisStr;
	
	myStr = myStr.replace(/\+/g, '%20')
	myStr = myStr.replace('%e2%80%b9','%3c'); myStr = myStr.replace('%e2%80%ba','%3e');
	myStr = decodeURIComponent(myStr);
	
	return myStr
}


function getValQuery(thisQyLib){
	//alert('thisQyLib='+thisQyLib)
	var reg = new RegExp('[?&]+', 'g');
	var qyTab = query.split(reg);
	var strTab, qyLib, qyVal, myQyVal
	myQyVal=''
	//alert('query.length='+query.length)
	if ( query.length > 0 ) {
		for ( var i=0; i < qyTab.length; i++ ) {
			strTab = qyTab[i].split('=')
			qyLib = qyTab[i].substr(0, qyTab[i].indexOf('='))
			qyVal = qyTab[i].substr(qyTab[i].indexOf('=')+1, qyTab[i].length)
			//alert('thisQyLib='+thisQyLib+' |strTab[0]='+strTab[0]+' |qyLib='+qyLib+' |qyVal='+qyVal)
			if ( strTab[0] == thisQyLib ){myQyVal =  strTab[1]}
		}
		//alert('myQyVal='+myQyVal)
	}else{
		myQyVal =  '';
	}
	return myQyVal;
}


function setStrQuery(thisQyLib, thisQyList, isEncode){
	var myQyTab;
	var myQyStr;

	myQyTab = thisQyList.split('|');		//--même si thisQyList vide, js créé un tableau de 1 dimension de valeur vide
	myQyStr = '';
	
	if ( myQyTab.length >= 1 ){
		if ( !(myQyTab[0] == null || myQyTab[0] == '') ){
			for ( xi = 0; xi < myQyTab.length; xi++ ){
				if ( isEncode == true ){
					myQyStr += thisQyLib+'='+encodeURIComponent(myQyTab[xi]);		//.replace(/ /g,'+')
				}else{
					myQyStr += thisQyLib+'='+myQyTab[xi];
				}
				if ( xi < (myQyTab.length-1) ){myQyStr += '&'}
			}
		}
	}
	return myQyStr;
}


function getIdObj(thisName){
	var myObjId; var myObjChp;
	myObjId = null;
	//alert('thisName='+thisName);
	//alert('document.all.length='+document.all.length)		//=document.getElementsByTagName('*').length

	for ( var i=0; i<document.all.length; i++ ){
		///alert('document.all[i].id='+document.all[i].id)
		if ( document.all[i].id != '' ){
			myObjChp = document.all[i].id;
			if ( String(myObjChp) == String(thisName) ){
				//alert('myObjChp='+myObjChp)
				myObjId = document.getElementById(document.all[i].id);
				//alert('myObjId='+myObjId)
				break;
			}
		}
	}
	return myObjId;
}


function getFormObj(thisName){
	var myObjForm; var myObjChp;
	myObjForm = null;
	//alert('thisName='+thisName);
	//alert('forms.length='+document.forms.length)
	for ( var i=0; i < document.forms.length; i++ ){
		//alert('<form name='+document.forms[i].name+'> contient '+document.forms[i].length+' éléments');
		for ( var j=0; j<document.forms[i].elements.length; j++ ){
			myObjChp = document.forms[i].elements[j];
			//alert('Elément['+j+'] = |'+myObjChp.name+'| <=> |'+thisName+'|')
			if ( String(myObjChp.name) == String(thisName) ){
				myObjForm = document.forms[i];
				//alert('myObjForm.name='+myObjForm.name)
				break;
			}
		}
	}
	return myObjForm;
}

/*
function getIdByName(thisName){
	var myForm = getFormObj(thisName);
	var myId;
	for ( var i=0; i < myForm.elements.length; i++ ){
		//alert('|'+myForm.elements[i].name+'| <=> |'+thisName+'|')
		if ( String(myForm.elements[i].name) == String(thisName) ){
			//alert(myForm.elements[i].name+' - '+myForm.elements[i].value+' - '+myForm.elements[i].id)
			//alert('myId='+myForm.elements[i].id)
			myId = myForm.elements[i].id;
			break;
		}
	}
	//alert('myId='+myId)
	return myId;
}
*/

function getElementByTitle(thisTagName, thisTitle){
	//alert('thisTagName='+thisTagName+' |thisTitle='+thisTitle)
	var list = document.getElementsByTagName(thisTagName);
	var elementTag;
	//alert('list.length='+list.length)
	for ( i=0; i < list.length; i++ ) {
		//alert('list[i].title='+list[i].title)
		if ( list[i].title == thisTitle ) {
			elementTag = list[i];
		}
	}
	return elementTag;
}



function isID(thisID){
	if ( document.getElementById(thisID) ) {return true} else {return false}
}


String.prototype.trim = function(){
	var chaine = this;
	chaine = chaine.replace(/(^\s*)|(\s*$)/g,'');
	return chaine;
}


String.prototype.destrophe = function(){		//--remplace une simple ou double strophe par un antislash + simple strophe pour l'interpréter litérallement
	var chaine = this;
	var newcar = String.fromCharCode(92)+String.fromCharCode(39)
	chaine = chaine.replace(String.fromCharCode(34), newcar);		//--"
	chaine = chaine.replace(String.fromCharCode(39), newcar);		//--'
	chaine = chaine.replace(String.fromCharCode(145), newcar);	//--'
	chaine = chaine.replace(String.fromCharCode(146), newcar);	//--'
	chaine = chaine.replace(String.fromCharCode(147), newcar);	//--"
	chaine = chaine.replace(String.fromCharCode(148), newcar);	//--"
	chaine = chaine.replace(String.fromCharCode(171), newcar);	//--"
	chaine = chaine.replace(String.fromCharCode(180), newcar);	//--'
	chaine = chaine.replace(String.fromCharCode(187), newcar);	//--"
	return chaine;
}


String.prototype.octal = function(){		//--convertir un caractère en octal  cf : http://www.pjb.com.au/comp/diacritics.html
	var chaine = this;
	chaine = chaine.replace(/['à']/g,'\340');
	chaine = chaine.replace(/['á']/g,'\341');
	chaine = chaine.replace(/['â']/g,'\342');
	chaine = chaine.replace(/['ä']/g,'\344');
	chaine = chaine.replace(/['ç']/g,'\347');
	chaine = chaine.replace(/['è']/g,'\350');
	chaine = chaine.replace(/['é']/g,'\351');
	chaine = chaine.replace(/['ê']/g,'\352');
	chaine = chaine.replace(/['ë']/g,'\353');
	chaine = chaine.replace(/['ô']/g,'\364');
	chaine = chaine.replace(/['ù']/g,'\371');
	chaine = chaine.replace(/['ú']/g,'\372');
	chaine = chaine.replace(/['û']/g,'\373');
	chaine = chaine.replace(/['°']/g,'\260');
	return chaine;
}


function rappel_client(){
	fenetre=window.open('../Fenetre_rappel_client.aspx?POPUP=Oui','fenetre','resizable=yes,scrollbars=no,location=no,width=500,height=250,top=100,left=110');
}


function getFormatPanier(thisValue){
	//alert(thisFormat)
	this.Format = thisValue;
}


function affPanierCorps(thisTopIni, thisFormat){
	var coor = getScrollPosition();
	//alert(coor[0]+' | '+coor[1]);
	var myCorps = window.parent.document.getElementById('corps');
	var myDiv1 = window.parent.document.getElementById('paniermobile');
	var myDiv2 = window.parent.document.getElementById('promopanier');
	var myFram1 = window.parent.document.getElementById('Actebis_Panier');
	var bodyH = window.parent.document.body.clientHeight;
	if ( myCorps ){
		myDiv1.style.top = parseInt(coor[1]) + thisTopIni;
		//alert('myDiv1.style.top='+myDiv1.style.top);
	}else{
		myDiv1.style.top = parseInt(coor[1]) + thisTopIni;
	}
	switch(thisFormat){
		case 'none':
			if ( myDiv1 ){myDiv1.style.display='none'}		//myDiv1.style.visibility='hidden';
			if ( myDiv2 ){myDiv2.style.display='block'}
			break;
		case 'mini':
			if ( myDiv1 ){myDiv1.style.display='block'; myDiv1.style.visibility='visible'}
			if ( myDiv2 ){myDiv2.style.display='none'}
			if ( myFram1 ){myFram1.style.height = Math.min(300, bodyH - 530)}
			break;
		default:
			if ( myDiv1 ){myDiv1.style.display='block'; myDiv1.style.visibility='visible'}
			if ( myDiv2 ){myDiv2.style.display='none'}
			if ( myFram1 ){myFram1.style.height = Math.min(300, bodyH - 330)}
			break;
	}
}


function affPanierTot() {
	var myUrl;
	if ( window.parent.document.getElementById('Actebis_Panier') ){
		nbLiCmd = document.form_Actebis_Panier.NBLIGNE.value.toString();
		PTotal = document.form_Actebis_Panier.PTOTAL.value.toString();
		PoidsTotal = document.form_Actebis_Panier.POIDSTOTAL.value.toString();
		myUrl = 'Actebis_Total.aspx?NBLIGNE='+nbLiCmd+'&TOTAL='+PTotal+'&POIDSTOTAL='+PoidsTotal;
		if ( window.parent.document.getElementsByName('Actebis_Total').length > 0 ){	
		//if ( window.parent.document.getElementById('Actebis_Total') ){	
			parent.Actebis_Total.location.replace(myUrl);	
		}
	}
}


function Minuscule(thisChp){
	var myFormObj; var myChpObj;
	//alert('thisChp='+thisChp);
	myFormObj = getFormObj(thisChp);		//--recherche de l'objet form contenant le champ
	myChpObj = myFormObj[thisChp];
	if ( myChpObj.name == thisChp && myChpObj.value.length > 0 ){
		myChpObj.value = myChpObj.value.toLowerCase();
	}
}


function Majuscule(thisChp){
	var myFormObj; var myChpObj;
	//alert('thisChp='+thisChp);
	myFormObj = getFormObj(thisChp);		//--recherche de l'objet form contenant le champ
	myChpObj = myFormObj[thisChp];
	if ( myChpObj.name == thisChp && myChpObj.value.length > 0 ){
		myChpObj.value = myChpObj.value.toUpperCase();
	}
}


function Capitale(thisChp){
//alert('thisChp='+thisChp);
	var myFormObj; var myChpObj; var myStrIn; var myStrOut;
	var car1; var carSuite;
	var nbCar;
	
	myStrIn = ''; myStrOut = '';
	
	if ( thisChp.length > 0 ){
		myFormObj = getFormObj(thisChp);		//--recherche de l'objet form contenant le champ
		if ( myFormObj ){
			myChpObj = myFormObj[thisChp];
			if ( myChpObj.name == thisChp && myChpObj.value.length > 0 ){
				myStrIn = myChpObj.value;
			}
		}else{
			myStrIn = thisChp
		}
			
		if ( myStrIn.length > 0 ){
			nbCar = myStrIn.length;
			car1 = myStrIn.substr(0,1);
			car1 = FiltrAccent(car1);
			carSuite = myStrIn.slice(-(nbCar - 1));
			myStrOut = car1.toUpperCase() + carSuite;
		}
	}

	if ( myFormObj ){
		myChpObj.value = myStrOut;
	}else{
		return myStrOut;
	}
}


function FiltrAccent(thisChp){
	var myFormObj; var myChpObj; var myStrIn; var myStrOut; var myCarIn; var myCarOut;
	var nbCar;
	var listAccents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
	var listCar = 'AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz';
	myStrIn = '';
	//alert('thisChp.length='+thisChp.length)
	if ( thisChp.length > 0 ){
		myFormObj = getFormObj(thisChp);		//--recherche de l'objet form contenant le champ
		if ( myFormObj ){
			myChpObj = myFormObj[thisChp];
			if ( myChpObj.name == thisChp && myChpObj.value.length > 0 ){
				myStrIn = myChpObj.value;
			}
		}else{
			myStrIn = thisChp
		}
		//alert('myStrIn='+myStrIn)
		nbCar = myStrIn.length;
		//alert('nbCar='+nbCar)
		if ( nbCar > 0 ){
			myStrOut = '';
			for ( var i=0; i < nbCar; i++ ) {
				myCarIn = myStrIn.charAt(i);
				myCarOut = myCarIn;
				for ( var j=0; j < listAccents.length; j++ ) {
					//alert('myCarIn='+myCarIn+' |accent='+listAccents.charAt(j))
					if ( myCarIn == listAccents.charAt(j) ){
						myCarOut = listCar.charAt(j);
						break;
					}
				}
				myStrOut += myCarOut;
			}
			//alert('myStrOut='+myStrOut)
			if ( myFormObj ){
				myChpObj.value = myStrOut;
			}else{
				return myStrOut;
			}
		}
	//}else{
		//return null;
	}
} 


function FiltrPonctu(thisChp){
	var myFormObj, myChpObj,  myStrIn, myStrOut, myCarIn, myCarOut;
	var nbCar;
	var listPonctu = ',;:.?!';
	myStrIn = '';
	//alert('thisChp.length='+thisChp.length)
	if ( thisChp.length > 0 ){
		myFormObj = getFormObj(thisChp);		//--recherche de l'objet form contenant le champ
		if ( myFormObj ){
			myChpObj = myFormObj[thisChp];
			if ( myChpObj.name == thisChp && myChpObj.value.length > 0 ){
				myStrIn = myChpObj.value;
			}
		}else{
			myStrIn = thisChp
		}
		//alert('myStrIn='+myStrIn)
		nbCar = myStrIn.length;
		//alert('nbCar='+nbCar)
		if ( nbCar > 0 ){
			myStrOut = '';
			for ( var i=0; i < nbCar; i++ ) {
				myCarIn = myStrIn.charAt(i);
				myCarOut = myCarIn;
				for ( var j=0; j < listPonctu.length; j++ ) {
					//alert('myCarIn='+myCarIn+' |accent='+listPonctu.charAt(j))
					if ( myCarIn == listPonctu.charAt(j) ){
						myCarOut = '';
						break;
					}
				}
				myStrOut += myCarOut;
			}
			//alert('myStrOut='+myStrOut)
			if ( myFormObj ){
				myChpObj.value = myStrOut;
			}else{
				return myStrOut;
			}
		}
	//}else{
		//return null;
	}
} 



function CheckBox(thisChp, thisNbBox){
	var myCpt;
	var myFormObj; var myBoxObj;
	var tabChp = thisChp.split('.');
	
	(thisNbBox > 1) ? myCpt = thisNbBox.toString() : myCpt = '';
	//alert('myCpt='+myCpt)
	
	//alert('tabChp.length='+tabChp.length)
	if ( parseInt(tabChp.length) >= 2 ){
		for ( var i=0; i < tabChp.length; i++ ) {
			myFormObj =  strTab[0];
			myBoxObj =  strTab[1];
		}
		//alert('myFormObj.name='+myFormObj+' |myBoxObj.name='+myBoxObj)
	}else{
		myFormObj = getFormObj(thisChp+String(myCpt));
		myBoxObj = myFormObj[thisChp+String(myCpt)];
		//alert('myFormObj.name='+myFormObj.name+' |myBoxObj.name[1]='+myBoxObj.name)
	}

	var allIsNull;
	if ( myBoxObj.title ){var id=myBoxObj.title}else{if ( document.getElementById ){var id=myBoxObj.id}else{var id='en surbrillance'}}
	allIsNull = true;
	
	if ( thisNbBox > 1 ){
		for ( var i=1; i <= thisNbBox; i++ ) {
			//alert('myFormObj[thisChp+String(i)].value='+myFormObj[thisChp+String(i)].value)
			if ( myFormObj[thisChp+String(i)].checked ){allIsNull = false}
		}
	}else{
		//alert('myFormObj[thisChp].value='+myFormObj[thisChp].value)
		if ( myFormObj[thisChp].checked ){allIsNull = false}
	}
	
	if ( allIsNull == true ){
		if ( thisNbBox > 1 ){
			alert('Merci de valider au moins une des options de la rubrique '+id);
			myFormObj[thisChp+'1'].style.backgroundColor = 'orange';
		}else{
			alert('Merci de valider l\'option de la rubrique '+id);
			myFormObj[thisChp].style.backgroundColor = 'orange';
		}
		return false;
	}
}


function CheckRadio(thisChp){
	/*
	--le bouton radio a la particularité d'être constitué de plusieurs balises portant le même nom (name) -> on doit spécifier l'indice
	--thisChp[0].name = getElementsByName(thisChp)(0).name
	*/
	//alert('thisChp='+thisChp)	//-> ok objet
	//alert('thisChp.length='+thisChp.length)	//-> ok nb de balises du même nom
	//alert('thisChp[0].name='+thisChp[0].name)	//-> ok nom
	//alert('thisChp[0].title='+thisChp[0].title)	//-> ok titre
	if ( thisChp[0].title ){var id=thisChp[0].title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
	var isSel = false;
	for (var i=0; i < thisChp.length; i++){
		if ( thisChp[i].checked == true){isSel = true}
	}
	if ( !isSel ){
		alert('Choisissez l\'une des options du champ\n'+id)
		for ( i=0; i < thisChp.length; i++ ){thisChp[i].style.backgroundColor = 'orange'}
		return false;
	}
}


function CheckSelect(thisChp){
	if ( thisChp.type == 'select-one' || thisChp.type == 'select-multiple' ){
		//alert('thisChp.id='+thisChp.id+' |thisChp.title='+thisChp.title)
		if ( thisChp.title ){var id=thisChp.title}else{if ( thisChp.id ){var id=thisChp.id}else{var id='en surbrillance'}}
		if ( thisChp.options[thisChp.selectedIndex].value.length == 0 || thisChp.options[thisChp.selectedIndex].value == '???' ){
			alert('Choisissez l\'une des options du menu deroulant\n'+id);
			thisChp.focus();
			return false;
		}
	}
}


function setRadio(thisChp, thisVal){
	//alert('thisChp[0].name='+thisChp[0].name+' |thisChp[0].value='+thisChp[0].value+' |thisVal='+thisVal)
	var mytype, mylength, myIndice;
	//myform = thisChp[0].form.name		//alert('myform='+myform)
	//myname = thisChp[0].name
	mytype = thisChp[0].type;			//alert('mytype='+mytype)
	mylength = thisChp.length;
	myIndice = -1;
	if ( mytype == 'radio' ){
		for ( var i=0; i<mylength; i++ ){
			//alert(thisChp[i].name+'['+i+'].value='+thisChp[i].value)
			if ( thisChp[i].value.toLowerCase() == String(thisVal.toLowerCase()) ){
				myIndice = i;		//alert('myIndice='+myIndice)
				break;
			}
		}
		//alert('myIndice='+myIndice+' |document[thisChp]['+myIndice+'].value='+document[thisChp][myIndice].value)
		if ( myIndice >= 0 ){
			thisChp[myIndice].click();
			//thisChp[myIndice].checked = true;
		}
	}
}


function ValSelRadio(thisChp){
	var mytype, mylength, myvalue;
	//myform = thisChp[0].form.name		//alert('myform='+myform)
	//myname = thisChp[0].name
	mytype = thisChp[0].type;			//alert('mytype='+mytype)
	mylength = thisChp.length;
	if ( mytype == 'radio' ){
		for ( var i=0; i<mylength; i++ ){
			//alert('thisChp['+i+'].checked='+thisChp[i].checked)
			if ( thisChp[i].checked ){
				myvalue = thisChp[i].value;		//alert('myvalue='+myvalue)
				break;
			}
		}
	}
	return myvalue;
}


function ValSelOption(thisChp){
	//var myForm = getFormObj(String(thisChp.name));
	//alert(myForm.name)
	return thisChp.options[thisChp.selectedIndex].value;
}


function getOption(thisForm, thisName, thisType){
	//alert('thisForm.name='+thisForm.name+' |thisName='+thisName+' |thisType='+thisType)
	var myVal;
	/*
	if ( thisName == 'ListPl' ){
		alert(thisForm[thisName].options[thisForm[thisName].selectedIndex].id)
		alert(thisForm[thisName].options[thisForm[thisName].selectedIndex].value)
		alert(thisForm[thisName].options[thisForm[thisName].selectedIndex].index)
	}
	*/
	switch (thisType){
		case 'id' :
			myVal = thisForm[thisName].options[thisForm[thisName].selectedIndex].id;
			break;
		case 'value' :
			myVal = thisForm[thisName].options[thisForm[thisName].selectedIndex].value;
			break;
		case 'index' :
			myVal = thisForm[thisName].options[thisForm[thisName].selectedIndex].index;
			break;
	}
	//alert('myVal='+myVal);
	return myVal;
	//return document[thisForm][thisName].options[document[thisForm][thisName].selectedIndex].value;	//--construction de code si l'argument est mis entres parenthèses
}


function CheckNull(thisChp){
	//alert('thisChp='+thisChp)	//-> [Object]
	//alert('thisChp.name='+thisChp.name)	//-> ok
	//alert('thisChp.title='+thisChp.title)	//-> ok
	//alert('getElementsByName(thisChp.name)='+document.getElementsByName(thisChp))		//-> 
	//alert('getElementsByName(thisChp.name).name='+document.getElementsByName(thisChp).name)		//-> 
	//alert('getElementsByName("Nom")='+document.getElementsByName('Nom'))		//-> 
	//alert('getElementsByName("Nom").name='+document.getElementsByName('Nom').name)		//-> 
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		if ( thisChp.value.length == 0 || thisChp.value == '???' ) {
			alert('renseignez le champ\n'+id)
			thisChp.focus();
			return false;
		}
	}
}


function CheckLen(thisChp, nbcarmin, nbcarmax){
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		var myString;
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		if ( thisChp.value.length > 0 ){
			myString = ' caractères minimum requis dans le champ\n';
			if ( thisChp.value.length < nbcarmin ) {
				alert(nbcarmin+ myString + id);
				thisChp.focus();
				return false;
			}else{
				if ( nbcarmax ){
					if ( thisChp.value.length > nbcarmax ) {
						myString = ' caractères maximum requis dans le champ\n';
						alert(nbcarmax+ myString + id);
						thisChp.focus();
						return false;
					}
				}
			}
		}
	}
}


function CheckNum(thisChp, thisExcept){
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		var allValid = true;
		var checkOK = '0123456789';
		if ( thisExcept ){checkOK += String(thisExcept)}
		for ( var i=0; i < thisChp.value.length; i++ ) {
			if ( checkOK.indexOf(thisChp.value.charAt(i)) == -1 ){allValid = false}
		}
		if ( allValid == false ) {
			alert('Ne saisir que des chiffres dans le champ\n' + id)
			thisChp.select();
			return false;
		}
		return allValid;
	}
}


function CheckZero(thisChp){
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		if ( parseInt(thisChp.value) == 0 ){
			alert('la valeur ne peut pas être égale à zéro dans le champ\n' + id)
			thisChp.select();
			return false;
		}
	}
}


function CheckInfZero(thisChp){
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		if ( parseInt(thisChp.value) < 0 ){
			alert('la valeur ne peut pas être négative dans le champ\n' + id)
			thisChp.select();
			return false;
		}
	}
}


function CheckSupZero(thisChp){
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		if ( parseInt(thisChp.value) > 0 ){
			alert('la valeur ne peut pas être positive dans le champ\n' + id)
			thisChp.select();
			return false;
		}
	}
}


function isImpair(thisChp){
	if ( (ParseFloat(thisChp / 2) - parseInt(thisChp%2)) > 0 ){return true}else{return false}
}


function CheckText(thisChp, thisExcept){
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		var allValid = true;
		var checkOK = 'ABCDEFGHIJKLMNOPQRSTUVWXYZaàâbcdeéèêëfghijklmnopqrstuvwxyz- ';
		if ( thisExcept ){checkOK += String(thisExcept)}
		for ( var i=0; i < thisChp.value.length; i++ ) {
			if ( checkOK.indexOf(thisChp.value.charAt(i)) == -1 ){
				allValid = false;
				error = thisChp.value.charAt(i);
			}
		}
		if ( allValid == false ) {
			alert('Caractère '+error+' invalide dans le champ\n' + id)
			thisChp.select();
			return false;
		}
		return allValid;
	}
}


function CheckTextNum(thisChp, thisExcept){
	if ( thisChp.type == 'text' || thisChp.type == 'password' ){
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		var allValid = true;
		var error;
		var checkOK = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZaàâbcdeéèêëfghijklmnopqrstuvwxyz- ';
		if ( thisExcept ){checkOK += String(thisExcept)}
		for ( var i=0; i < thisChp.value.length; i++ ) {
			if ( checkOK.indexOf(thisChp.value.charAt(i)) == -1 ){
				allValid = false;
				error = thisChp.value.charAt(i);
			}
		}
		if ( allValid == false ) {
			var nomch = thisChp.name.substr(4,thisChp.name.length)
			alert('Caractère "'+error+'" invalide dans le champ\n' + id)
			thisChp.select();
			return false;
		}
		return allValid;
	}
}


function CheckDouble(thisStr, sep, thisTitle){
	//alert('thisStr='+thisStr+' |sep='+sep)
	var tabStr;
	var valCum = '';
	tabStr = thisStr.split(sep);
	for ( var i=0; i < tabStr.length; i++ ) {
		if ( tabStr[i] != '' ){
			if ( valCum.indexOf(tabStr[i], 0) >= 0 ){
				alert('Votre choix conduit à des valeurs en doublon parmi les sélections de ' + thisTitle);
				if ( getElementByTitle('SELECT', thisTitle) ){getElementByTitle('SELECT', thisTitle).focus();}
				return false;
			}
			if ( i > 0 ){valCum += '|';}
			valCum += tabStr[i];
		}
	}
	//alert(valCum)	
}


function CheckMail(thisChp){
	if ( thisChp.type == 'text' ){
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		var iChars = '*|,\":<>[]{}`\';()&$#%';
		var allValid = true;
		for ( var i=0; i < thisChp.value.length; i++ ) {
			if ( iChars.indexOf(thisChp.value.charAt(i)) != -1 ){allValid = false}
		}
		if ( thisChp.value.indexOf('@',0) == -1 || thisChp.value.indexOf('.',0) == -1 ) {allValid = false}
		if ( allValid == false ) {
			var nomch = thisChp.name.substr(4,thisChp.name.length);
			alert('Email invalide dans le champ\n' + id + '\nle champ '+id+' doit être sous la forme\nnom@herbergeur.extension')
			thisChp.select();
			return false;
		}
		return allValid;
  }
}


function CheckDate(thisChp){
	if ( thisChp.type == 'text' ){
		var tabDate;
		var day; var month; var year;
		var nbSlash=0;
		if (thisChp.value.length == 0) {return true}
		if ( thisChp.title ){var id=thisChp.title}else{if ( document.getElementById ){var id=thisChp.id}else{var id='en surbrillance'}}
		var allValid = true
		var checkOK = '0123456789/'
		for (var i=0; i < thisChp.value.length; i++) {
			if (checkOK.indexOf(thisChp.value.charAt(i)) == -1){allValid = false}
			if ( thisChp.value.charAt(i) == '/' ){nbSlash += 1}
		}
		if ( allValid == false ) {
			alert('Caractère incorrect dans le champ\n'+id)
			thisChp.select();
			return false;
		}
		if ( nbSlash < 2 ){
			alert('Séparateur manquant ou incorrect dans le champ\n'+id)
			thisChp.select();
			return false;
		}
		tabDate = thisChp.value.split('/');
		day = tabDate[0];
		month = tabDate[1];
		year = tabDate[2];
		if ( year.length == 2 ){if ( year < 30 ){year = 20 + tabDate[2]}else{year = 19 + tabDate[2]}}		//--YY<30 ? YYYY=20YY : YYYY=19YY
		if ( (!year) || (!month) || (!day) || parseFloat(day) < 1 || parseFloat(month)<1 || parseFloat(year)<1930 ){
			alert('Date '+ thisChp.value + ' invalide')
			thisChp.select();
			return false;
		}
		/*--inutile
		var test = new Date(year,month-1,day)
		if( year.slice(-2) != test.getYear() || month != test.getMonth()+1 || day != test.getDate() ){
			alert('Date '+ thisChp.value + ' invalide')
			thisChp.select();
			return false;
		}
		*/
	}
}


function NbDaysOfMonth(Month, Year){
	switch (parseFloat(Month)){
		case 2: return ( ((Year % 4 == 0) && ((! (Year % 100 == 0)) || (Year % 400 == 0) ) ) ? 29 : 28);
		case 4:; case 6:; case 9:; case 11: return 30;
		case 1:; case 3:; case 5:; case 7:; case 8:; case 10:; case 12: return 31;
		default: return -1;
	}
}


function DatFormat(datStr, formIn, formOut){
	var myDatIn = new Date();
	var myTxtDatOut;
	var reg=new RegExp('[-\/]+', 'g');
	var tabStr = datStr.split(reg)
	var myJ; var myM; var myA;
	//alert('datIn='+parseInt(tabStr['0'])+'/'+parseInt(tabStr['1'])+'/'+parseInt(tabStr['2']))
	switch (formIn){
		case 'jma':
			myDatIn.setDate(parseInt(tabStr['0'])); myDatIn.setMonth(parseInt(tabStr['1'])); myDatIn.setYear(parseInt(tabStr['2']));
			break;
		case 'mja':
			myDatIn.setDate(parseInt(tabStr['1'])); myDatIn.setMonth(parseInt(tabStr['0'])); myDatIn.setYear(parseInt(tabStr['2']));
			break;
		case 'amj':
			myDatIn.setDate(parseInt(tabStr['2'])); myDatIn.setMonth(parseInt(tabStr['1'])); myDatIn.setYear(parseInt(tabStr['0']));
			break;
		default:
			myDatIn = new Date(datStr);
			break;
	}
	myJ = myDatIn.getDate();		//myJ = '0'+myDatIn.getDate(); myJ = myJ.slice(-2);
	myM = (myDatIn.getMonth());		//myM = '0'+(myDatIn.getMonth()+1); myM = myM.slice(-2);
	myA = myDatIn.getFullYear();
	
	//alert(myJ+'/'+myM+'/'+myA);
	switch (formOut){
		case 'jma':
			myTxtDatOut =  myJ+'/'+myM+'/'+myA;
			break;
		case 'mja':
			myTxtDatOut =  myM+'/'+myJ+'/'+myA;
			break;
		case 'amj':
			myTxtDatOut =  myA+'/'+myM+'/'+myJ;
			break;
		default:
			myTxtDatOut =  myJ+'/'+myM+'/'+myA;
			break;
	}	
	//alert(myTxtDatOut)
	return myTxtDatOut;
}


function DatAdd(datIn, interval, nbi){
	var datOut;
	if ( typeof(datIn) == 'string' ){
    datIn = new Date(datIn);
  }
  if ( isNaN(datIn) ){
		throw('La date n\'est pas valide');
	}else{
		if ( typeof(datIn) != 'object' || datIn.constructor.toString().indexOf('Date()') == -1 )
			{throw('le 1er paramètre doit être un objet date');}
	}
  if ( interval != 'M' && interval != 'D' && interval != 'Y' && interval != 'h' && interval != 'm' && interval != 'uM' && interval != 'uD' && interval != 'uY' && interval != 'uh' && interval != 'um' && interval != 'us' )
		{throw('Le second paramètre doit être : M, D, Y, h, m, uM, uD, uY, uh, um or us');}

	if ( typeof(nbi) != 'number' )
		{throw('Le 3ème paramèrte doit être un chiffre');}

	datOut = new Date(datIn);		//--new Date() afin que les traitements n'affectent pas datIn

  switch (interval){
    case 'M':
    datOut.setMonth(parseInt(datOut.getMonth()) + parseInt(nbi));
    break;

    case 'D':
    datOut.setDate(parseInt(datOut.getDate()) + parseInt(nbi));
    break;

    case 'Y':
    datOut.setYear(parseInt(datOut.getYear()) + parseInt(nbi));
    break;

    case 'h':
    datOut.setHours(parseInt(datOut.getHours()) + parseInt(nbi));
    break;

    case 'm':
    datOut.setMinutes(parseInt(datOut.getMinutes()) + parseInt(nbi));
    break;

    case 's':
    datOut.setSeconds(parseInt(datOut.getSeconds()) + parseInt(nbi));
    break;

    case 'uM':
    datOut.setUTCMonth(parseInt(datOut.getUTCMonth()) + parseInt(nbi));
    break;

    case 'uD':
    datOut.setUTCDate(parseInt(datOut.getUTCDate()) + parseInt(nbi));
    break;

    case 'uY':
    datOut.setUTCFullYear(parseInt(datOut.getUTCFullYear()) + parseInt(nbi));
    break;

    case 'uh':
    datOut.setUTCHours(parseInt(datOut.getUTCHours()) + parseInt(nbi));
    break;

    case 'um':
    datOut.setUTCMinutes(parseInt(datOut.getUTCMinutes()) + parseInt(nbi));
    break;

    case 'us':
    datOut.setUTCSeconds(parseInt(datOut.getUTCSeconds()) + parseInt(nbi));
    break;
  }
  //alert('datIn=' + datIn + ' |datOut=' + datOut)
  return new Date(datOut);
	//return datOut;
}


function DatChange(datIn, Nb, Type){
	//--return a object Date ... up or down a date value
	//--datIn is a Date Object; Nb is a integer; Type is a choice: ['DAY','MONTH','YEAR']['HOUR','MINUTE','SECOND','TIME']
  var Year = datIn.getFullYear();
  var Month = datIn.getMonth() + 1;
  var Day = datIn.getDate();
  var datOut = new Date(datIn);		//--new Date() afin que les traitements n'affectent pas datIn
  //alert('datOut='+datOut)
  var Hour = 0;
  var Minute = 0;
  var Second = 0;
  var Time = 0; 
  
  if (Type.toUpperCase().substr(0,3) == 'DAY'){
		//--datOut=nouvelle date en miliseconde
		datOut.setTime(datOut.getTime() + ((24 * 3600 * 1000) * Nb));	
		Day = datOut.getDate();
  }
    
  if (Type.toUpperCase().substr(0,5) == 'MONTH'){
    Month += Nb;
    if (Month < 1){
      Month += 12;
      Year -= 1;
    }
    if (Month > 12){
      Month -= 12;
      Year += 1;
    }
  }
  
  if (Type.toUpperCase().substr(0,4) == 'YEAR'){Year += Nb};
   
  if ( Day > NbDaysOfMonth(Month,Year) ) {Day = NbDaysOfMonth(Month,Year)};
  
	if ( Type.Length > 3 ){
		if (Type.toUpperCase().slice(-4) == 'TIME' ){
			Hour = datOut.getHours();
			Minute = datOut.getMinutes();
			Second = datOut.getSeconds();
		 }else{
			Hour = (Type.toUpperCase().slice(-4) == 'HOUR' ? datOut.getHours() : Hour)
			Minute = (Type.toUpperCase().slice(-6) == 'MINUTE' ? datOut.getMinutes() : Minute)
			Second = (Type.toUpperCase().slice(-6) == 'SECOND' ? datOut.getSeconds() : Second)
		 }
	 }
  
  //alert('datIn='+datIn+' |datOut= '+Day+'/'+Month+'/'+Year)
	return new Date(Year, Month-1, Day, Hour, Minute, Second);
}


function DatDiff(dat1, dat2, nbJrSem){
	//alert(dat1 + ' / ' + dat2)
	var nbJr = 0;
	var jms = 24 * 3600 * 1000;
	var cptDat1; var cptDat2;
	var datDeb; var datFin;
	var datPlus;
	
	dat1.setHours(0,0,0,0); dat2.setHours(0,0,0,0)	//--initialisation du temps (hh:mm:ss) à 00:00:00 pour compter en jours pleins
	cptDat1 = Math.floor(parseFloat(dat1.getTime()/jms) + 0.05);		//--approximation de 0.05jr
	cptDat2 = Math.floor(parseFloat(dat2.getTime()/jms) + 0.05);
	//alert('cptDat1='+cptDat1 + ' |cptDat2=' + cptDat2)
	datDeb =  cptDat1 <= cptDat2 ? dat1 : dat2;		//--la date de début est la plus antérieure
	datFin = cptDat1 <= cptDat2 ? dat2 : dat1;
	//alert('datDeb='+datDeb+' |datFin='+datFin)	
	diff = cptDat1 - cptDat2;
	//alert('diff=' + diff)
	if ( diff <= 0 ){
		nbJr = diff
	}else{
		datPlus = new Date(datDeb);		//--new Date() afin que les traitements n'affectent pas datDeb
									//var dTest = new Date();
									//dTest = dTest.setFullYear(1970,0,1)
									//dTest -= 12*(3600*1000)		//--setFullYear positionne la date à midi
		for ( var i=1; i <= diff; i++ ){
			datPlus = DatAdd(datPlus,'D',1)
			//alert('dat1='+dat1+' |dat2='+dat2+'datDeb='+datDeb+' |datPlus='+datPlus)
			//alert('datPlus='+datPlus+'('+datPlus.getDay()+')')
			switch (parseInt(nbJrSem)){
				case 5 :
					if ( parseInt(datPlus.getDay()) != 6 && parseInt(datPlus.getDay()) != 0 ){nbJr++;}
					break;
				case 6 :
					if ( parseInt(datPlus.getDay()) != 0 ){nbJr++;}
					break;
				default :
					nbJr++;
					break;
			}
		}
	}
  //alert(nbJr)
  return nbJr;
}


//function inverser(tab, i, j) {
//	var temp=tab[i];
//	tab[i]=tab[j];
//	tab[j]=temp;
//}
function TriTab(thisTab, ordre) {
	//--thisTab est le nom du tableau
	//--ordre vaut 1 si tri croissant et -1 si décroissant
	ordre = -ordre;
	var temp;
	var n = thisTab.length;
	var continuer = true;
	var i = 0;
	var iter = 0;
	for ( i=0; i<n; i++ ){thisTab[i] = ordre * thisTab[i]}
	while (continuer) {
		iter++;
		continuer = false;
		for ( i=0; i<n-1; i++ ) {
			if ( Math.min(thisTab[i], thisTab[i+1]) != thisTab[i+1] ){
				temp = thisTab[i]; thisTab[i] = thisTab[i+1]; thisTab[i+1] = temp;	//--inversion de l'ordre
				//inverser(thisTab, i, i+1);
				continuer=true;
			}
		}
	}
	for ( i=0; i<n; i++ ){thisTab[i] = ordre * thisTab[i]}

	return thisTab;
}


function DedoublTab(thisTab){
	//alert('thisTab='+thisTab+' |thisTab.length='+thisTab.length)
	var xi, xj, cpt;
	var isExist;
	
	if ( thisTab.length >= 1 ){
		tabTmp = new Array(thisTab.length);
		tabTmp[0] = thisTab[0];
		for ( xi = 1; xi < tabTmp.length; xi++ ){tabTmp[xi] = null;}
		//alert('tabTmp='+tabTmp);
		cpt = 1;
		
		for ( xi=1; xi < thisTab.length; xi++ ){
			isExist = false;
			for ( xj=0; xj < tabTmp.length; xj++ ){
				//alert('tabTmp.length='+tabTmp.length)
				if ( thisTab[xi] == tabTmp[xj] ){
					isExist = true;
					break;
				}
			}
			//alert('isExist('+thisTab[xi]+')='+isExist)
			if ( isExist == true ){
				tabTmp[xi] = null;
			}else{
				tabTmp[xi] = thisTab[xi];
				cpt += 1;
			}
		}
		//alert('tabTmp='+tabTmp);
		if ( cpt >= 1 ){
			myTab = new Array(cpt)
			myTab[0] = tabTmp[0];
			cpt = 1;
			for ( xi = 1; xi < tabTmp.length; xi++ ){
				if ( tabTmp[xi] != null ){
					myTab[cpt] = tabTmp[xi];
					cpt++;
				}
			}
		}
		//alert('myTab='+myTab)
		thisTab = myTab;
	}
	//alert('thisTab='+thisTab)
	return thisTab;
}



function ListEditeur_onchange(s){
	location.href= 'dsmcotation2.aspx?BT=Non&Listediteur='+ s.options[s.selectedIndex].value;
	return;
}


function ListCat_onchange(s){
	location.href= 'dsmcotation2.aspx?BT=Non&ListCat='+ s.options[s.selectedIndex].value;
	return;
}


function ListScat_onchange(s){
	location.href= 'dsmcotation2.aspx?BT=Non&ListScat='+ s.options[s.selectedIndex].value;
	return;
}


function ListEditeur_consolist_onchange(s){
	location.href= 'Conso_list.aspx?BT=Non&Listediteur='+ s.options[s.selectedIndex].value;
	return;
}


function ListProLine_consolist_onchange(s){
	location.href= 'Conso_list.aspx?BT=Non&ProductLine='+ s.options[s.selectedIndex].value;
	return;
}


function Comparateur(tabindex){
	var CleLigne='vide';
	var Comp='Non';
	CleLigne = document.form1['CLE' + String(tabindex)].value;
	if ( document.form1['COMPARE' + String(tabindex)].checked ){
		Comp='Oui';
	}
	document.getElementById('Actebis_Panier').src=( 'Actebis_Panier.aspx?CLE='+String(CleLigne)+'&Compare=' + Comp);
}


function ListClass_comparateurlist_onchange(s){
	location.href= 'Comparateur_Main.aspx?BT=Non&IDCLASS='+ s.options[s.selectedIndex].value;
	return;
}


function ListGamme_comparateurlist_onchange(s){
	location.href= 'Comparateur_Main.aspx?BT=Non&IDGAMME='+ s.options[s.selectedIndex].value;
	return;
}


function ScrollUp(){
	if ( loop < 18 ){
		window.parent.document.Actebis_Panier.scrollBy(0,-1);
		loop++;
		setTimeout('ScrollUp()',5);
	}else{
		loop = 0;
	}
}


function ScrollDown(){
	if ( loop < 18 ){
		window.parent.document.Actebis_Panier.scrollBy(0,1);
		loop++;
		setTimeout('ScrollDown()',5);
	}else{
		loop = 0;
	}
}


function QteMoins(tabindex){
		MajQte(tabindex, -1);
}


function QtePlus(tabindex){
		MajQte(tabindex, 1);
}


function MajQte(tabindex, NewQte){
	var myEditeur = document.form1['EDITEUR'+ String(tabindex)].value;
	var myCat = document.form1['CAT'+ String(tabindex)].value;
	var myClePro = document.form1['CLE' + String(tabindex)].value;
	var QteChar = Number(document.form1['QTE'+ String(tabindex)].value);
	var myQteCmd = 0;
	var myQteMinTar = Number(document.form1['QTEMINTAR'+ String(tabindex)].value);
	var myQteMinLog = Number(document.form1['QTEMINLOG'+ String(tabindex)].value);
	var myQteMinSpq = Number(document.form1['QTEMINSPQ'+ String(tabindex)].value);
	var myQteMaxTar = Number(document.form1['QTEMAXTAR'+ String(tabindex)].value);
	var myQteMaxSpq = Number(document.form1['QTEMAXSPQ'+ String(tabindex)].value);
	var myNumReb = document.form1['NUMREB'+ String(tabindex)].value;
	//alert('myNumReb='+myNumReb)
	var msg = ''
	var isDblBloc = false;
	//alert('myQteMinTar='+myQteMinTar+' |myQteMinLog='+myQteMinLog+' |myQteMinSpq='+myQteMinSpq+' |myQteMaxTar='+myQteMaxTar+' |myQteMaxSpq='+myQteMaxSpq)
	
	if ( isNaN(QteChar) ) {myQteCmd = 1;}else{myQteCmd = QteChar;}

	if ( NewQte == 0 ){myQteCmd = Math.max(0, myQteCmd);}
	if ( NewQte == 1 ){myQteCmd += 1;}
	if ( NewQte == -1 ){myQteCmd -= 1;}
	
	//alert('NewQte='+NewQte+' |myQteCmd='+myQteCmd)

	//--controle 1 sur le min----------------------
	//--blocage qté min / tarif
	if ( myQteMinTar> 1 && myQteCmd > 0 && myQteCmd < myQteMinTar ){
		msg = 'La quantité commandable minimum est de ' + myQteMinTar + 'pcs pour cette grille de tarif';
		if ( NewQte >= 0 ){myQteCmd = Math.max(myQteMinTar, myQteCmd);}
		if ( NewQte == -1 ){myQteCmd = 0;}
		alert(msg);
	}
	
	//--blocage qté min / spq
	if ( myQteMinSpq > 1 && myQteCmd > 0 && myQteCmd < myQteMinSpq ){
		msg = 'La quantité commandable minimum est de ' + myQteMinSpq + 'pcs sous la/les cotation(s) n° ' + myNumReb;
		if ( NewQte >= 0 ){myQteCmd = Math.max(myQteMinSpq, myQteCmd);}
		if ( NewQte == -1 ){myQteCmd = 0;}
		alert(msg);
	}
	
	//--blocage qté min / logistique
	if ( myQteMinLog > 1 && myQteCmd > 0 && myQteCmd < myQteMinLog ){
		msg = 'La quantité de conditionnement est de ' + myQteMinLog + 'pcs';
		if ( myEditeur == 'HP TOP-CONFIG' ){
			//--seuil min = 10 sur HP TOP-CONFIG (hors serveur - JdG le 18/06/2010)
			msg += ' sur les configurations HP Top-Config (hors serveur)';
			if ( NewQte >= 0 ){myQteCmd = Math.max(myQteMinSpq, myQteCmd);}
			if ( NewQte == -1 ){myQteCmd = 0;}
		}else{
			msg += '\nDes frais de logistique seront ajoutées à la validation de votre commande';
		}
		alert(msg);
	}
	
	//--controle 2 sur le max----------------------
	//--blocage qté max / tarif
	myQteCmd = Math.max(0, myQteCmd);
	if ( myQteMaxTar != 0 ){
		if  ( myQteCmd > myQteMaxTar ){
			alert('La quantité commandable maximum est de ' + String(myQteMaxTar) + 'pcs dans cette grille de tarif et/ou dans la configuration de votre panier');
			myQteCmd = myQteMaxTar;
		}
	}
	
	//--blocage qté max / spq
	if ( myQteMaxSpq != 0 ){
		if  ( myQteCmd > myQteMaxSpq ){
			alert('La quantité commandable maximum est de ' + String(myQteMaxSpq) + 'pcs sous la/les cotation(s) n° ' + myNumReb);
			myQteCmd = myQteMaxSpq;
		}
	}
	
	//--controle 3 sur conflit min/max sur tarif ou spq (le min logistique n'est pas une conditions blocante)-------------
	//--reblocage qté min / tarif
	if ( myQteMinTar> 1 && myQteCmd > 0 && myQteCmd < myQteMinTar ){
		isDblBloc = true;
	}else{
		//--reblocage qté min / spq
		if ( myQteMinSpq > 1 && myQteCmd > 0 && myQteCmd < myQteMinSpq ){
			isDblBloc = true;
		}
	}
	if ( isDblBloc == true ){
		myQteCmd = 0;
		alert('L\'article ne peut être commandé sous les conditions édictées par la grille de tarif ou la cotation car elles sont conflictuelles');
	}
	
	//alert('CLE='+String(myClePro)+' |QTE='+String(myQteCmd)+' |NUMREB='+String(myNumReb))
	urlActebisPanier = 'Actebis_Panier.aspx?PAGESOURCE='+String(pageActuelle)+'&CLE='+String(myClePro)+'&QTE='+String(myQteCmd)+'&NUMREB='+String(myNumReb)+'&IDLOG='+String(getValQuery('IDLOG'));
	//alert('page='+pageActuelle+' |qyPopup= '+getValQuery('POPUP'))
	if ( ( pageActuelle == 'cnet_produit' || pageActuelle.substr(0,5) == 'promo' ) && getValQuery('POPUP') == 'Oui' )	{
		window.opener.document.getElementById('Actebis_Panier').src = (urlActebisPanier);
	}else{
		//alert('urlActebisPanier='+urlActebisPanier)
		document.getElementById('Actebis_Panier').src = (urlActebisPanier);
	}
	document.form1['QTE'+ String(tabindex)].value = String(myQteCmd);
}


function QteMoinsSPQ(formindex, tabindex){
	//alert('Moins ' + formindex + ' ' + tabindex + '  ');
	MajQteSPQ(formindex,tabindex,-1);
}


function QtePlusSPQ(formindex, tabindex){
	//alert('Plus ' + formindex + ' ' + tabindex + '  ');
	MajQteSPQ(formindex,tabindex,1);
}


function MajQteSPQ(fID, tabindex, NewQte){
	var QteLigne = 0;
	var myQteMaxTar = 0;
	var QteChar = Number(document.getElementById(fID)['QTE'+ String(tabindex)].value);
	//alert('MAJ ' + fID + ' ' + tabindex + ' ' + NewQte + ' ' + QteChar);
	var myQteMaxSpq = Number(document.getElementById(fID)['QTEMAXSPQ' + String(tabindex)].value);
	if ( isNaN(QteChar)){
		QteLigne = 1;
	}else{
		QteLigne = QteChar;
	}
	//alert('MAJ2 ' + fID + ' ' + tabindex + ' ' + NewQte + ' ' + QteChar);
	if ( NewQte == 1 ){QteLigne += 1;}
	if ( NewQte == -1 ){QteLigne -= 1;}
	//alert(QteLigne)
	//if (NewQte == 0){
		if ( QteLigne < 0 ){QteLigne = 0;}
		//QteLigne=QteLigne;
	//}
	//alert('MAJ4 ' + fID + ' ' + tabindex + ' ' + NewQte + ' ' + myQteMaxSpq);
	if ( myQteMaxSpq != 0 ){
		if  ( QteLigne > myQteMaxSpq ){
			QteLigne = myQteMaxSpq;
			alert('Quantit\351 maximum pour la cotation atteinte : ' + String(myQteMaxSpq) + ' ');
		}
	}
	//alert('MAJ5 ' + fID + ' ' + tabindex + ' ' + NewQte + ' ' + myQteMaxSpq + ' ' + QteLigne);
	document.getElementById(fID)['QTE'+ String(tabindex)].value = String(QteLigne);
}


function QteMoinsModifCmd(tabindex){
	MajQteModifCmd(tabindex,-1);
}


function QtePlusModifCmd(tabindex){
	MajQteModifCmd(tabindex,1);
}


function MajQteModifCmd(tabindex, NewQte){
	var QteLigne=0;
	var CleLigne='vide';
	var NumordreLigne=0;
	var myNumReb='0';
	var myQteMaxTar=0;
	var myQteMaxSpq=0;
	var QteChar=Number(document.form1['QTE'+ String(tabindex)].value);
		
	if ( isNaN(QteChar))
		{QteLigne = 1;}
	else
		{QteLigne = QteChar;}
	CleLigne = document.form1['CLE' + String(tabindex)].value;
	NumordreLigne = Number(document.form1['NUMORDRE'+ String(tabindex)].value);
	myNumReb = document.form1['NUMREB'+ String(tabindex)].value;
	if ( NewQte == 1 ){QteLigne += 1;}
	if ( NewQte == -1 ){QteLigne -= 1;}
	//alert(QteLigne)
	if ( NewQte == 0 ){
		if (QteLigne < 0){QteLigne = 0;}
		QteLigne=QteLigne;
	}
	if (QteLigne < 0){QteLigne = 0;}
	myQteMaxTar = Number(document.form1['QTEMAXTAR'+ String(tabindex)].value);
	if ( myQteMaxTar != 0 ){
		if  ( QteLigne > myQteMaxTar ){
			QteLigne = myQteMaxTar;
			alert('Quantite commandable ' + String(myQteMaxTar) + ' maximum dans la grille de tarif');
		}
	}
	myQteMaxSpq = Number(document.form1['QTEMAXSPQ'+ String(tabindex)].value);
	if ( myQteMaxSpq != 0 ){
		if  ( QteLigne > myQteMaxSpq ){
			QteLigne = myQteMaxSpq;
			alert('Quantite commandable ' + String(myQteMaxSpq) + ' maximum sous la promotion');
		}
	}
 	document.getElementById('Actebis_Panier').src=( 'Actebis_Panier_Modif_CMd.aspx?CLE='+String(CleLigne)+'&QTE='+String(QteLigne)+'&NUMORDRE='+String(NumordreLigne)+'&NUMREB='+String(myNumReb));
	document.form1['QTE'+ String(tabindex)].value = String(QteLigne);
}


function QteMoins_Microsoft(tabindex){
	MajQte_Microsoft(tabindex,-1);
}


function QtePlus_Microsoft(tabindex){
	MajQte_Microsoft(tabindex,1);
}


function MajQte_Microsoft(tabindex, NewQte){
	var QteLigne=0;
	var DesigLigne='vide';
	var GrpProdLigne='vide';
	var QteChar=Number(document.form1['MSQTE'+ String(tabindex)].value);
	
	if ( isNaN(QteChar) )
		{QteLigne = 1;}
	else
		{QteLigne = QteChar;}
	DesigLigne = document.form1['MSDESIG' + String(tabindex)].value;
	GrpProdLigne = document.form1['MSGROUPEPRODUIT' + String(tabindex)].value;
	//alert(DesigLigne);
	if ( NewQte == 1 ){QteLigne += 1;}
	if ( NewQte == -1 ){QteLigne -= 1;}
	//alert(QteLigne);
	if (NewQte == 0){
		if (QteLigne < 0){QteLigne = 0;}
		QteLigne=QteLigne;
	}
	if (QteLigne < 0){QteLigne = 0;}
 	document.getElementById('Actebis_Panier').src=( 'Actebis_Panier_Microsoft.aspx?MSDESIG='+encodeURIComponent(DesigLigne)+'&MSQTE='+String(QteLigne)+'&MSGROUPEPRODUIT='+encodeURIComponent(GrpProdLigne));
	document.form1['MSQTE'+ String(tabindex)].value = String(QteLigne);
}


function QteMoins_Symantec(tabindex){
	MajQte_Symantec(tabindex,-1);
}


function QtePlus_Symantec(tabindex){
	MajQte_Symantec(tabindex,1);
}


function MajQte_Symantec(tabindex, NewQte){
	var QteLigne=0;
	var DesigLigne='vide';
	var ServeurLigne='vide';
	var GrpAplLigne='vide';
	var QteChar=Number(document.form1['SYQTE'+ String(tabindex)].value);
		
	if ( isNaN(QteChar))
		{QteLigne = 1;}
	else
		{QteLigne = QteChar;}
	DesigLigne = document.form1['SYDESIG' + String(tabindex)].value;
	ServeurLigne = document.form1['SYSERVEUR' + String(tabindex)].value;
	GrpAplLigne = document.form1['SYGROUPEAPPLICATION' + String(tabindex)].value;
	PtsLigne = document.form1['SYPTS' + String(tabindex)].value;
	if (NewQte == 1){QteLigne += 1;}
	if (NewQte == -1){QteLigne -= 1;}
	//alert(QteLigne);
	if (NewQte == 0){
		if (QteLigne < 0){QteLigne = 0;}
		QteLigne=QteLigne;
	}
	if (QteLigne < 0){QteLigne = 0;}
 	document.getElementById('Actebis_Panier').src=( 'Actebis_Panier_Symantec.aspx?SYDESIG='+encodeURIComponent(DesigLigne)+'&SYQTE='+String(QteLigne)+'&SYPTS='+String(PtsLigne)+'&SYGRPAPPLICATION='+encodeURIComponent(GrpAplLigne)+'&SYSERVEUR='+encodeURIComponent(ServeurLigne));
	document.form1['SYQTE'+ String(tabindex)].value = String(QteLigne);
}


function QteMoins_Adobe(tabindex){
	MajQte_Adobe(tabindex,-1);
}


function QtePlus_Adobe(tabindex){
	MajQte_Adobe(tabindex,1);
}


function MajQte_Adobe(tabindex, NewQte){
	var QteLigne=0;
	var DesigLigne='vide';
	var PointLigne='vide';
	var GrpAplLigne='vide';
	var QteChar=Number(document.form1['ADQTE'+ String(tabindex)].value);
		
	if ( isNaN(QteChar) ){
		QteLigne = 1;
	}else{
		QteLigne = QteChar;
	}
	DesigLigne = document.form1['ADDESIG' + String(tabindex)].value;
	PointLigne = document.form1['ADPOINT' + String(tabindex)].value;
	GrpAplLigne = document.form1['ADGROUPEAPPLICATION' + String(tabindex)].value;
	if ( NewQte == 1 ){QteLigne += 1;}
	if ( NewQte == -1 ){QteLigne -= 1;}
	//alert(QteLigne);
	if ( NewQte == 0 ){
		if ( QteLigne < 0 ){QteLigne = 0;}
		QteLigne=QteLigne;
	}
	if ( QteLigne < 0 ){QteLigne = 0;}
 	document.getElementById('Actebis_Panier').src=('Actebis_Panier_Adobe.aspx?ADDESIG='+encodeURIComponent(DesigLigne)+'&ADQTE='+String(QteLigne)+'&ADGRPAPPLICATION='+encodeURIComponent(GrpAplLigne)+'&ADPOINT='+String(PointLigne));
	document.form1['ADQTE'+ String(tabindex)].value = String(QteLigne);
}


function checkBrowser(){
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.ie5=(this.ver.indexOf('MSIE 5')>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
	return this
}


function popup_form(Pub_Url,Pub_Size_Large) {
	fenetre=window.open(Pub_Url, 'fenetre', 'resizable=yes,scrollbars=no,location=no,width=' + Pub_Size_Large + ',height=350,top=0,left=50');
	if( fenetre.opener ){fenetre.window.focus()}
}


function popup_form3(Pub_Url, Pub_Size_Large, Pub_Size_Haut) {
	fenetre=window.open(Pub_Url, 'fenetre', 'resizable=yes,scrollbars=no,location=no,width=' + Pub_Size_Large + ',height=' + Pub_Size_Haut + ',top=0,left=50');
	if( fenetre.opener ){fenetre.window.focus()}
}


function popup_form4(Pub_Url, Pub_Size_Large, Pub_Size_Height, Pub_Fen) {
	var myPop;
	if ( Pub_Fen && typeof Pub_Fen != 'undefined' ){myPop=Pub_Fen}else{myPop='fenetre'}
	fenetre=window.open(Pub_Url , myPop, 'resizable=yes,scrollbars=yes,location=no,width='+Pub_Size_Large+',height='+Pub_Size_Height+',top=0,left=50');
	if( fenetre.opener ){fenetre.window.focus()}
}


function mdmain(thisPath){
	if ( window.opener && !window.opener.closed ){
		window.opener.document.location.href = thisPath;
		//window['fenetre'].focus()
	}else{
		window.document.location.href = thisPath;
	}
}


function cnet(cle, bundle){
	if ( window.opener && !window.opener.closed ){
		window.opener.document.location.href='/cnet_produit.aspx?CLE='+cle+'&amp;BUNDLE='+bundle+'&IDLOG='+String(getValQuery('IDLOG'))
	}else{
		fenetre=window.open('cnet_produit.aspx?CLE='+cle+'&BUNDLE='+bundle+'&IDLOG='+String(getValQuery('IDLOG'))+'&POPUP=Oui' ,'fenetre','resizable=yes,scrollbars=yes,location=no,width=820,height=550,top=10,left=50')
		if(!fenetre){
			alert('Vous devez desactiver l\'utilitaire anti-popup installe pour afficher les descriptifs produits');
		}
	}
}


function maliste(cle){
	if (window.opener && !window.opener.closed){
		window.opener.document.location.href='../Actebis_liste_perso.aspx?CLE=' + cle
	}else{
		document.location.href='../Actebis_liste_perso.aspx?CLE=' + cle
	}
}


function clicMenu(thisId, thisIndex){
	var nbId = 0;
	var myIdObj;
	var menu;

	for ( var i=0; i < document.all.length; i++ ){
		if ( document.all[i].id.substr(0,thisId.length) == thisId ){
			//alert('id'+(i+1)+'='+document.all[i].id)
			nbId += 1;
		}
	}
	//alert('nbId='+nbId)
	
	if ( nbId == 1 || !thisIndex ){
		//--1 seul menu à traiter -> mono-clic
		menu = document.all[thisId];
		if ( menu.style.display == 'none' ){
			menu.style.display = '';
		}else{
			menu.style.display = 'none';
		}
	}else{
		//--plusieurs menus à traiter : multi-clic
		if ( thisIndex ){
			for ( var j=1; j <= nbId; j++ ){
				myIdObj = document.getElementById(thisId+String(j));
				//alert('document.getElementById('+thisId+'+String('+j+'))='+myIdObj.innerHTML)
				if ( j == parseInt(thisIndex) ){
					if ( myIdObj ){myIdObj.style.display = ''}
				}else{
					if ( myIdObj ){myIdObj.style.display = 'none'}
				}
			}
		}
	}
}


function switchMenu(id1, id2){
	//alert('id1='+id1+' |id2='+id2)
	var menu1 = document.all[id1];
	var menu2 = document.all[id2];
	//alert('menu1='+menu1+' |menu2='+menu2)
	if ( menu1 ){
		if ( menu1.style.display == 'none' ){	//--si menu1 masque
		  menu1.style.display = '';
		  if ( menu2 ){
				menu2.style.display = 'none';				//--j affiche menu1 et je masque menu2
			}else{
				//alert(document.getElementById('id1').id)
			}
		}else{	//--si menu1 visible
		  menu1.style.display = 'none'; menu2.style.display = '';	//--je masque menu1 et j'affiche menu2
		}
	}
}


function switchFontColor(id,color){
	if ( document.getElementById(id).style.color != color )
		{document.getElementById(id).style.color = color}
	else
		{document.getElementById(id).style.color = document.getElementById(id).style.defaultColor}
}

//============================================================================================//
var menu_Actif=false;
var menu_Actif_Nom='';
var menu_Bouton_Actif=false;
var menu_Bouton_Nom='';

var ie4=false;
var ie4=document.all;
var ns4=false;
var ns4=document.layers;
var dom=false;
var dom=document.getElementById;

var hideTimeout;
var layer2Hide;


function menu_barre(theMenu, hoverFlag, color){
	if ( hoverFlag ){
		document.getElementById(theMenu).style.backgroundColor = color;
	}else{
		document.getElementById(theMenu).style.backgroundColor = color;
	}
}


function menu_barreClick( tableCellRef, url ){
	window.location.href = url;
}


function timeout(a_effacer){
	hideTimeout = window.setTimeout(a_effacer, 500);
	layer2Hide = a_effacer;
}


function clearTime(){
	window.clearTimeout(hideTimeout);
}


function hideLayer(){
	desactivation_ouverture();
}


function activation(le_niveau, l_objet){
	//alert('le_niveau='+le_niveau)
	if ( layer2Hide == 'hideLayer()' ){window.clearTimeout(hideTimeout)}
	desactivation_ouverture();
	menu_Actif = true;
	menu_Actif_Nom = le_niveau;
	menu_Bouton_Actif = true;
	menu_Bouton_Nom = l_objet
	menu_barre(l_objet, 1, '');		//-- 3ème paramètre = couleur

	var coords = getPageCoords(l_objet);
	var myLeft = coords.x;
	var myTop = coords.y;
	//alert('myLeft='+myLeft+' |myTop='+myTop)
				
	if ( ie4 ){
		var monurl = document.URLUnencoded;
		var monitem;
		//*document.body.style.visibility = 'hidden';*//
		document.all[le_niveau].style.position='fixed';
		document.all[le_niveau].style.left = String(myLeft)+'px';
		document.all[le_niveau].style.top = String(myTop)+'px';
		document.all[le_niveau].style.visibility = 'visible';
		//alert('[le_niveau].style.left='+document.all[le_niveau].style.left+' |[le_niveau].style.top='+document.all[le_niveau].style.top)
		//document.all[le_niveau].style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';		//--créé un flou dans la typo
		for (var j=0; j< document.forms.length; j++){
			for (var i=0; i< document.forms[j].length; i++){
				if (document.forms[j].elements[i].type == 'select-one' | document.forms[j].elements[i].type == 'select-multiple'){
					document.forms[j].elements[i].style.visibility = 'hidden';
				}
			}
		}
	}else if ( dom ){
		//alert('document.getElementById(le_niveau)='+document.getElementById(le_niveau))
		//alert('myLeft='+myLeft+' |myTop='+myTop)
		document.getElementById(le_niveau).style.position = 'fixed';
		document.getElementById(le_niveau).style.left = String(Math.max(0,myLeft))+'px';
		document.getElementById(le_niveau).style.top = String(Math.max(0,myTop))+'px';
		document.getElementById(le_niveau).style.visibility = 'visible';
		//alert('le_niveau='+le_niveau+'\ndocument.getElementById(le_niveau)='+document.getElementById(le_niveau)+'\ngetElementById(le_niveau).style.left='+document.getElementById(le_niveau).style.left+'\ngetElementById(le_niveau).style.top='+document.getElementById(le_niveau).style.top)
	}
	
}


function desactivation_ouverture(){
	if (menu_Bouton_Actif){
		menu_barre(menu_Bouton_Nom, 0, '');
		menu_Bouton_Actif = false;
		menu_Bouton_Nom = '';
	}
	if (menu_Actif){
		le_niveau = menu_Actif_Nom;
		if ( ie4 ){
			document.all[le_niveau].style.visibility = 'hidden';
			for (var j=0; j< document.forms.length; j++){
				for (var i=0; i< document.forms[j].length; i++){
					if (document.forms[j].elements[i].type == 'select-one' | document.forms[j].elements[i].type == 'select-multiple'){
						document.forms[j].elements[i].style.visibility = 'visible';
					}
				}
			}
		}
	    else if (dom) document.getElementById(le_niveau).style.visibility = 'hidden';
		menu_Actif = false;
		menu_Actif_Nom = '';
	}
}


function getPageCoords(id_element){
  var coords = {x: 0, y: 0}
  var element;
  var haut;
  if ( document.all ) element = document.all[id_element];
  else if ( document.getElementById ) {element = document.getElementById(id_element)};
		  
  haut = element.offsetHeight;
  while (element){
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
    element = element.offsetParent;
  }
  coords.x -= 1;
  coords.y += haut;
  //alert('coords.x='+coords.x+' |coords.y='+coords.y)
  return coords;
}


function clear_checkox(){
	document.form1.COMPARE1.checked = false;
	for ( var xi=0; xi< document.form1.length; xi++ ){
		if ( document.form1.elements[xi].name.length >= 7 ){
			if ( (document.form1.elements[xi].type == 'checkbox') && (document.form1.elements[xi].name.substring(0,7) == 'COMPARE') ){
				document.form1.elements[xi].checked=false;
			}
		}
	}
	popup_form4('Comparateur_Vue.aspx?POPUP=Oui',800,550);
}


function cache(ID){
	if ( document.getElementById(ID).style.display == '' ){
		document.getElementById(ID).style.display = 'none';
		if( document.getElementById(ID + 'Lien') != null )
		document.getElementById(ID + 'Img').src = 'images/plus_aff.gif';
	}else{
		document.getElementById(ID).style.display = '';
		if ( document.getElementById(ID + 'Lien') != null )
		document.getElementById(ID + 'Img').src = 'images/moins_masq.gif';
	}
}


function DoSend(ID_form){
	//alert (ID_form);
	document.getElementById(ID_form).elements['action1'].value='SEND';
	document.getElementById(ID_form).submit();
}


function FormatDigit(num,d,r){
	//d : nb de chiffres dans la décimale // r : nb de chiffres dans la racine
	var number,racine,delta,decim
	racine = Math.floor(num).toString(10);
	delta = r - parseInt(racine.length);
	if ( d > 0 ){
		d=Math.pow(10,d)
		number = Math.round(num*d)/d;								// arrondi à d digits ap virgule max (base100)
		decim = number - Math.floor(number);				// partie décimale de la valeur
		decim = Math.round(decim*100)/10;						// extraction de la base10 de decim
		if ( number >= 0 ){
			if ( d>0 && decim == Math.floor(decim) ){	// si la partie décimale correspond à une base10
				if ( decim == '0' )											// si la base10 est nulle (entier)
					{number = number+'.00'}								// je reconstitue la valeur au format entier + 2 chiffres ap virgule
				else																		// sinon
					{number = number+'0'}									// j'ajoute un zéro à la fin
			}
		}
	}else{
		number = parseInt(num)
	}
	if ( r > parseInt(racine.length) ){
		for (var i=1; i<=delta; i++){
			number = '0'+number
		}
	}
	return number
}


//--FLASH PLUG-INS DETECTION---------------------------

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision){
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given 'WIN 2,0,0,11'
			tempArray         = versionStr.split(' '); 	// ['WIN', '2,0,0,11']
			tempString        = tempArray[1];			// '2,0,0,11'
			versionArray      = tempString.split(',');	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split('.');
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}


// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']) {
			var swVer2 = navigator.plugins['Shockwave Flash 2.0'] ? ' 2.0' : '';
			var flashDescription = navigator.plugins['Shockwave Flash' + swVer2].description;
			var descArray = flashDescription.split(' ');
			var tempArrayMajor = descArray[2].split('.');			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == '') {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == 'd') {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == 'r') {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf('d') > 0) 
					{versionRevision = versionRevision.substring(0, versionRevision.indexOf('d'))}
				
			}
			var flashVer = versionMajor + '.' + versionMinor + '.' + versionRevision;
			//alert('flashVer='+flashVer);
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf('webtv/2.6') != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf('webtv/2.5') != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf('webtv') != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}


function ControlVersion(){
	var version;
	var axo;
	var e;
	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
		version = axo.GetVariable('$version');
	} catch (e) {
	}
	if (!version){
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
			
			// installed player is some revision of 6.0
			// GetVariable('$version') crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			// default to the first public version
			version = 'WIN 6,0,21,0';

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = 'always';

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable('$version');

		} catch (e) {
		}
	}
	if (!version){
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.3');
			version = axo.GetVariable('$version');
		} catch (e) {
		}
	}
	if (!version){
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.3');
			version = 'WIN 3,0,18,0';
		} catch (e) {
		}
	}
	if (!version){
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
			version = 'WIN 2,0,0,11';
		} catch (e) {
			version = -1;
		}
	}
	return version;
}


/*
Passage par valeur / passage par référence :
http://www.tddsworld.com/blogs/eapc/?2006/03/10/439-javascript-contextes

*/
