<!--
var fenetre;
var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
var focusVersion = "no"
var servletRoot = "/oi/servlet/"
var staticRoot = "/oiweb/"
var plusTextGras=0;

if ( browserName == "Netscape" && browserVer >= 3 ) focusVersion = "yes";
else if ( browserVer >= 4 ) focusVersion = "yes";
else focusVersion = "no";

//
//
//	
function ouvrirFenetre(urlFenetre, nomFenetre, location, toolbar, directories, barremenu, resizable, scrollbars, status, width, height) {
	var options = 'location=' + location + ',toolbar=' + toolbar + ',directories=' + directories + ',menubar=' + barremenu + ',resizable=' + resizable + ',scrollbars=' + scrollbars +',status=' + status +',width=' + width + ',height=' + height;
	fenetre = window.open (urlFenetre, nomFenetre, options);
	if (focusVersion=="yes") fenetre.focus();
	var start = urlFenetre.indexOf("appel=1");
	if (start != -1) {
		fenetre.moveTo(0,0);
		fenetre.resizeTo(screen.availWidth,screen.availHeight);
	}
}

//
//
//	
function ouvrirContenuSite(urlFenetre, nomFenetre, location, toolbar, directories, barremenu, resizable, scrollbars, status, width, height) {
	var options = 'location=' + location + ',toolbar=' + toolbar + ',directories=' + directories + ',menubar=' + barremenu + ',resizable=' + resizable + ',scrollbars=' + scrollbars +',status=' + status +',width=' + width + ',height=' + height;
	fenetre = window.open (urlFenetre, nomFenetre, options);
	if (focusVersion=="yes") fenetre.focus();
	var start = urlFenetre.indexOf("appel=1");
	if (start != -1) {
		fenetre.moveTo(0,0);
		fenetre.resizeTo(screen.availWidth,screen.availHeight);
	}
}

//
//
//	
function backToHomePage(marque) {
	if (window.name==('PORTAIL'+marque))  {
		document.location='/';
	} else {
		ouvrirFenetre('/', 'PORTAIL'+marque, 'yes', 'yes', 'no', 'yes', 'yes', 'yes', 'yes');
		//window.close();
		parent.window.close();
	}
	return;
}

//
//
//	
function retrieveCookieLangue(name, formulaire) {
	var cookieValue;
	var indexLangue;
	cookieValue = Get_Cookie(name);
	if (cookieValue != null) {
	  formulaire.CODE_LANGUE.options.selectedIndex = cookieValue;
	} else {
	  formulaire.CODE_LANGUE.options.selectedIndex = 0;
	}
	indexLangue = formulaire.CODE_LANGUE.options.selectedIndex;
}

