﻿NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;


// Create a cookie with the specified name and value.
// The cookie expires at the end of the 20th century.
function SetCookie(sName, sValue)
{
  date = new Date();
  date.setYear(date.getFullYear()+1)
  document.cookie = sName + "=" + escape(sValue) + "; expires=" + date;
}

// Retrieve the value of the cookie with the specified name.
function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}


var AfficheVirgule = true;
var CodeDevise;

function FormatNumber(n, codeDevise)
{
	CodeDevise=codeDevise;
	FormatNumber(n);
}

function FormatNumber(n)
{
	var returnValue;
	n = String(n);
	n = n.replace(/ +/gi,"");
	n = n.replace(/(&nbsp;)+/gi,"");
	n = n.replace(",",".");

	n = parseFloat(n);
	n = Math.round(n*100)/100;
	n = String(n);
	
	if (CodeDevise=='CFA')
	{// si on est en cfa, il n'y a pas de virgule
		returnValue = n;
		p = n.length
	}
	else
	{// sinon, on complète si besoin avec des zeros après la virgule
		
		p = n.indexOf(".");
		switch (p)
		{
			case -1:
				returnValue = n+".00";
				break;
			case (n.length-2):
				returnValue = n+"0";
				break;
			default:
				returnValue = n;
				break;
		}
		p = returnValue.indexOf(".");
	}

	while (p>3)
	{// on met des espaces tout les 10^3
		p-=3;
		returnValue = returnValue.substring(0,p) + " " + returnValue.substring(p,returnValue.length);
	}

	if (AfficheVirgule)
	{// on remet une virgule à la place du point
		returnValue = returnValue.replace(".",",");
	}
	return returnValue;
}

function frm_doAction(frm, strAction){
	frm.hAction.value = strAction;
	frm.submit();
}

function set_cmb(cmb, val){
	//alert(val);
	for(i=0;i<=cmb.length-1;i++){
		if(cmb.options[i].value==val){
			cmb.selectedIndex=i;
			return true;
		}
	}
}

function set_chk(chk, val){
	for(i=0;i<=chk.length-1;i++){
		if(chk[i].value==val){
			chk[i].checked=true;
			return true;
		}
	}
}

function get_radio_val(radbox){

	if(isNaN(radbox.length))
	{
		return radbox.value; 
	}
	for(i=0;i<=radbox.length-1;i++){
		if(radbox[i].checked){
			return(radbox[i].value);
		}
	}	
	return null;
}


//ouvre une url contenu dans la propriéte value d'une combobox cmb
function open_cmb(cmb){
	url=cmb.options[cmb.selectedIndex].value;
	if(url=='#') 	cmb.selectedIndex=0;
	else 		document.location.href=url;
}

//ouvre une url contenu dans la propriéte value d'une combobox cmb dans une frame [GT]

function open_cmb_target(url, frame){
		url=url.options[url.selectedIndex].value;
		if(url=='#') 	url.selectedIndex=0;
		else frame.document.location.href = url;
}





// PIERRE : g deja cree il y a bien longtemps une fonctions du mm nom, et je m'en sert partout, alors trouvez un autre nom !!!
function open_url(url){
	self.document.location.href=url;
}


//------------------------------------------------------
function save_email(){
	var email=document.promotion.email.value;
	
	if(email==''){
		alert("Saisissez une adresse e-mail !");
	}
	else if(!verifMail(email)){
		alert('Votre adresse e-mail est incorrecte.'); 
	}
	else	document.promotion.submit();
}


/*

JavaScript pris sur le site: http://www.scripts-france.net
Ce JavaScript vérifie:
- la présence d'un @
- la présence d'au moins 4 caractères après l'@, dont un point suivi d'au moins 2 caractères
- la présence d'au moins 1 caractère avant l'@ 

*/

function verifMail(a) {
	testm = false ;
 
	for (var j=1 ; j<(a.length) ; j++) {
		if (a.charAt(j)=='@') { 
			if (j<(a.length-4)){ 
				for (var k=j ; k<(a.length-2) ; k++) { 
					if (a.charAt(k)=='.') testm = true; 
				} 
			} 
		} 
	} 
	return testm ; 
}
//------------------------------------------------------
function convert2SQLdate(dte){
	if(dte=='')	return('');
	else 		return(dte.substr(6,4)+"/"+dte.substr(3,2)+"/"+dte.substr(0,2));
}

function convertSQLdate2Date(dte){
	if(dte=='')	return('');
	else 		return(dte.substr(8,2)+"/"+dte.substr(5,2)+"/"+dte.substr(0,4));
}

//------------------------------------------------------
var curdatefieldname;
var mywincalend;

function get_calend(fieldbox){
	if(mywincalend==null||mywincalend.closed)
		 mywincalend=window.open("/library/include/html/commun/calendrier.asp?curdate="+fieldbox.value,"neww","width=220,height=400,scrolling=0");
	curdatefieldname=fieldbox;
	mywincalend.focus();
}

function get_calendrier(fieldbox, defaultvalue){
	var v = fieldbox.value;
	if(v == '')
		v = defaultvalue;
		
	if(mywincalend==null||mywincalend.closed)
		 mywincalend=window.open("/library/include/html/commun/calendrier.asp?curdate="+v,"neww","width=220,height=400,scrolling=0");
	curdatefieldname=fieldbox;
	mywincalend.focus();
}

function set_datefieldvalue(v){
	curdatefieldname.value=v;
	curdatefieldname.focus();
}
var popupsearchdate;

function get_searchdate(rep_societe){
	var typedate_search=1;
	var screentop=(NS4)?self.screenY:self.screenTop;
	var screenleft=(NS4)?self.screenX:self.screenLeft;
	if(popupsearchdate==null||popupsearchdate.closed) popupsearchdate=window.open("/library/include/html/commun/popup_searchdate.asp","toto","width=320,height=260,scrollbars=1");
	popupsearchdate.moveTo(parseInt(screenleft)+100,parseInt(screentop)+200);
	popupsearchdate.focus();
}
//------------------------------------------------------
//dte est une une chaine de caractere au format (jj/mm/aaaa)

//-- DEPRICATED, utiliser : [/library/include/js/lib_date.js]::isValidDate(dte)

function test_validDate(dte){
	
	var strDte = new String(dte);
	
	if(strDte.length>10 || strDte.length<8)	
		return(false);
	var tmpstr= new String(dte);
	
	//jour
	var pos_slash=tmpstr.indexOf('/');
	
	var dte_part=tmpstr.substr(0,pos_slash);

	if(pos_slash==-1 || pos_slash>2 || isNaN(dte_part) || dte_part>31 || dte_part<1)
	{
		return(false);
	}	
	
	//mois
	tmpstr=tmpstr.substr(pos_slash+1);
	pos_slash=tmpstr.indexOf('/');
	dte_part=tmpstr.substr(0,pos_slash);
	
	if(pos_slash==-1 || pos_slash>2 || isNaN(dte_part) || dte_part>12 || dte_part<1)  
	{
		return(false);	
	}	
	//annee
	dte_part=tmpstr.substr(pos_slash+1);
	if(dte_part.length < 2 || dte_part.length > 4){
		return false;
	}
	
	if(!isNaN(dte_part) && parseInt(dte_part)<1000)
	{
		return(false);	
	}
	return(true);
}
//dte est une une chaine de caractere au format (jj/mm/aaaa)

//-- DEPRICATED, utiliser : [/library/include/js/lib_date.js]::strdte_getYear(dte)

function strDate_getDay(dte){
	if(!test_validDate(dte)){
		return(null);
	}
	return(parseInt(dte.substr(0, dte.indexOf('/'))));
}

//dte est une une chaine de caractere au format (jj/mm/aaaa)

//-- DEPRICATED, utiliser : [/library/include/js/lib_date.js]::strdte_getYear(dte)
function strDate_getMonth(dte){
	if(!test_validDate(dte)){
		return(null);
	}
	//jour
	var tmpstr=dte;
	var pos_slash=tmpstr.indexOf('/');
	var dte_part=tmpstr.substr(0,pos_slash);
	
	//mois
	tmpstr=tmpstr.substr(pos_slash+1);
	pos_slash=tmpstr.indexOf('/');
	dte_part=tmpstr.substr(0,pos_slash);
	
	return(parseInt(dte_part));
}

//dte est une une chaine de caractere au format (jj/mm/aaaa)