//
//
//	
function Get_Cookie(name) {
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

//
//
//	
function Set_Cookie(name,value,expires,path,domain,secure) {
     document.cookie = name + "=" +escape(value) +
         ( (expires) ? ";expires=" + expires.toGMTString() : "") +
         ( (path) ? ";path=" + path : "") + 
         ( (domain) ? ";domain=" + domain : "") +
         ( (secure) ? ";secure" : "");
}

//
//
//	
function setCookieLangue(codeLangue, codePays) {
	var chaineCookie = codeLangue + '_' + codePays;
	var dateExpiration =  new Date();
	var year = dateExpiration.getYear();
	if (year < 1000 ) year += 1900;
	dateExpiration.setYear(year + 1);  
	Set_Cookie('CodeLanguePaysOI', chaineCookie, dateExpiration, '/', null, null);
}

//
//
//	
function setFlag(locale) {
	var codeLangue = locale.substring(3,5);
	document.getElementById('flag').src='/images/bandiere/'+codeLangue.toLowerCase()+'.gif';
	
}

//
//
//
function validChoixLangue(locale) {
	var codeLangue = locale.substring(0,2);
	var codePays = locale.substring(3,5);
	if (Test_Cookie() == 1) {
		setCookieLangue(codeLangue, codePays);
		location.reload(true);
		//document.location="/";
	} else window.alert ('Your browser must be configure to accept cookies.\nVotre navigateur doit-etre configurer pour accepter les cookies.');
	
}

//
//
//	
function validationChoixLangue(codeLangue, codePays) {
	
	if (Test_Cookie() == 1) {
		formulaire = document.forms[0];
		formulaire.langue.value = codeLangue + '_' + codePays;
		setCookieLangue(codeLangue, codePays);
		formulaire.submit();
		window.close();
	} else window.alert ('Your browser must be configure to accept cookies.\nVotre navigateur doit-etre configurer pour accepter les cookies.');
}

//
//
//	
function validationChoixLangue2(codeLangue, codePays) {
	if (Test_Cookie() == 1) {
		formulaire = document.forms[0];
		formulaire.langue.value = codeLangue + '_' + codePays;
		setCookieLangue(codeLangue, codePays);
		formulaire.submit();
	} else window.alert ('Your browser must be configure to accept cookies.\nVotre navigateur doit-etre configurer pour accepter les cookies.');
}

//
//
//	
function validationChoixMenu(codeMenu) {
	formulaire = document.form_menu;
	formulaire.menu.value = codeMenu;
	formulaire.target='_top';
	formulaire.submit();
	return;
}

//
//
//	
function validationChoixInformations(type, marque) {
	
//	urlInformation = "/pages/abonnement/cgv.jsp";
	urlInformation = "/cgv";
	ouvrirFenetre(urlInformation, "INFO", "no", "no", "no", "no", "no", "yes", "yes", "700", "875");
	return;
}

function validationChoixInformationsOld(type, marque) {
	
	urlInformation = servletRoot+"Informations?type=" + type +"&marque="+marque;
	ouvrirFenetre(urlInformation, "INFO", "no", "no", "no", "no", "no", "yes", "yes", "700", "875");
	return;
}

//
//
//	
function validationChoixContact(type, marque) {
	
	urlInformation = servletRoot+"Informations?type=" + type +"&marque="+marque;
	ouvrirFenetre(urlInformation, "INFO", "no", "no", "no", "no", "no", "yes", "yes", "700", "300");
	return;
}

//
//
//	
function validationChoixContactConnect(type, marque,langue) {
	urlInformation = servletRoot+"Informations?type=" + type +"&marque="+marque+"&langue="+langue;
	ouvrirFenetre(urlInformation, "INFO", "no", "no", "no", "no", "no", "yes", "yes", "700", "300");
	return;
}

//
//
//	
function validationMail(type, marque) {
	urlInformation = servletRoot+"Informations?type=" + type +"&marque="+marque;
	ouvrirFenetre(urlInformation, "INFO", "no", "no", "no", "no", "yes", "yes", "yes", "700", "300");
	return;
}

//
//
//	
function validationContenu(type, marque) {
	urlInformation = servletRoot+"Informations?type=" + type +"&marque="+marque;
	ouvrirContenuSite(urlInformation, "INFO", "no", "no", "no", "no", "no", "no", "no", "760", "600");
	return;
}

//
//
//	
function Test_Cookie() {
	var aujourdhui = new Date();
	var expiration = new Date();
	// la date d'expiration du cookie : ici, 24 heures
	expiration.setTime(aujourdhui.getTime() + 1000*60*60*24*365);
	Set_Cookie ("testInfotec", 1, expiration);
	Set_Cookie ("testSession", 1);
	var start = document.cookie.indexOf("testInfotec=");
	var startSession = document.cookie.indexOf("testSession=");
	if (start != -1 && startSession != -1) {	
		var today = new Date();		
		var expired = new Date(today.getTime() - 48 * 60 * 60 * 1000);
		// less 2 days	
		// Delete cookie with given name
		Set_Cookie("testInfotec", null, expired);
		Set_Cookie("testSession", null, expired);
		return 1;	
	} else return 0;
}

//
//
//	
function resetgras() {
	document.inscriptionForm.reset();
	for (i=2; document.getElementsByTagName("div")[i]!= null; i++) 
		if(document.getElementsByTagName("div")[i].id!='tvaIntracom1'){
			document.getElementsByTagName("div")[i].className='textbold';
		}
	//getOtherCountry();
}


//
//
//	
function verifgras(id,name) {
	name = 'document.inscriptionForm.'+name+'.value.length';
	if (eval(name) != 0) {
		document.getElementById(id).className='text';
		return true; 
	}
	else { document.getElementById(id).className='textbold'; return false;}
}

//
//
//	
function verifpaysgras(id,name) {
	
	name = 'document.inscriptionForm.'+name+'.value';

	if (eval(name) != '0') {
		document.getElementById(id).className='text';
		return true; 
	}
	else { document.getElementById(id).className='textbold'; return false;}
}

//
//
//	
function verifgras3(id,name) {
	name = 'document.inscriptionForm.'+name+'.value.length';
	if (eval(name) != 0) {
		document.getElementById(id).className='text';
		return true; 
	}
	else { document.getElementById(id).className='textbold'; return false;}
}

//
//
//
function verifgrasForAll(){
	var formulaire = document.inscriptionForm;
	var statut = formulaire.statut.value;
	verifcivilitegras('civilite1');
	verifgras('nom1','nom');
	verifgras('prenom1','prenom');
	verifgras('mail1','mail');
	verifgras('confmail1','confmail');
	verifgras('adresse1','adrFacturation');
	verifgras('code1','codePostal');
	verifgras('ville1','ville');
	verifpaysgras('pays1','pays');
	verifgras('pass1','passwd');
	verifgras('pass2','passwd2');
	
	// professionnels
	if (statut != 0) {
		verifgras('raison1','raisonSociale');
		//verifgras('tvaIntracom1','tvaIntracom');
	}
}

//
//
//	
function verifcivilitegras(id) {
	if (document.inscriptionForm.civilite[0].checked 
		|| document.inscriptionForm.civilite[1].checked 
		|| document.inscriptionForm.civilite[2].checked ) {
		document.getElementById(id).className='text';
		return true;
	}
	else { document.getElementById(id).className='textbold'; return false;}
}

//
//
//	
function BoutonAnnulerResetGras(ListDiv)
{
	plusTextGras=1;	
	MettreToutEnText(ListDiv);
	
}

//
//
//	
function MettreToutEnText(ListDiv)
{
	if (plusTextGras==0)
	{
		for (i=2; document.getElementsByTagName("div")[i]!= null; i++) 
		{
			document.getElementsByTagName("div")[i].className='textbold';
		}
	}
	else
	{
		for (i=2; document.getElementsByTagName("div")[i]!= null; i++) 
		{
			document.getElementsByTagName("div")[i].className='text';
		}
	}
}

//
//
//	
function retourPageLogin(marque)
{
	top.location= staticRoot+marque;
	return;
}


//
//
//	
function validationCreation3(valeurMail,valeurConfMail,msgerror,champs)
{
	var formulaire=document.inscriptionForm;
	var formulaire1=document.inscriptionForm;
	var retour='';
	var focus=0;
	
	if (valeurMail == '') 
	{
		retour = retour + '<li>'+ champs[3] + '</li>';
		if (focus == 0) formulaire.mail.focus();
		focus++;
	}
	
	if (valeurConfMail == '') 
	{
		retour = retour + '<li>'+ champs[4] + '</li>';
		if (focus == 0) formulaire.confmail.focus();
		focus++;
	}
	
	if (verifemail(valeurMail)==false) {
		retour = retour + '<span class="MsgWarning">'+msgerror[4]+'</span><br/>';
		if (focus == 0) formulaire.mail.focus();
		focus++;
		
	}
	
	if (valeurMail != valeurConfMail) 
	{
		retour = retour + '<span class="MsgWarning">'+msgerror[5]+'</span><br/>';
		if (focus == 0) formulaire.confmail.focus();
		focus++;
	}
	
	if(retour!='')
	{
		retour ='<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
		document.getElementById('jsMsg').innerHTML=retour;
		return;
	}
	else
	{
		formulaire.laValeurMailValide.value='mailValide';
		formulaire.mailEnvoi.value=valeurMail;
		formulaire.submit();
	}
	
}



//
//
//	
function ouvre_popup(page) 
{
     window.open(page,"nom_popup","menubar=yes, status=yes, scrollbars=yes, menubar=no,resizable=yes, width=800, height=650");
     return;
}

//
//
//	
function controleDonneesCreation_phase1 (msgerror, msggen) {
	var formulaire = document.inscriptionForm;
	if ((formulaire.statut[0].checked == false && formulaire.statut[1].checked == false && formulaire.statut[2].checked == false && formulaire.statut[3].checked == false)) {
		document.getElementById('jsMsg').innerHTML='<span class="MsgWarning">'+msgerror[1]+'</span><br/>';
		return;
	}
	formulaire.submit();
}

//
//
//	
function controleTauxMo(msgerror, champs,msggen,actionEnvoi)
{
	var formulaire=document.gestionPdvForm;
	ControleEnvoiMO(formulaire,msgerror,champs,actionEnvoi);
}

//
//
//	
function EnvoiTVA(msgerror)
{

	var formulaire=document.gestionPdvForm;
	var tvaTauxMO = formulaire.tvaTauxMO.value;
	
	var retour='';
	
	//alert('COUCOU');
	
	
		if (tvaTauxMO == '') 
		{
			formulaire.tvaTauxMO.value=0;
			formulaire.action.value='modifierTVA';
			formulaire.submit();
		}
		else 
		{
			if(TestTVA(tvaTauxMO))
			{
			//	alert('SALUT JE SUIS LA');
				formulaire.action.value='modifierTVA';
				formulaire.submit();
			}
			else
			{
				//retour ='<span class="MsgWarning"><ul>'+msgerror[8]+'</ul></span>';
				retour ='<span class="MsgWarning"><ul>'+msgerror[1]+'</ul></span>';
				document.getElementById('TxMsg').innerHTML=retour;
				return;
			}
		}
		
		
	
}

//
//
//
function TestTVA(tvaTauxMO)
{
	var reg=/^((\d{1,3}((\.|\,)\d{1,2}){0,1})|(\d{1,4}((\.|\,)\d{1,1}){0,1}))$/;
	return (reg.exec(tvaTauxMO)!=null);
}



//
//
//	
function selectionCheckinglibelle(libelle) 
{
	var extension=libelle.substring(libelle.lastIndexOf("."));
   	var chiffre=extension.charAt(8);
  	document.getElementsByName("check")[chiffre].checked = true;
	return;
}

//
//
//	
function selectionCheckingprix(prix) 
{
	var extension=prix.substring(prix.lastIndexOf("."));
 	var chiffre=extension.charAt(5);
   	document.getElementsByName("check")[chiffre].checked = true;
	return;
}

//
//
//	
function UpdateTaux(champs,msgerror)
{
	var formulaire=document.gestionPdvForm;
	var validationCheck=false;
	
	var j=0;
	var k='';
	var h=',';
	var m=0;
	var test='';

	for(i=0;i<formulaire.check.length;i++) 
	{
		j++;
		if(formulaire.check[i].checked)
		{
			test = 'document.gestionPdvForm.prix'+i+'.value.length';		
			if (eval(test)==0)
			{
				m++;
			}
		}
	}
	
	for(i=0;i<formulaire.check.length;i++) 
	{
		if(formulaire.check[i].checked)
		{
			validationCheck=true;
			k=k.concat(i).concat(h);
		}
	}
	
	if(formulaire.check.length==null){
		if(formulaire.check.checked)
		{
			//alert(document.gestionPdvForm.prix0.value);
			if(document.gestionPdvForm.prix0.value.length==0){
				//alert("ici");
				m++;
			}
		}
	}
	
	if (m!=0)
	{
		retour ='<li>'+champs[22]+'</li>';
		retour ='<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
		document.getElementById('TxMsg').innerHTML=retour;
		return;
	}
	
	if (k=='')
	{
		if(formulaire.check.checked)
		{
				validationCheck=true;
				formulaire.single.value=1;
				formulaire.action.value='UpdateTauxSingle';
				formulaire.submit();
				return;
		}
		
		else
		{
			retour ='<li>'+champs[19]+'</li>';
			retour ='<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
			document.getElementById('TxMsg').innerHTML=retour;
			return;
		}
	}
	
	if (validationCheck)
 	{
		formulaire.action.value='UpdateTaux';
		formulaire.ssaction.value=j;
		formulaire.tabaction.value=k;
		formulaire.maction.value=m;
		formulaire.submit();
		return;
	}else{
		retour =retour + '<li>'+champs[19]+'</li>';
		retour ='<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
		document.getElementById('TxMsg').innerHTML=retour;
		return;
	}

}



//
//
//	
function SupprimerTaux(champs,msgerror)
{
	var formulaire=document.gestionPdvForm;
	var validationCheck=false;
	var j=0;
	var k='';
	var h=',';
	
	for(i=0;i<formulaire.check.length;i++) 
	{
		j++;
	}

	for(i=0;i<formulaire.check.length;i++) 
	{
		if(formulaire.check[i].checked)
		{
			validationCheck=true;
			k=k.concat(i).concat(h);
		}
	}
	
	if (k=='')
	{
		if(formulaire.check.checked)
		{
			validationCheck=true;
			formulaire.single.value=1;
			formulaire.action.value='SuppressionTauxSingle';
			formulaire.submit();
			return;
		}
		
		else
		{
			retour ='<li>'+champs[20]+'</li>';
			retour ='<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
			document.getElementById('TxMsg').innerHTML=retour;
			return;
		}
	}
	
	if (validationCheck)
	{
		formulaire.action.value='SuppressionTaux';
		formulaire.ssaction.value=j;
		formulaire.tabaction.value=k;
		formulaire.submit();
		return;
	}

	if (!validationCheck)
	{
		retour ='<li>'+champs[20]+'</li>';
		retour ='<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
		document.getElementById('TxMsg').innerHTML=retour;
		return;
	}

}
//
//
//	
function AjoutTaux(champs,msgerror)
{
	//var formulaire=document.gestionPdvForm;
	//var formulaire=document.getElementById("gestionPdvForm");
	//formulaire.action.value='AjoutTaux';
	//formulaire.submit();
	//return;
	
	var formulaire=document.gestionPdvForm;
	formulaire.action.value='AjoutTaux';
	formulaire.submit();
	return;
	
}

//
//
//	
function tauxMOvalidation (champs,msgerror)
{
	var formulaire=document.gestionPdvForm;
	var retour='';
	
	if (formulaire.idtype.value=='' || formulaire.prix.value=='')
	{
		retour ='<li>'+champs[21]+'</li>';
		retour ='<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
		document.getElementById('TxMsg').innerHTML=retour;
		return;
	}

	else
	{
		formulaire.action.value='AjoutTauxLive';
		formulaire.submit();
		return;
	}

}

//
//
//	
function tauxMOannulation (champs,msgerror)
{
	var formulaire=document.gestionPdvForm;
	formulaire.submit();
	return;

}


//
//
//	
function ControleEnvoiMO(formulaire, msgerror, champs,actionEnvoi)
{
		var tvaTauxMO = formulaire.tvaTauxMO.value;
		var chptaux=formulaire.tvaTauxMO.value;
		var actionSubmit=actionEnvoi;
		
		var focus=0;
		var retour='';
		
		
		if (tvaTauxMO == '') 
		{
//			retour ='<li>'+champs[17]+'</li>';
//			retour = '<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
			formulaire.tvaTauxMO.value=0;
//			if (focus == 0) formulaire.tvaTauxMO.focus();
//			focus++;
			
		}
			
		if(retour!='')
		{
			document.getElementById('TxMsg').innerHTML=retour;
			return;
		}
		else
		{
			formulaire.action.value=actionSubmit;
			formulaire.submit();
		}
}

//
//
//	
// Script de vérification des donnees de creation d'un compte client
function controleDonneesCreation_phase2(msgerror, champs, msggen,actionEnvoi) {
	var formulaire = document.inscriptionForm;
	controleDonneesCommunes(false, formulaire, msgerror, champs, msggen,actionEnvoi);
}	

//
//
//	
// Script de vérification des donnees de creation d'un compte client
function controleDonneesinscriptionForm(msgerror, champs, msggen,actionEnvoi) {
	var formulaire = document.inscriptionForm;
	controleDonneesCommunes(false, formulaire, msgerror, champs, msggen,actionEnvoi);
}	

//
//
//	
// Script de vérification des donnees de modification d'un compte client
function controleDonneesModification_phase1 (msgerror, champs,msggen, actionEnvoi) 
{
    var formulaire = document.inscriptionForm;
	controleDonneesCommunes(true, formulaire, msgerror, champs, msggen, actionEnvoi);
}

/*
 * FormatTVAIntracom
 * controle le format de la TVA intracommunautaire suivant le pays d'inscription
 * cf : http://ec.europa.eu/taxation_customs/vies/fr/faqvies.htm#item11
 * return true if TVA format is according with the country
 *
 */
function FormatTVAIntracom(pays, tvaIntracom) {
	var reg = /^.*$/
	if (pays == 'AT') { var reg = /^ATU\d{8}$/ }
	if (pays == 'BE') { var reg = /^BE0?\d{9}$/ }
	if (pays == 'BG') { var reg = /^BG\d{9,10}$/ }
	if (pays == 'CY') { var reg = /^CY\d{8}[A-Z]$/ }
	if (pays == 'CZ') { var reg = /^CZ\d{8,10}$/ }
	if (pays == 'DE') { var reg = /^DE\d{9}$/ }
	if (pays == 'DK') { var reg = /^DK\d\d(\s?\d\d){3}$/ }
	if (pays == 'EE') { var reg = /^EE\d{9}$/ }
	if (pays == 'GR') { var reg = /^EL\d{9}$/ }
	if (pays == 'ES') { var reg = /^ES[A-Z0-9]\d{7}[A-Z0-9]$/ }
	if (pays == 'FI') { var reg = /^FI\d{8}$/ }
	if (pays == 'FR') { var reg = /^FR[A-Z0-9]{2}\s?\d{9}$/ }
	if (pays == 'GB') { var reg = /^GB(((GD|HA)\d{3})|(\d{3}\s?\d{4}\s?\d{2}\s?(\d{3})?))$/ }
	if (pays == 'HU') { var reg = /^HU\d{8}$/ }
	if (pays == 'IE') { var reg = /^IE\d[A-Z0-9+*]\d{5}[A-Z]$/ }
	if (pays == 'IT') { var reg = /^IT\d{11}$/ }
	if (pays == 'LT') { var reg = /^LT(\d{9}|\d{12})$/ }
	if (pays == 'LU') { var reg = /^LU\d{8}$/ }
	if (pays == 'LV') { var reg = /^LV\d{11}$/ }
	if (pays == 'MT') { var reg = /^MT\d{8}$/ }
	if (pays == 'NL') { var reg = /^NL\d{9}B\d\d$/ }	
	if (pays == 'PL') { var reg = /^PL\d{10}$/ }
	if (pays == 'PT') { var reg = /^PT\d{9}$/ }
	if (pays == 'RO') { var reg = /^RO\d{2,9}$/ }
	if (pays == 'SE') { var reg = /^SE\d{12}$/ }
	if (pays == 'SI') { var reg = /^SI\d{8}$/ }	
	if (pays == 'SK') { var reg = /^SK\d{10}$/ }

	return (reg.exec(tvaIntracom)!=null);
}

//
//
//	
function controleDonneesCommunes(maj, formulaire, msgerror, champs, msggen, actionEnvoi) {
	var focus = 0;
	var retour = '';
	var actionSubmit = actionEnvoi;
	var statut = formulaire.statut.value;
	var nom = STrim(formulaire.nom.value);
	var prenom = STrim(formulaire.prenom.value);
	var codePostal = STrim(formulaire.codePostal.value);
	var mail = STrim(formulaire.mail.value);
	var ville = STrim(formulaire.ville.value);
	var adrFacturation = STrim(formulaire.adrFacturation.value);
	var telephone = formulaire.telephone.value;
	var tvac="";
	var checkItvac=false;
	var siretFR="";
	var checkSiretFR=false;
	if(document.getElementById("tvaic")){
		if(document.getElementById("tvaic").style.display=="block"){
			var tvac=formulaire.tvaIntracom.value;
			checkItvac=true;
			if(document.forms[0].pays.value == 305)checkItvac=false;
		}else{
			checkItvac=false;
		}
	}
	if(document.getElementById("siretFR")){
		if(document.getElementById("siretFR").style.display=="block"){
			var siretFR=formulaire.siret.value;
			checkSiretFR=true;
		}else{
			checkSiretFR=false;
		}	
	}	
	formulaire.action.value=actionSubmit;	
	formulaire.nom.value=nom;
	formulaire.prenom.value=prenom;
	formulaire.codePostal.value=codePostal;
	formulaire.mail.value=mail;
	formulaire.ville.value=ville;
	formulaire.adrFacturation.value=adrFacturation;

	// Début des controles
	document.getElementById('jsMsg').innerHTML='';
	
	// **************************************
	// ** Controle des champs obligatoires **
	// **************************************
	
	// civilite
	if (!maj)
	{
		if (formulaire.civilite[0].checked == false && formulaire.civilite[1].checked == false && formulaire.civilite[2].checked == false) {
			retour = retour + '<li>'+ champs[0] + '</li>';
			formulaire.civilite[0].focus();
			focus++;
		}
	}
	
	// telephone
	if(!ValidatePhone(telephone)) {
		retour = retour + '<li>' + champs[5] + '</li>';
		if (focus == 0) formulaire.telephone.focus();
		focus++;  	 
	}
	
	// nom
	if (nom == '') {
		retour = retour + '<li>' + champs[1] + '</li>';
		if (focus == 0) formulaire.nom.focus();
		focus++;
	}
	
	// prenom
	if (prenom == '') {
		retour = retour + '<li>'+ champs[2] + '</li>';
		if (focus == 0) formulaire.prenom.focus();
		focus++;
	}
	
	// email		
	if (mail == '') {
		retour = retour + '<li>'+ champs[3] + '</li>';
		if (focus == 0) formulaire.mail.focus();
		focus++;
	}
	
	// email de confirmation
	if (!maj) {
		var confmail = formulaire.confmail.value;
		formulaire.confmail.value=confmail;
		if (confmail == '') {
			retour = retour + '<li>'+ champs[4] + '</li>';
			if (focus == 0) formulaire.confmail.focus();
			focus++;
		}
	}
	
	// adresse
	if (adrFacturation == '') {
		retour = retour + '<li>'+ champs[6] + '</li>';
		if (focus == 0) formulaire.adrFacturation.focus();
		focus++;
	}
	
	// code postal
	if (codePostal == '') {
		retour = retour + '<li>'+ champs[7] + '</li>';
		if (focus == 0) formulaire.codePostal.focus();
		focus++;
	}
	
	// ville
	if (ville == '') {
		retour = retour + '<li>'+ champs[8] + '</li>';
		if (focus == 0) formulaire.ville.focus();
		focus++;
	}
	
	// pays 
	if (!maj) {
	
		var pays = formulaire.pays.value
		if (pays == '' || pays == '0' ) {
			retour = retour + '<li>'+ champs[9] + '</li>';
			if (focus == 0) formulaire.pays.focus();
			focus++;
		}
	}
	
	//itva
	/*if(checkItvac&&tvac==''){
		retour = retour + '<li>'+ champs[13] + '</li>';
	}*/
	
	//siret
	if(checkSiretFR&&siretFR==''){
		retour = retour + '<li>'+ champs[12] + '</li>';
	}
	// professionnels
	if (statut != 0) 
	{ 
		// raison sociale
		var raisonSociale = STrim(formulaire.raisonSociale.value);
		formulaire.raisonSociale.value=raisonSociale;
		if (raisonSociale == '') 
		{
			retour = retour + '<li>'+ champs[11] + '</li>';
			if (focus == 0) formulaire.raisonSociale.focus();
			focus++;
		}

		// Controle tva intracom uniquement pour pays de l'ue
		var tvaIntracom = STrim(formulaire.tvaIntracom.value);
		tvaIntracom = tvaIntracom.toUpperCase();
		formulaire.tvaIntracom.value=tvaIntracom;
		if (!maj) {
					if (formulaire.pays.selectedIndex > 1 )
					{
						if (!tvaIntracom=='')
						{
							if (tvaIntracom=='' || !FormatTVAIntracom(formulaire.pays.value, tvaIntracom)) 
							{
								retour = retour + '<li>'+ champs[13] + '</li/>';
								if (focus == 0) formulaire.tvaIntracom.focus();
								focus++;
							}
						}
					
					}
				}
		else {
						if (!tvaIntracom=='')
						{
							if (!FormatTVAIntracom(formulaire.paysid.value, tvaIntracom)) 
							{
								retour = retour + '<li>'+ champs[13] + '</li/>';
								if (focus == 0) formulaire.tvaIntracom.focus();
								focus++;
							}
						}	
		}
	}

	if (!maj) {
	
		// password
		var passwd =formulaire.passwd.value;		
		formulaire.passwd.value=passwd;
		if (passwd== '') 
		{
			retour = retour + '<li>'+ champs[14] + '</li>';
			if (focus == 0) formulaire.passwd.focus();
			focus++;
		}
		
		// confirmation du password
		var passwd2 =formulaire.passwd2.value;
		formulaire.passwd2.value=passwd2;
		if (passwd2 == '') 
		{
			retour = retour + '<li>'+ champs[15] + '</li>';
			if (focus == 0) formulaire.passwd.focus();
			focus++;
		}
	}
		
	if (retour != '') {
		retour = '<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
	}
	
	// ***********************************
	// ** Controle du format de l'email **
	// ***********************************
	if (mail != '') {
	
		if (verifemail(mail)==false) {
			retour = retour + '<span class="MsgWarning">'+msgerror[4]+'</span><br/>';
			if (focus == 0) formulaire.mail.focus();
			focus++;
		}else{		
			if (!maj) {
				var confmail = STrim(formulaire.confmail.value);
				formulaire.confmail.value=confmail;
				if (confmail != '') {		
					if (mail != confmail) {
						retour = retour + '<span class="MsgWarning">'+msgerror[5]+'</span><br/>';
						if (focus == 0) formulaire.confmail.focus();
						focus++;
					}
				}
			}
		}
	}

	// ************************************
	// ** Controle du format du password **
	// ************************************
	if (!maj) {
		
		if (passwd != '') {
			if (!isPasswdOK(passwd))
			{
				retour = retour + '<span class="MsgWarning">'+msgerror[3]+'</span><br/>';
				if (focus == 0) formulaire.passwd.focus();
				focus++;
				
			}else{
				
				if(passwd2 != ''){
					if ( passwd != passwd2)
					{
						retour = retour + '<span class="MsgWarning">'+msgerror[6]+'</span><br/>';
						if (focus == 0) formulaire.passwd.focus();
						focus++;
					}
				}
			}
		}
	}

	if (!maj) {
	
		if(formulaire.collecte.checked==true)
		{
			formulaire.actionCollecte.value='collecte';
		}
	}
	


	// Fin des controles
	if (retour!=''){
		document.getElementById('jsMsg').innerHTML=retour;
		return;
	}
	else 
	{
		formulaire.submit();
	}
}

//
//
//	
function choisirLangue (chemin) {
	setCookieLangue('','');
	top.location.href = chemin;
	return;
}

//
//
//	
function modificationTauxMO (err, longueur) {
	var formulaire = document.modificationTaux;
	var isGood = 1;

	for(var i=0;i<longueur;i++) {
		if (formulaire.elements[i] == '') {
			isGood = 0;
			break;
		}
	}
	if (isGood == 0) {
		return;
	} else {
		formulaire.ssaction.value='modifierTaux';
		formulaire.submit();
	}
}

//
//
//	
function actualiserTableLiens() 
{
	top.GAUCHE.location= servletRoot+"MenuGeneral";
}

//
//
//	
function LTrim(str){
	var i=0
	if (str==null) {return "";}
	if (str=="") {return "";}
	
	if (str.length>0) { 
		for(var i=0;str.charAt(i)==" ";i++);
		return str.substring(i,str.length);
	}
	return str;
}

//
//
//	
function RTrim(str){
	var i=0
	if (str==null) {return "";}
	if (str=="") {return "";}
	if (str.length>0) {
			for(var i=str.length-1;str.charAt(i)==" ";i--);
			return str.substring(0,i+1);
	}
	return str;
}

//
//
//	
function STrim(str){return LTrim(RTrim(str));}


//-------------------------------------------------------------------
// setNullIfBlank(input_object)
//   Sets a form field to "" if it isBlank()
//-------------------------------------------------------------------
function setNullIfBlank(obj){if(isBlank(obj.value)){obj.value="";}}

//-------------------------------------------------------------------
// isBlank(value)
//   Returns true if value only contains spaces
//-------------------------------------------------------------------
function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) 
		{
			if ((val.charAt(i)!=' ')&&
				(val.charAt(i)!="\t")&&
				(val.charAt(i)!="\n")&&
				(val.charAt(i)!="\r"))
				{return false;}
		}
	return true;
}