//-- DEPRICATED, utiliser : [/library/include/js/lib_date.js]::strdte_getYear(dte)
function strDate_getYear(dte){
	if(!test_validDate(dte)){
		return(null);
	}
	//jour
	var tmpstr=dte;
	var pos_slash=tmpstr.indexOf('/');
	var dte_part=tmpstr.substr(0,pos_slash);
	
	//mois
	tmpstr=tmpstr.substr(pos_slash+1);
	pos_slash=tmpstr.indexOf('/');
	dte_part=tmpstr.substr(0,pos_slash);
	
	//annee
	dte_part=tmpstr.substr(pos_slash+1);
	if(dte_part.length == 2){
		return(2000 + parseInt(dte_part));
	}
	else{
		return(parseInt(dte_part));
	}
}

// renvoie 1 si dte1 < dte2
//	   -1 si dte1 > dte2
//	   0 si dte1 = dte2
function compDates(dte1, dte2){
	if(!(test_validDate(dte1) && test_validDate(dte2))){
		return null;
	}
	var tmpDay1 = strDate_getDay(dte1);
	var tmpDay2 = strDate_getDay(dte2);
	var tmpMonth1 = strDate_getMonth(dte1);
	var tmpMonth2 = strDate_getMonth(dte2);
	var tmpYear1 = strDate_getYear(dte1);
	var tmpYear2 = strDate_getYear(dte2);
	
	if(tmpYear1 > tmpYear2){
		return(-1);
	}
	else if(tmpYear1 < tmpYear2){
		return(1);
	}
	else{
		if(tmpMonth1 > tmpMonth2){
			return(-1);
		}
		else if(tmpMonth1 < tmpMonth2){
			return(1);
		}
		else{
			if(tmpDay1 > tmpDay2){
				return(-1);
			}
			else if(tmpDay1 < tmpDay2){
				return(1);
			}
			else{
				return(0);
			}
		}
	}
}
//
//function isNumeric(strg){
//	var fdot = false;
//	if(strg == '' ) return false;
//	for (var j=0 ; j<(strg.length) ; j++) {
//		if(strg.charAt(j) == '.' || strg.charAt(j) == ','){
//			if(!fdot) fdot = true;
//			else	  return(false);
//		}
//		else{
//			if (isNaN(strg.charAt(j))){
//				return(false);
//			}
//		}
//	} 
//	return(true) ; 
//}

function ValIsNumeric(strg){
	var fdot = false;
	if(strg == '' ) return false;
	for (var j=0 ; j<(strg.length) ; j++) {
		if(strg.charAt(j) == '.' || strg.charAt(j) == ','){
			if(!fdot) fdot = true;
			else	  return(false);
		}
		else{
			if(!(strg.charAt(j) == '-' && j == 0)){
				if (isNaN(strg.charAt(j))){
					return(false);
				}
			}
		}
	}
	return(true); 
}

function DeviseFormatNumber(Montant, CodeDevise){
	if (CodeDevise == "")
		CodeDevise = "EUR";
	switch(CodeDevise) {
		case "CFA" :
		case "XOF" :
			Montant = Math.round(Montant/10);
			return formatNumber(Montant * 10, 0);
		default: 
			return formatNumber(Math.round(Montant * 100) / 100, 2);
	}
}

function formatNumber(vt, d){
	var vl='';
	var parseInt_v
	vl+=vt;
	vl=vl.replace(/\s*/g,'');
	if(vl=='')	return('0,'+ addzeros(d));
	var v=''+vl;
	var t=(v.indexOf('.')!=-1)?v.indexOf('.'):v.indexOf(',');
	var decpart=(t!=-1)?v.substr(t+1):'';
	
	if (-1 < v && v < 0)
		parseInt_v = '-' + parseInt(v);
	else
		parseInt_v = parseInt(v);
	if(decpart.length<d)	return(parseInt_v+'.'+decpart+addzeros(d- decpart.length));
	else if(decpart.length == d) 	return(parseInt_v+'.'+decpart);
	else{
		//arrondi
		if(parseInt(decpart.charAt(d)) <= 5){
			var tmpdecpart = decpart.substr(0,d) //+ decpart.charAt(d-1);
		}
		else{
			var tmpdecpart = parseInt(decpart.substr(0,d)) + 1 // + (parseInt(decpart.charAt(d-1)) + 1);
		}
		return(parseInt(v)+'.'+tmpdecpart);
	}
	function addzeros(nb){
		var tmp='';
		for(var i=0;i<=nb-1;i++)tmp+='0';
		return(tmp);
	}
}