//
//
//	
function isAlphaNum(str) {
	var strChar
	for(var i=0;i<str.length;i++)
	{
		strChar = str.charAt(i);
		 if (!(((strChar >= "a") && (strChar <= "z"))||((strChar >= "A") && (strChar <= "Z"))||((strChar >= "0") && (strChar <= "9"))))
		 { 
			 return false;
		 }
	}
	return true;
}

//
//
//	
// fonction de choix d'un pays en dehors de l'Europe
function getOtherCountry() {
	indexSelectionne = document.forms[0].pays.selectedIndex;
	if (indexSelectionne < 301) {
		document.getElementById("tvaic").style.display = "none";
		ouvrirFenetre(servletRoot+"ChoixPays", 'choixPays', 'no', 'no', 'no', 'no', 'no', 'yes', 'no', '680', '420');
	} else {
		document.getElementById("tvaic").style.display = "block";
//     		document.forms[0].pays.options[1]=new Option(document.forms[0].autrePays.value, '000', false, false);
		document.forms[0].pays.options[1].text=document.forms[0].autrePays.value;
		document.forms[0].lePays.value='';
		document.forms[0].pays.options[indexSelectionne].selected=true;
	}
}

//
//
//	
function checkTVA(objtva) {
    var tva = objtva.value;
    
    if(!isVirgule(tva) && !hasWhiteSpace(tva))
    {
    
        tva = tva.replace(/,/,"\.");
     
	    if (isNaN(tva)==true) 
	    {
	     
	    	objtva.value = "";return;
	    }
	
	    var tvaLongueur = tva.length;
	   
	       
	    var point = tva.indexOf(".");
	   
	    var TempVirgule = tvaLongueur - point;
	    
	
		if(TempVirgule > 3 && point != -1) 
		 
		{
		
		objtva.value = tva.substring(0,point+3);
		  
		}
    	
    }
    else
    {
    	objtva.value = "";return;
    }
       

}