//------------------------------
// Verifie que le code postal est un nombre
//------------------------------
function isCPvalid(cp){
//------------------------------
	if(cp == '' ) return false;
	for (var j=0 ; j<(cp.length) ; j++){
		if(isNaN(cp.charAt(j))){
			return(false);
		}
	}
	return(true);
}

// JKH : Indique si la fenetre passé en paramètre est ouverte ou pas (That is the question)
function isWindowIsOpen(theWindow)
{
	// test to see if window exists
	if ( theWindow!=null
		&& typeof(theWindow) != "undefined" ) 
	{ 
		// test to see if a window is still open
		if ( !(theWindow.closed) ) 
		{ 
			return true;

		}
	}
	return false;
}

// JKH : Ouverture de la fenetre qui prend en compte le bug d'IE car window.open ne transfert pas le cookie de session, alors on fait un showModelessDialog pour combler tout ça
function openfenetreWithOpener(mypage,myname,w,h,scroll,pos,winOpener){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	//settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	//window.showModalDialog("SMD_target.htm","Dialog Box Arguments # 1","dialogHeight: 250px; dialogWidth: 500px; dialogTop: 282px; dialogLeft: 386px; edge: Sunken; center: Yes; help: Yes; resizable: No; status: Yes;");
	if(IE4==1)
	{
		if ( pos=="center" )
		{
			settings='dialogHeight: '+h+'px; dialogWidth: '+w+'px; dialogTop: px; dialogLeft: px; scroll: '+scroll+'; center: Yes; help: No; resizable: Yes; status: No; edge: Raised;'
		}
		else
		{
			settings='dialogHeight: '+h+'px; dialogWidth: '+w+'px; dialogTop: '+TopPosition+' px; dialogLeft: '+LeftPosition+' px; scroll: '+scroll+'; help: No; resizable: Yes; status: No; edge: Raised;'
		}

	//	alert("setting : "+settings);
	//	alert("mypage : "+mypage);
		win=window.showModelessDialog(mypage, window, settings);
	}
	if(NS4==1)
	{
		settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		win=window.open(mypage,myname,settings);
		win.opener=winOpener;
	}
	win.focus();
	return win;
}

function show_props(obj, objName) 
{   
	var result = "";
	var cpt = 0;
	for (var i in obj) 
	{      
		cpt++;
		result += objName + "." + i + " = " + obj[i];
		if (cpt==10)
		{
			cpt=0;
			result += "\n";
		}
	}   
	return result;
}

var coefSpeed=0.2;
var speed;
var delay= 1;
var timer=0;
var maxBoucles;
var savedHeight;

function ChangeDivHeight(id, initialHeight, finalHeight)
{
	
}

function CacherObjet(id)
{
	obj = document.getElementById(id)	;
	if (obj)
	{
		pixelHeight = parseInt(obj.style.height.replace('px', ''));
		var h = pixelHeight - speed;
		maxBoucles--;
		if (h>0 && maxBoucles>0)
		{
			obj.style.height = h;
		}
		else
		{
			clearInterval(timer);
			timer = 0;
			obj.style.display	= 'none';
			obj.style.height	= savedHeight;
			objinfo = document.getElementById(id+'_infoVisible');
			if (objinfo)
			{
				objinfo.value='false';
			}
		}
	}
}

function AfficherObjet(id)
{
	obj = document.getElementById(id)	;
	if (obj)
	{
		pixelHeight = parseInt(obj.style.height.replace('px', ''));
		var h = pixelHeight + speed;
		maxBoucles--;
		if (h<savedHeight && maxBoucles>0)
		{
			obj.style.height = h;
		}
		else
		{
			clearInterval(timer);
			timer = 0;
			obj.style.height = savedHeight;
			objinfo = document.getElementById(id+'_infoVisible');
			if (objinfo)
			{
				objinfo.value='true';
			}
		}
	}
}

function ShowHideDetails2(idBloc,idImage)
{
	if (timer != 0)
	{
		return;
	}
	if (window.event == undefined || window.event.srcElement.type == undefined || 
		(window.event.srcElement.nodeName.toUpperCase() == "A" && window.event.srcElement.href == ""))
	//ce test sert à ne pas afficher/cacher le div lorsque le clic est fait sur 
	//le bouton modifier ou supprimer, situés dans le tr cliquable
	{
		Bloc					= document.getElementById(idBloc);
		Bloc.style.overflowY	= "hidden";
		imageCroix				= document.getElementById(idImage);
		if (imageCroix)
		{
			imageCroixSrc		= imageCroix.src;
		}		
		maxBoucles = 30;
		
		if (Bloc.offsetHeight>0)
		{
			savedHeight			= Bloc.scrollHeight;
			speed				= parseInt(savedHeight * coefSpeed);
			Bloc.style.height	= savedHeight;
			if (imageCroix)
			{
				imageCroix.src	= imageCroixSrc.replace('moins','plus');
			}			
			timer = setInterval("CacherObjet('"+Bloc.id+"')", delay);
		}
		else
		{
			if (Bloc.scrollHeight == 0)
			{
				Bloc.style.display	= 'block';
				savedHeight			= Bloc.offsetHeight;
				Bloc.style.height	= 1;
			}
			else
			{
				savedHeight			= Bloc.scrollHeight;
				Bloc.style.height	= 1;
				Bloc.style.display	= 'block';
			}
			speed					= parseInt(savedHeight * coefSpeed);
			if (imageCroix)
			{
				imageCroix.src		= imageCroixSrc.replace('plus','moins');
			}
			timer = setInterval("AfficherObjet('"+Bloc.id+"')", delay);
		}
	}
	return false;
}

// JKH : Ouverture de la fenetre qui prend en compte le bug d'IE car window.open ne transfert pas le cookie de session, alors on fait un showModalDialog pour combler tout ça
function openfenetreWithOpenerModelLessDialog(mypage,myname,w,h,scroll,pos,winOpener){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	else if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else {LeftPosition=0;TopPosition=20}
	
	//settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	//window.showModalDialog("SMD_target.htm","Dialog Box Arguments # 1","dialogHeight: 250px; dialogWidth: 500px; dialogTop: 282px; dialogLeft: 386px; edge: Sunken; center: Yes; help: Yes; resizable: No; status: Yes;");
	if(IE4==1)
	{
		if ( pos=="center" )
		{
			settings='dialogHeight: '+h+'px; dialogWidth: '+w+'px; dialogTop: px; dialogLeft: px; scroll: '+scroll+'; center: Yes; help: No; resizable: Yes; status: No; edge: Raised;'
		}
		else
		{
			settings='dialogHeight: '+h+'px; dialogWidth: '+w+'px; dialogTop: '+TopPosition+' px; dialogLeft: '+LeftPosition+' px; scroll: '+scroll+'; help: No; resizable: Yes; status: No; edge: Raised;'
		}

	//	alert("setting : "+settings);
	//	alert("mypage : "+mypage);
		window.showModelessDialog(mypage, winOpener, settings);
	}
	if(NS4==1)
	{
		settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		win=window.open(mypage,myname,settings);
		win.opener=winOpener;
	}
	if ( typeof(win) != "undefined" )
	{
		win.focus();
		return win;
	}
	else
	{
		return null;
	}
}

// JKH : Ouverture de la fenetre qui prend en compte le bug d'IE car window.open ne transfert pas le cookie de session, alors on fait un showModalDialog pour combler tout ça
function openfenetreWithOpenerModal(mypage,myname,w,h,scroll,pos,winOpener){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	else if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else {LeftPosition=0;TopPosition=20}
	
	//settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	//window.showModalDialog("SMD_target.htm","Dialog Box Arguments # 1","dialogHeight: 250px; dialogWidth: 500px; dialogTop: 282px; dialogLeft: 386px; edge: Sunken; center: Yes; help: Yes; resizable: No; status: Yes;");
	if(IE4==1)
	{
		if ( pos=="center" )
		{
			settings='dialogHeight: '+h+'px; dialogWidth: '+w+'px; dialogTop: px; dialogLeft: px; scroll: '+scroll+'; center: Yes; help: No; resizable: Yes; status: No; edge: Raised;'
		}
		else
		{
			settings='dialogHeight: '+h+'px; dialogWidth: '+w+'px; dialogTop: '+TopPosition+' px; dialogLeft: '+LeftPosition+' px; scroll: '+scroll+'; help: No; resizable: Yes; status: No; edge: Raised;'
		}

	//	alert("setting : "+settings);
	//	alert("mypage : "+mypage);
		window.showModalDialog(mypage, winOpener, settings);
	}
	if(NS4==1)
	{
		settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		win=window.open(mypage,myname,settings);
		win.opener=winOpener;
	}
	if ( typeof(win) != "undefined" )
	{
		win.focus();
		return win;
	}
	else
	{
		return null;
	}
}