//
//
//	
function isVirgule(str) {
	var strChar
	for(var i=0;i<str.length;i++)
	{
		strChar = str.charAt(i);
		 if ((strChar == ","))
		 { 
			 return true;
		 }
	}
	return false;
}

function hasWhiteSpace(str) {
	var strChar
	for(var i=0;i<str.length;i++)
	{
		strChar = str.charAt(i);
		 if ((strChar == " "))
		 { 
			 return true;
		 }
	}
	return false;
}

//
//
//	
function checkChpRempli(type,prix,msgerror, champs, msggen)
{
	var type=type;
	var prix=prix;
	var retour='';
	
	if (type=='' ||  prix=='')
	{
		retour ='<li>'+champs[19]+'</li>';
	}
		
	if (retour != '') 
	{
		retour = '<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span><BR/>';
		document.getElementById('TxMsg').innerHTML=retour;
		return;
	}
	
	else
	{
		EnvoiModifTaux(msgerror, champs, msggen);
		return;
	}
	
}

// fonction qui positionne la valeur du pays dans la fenetre parente
function setAutrePays(code, libelle) {
//	window.opener.document.forms[0].pays.options[1] = new Option(window.opener.document.forms[0].pays.options[window.opener.document.forms[0].pays.selectedIndex].text + '  ' + libelle, '000', false, false);
window.opener.document.forms[0].pays.options[1].text=window.opener.document.forms[0].pays.options[window.opener.document.forms[0].pays.selectedIndex].text + '  ' + libelle;
	window.opener.document.forms[0].lePays.value=code;
	window.close();
}

//fonction reprise de la cg
function showTab(OBJ,ID, marque){
	var lisTab = new Array();
	lisTab[0] = new Array('tb1');
	lisTab[1] = new Array('tb2');
	lisTab[2] = new Array('tb3');
	lisTab[3] = new Array('tb4');
	lisTab[4] = new Array('tb5');
	lisTab[5] = new Array('tb6');
	lisTab[6] = new Array('tb7');
	lisTab[7] = new Array('tb8');
	lisTab[8] = new Array('tb9');
	lisTab[9] = new Array('tb10');
	lisTab[10] = new Array('tb11');
	lisTab[11] = new Array('tb12');
	lisTab[12] = new Array('tb13');
	lisTab[13] = new Array('tb14');

	if(OBJ.src.substr(OBJ.src.lastIndexOf("/")+1) == "closelem.gif"){
		OBJ.src = staticRoot+marque+"/img/picto/openelem.gif";
		document.getElementById(lisTab[ID]).style.display = 'block';
	} else {
		OBJ.src = staticRoot+marque+"/img/picto/closelem.gif";
		document.getElementById(lisTab[ID]).style.display = 'none';
	}
}

//
//
//	
function controleDonneesPassword (msgerror, champs, msggen,actionEnvoi) 
{
	var formulaire=document.inscriptionForm;
	ControlMdp(true,formulaire, msgerror, champs, msggen,actionEnvoi);
	
}