function openfenetre(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
	win.focus();
	return win;
}

			//-----------------------------------
			// JKH 2005-06-09
			// Méthode permettant de changer dans la querystring l'id_langue
			// Si l'id_langue est déjà présente dans la querystring elle sera remplacé par la nouvelle valeur
			//------------------------------------
			// PARAMETRES
			// key: la clé qui contiendra la valeur de l'id_langue dans la querystring par exemple : id_langue=1 ou alors id_sessionlangue=1
			// id_langue : la valeur de l'id_langue
			//------------------------------------
			// Exemple d'utilisation :
			// <a href="javascript:changeLangueInQueryString('id_Sessionlangue','2');">English</a><br/>
			// <a href="javascript:changeLangueInQueryString('id_Sessionlangue','1');">Français</a><br/>
			//------------------------------------
			function changeLangueInQueryString(key,id_langue)
			{
				var url;
				url=document.location.href;
				
				var chaine
				var urltaille
				urltaille = url.length-1;
				chaine="\\?"+key+"=[^&]&","gi";
				//alert(chaine);
				url=url.replace(new RegExp(chaine),"?");
				chaine="\\?"+key+"=.*";
				//alert(chaine);
				url=url.replace(new RegExp(chaine,"gi"),"");
				chaine="&"+key+"=[^&]*&";
				//alert(chaine);
				url=url.replace(new RegExp(chaine,"gi"),"&");
				chaine="&"+key+"=.*";
				//alert(chaine);
				url=url.replace(new RegExp(chaine,"gi"),"");
				
				if ( url.indexOf('?')>0)
				{
					
					if (url.charAt(urltaille) == "?")
					{
						url+=key+"="+id_langue;
					}
					else
					{
						url+="&"+key+"="+id_langue;
					}
	//				url+="&"+key+"="+id_langue;
					
				}
				else
				{
					url+="?"+key+"="+id_langue;
				}
				document.location=url;
			}


// JKH/JRN
// Supprime les ,
// Supprime les " " whitespace
// Renvoie un float si c'est un nombre
function GetFloatFromId(Id)
{
	var tmp;
	var element = document.getElementById(Id);
	if ( element.tagName=="INPUT" )
	{
		tmp=element.value;
	}
	else
	{
		tmp = element.innerHTML;	
	}
	
	if (tmp.indexOf(".")!=-1) 
	{
		if  ( typeof(AfficheVirgule) != "undefined" )
		{
			AfficheVirgule=false;
		}
	}	
	//si formaté 1,000.00 on remplace les virgules par des espaces
	if (tmp.indexOf(".")!=-1)
	{
		tmp = tmp.replace(/,+/gi,"");
	}
	//TODO: si pas de décimal, on remplace les virgules par des espaces
	
	//si formaté 1 000,00 on remplace la virgule par un point
	else if ( tmp.indexOf(",") == tmp.lastIndexOf(",") )
	{
		tmp = tmp.replace(",",".");
	}
//	if (tmp.indexOf(".")!=-1 && tmp.indexOf(",")!=-1)
//	{
//		tmp = tmp.replace(/,+/gi,"");
//	}
//	si formaté 1 000,00 on fait le traitement suivant 1000.00
//	else if ( ) //if ( ...)
//	{
//		tmp = tmp.replace(/,+/gi,".");
//	}
	tmp = tmp.replace(/ +/gi,"");
	tmp = tmp.replace(/(&nbsp;)+/gi,"");
	//if (
//	alert(tmp);
	if (!isNaN(tmp) && tmp!='')
	{
		return parseFloat(tmp);
	}
	else return 0;
}

function OpenPopupForLogin(url)
{
	if(IE4==1)
	{
		settings='dialogHeight: 200px; dialogWidth: 300px; dialogTop: px; dialogLeft: px; scroll: Off; center: Yes; help: No; resizable: Yes; status: No; edge: Raised;'
		returnValue = window.showModalDialog(url, window, settings);
		if (returnValue == true)
		{
			return true;
		}
	}
	return false;
}