// controle mot de passe

//
//
//	
function ControlMdp(maj,formulaire,msgerror,champs,msggen,actionEnvoi)
{
	var focus = 0;
	var actionSubmit=actionEnvoi;
	var passwd = formulaire.passwd.value;
	var passwd2 = formulaire.passwd2.value;
	var retour = '';

	formulaire.action.value=actionSubmit;	

		if (passwd== '' || !isPasswd(passwd)) 
		{
			retour = retour + '<li>'+ champs[14] + '</li>';
			if (focus == 0) formulaire.passwd.focus();
			focus++;
		}
		
		if (passwd2 == '' || !isPasswd(passwd2)) 
		{
			retour = retour + '<li>'+ champs[15] + '</li>';
			if (focus == 0) formulaire.passwd.focus();
			focus++;
		}
		
		if (retour != '') {
			retour = '<span class="MsgWarning">'+msgerror[1]+'<ul>'+retour+'</ul></span>';
		}
		
		if (passwd.length<5 || passwd2.length<5 )
		{
			retour = retour + '<span class="MsgWarning">'+msgerror[3]+'</span><br/>';
			if (focus == 0) formulaire.passwd.focus();
			focus++;
		}
		
		if ( passwd != passwd2)
		{
			retour = retour + '<span class="MsgWarning">'+msgerror[6]+'</span><br/>';
			formulaire.passwd.value='';
			formulaire.passwd2.value='';
			if (focus == 0) formulaire.passwd.focus();
			focus++;
		}

		if (!isAlphaNum(passwd))
		{
			retour = retour + '<br><span class="MsgWarning">'+msgerror[7]+'</span><br/>';
		}
		
	
	if (retour != '') {
		document.getElementById('jsMsg').innerHTML=retour;
		return;
	}
		formulaire.submit();
}
	

//
//
//	
// vérif validité passwd
function isPasswdOK(str) {
	if (str.length < 5 || str.length > 10) return false;
	if (isBlank(str)) return false;
	if(isAlphaNum(str)) return true;
	return false;
}

//
//
//	
// vérif validité passwd dans sauvegarde
function isPasswd(str) 
{
	if (str.length < 5 || str.length > 10) return false;
	else return true;
}

//
//
//	
// vérif validité email par REGEXP
function verifemail(email) { 
//	var reg = /^[a-z0-9._-]+@[a-z0-9-]{2,}([.][a-z0-9-])?[.][a-z]{2,4}$/
//	var reg = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9]+)*$/
//  var reg = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/

/* Uniquement des minuscules, format minimum accepté : s@s.fr, tjrs une lettre après un ./_/- */
	var reg = /^[a-z0-9]+([_.-]?[a-z0-9])*@[a-z0-9]+([_.-]?[a-z0-9])*\.([a-z]{2,})$/
	return (reg.exec(email)!=null);
}



//
//
//	
// focus sur la ligne de mot de passe
function chargement()
{
	if(document.charge.login.value!='')
	{
			document.charge.passwd.focus();
	}
	else
	{

		document.charge.login.focus();
	}
	
}


//
//
//	
function EnvoiMotDePasse(msgerror, champs, msggen)
{
	controleDonneesPassword (msgerror, champs, msggen,'modifier3');
}

//
//
//	
function EnvoiModifCptClient(msgerror, champs, msggen)
{
	controleDonneesModification_phase1 (msgerror, champs, msggen,'modifier2');
}

//
//
//	
function EnvoiModifTaux(msgerror, champs, msggen)
{
	controleTauxMo(msgerror, champs,msggen,'modifier4');
}

//
//
//	
function check(errValidation) 
{
	var formulaire=document.administration;
	var j=0;

	 for (i=0, n=formulaire.elements.length; i<n; i++)
	 {
	    var objType = formulaire.elements[i].type;
	
	    if (objType = "checkbox")
	    {
	      box = eval(formulaire.elements[i]);
    	
			if (box.checked==true)
			{
				j=j+1;
				ValidationTableauLibellePositive(formulaire);
			}
	   		
   		}
  	}
  	
  	if(j>0)
  	{
  		ValidationTableauLibellePositive(formulaire);

  	}
  	else
  	{
		ValidationTableauLibelleNegative(errValidation);
  	}
  	
  	
}

//
//
//	
function ValidationTableauLibellePositive(formulaire)
{
	var obje=document.forms["administration"].elements["affichageNecessary"].value = 'validation';
	formulaire.submit();
	return;
}


//
//
//	
function ValidationTableauLibelleNegative(errValidation)
{	
	document.getElementById('jsMsg').innerHTML='<span class="MsgWarning">'+errValidation+'</span><br/>';
	return;
}

//
//
//	
function affichageTableauLibelle(message)
	{  
	
		var obje=document.forms["administration"].elements["affichageNecessary"].value = message;
	 	document.administration.submit();
	 	
		return;
	}
	
//
//
//	
function validationDesignation(message,errValidation)
 {
	      
       if(document.forms["administration"].elements["designation"].value=='')
       {
            document.getElementById('jsMsg').innerHTML='<span class="MsgWarning">'+errValidation+'</span><br/>';
			return;

       }
       else
       {
         	var obje=document.forms["administration"].elements["affichageNecessary"].value = message;
			document.forms["administration"].submit();
			return;
       }
       
  }
     
//
//
//	
function validationAchats(errPaiement,errEmptyField,errValidCGV)
{

				var formulaire=document.abonnementForm;
				var validationAchat=false;
				var validationCGDV=false;
				var validationPaiement=false;
				var retour = '';

/*			
// cas de plusieurs choix de paiement
				for(i=0;i<formulaire.paiement.length;i++) 
				{
					if (formulaire.paiement[i].checked) 
					{
						validationPaiement=true;
						break;
					}
				}
*/			

				if (formulaire.paiement.checked) 
				{
					validationPaiement=true;
				}
				
				for(i=0;i<formulaire.idAbonnement.length;i++) 
				{
					if (formulaire.idAbonnement[i].checked) 
					{
						validationAchat=true;
						break;
					}
				}
				
				if (formulaire.cgdv.checked) 
				{
					validationCGDV=true;
				}
					
										
				if (validationAchat && validationCGDV && validationPaiement) 
				{
					formulaire.submit();
					return;
				} 
				
				if(!validationAchat)
				{
					retour = retour + '<span class="MsgWarning">'+errEmptyField+'</span><br/>';
				}
				if(!validationPaiement)
				{
					retour = retour + '<span class="MsgWarning">'+errPaiement+'</span><br/>';
				}
				if(!validationCGDV)
				{
					retour = retour + '<span class="MsgWarning">'+errValidCGV+'</span><br/>';
				}
				
				if (retour!='')
				{
					document.getElementById('jsMsg').innerHTML=retour;
					return;
				}
	}


//
//
//	
 function controleDonneesRestitution_phase1(errEmptyField) 
 {
 		var retour='<span class="MsgWarning">'+errEmptyField+'</span><br/>'
      	var formulaire=document.form_restitution_phase1;
      	var mail=formulaire.email.value;
      	if (mail==null || mail=='' ) 
      	{
      		document.getElementById('jsMsg').innerHTML=retour;
      		return;
      	} 
      	else 
      	{
      		
      		if(verifemail(mail)==false)
      		{
      			document.getElementById('jsMsg').innerHTML=retour;
      			return;
      		}
      		else
      		{
      			
      			formulaire.submit();
	      		return;
      		}

      	}
  }
  
//
//
//	
 function verifTestMailUnique(ajout,test,bordel)
{
	
	var formulaire=document.modification_phase1;
	var reg=new RegExp("[,]+","g");
	var tableau=ajout.split(reg);
	
	for (var i=0; i<tableau.length; i++) 
	{	
		if (tableau[i]==test.value)
		{
			formulaire.mail.value='';
			formulaire.mail.focus();
			document.getElementById('TxMsg').innerHTML='<span class="MsgWarning">'+bordel+'</span><br/>';
			return;

		}
	}
	
 }

//
//
//	
function annuler(marque)
{
	document.charge.login.value='';
	document.charge.passwd.value='';
	redirection();
}

//
//
//	
function redirection()
{
	top.location= servletRoot+"Quitter";
}

//
//
//	
 function i18nControleAjoutLibelle() 
 {
	var formulaire=document.forms['update'];      			
      	
    // TODO: Ajouter des contrôles
      	
  	formulaire.submit();
    return;  
 }

//
//
//	
 function i18nControleEnregistrerLibelle() 
 {
	var formulaire=document.forms['update'];      			
      	
    // TODO: Ajouter des contrôles
      	
  	formulaire.submit();
    return;  
 } 
 
 function isEuropean(){
	indexSelectionne = document.forms[0].pays.value;
	if (indexSelectionne < 301) {
		document.getElementById("tvaic").style.display = "none";
	} else {
		document.getElementById("tvaic").style.display = "block";
	}
 	if(indexSelectionne==304) {
 		document.getElementById("siretFR").style.display = "block";
 	}else{
	 	document.getElementById("siretFR").style.display = "none";
 	}
 }
 
 // Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 0;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidatePhone(Phone){
	
	if ((Phone!=null)||(Phone!="")){
		if (checkInternationalPhone(Phone)==false){	
			document.inscriptionForm.telephone.value=""
			return false
		}
	}
	return true
 }