/*  Initialisation des flags pour les validations de formulaires */
/* Version WWW.GOTO.FR*/

var flagmail = true ;
var flag=0 ;

if (!document.all && document.getElementById)
{
	function go(val)
	{
		this.back() ;
	}
}

/*
FONCTION POUR REMPLACER
un ou plusieurs caractères
par d'autres caractères une STR
*/
function StrReplace(Str,bad, good)
{
//alert (Str);
	while (Str.indexOf(bad) > 0 )
	{
		LEFT = Str.slice(0, Str.indexOf(bad));
		//alert ("LEFT = " + LEFT)
		RIGHT = Str.slice(Str.indexOf(bad) + bad.length, Str.length);
		//alert ("RIGHT = " + RIGHT)
		Str = LEFT + good + RIGHT;
		//alert ("Str = " + Str)
		// ReplaceFRInc++
	}
//alert (Str);
	return(Str);
}

// FONCTIONS POUR ENREGISTRER ET RECUPERER LES INFOS UTILISATEURS DANS LES PAGES DE VALIDATION DES PAIEMENTS
function getInfo(){
	var coordinit = new getCookieArray("utilisateur");
	if (coordinit[1] && coordinit[1]!="" && document.mainform.genre) document.mainform.genre.value = coordinit[1];
	if (coordinit[2] && document.mainform.nom) document.mainform.nom.value = coordinit[2];
	if (coordinit[3] && document.mainform.eml) document.mainform.eml.value = coordinit[3];
	if (coordinit[4] && document.mainform.prenom) document.mainform.prenom.value = coordinit[4];
	if (coordinit[5] && document.mainform.adr1) document.mainform.adr1.value = coordinit[5];
	if (coordinit[6] && document.mainform.adr2) document.mainform.adr2.value = coordinit[6];
	if (coordinit[7] && document.mainform.cp) document.mainform.cp.value = coordinit[7];
	if (coordinit[8] && document.mainform.ville) document.mainform.ville.value = coordinit[8];
	if (coordinit[9] && coordinit[9]!="" && document.mainform.pays) document.mainform.pays.value = coordinit[9];
	if (coordinit[10] && document.mainform.ste) document.mainform.ste.value = coordinit[10];
	if (coordinit[11] && document.mainform.tvaintra) document.mainform.tvaintra.value = coordinit[11];
}
function saveInfo(){
	var coord = new Array();
	coord[1] = document.mainform.genre.value;
	coord[2] = document.mainform.nom.value;
	coord[3] = document.mainform.eml.value;
	coord[4] = document.mainform.prenom.value;
	coord[5] = document.mainform.adr1.value;
	coord[6] = document.mainform.adr2.value;
	coord[7] = document.mainform.cp.value;
	coord[8] = document.mainform.ville.value;
	coord[9] = document.mainform.pays.value;
	coord[10] = (document.mainform.ste)?document.mainform.ste.value:'';
	coord[11] = (document.mainform.tvaintra)?document.mainform.tvaintra.value:'';
	var coordonnees = new setCookieArray("utilisateur",coord[1],coord[2],coord[3],coord[4],coord[5],coord[6],coord[7],coord[8],coord[9],coord[10],coord[11]);
}

// FONCTION POUR ENREGISTRER LES ABONNEMENTS NEWSLETTER
function Abonnement(){
	var toReturn=true;
	var email= new String(document.news.email.value);
	// Verif champs
	var Util = new String('');
	var Pro = new String('');

	if (document.news.Util.checked){
		Util = 'oui';
	}
	if (document.news.Pro.checked){
		Pro = 'oui';
	}

	if (chkForm('fr','news','email')){
		var url = "http://www.goto.fr/fr/merci.asp?section=1&email="+ email +"&util="+ Util + "&pro=" + Pro;
		openVisite(url);
	}else{
		toReturn=false;
	}
	return toReturn;
}


/* Animation de la barre du milieu dans tout le site */
function SwitchPanneau(Sens,ID){
	//alert("SwitchPanneau")
	var toReturn=false;
	var SensMove = Sens;
	//alert (Sens);
	if(ID==null){ /* first time : initialisation Positions*/
		if(SensMove==null){
			if (document.getElementById("MediumLayer").style.top=="0px"){
				//ouvre la barre de navigation
				document.Pos = new Array(0,-10, -40, -70,-95);
				document.Txt = new String("Ouvrir cette barre...")
			}else{
				// ferme la barre de navigation
				document.Pos = new Array(-95, -60, -40 , -10, -5, 0);
				document.Txt = new String("Fermer cette barre...")
			}
		}else{
			if(SensMove.toUpperCase() == 'RENTRE'){
				if(document.getElementById("MediumLayer").style.top == "0px"){
					//Ferme la barre de navigation
					document.Pos = new Array(0,-10, -40, -70,-95);
					document.Txt = new String("Ouvrir cette barre...")
				}else{
					toReturn=true;
				}
			}else{
				document.Pos = new Array(0,-10, -40, -70,-95);
				document.Txt = new String("Fermer cette barre...")
			}
		};
		SwitchPanneau(SensMove,0);
	}else{
		if (ID < document.Pos.length){
			document.getElementById("MediumLayer").style.top = "" + document.Pos[ID] + "px" ;
			if (screen.width > 800 ){
				document.getElementById("MediumLayer").style.clip = "rect("+ (-document.Pos[ID]) +"px 860px 130px 0px)" ;
			}else{
				document.getElementById("MediumLayer").style.clip = "rect("+ (-document.Pos[ID]) +"px 635px 130px 0px)" ;
			}
			document.getElementById("BtFermer").alt = document.Txt ;
		};
		ID++;
		Timer = setTimeout('SwitchPanneau("'+ Sens +'",'+ ID +')', 0);
	}
	return toReturn;
}

function RecupNomPage()
{
	var URL =  new String(window.location.href)
	var BASE = new String("http://www.goto.fr/fr/")
	var SortieSTR = new String("<span style='font-size: 10px'><a href='" + BASE + "index.asp' class='TopLink'>Accueil</a>");
	var RelURL = new String("");
	var ProdName = new String("")
	var TempProdName = new String("")
	URL = URL.slice(BASE.length, URL.length)
	while (URL.length > 0)
	{
		if(URL.indexOf("/") == -1)
		{
			SortieSTR +=  " > <a href='" + BASE + RelURL + URL.slice(0,URL.length) + "' class='TopLink'>" + document.title +"</a>";
				URL = "";
		}
		else
		{
			TempProdName = URL.slice(0,URL.indexOf("/")) ;
			/* On ajuste le format des noms : produit => Produit */
			ProdName = TempProdName.slice(0,1).toUpperCase() + TempProdName.slice(1,TempProdName.length)
			SelectProds :
			{
				switch(ProdName)
				{
					case "Mw" : 		ProdName = "MemoWeb 4" ; break SelectProds ;
					case "Sa" : 		ProdName = "Sarbacane" ; break SelectProds ;
					case "SA" : 		ProdName = "Sarbacane" ; break SelectProds ;
					case "Bf" : 		ProdName = "ButtonFly Edition Professionnelle V.2" ; break SelectProds ;
					case "Bh" : 		ProdName = "ButtonFly Home Edition" ; break SelectProds ;
					case "Mt" : 		ProdName = "MemoTel X-pert" ; break SelectProds ;
					case "Ach" : 		ProdName = "Achat en Ligne"; break SelectProds ;
					case "Corpo" : 		ProdName = "Sociétés"; break SelectProds ;
					case "Tel" : 		ProdName = "Téléchargements"; break SelectProds ;
					case "Inf" : 		ProdName = "Informations"; break SelectProds ;
					case "INF" : 		ProdName = "Informations"; break SelectProds ;
				}
			}
			// On élimine les _
			ProdName = StrReplace(ProdName,"_"," ")

			SortieSTR +=  " > <a href='" + BASE +RelURL + URL.slice(0,URL.indexOf('/')) +"'  class='TopLink'>"+ ProdName +"</a>"
			//alert(SortieSTR)
			RelURL += URL.slice(0,URL.indexOf("/")) + "/"
			URL = URL.slice(URL.indexOf("/")+1,URL.length+1)
		}
	}
	return(SortieSTR + "</span>")
}

function openVisite(urlArt)
{
	newWindow = window.open(urlArt,"Article","width=600,height=370,innerWidth=600,innerHeight=350,scrollbars=0,resizable=0,dependent,screenX=50, screenY=50,titlebar=no");
	newWindow.focus();
	}

function openFlash(urlArt)
{
	newWindow = window.open(urlArt,"Article","width=600,height=450,innerWidth=600,innerHeight=450,scrollbars=0,resizable=0,dependent,screenX=50, screenY=50,titlebar=no");
	newWindow.focus();
	}


function openMulti(urlArt)
{
	newWindow = window.open(urlArt,"Article","width=700,height=600,innerWidth=700,innerHeight=600,scrollbars=0,resizable=0,dependent,screenX=50, screenY=50,titlebar=no");
	newWindow.focus();
	}



function openWin(urlArt,larg,lng)
{
	newWindow = window.open(urlArt,"Article","width="+larg+",height="+lng+",innerWidth="+larg+",innerHeight="+lng+",scrollbars,resizable=1,");
	newWindow.focus();
	}

function swapImg(urlImg,nameImg)
{
	if (document.images)
	{
		document.images[nameImg].src = urlImg;
	}
}

function imprimer()
{
	if (window.print())
	{
		window.print();
	}
}

function sendForm()
  {


//  	alert("sendForm");
    // Variable du texte de confirmation
  var TxtConf = '' ;
// crée la variable de langue
 	if (!arguments[0])
	{
		var lang='fr'
	}
	else
	{
		var lang = arguments[0].toLowerCase() ;
	}
// remplit la variable de texte de confirmation
	if (lang == 'fr')    TxtConf = "Souhaitez-vous confirmer votre paiement ?" ;
	if (lang == 'uk')    TxtConf = "Would you like to confirm your payment ?"  ;
	if (lang == 'us')    TxtConf = "Would you like to confirm your payment ?"  ;
	if (lang == 'es')    TxtConf = "¿ Quiere Usted confirmar su pago ?"        ;
	if (lang == 'de')    TxtConf = "Bitte bestätigen Sie Ihre Zahlung"         ;
	if (lang == 'nl')    TxtConf = "Wilt U uw betaling bevestigen ?"           ;
	if (lang == 'it')    TxtConf = "Desiderate confermare il vostro pagamento?";
	if (lang == 'qc')    TxtConf = "Souhaitez-vous confirmer votre paiement ?" ;
	if (lang == 'ca')    TxtConf = "Would you like to confirm your payment ?"  ;


// ajouté pour prendre en compte le débridage de produits en uk, Italien, Espagnol, anglais US
	if (lang == 'debuk')    TxtConf = "Would you like to confirm your payment ?"  ;
	if (lang == 'debus')    TxtConf = "Would you like to confirm your payment ?"  ;
	if (lang == 'debit')    TxtConf = "Desiderate confermare il vostro pagamento?";
	if (lang == 'debes')    TxtConf = "¿ Quiere Usted confirmar su pago ?"        ;
	if (lang == 'debfr')    TxtConf = "Souhaitez-vous confirmer votre paiement ?" ;
	if (lang == 'debde')    TxtConf = "Bitte bestätigen Sie Ihre Zahlung"         ;
	if (lang == 'debus')    TxtConf = "Would you like to confirm your payment ?"  ;
	if (lang == 'debqc')    TxtConf = "Souhaitez-vous confirmer votre paiement ?" ;
	if (lang == 'debca')    TxtConf = "Would you like to confirm your payment ?"  ;


// ajouté le 10/10/2001 pour NetGammon
	if (lang == 'nguk')    TxtConf = "Would you like to confirm your payment ?"  ;
	if (lang == 'ngus')    TxtConf = "Would you like to confirm your payment ?"  ;
	if (lang == 'ngit')    TxtConf = "Desiderate confermare il vostro pagamento?";
	if (lang == 'nges')    TxtConf = "¿ Quiere Usted confirmar su pago ?"        ;
	if (lang == 'ngfr')    TxtConf = "Souhaitez-vous confirmer votre paiement ?" ;
	if (lang == 'ngde')    TxtConf = "Bitte bestätigen Sie Ihre Zahlung"         ;
	if (lang == 'ngus')    TxtConf = "Would you like to confirm your payment ?"  ;

// ajouté pour prendre en compte la page d'achat par courrier et fax et chèque

  if (arguments[1] == "coufaxchq")
	{
	  formOk = chkForm(lang,'mainform','nom','adr1','cp','ville','eml');
	  // vérifie le formOK
	  if (formOk)
		{
		  if (flag == 0)
			{
				//ShowLayer(lang) ;
				setTimeout("document.mainform.submit()",100);
				flag = 1;
			}
	    }
	}
  else
	{
	formOk = chkForm(lang,'mainform','nom','adr1','cp','ville','eml');
	// vérifie le formOK
	if (formOk)
	{
		document.mainform.submit();
		flag=1;
		//if (confirm(TxtConf)) // demande confirmation
		//{
		 // if (flag == 0)
		//	{
				//ShowLayer(lang) ;
				//setTimeout("document.mainform.submit()",2000);
		//		flag = 1;
	//		}
	  //}
	}
	}

}


function sendFormMin(lng)
 {
	if (!lng) lng='fr';
	formOk = chkForm(lng,'mainform','nom','adr1','cp','ville','eml');

	if (formOk) {
		if (flag == 0){
			setTimeout("document.mainform.submit()",1000);
			flag = 1;
		}
	}
 }

// FONCTION POUR EFFACER LES BOUTONS DANS ACHLI.ASP
function ShowLayer()
{
	if (document.getElementById)
	{
		if (document.getElementById("cache"))
		{
			//alert ('Langue=' + lng);
			//var ctn = '<table width="100%" cellPading=0 cellSpacing="0" border="0" id="cache" bgcolor="#003366"  ><tr>';
			//ctn += '<td align=center><img src="/fr/images/paiement/veuillez-patienter.gif" alt="Veuillez patienter."></td>';
			//ctn += '</tr></table>';
			//document.getElementById("cache").innerHTML = ctn;
			if (lng == "fr")
			{
			document.getElementById("cache").innerHTML = "<img src='/img/paiement/veuillez-patienter.gif' alt='Veuillez patienter.'>";
			}
			else
			{
			document.getElementById("cache").innerHTML = "<img src='/img/paiement/us-veuillez-patienter.gif' alt='Veuillez patienter.'>";
			}
		}
	}
}


function setCookie (name, value)
{
  var ojourdhui  = new Date() ;
  var expiration = new Date() ;
  expiration.setTime(ojourdhui.getTime() + 1000 * 60 * 60 * 24 * 60)
  document.cookie = name + "=" + escape (value) +"; path=/ ; expires=" + expiration.toGMTString();
}

function getCookie(name)
{
  var dcookie = document.cookie;
  var cname = name + "=";
  var clen = dcookie.length;
  var cbegin = 0;

	while (cbegin < clen)
	{
		var vbegin = cbegin + cname.length;
		if (dcookie.substring(cbegin, vbegin) == cname)
		{
			var vend = dcookie.indexOf (";", vbegin);
			if (vend == -1)
			{
				vend = clen;
			}
		return (unescape(dcookie.substring(vbegin, vend)));
		}
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
		if (cbegin == 0)
		{
			break ;
		}
	}
	return null;
}

function setCookieArray(name)
{
	this.length = setCookieArray.arguments.length - 1;
  for (var i = 0; i < this.length; i++)
	{
  	data = setCookieArray.arguments[i + 1]
    setCookie (name + i, data);
  }
}

function getCookieArray(name)
{
	var i = 0;
	while (getCookie(name + i) != null)
	{
		this[i + 1] = getCookie(name + i);
		i++; this.length = i;
	}
}

//FONCTIONS DE VERIFICATION DES FORMULAIRES
function chkField(champ){
	var toReturn=true;
	if(document.obli.length != 0){
		var bool = new Number(0)
		var i=0;
		while( i < document.obli.length){
			if(champ == document.obli[i]){
				if(champ == "email" || champ == "eml" || champ == "destemail"){
					var email = document.forms[0].elements[champ].value;
					if (!testEmail(email)){
						bool += 1;
						alertMsg(champ,'fr');
						break ;
					}
				}else if(document.forms[0].elements[champ].name == document.obli[i]){
					if(document.forms[0].elements[champ].value == ""){
						bool += 1;
						alertMsg(champ,'fr');
						break ;
					}
				}
			}
			i++;
		}
	}else{
		alert("Pas de document.obli") ;
	}
	if(bool == 0){
		toReturn=true;
	}else{
		toReturn=false;
	}
	return toReturn;
}


function chkForm(){
  nbChamp = arguments.length; // compte le nombre de champs renvoyés
	var champ = new Array();
	var flag = true ;
	var start;
	if (nbChamp > 1 )
	{
		if (arguments[0]=='fr' || arguments[0]=='uk' || arguments[0]=='de' || arguments[0]=='es' || arguments[0]=='it' || arguments[0]=='ca' || arguments[0]=='qc' || arguments[0]=='us' || arguments[0]=='pl')
		{
			lng = arguments[0];
			formName = arguments[1];
			start = 2 ;
		}
		else  // Si la langue n'est pas précisée, le français est choisi par defaut ...
		{
			lng = 'fr';
			formName = arguments[0];
			start = 1 ;
		}
	// démarre la vérification en faisant une boucle, si un champ est vide la boucle est arrêtée et un message d'alerte est renvoyé
		if (flag) {
			for ( var a = start ; a < nbChamp ; a++)
			{
				//alert( arguments[a] );

				if (arguments[a] == 'eml' || arguments[a] == 'email' || arguments[a] == 'destemail')
				// vérifie si le champs est un email
				{
					var email = document.forms[formName].elements[arguments[a]].value;
				//alert(email);
					if (!testEmail(email))
					{
						flag = false;
						alertMsg(arguments[a],lng);
						document.forms[formName].elements[arguments[a]].focus();
						break;
					}
				}

				if (arguments[a] == 'cardnumber')
				{
					//alert("verif cardnumber");
					document.forms[formName].elements[arguments[a]].value = StrReplace( document.forms[formName].elements[arguments[a]].value ," ","")
				}
				else
				// autres cas de champs
				{
					var valChamp = document.forms[formName].elements[arguments[a]].value;
					valChamp = RemplaceQuote(valChamp);
					if ((document.forms[formName].elements[arguments[a]].name == 'cgv') && (document.forms[formName].elements[arguments[a]].checked == false)) 
					{
						flag = false;
						alertMsg(arguments[a],lng);
						break;
					}
					
					if ((document.forms[formName].elements[arguments[a]].name == 'mention_liberte') && (document.forms[formName].elements[arguments[a]].checked == false)) 
					{
						flag = false;
						alertMsg(arguments[a],lng);
						break;
					}
					
					if (valChamp == "")
					{
						flag = false;
						alertMsg(arguments[a],lng);
						document.forms[formName].elements[arguments[a]].focus();
						break;
					}
				}
				// fin de vérification
			}
		}
	}
	else
	{
		flag=true;
	}
	return flag;
}
// FONCTION QUI RENVOIE LES MESSAGES D'ERREUR DANS LA SAISIE DES CHAMPS DE FORMULAIRES
function alertMsg(champ,langue)
{  // Vérifie que le champs appartient à la liste des textes
if (langue == "fr" || !langue || langue == "debfr" || langue == "ngfr" )
	{
		//alert ("fr")
		if (!testChamps(champ))
		{
			if ((champ ==  "nom") || (champ == "livr_nom"))     alert('Vous n\'avez pas saisi votre nom.');
			if ((champ ==  "prenom") || (champ ==  "livr_prenom"))  alert('Vous n\'avez pas saisi votre prénom.');
			if (champ ==  "objet")   alert('Vous n\'avez pas saisi de sujet.');
			if (champ ==  "eml")     alert('N\'oubliez pas de saisir correctement votre adresse email.');
			if (champ ==  "eml2")     alert('N\'oubliez pas de confirmer votre adresse email.');
			if (champ ==  "pwd")     alert('Veuillez saisir un mot de passe.');
			if (champ ==  "pwd2")     alert('Veuillez confirmer le mot de passe');
			if (champ ==  "email")	 alert('Vous n\'avez pas saisi correctement votre adresse email.');
			if (champ ==  "destemail")	 alert('Vous n\'avez pas saisi correctement l\'e-mail du destinataire.');
			if (champ ==  "msg")     alert('Vous n\'avez pas saisi de message.');
			if ((champ ==  "adr1") || (champ ==  "livr_adr1"))    alert('Vous n\'avez pas saisi votre adresse.');
			if (champ ==  "tel")     alert('Vous n\'avez pas saisi votre numéro de téléphone.');
			if (champ ==  "fax")     alert('Vous n\'avez pas saisi votre numéro de fax.');
			if ((champ ==  "cp") || (champ ==  "livr_cp"))      alert('Vous n\'avez pas saisi votre code postal.');
			if ((champ ==  "ville") || (champ ==  "livr_ville"))   alert('Vous n\'avez pas saisi votre ville.');
			if (champ ==  "version") alert('Vous n\'avez pas sélectionné votre version.');
			if (champ ==  "type")    alert('Vous n\'avez pas sélectionné le type de votre version.');
			if (champ ==  "modem")   alert('Vous n\'avez pas saisi votre modem.');
			if (champ ==  "driver")  alert('Vous n\'avez pas saisi les drivers.');
			if (champ ==  "cardnumber") alert('Vous n\'avez pas saisi votre numéro de carte bleue.');
			if (champ ==  "logver")  alert('N\'oubliez pas de saisir la version de votre logiciel');
			if (champ ==  "societe") alert('Vous n\'avez pas saisi le nom de votre société.');
			if (champ ==  "soc") alert('Vous n\'avez pas saisi le nom de votre société.');
			if (champ ==  "ste") alert('Vous n\'avez pas saisi le nom de votre société.');
			if (champ == "fonction") alert('Vous n\'avez pas saisi votre fonction.');
			if (champ == "magazines") alert ('Vous n\'avez pas saisi de magazine(s).');
			if (champ == "WinVer") alert ('Vous n\'avez pas indiqué votre version de Windows.');
			if (champ == "prd") alert ('Vous n\'avez pas indiqué votre produit.');
			if (champ == "fonction") alert ('Vous n\'avez pas indiqué votre fonction.');
			if (champ == "login") alert ('Vous n\'avez pas indiqué votre login.');
			if (champ == "tvaintra") alert ('Vous n\'avez pas indiqué votre n° de TVA Intracommunautaire.');
			if (champ == "civilite") alert ('Vous n\'avez pas indiqué votre civilité.');
			if (champ == "genre") alert ('Vous n\'avez pas indiqué votre civilité.');
			if (champ == "lic1") alert ('Vous n\'avez pas indiqué votre licence.');
			if (champ == "lic2") alert ('Vous n\'avez pas indiqué votre licence.');
			if (champ == "lic3") alert ('Vous n\'avez pas indiqué votre licence.');
			if (champ == "lic4") alert ('Vous n\'avez pas indiqué votre licence.');
			if (champ == "password") alert ('Vous n\'avez pas indiqué votre mot de passe.');
			if (champ == "cgv") alert('Veuillez lire et accepter les Conditions Générales de Vente.');
			if (champ == "nif") alert('Veuillez saisir un n° d\'identification fiscale');
			if (champ == "mention_liberte") alert('Veuillez accepter la mention concernant les formules mensuelles "Liberté"');
		 } // il est pas dans la liste des champs :
		else alert('Vous n\'avez pas rempli tous les champs du formulaire.');
	}
	else
		{
			if (langue == "de")
			{
				if (!testChamps(champ))
				{
				 if ((champ ==  "nom") || (champ == "livr_nom"))     alert('Sie haben keinen Namen eingegeben .');
			   if ((champ ==  "prenom") || (champ ==  "livr_prenom"))  alert('Sie haben keinen Vornamen eingegeben.');
			   if (champ ==  "objet")   alert('Sie haben keinen Betreff eingegeben.');
			   if (champ ==  "eml")     alert('Vergessen Sie nicht Ihre Email Adresse einzugeben.');
			   if (champ ==  "eml2")     alert('Vergessen nicht Ihre E-Mail zu bestätigen');
			   if (champ ==  "pwd")     alert('Geben Sie bitte ein Passwort ein.');
				 if (champ ==  "pwd2")     alert('Bestätigen Sie bitte dieses Passwort');
			   if (champ ==  "email")   alert('Ihre Email Adresse ist ungültig.');
			   if (champ ==  "destemail")          alert('Die Email Adresse des Empfängers ist ungültig.');
			   if (champ ==  "msg")     alert('Sie haben keine Nachricht eingegeben.');
			   if ((champ ==  "adr1") || (champ ==  "livr_adr1"))    alert('Sie haben keine Adresse eingegeben.');
			   if (champ ==  "tel")     alert('Sie haben keine Telefonnummer eingegeben.');
			   if (champ ==  "fax")     alert('Sie haben keine Faxnummer eingegeben.');
			   if ((champ ==  "cp") || (champ ==  "livr_cp"))      alert('Sie haben keinen PLZ eingegeben.');
			   if ((champ ==  "ville") || (champ ==  "livr_ville"))   alert('Sie haben Ihre Stadt nicht eingegeben.');
			   if (champ ==  "version") alert('Sie haben Ihre Version nicht gewählt.');
			   if (champ ==  "type")    alert('Sie haben keinen Versionstyp gewählt.');
			   if (champ ==  "modem")   alert('Sie haben Ihr Modem nicht eingegeben.');
			   if (champ ==  "driver")  alert('Sie haben die Drivers nicht eingegeben.');
			   if (champ ==  "cardnumber") alert('Sie haben Ihre Kreditkartenummer nicht eingegeben.');
			   if (champ ==  "logver")  alert('Vergessen Sie nicht, die Version Ihrer Software einzugeben');
			   if (champ ==  "societe") alert('Sie haben den Namen Ihrer Firma nicht eingegeben.');
			   if (champ ==  "soc") alert('Sie haben den Namen Ihrer Firma nicht eingegeben.');
			   if (champ ==  "ste") alert('Sie haben den Namen Ihrer Firma nicht eingegeben.');
			   if (champ == "fonction") alert('Sie haben Ihre Position nicht eingegeben.');
			   if (champ == "magazines") alert ('Sie haben keinen Magazin gewählt');
			   if (champ == "WinVer") alert ('Sie haben Ihre Windows Version nicht eingegeben');
			   if (champ == "prd") alert ('Sie haben Ihr Produkt nicht eingegeben');
			   if (champ == "fonction") alert ('Sie haben Ihre Position nicht eingegeben.');
			   if (champ == "login") alert ('Sie haben Ihr Login nicht eingegeben.');
			   if (champ == "tvaintra") alert ('Sie haben Ihre Ust.-ID Nummer nicht eingegeben.');
			   if (champ == "civilite") alert ('Sie haben Ihre Anrede nicht eingegeben.');
			   if (champ == "genre") alert ('Sie haben Ihre Anrede nicht eingegeben.');
			   if (champ == "lic1") alert ('Sie haben Ihre Lizenz nicht eingegeben.');
			   if (champ == "lic2") alert ('Sie haben Ihre Lizenz nicht eingegeben.');
			   if (champ == "lic3") alert ('Sie haben Ihre Lizenz nicht eingegeben.');
			   if (champ == "lic4") alert ('Sie haben Ihre Lizenz nicht eingegeben.');
			   if (champ == "password") alert ('Sie haben Ihr Passwort nicht eingegeben');
			   if (champ == "nif") alert('Sie haben Ihr Umsatzsteuer-Identifikationsnummer nicht eingegeben');
			} else alert('Sie haben nicht alle Felder ausgefüllt');

			}
			else
				{
					if (langue == "es")
					{
						if (!testChamps(champ))
						{
	             if ((champ ==  "nom") || (champ == "livr_nom"))     alert('No ha introducido su apellido.');
	             if ((champ ==  "prenom") || (champ ==  "livr_prenom"))  alert('No ha introducido su nombre.');
	             if (champ ==  "objet")   alert('No ha introducido el asunto.');
	             if (champ ==  "eml")     alert('Introduzca correctamente su dirección de email.');
	             if (champ ==  "eml2")     alert('Confirme su dirección de email.');
	             if (champ ==  "pwd")     alert('Introduzca una contraseña. ');
	             if (champ ==  "pwd2")     alert('Confirme la contraseña.');
	             if (champ ==  "email")   alert('No ha introducido correctamente su dirección de email.');
	             if (champ ==  "destemail")          alert('No ha introducido correctamente la dirección de email del destinatario.');
	             if (champ ==  "msg")     alert('No ha introducido ningún contenido en el mensaje.');
	             if ((champ ==  "adr1") || (champ ==  "livr_adr1"))    alert('No ha introducido su dirección.');
	             if (champ ==  "tel")     alert('No ha introducido su número de teléfono.');
	             if (champ ==  "fax")     alert('No ha introducido su número de fax.');
	             if ((champ ==  "cp") || (champ ==  "livr_cp"))      alert('No ha introducido su código postal.');
	             if ((champ ==  "ville") || (champ ==  "livr_ville"))   alert('No ha introducido su población.');
	             if (champ ==  "version") alert('No ha introducido la versión.');
	             if (champ ==  "type")    alert('No ha seleccionado la categoría de la versión.');
	             if (champ ==  "logver")  alert('Introduzca la versión del programa');
	             if (champ ==  "societe") alert('No ha introducido el nombre de su empresa.');
	             if (champ ==  "soc") alert('No ha introducido el nombre de su empresa.');
	             if (champ ==  "ste") alert('No ha introducido el nombre de su empresa.');
	             if (champ == "WinVer") alert ('No ha seleccionado su versión de Windows');
	             if (champ == "prd") alert ('No ha seleccionado el producto.');
	             if (champ == "login") alert ('No ha introducido su login.');
	             if (champ == "tvaintra") alert ('No ha introducido su número de IVA intracomunitario.');
	             if (champ == "civilite") alert ('No ha seleccionado su tratamiento.');
	             if (champ == "genre") alert ('No ha seleccionado su tratamiento.');
	             if (champ == "lic1") alert ('No ha introducido su número de licencia.');
	             if (champ == "lic2") alert ('No ha introducido su número de licencia.');
	             if (champ == "lic3") alert ('No ha introducido su número de licencia.');
	             if (champ == "lic4") alert ('No ha introducido su número de licencia.');
	             if (champ == "password") alert ('No ha introducido su contraseña.');
	             if (champ == "cgv") alert('Lea y confirme las condiciones de uso.');
	             if (champ == "nif") alert('No ha introducido su NIF.');
	             if (champ == "mention_liberte") alert('Lea y confirme la información acerca de las suscripciones mensuales.');
					} else alert('Faltan campos a rellenar en el formulario.');
		
					}
					else {
						if (!testChamps(champ))
						{
							if ((champ ==  "nom") || (champ == "livr_nom"))     alert('You didn\'t provide your last name');
							if ((champ ==  "prenom") || (champ ==  "livr_prenom"))  alert('You didn\'t provide your first name');
							if (champ ==  "objet")   alert('You didn\'t provide a subject');
							if (champ ==  "eml")     alert('You didn\'t provide your email address');
							if (champ ==  "eml2")     alert('You didn\'t confirm your email address');
							if (champ ==  "pwd")     alert('Please choose a password');
						  if (champ ==  "pwd2")     alert('Please confirm the password');
							if (champ ==  "email")	 alert('You didn\'t provide your email address');
							if (champ ==  "destemail")	 alert('You didn\'t provide an email address');
							if (champ ==  "msg")     alert('You didn\'t provide the message');
							if ((champ ==  "adr1") || (champ ==  "livr_adr1"))    alert('You didn\'t provide your address');
							if (champ ==  "tel")     alert('You didn\'t provide your phone number');
							if (champ ==  "fax")     alert('You didn\'t provide your fax number');
							if ((champ ==  "cp") || (champ ==  "livr_cp"))     alert('You didn\'t provide your zipcode');
							if ((champ ==  "ville") || (champ ==  "livr_ville"))   alert('You didn\'t provide your city');
							if (champ ==  "logver")  alert('You didn\'t provide your software\'s version');
							if (champ ==  "societe") alert('You didn\'t provide your company');
							if (champ ==  "soc") 		 alert('You didn\'t provide your company');
							if (champ ==  "ste") 		 alert('You didn\'t provide your company');
							if (champ == "fonction") alert('You didn\'t provide your job title');
							if (champ == "WinVer") 	 alert('You didn\'t provide your Windows version');
							if (champ == "tvaintra") alert('You didn\'t provide your European VAT number');
							if (champ == "civilite") alert('You didn\'t provide your title');
							if (champ == "genre") alert('You didn\'t provide your title');
							if (champ == "lic1") 		 alert('You didn\'t provide your licence number');
							if (champ == "lic2") 		 alert('You didn\'t provide your licence number');
							if (champ == "lic3") 		 alert('You didn\'t provide your licence number');
							if (champ == "lic4") 		 alert('You didn\'t provide your licence number');
							if (champ == "password") alert('You didn\'t provide your password');
							if (champ == "nif") alert('You didn\'t provide your Tax Identification Number');
							if (champ == "cgv") alert('You have to agree with the terms of use');
						 } // il est pas dans la liste des champs :
						else 		 alert('You didn\'t provide all the required fields');
					}
				}
		}
}

// FONCTION QUI TEST LE NOM DES CHAMPS VERIFIES
function testChamps(){ // La liste des champs qui ont un texte associé
	var toReturn=true;
	var ChampArray = new Array("nom","prenom","objet","eml","eml2", "pwd", "pwd2", "email","msg","adr1","tel","fax","cp","ville","version","type","modem","driver","cardnumber","logver","societe","destemail", "WinVer", "soc", "prd", "fonction", "login", "ste", "tvaintra", "civilite", "lic1", "lic2", "lic3","lic4","password","genre","livr_nom", "livr_prenom", "livr_adr1", "livr_cp", "livr_ville", "cgv", "mention_liberte", "nif");
	var j = 0 ;
	for (i=0;i < ChampArray.length ;i++){ // Si le nom de champs appartient à la liste, on incrémente
		if(arguments[0] == ChampArray[i]){j++;}
	}  // et un return.

	if(j != 0){
		toReturn=false;
	}else{
		toReturn=true;
	}
	return toReturn;
}

// Fonction pour remplacer les ' par des ´
function RemplaceQuote(Str){
	while (Str.indexOf("'") > 0){
		var IndexQuote = Str.indexOf("'");
		var LeftStr = Str.slice(0,IndexQuote);
		var RightStr = Str.slice(IndexQuote + 1 ,Str.length + 1 );
		Str = LeftStr + "´" + RightStr;
	}
	return (Str);
}

// FONCTIONS DE VERIFICATION D'EMAIL
// est LocalPart
function isLocalPart(STR){
	if (isDotString(STR)){
		return(true) ;
	}else{
		return(false) ;
	}
}


// est Domaine
function isDomaine(STR){
	var POINT = STR.indexOf(".")
	var IncDom = 0 ;
	if(POINT > 0){
		//alert ('IL Y A UN POINT ' + POINT)
		var LeftPart = STR.slice(0,POINT);// alert(LeftPart) ;
		var RightPart = STR.slice(POINT + 1 , STR.length); //  alert (RightPart) ;
		if (!isName(LeftPart)){
			IncDom++ ; // alert(LeftPart + ' = Left N\'est pas un isName + ' + IncDom)
		}
		if(!(isDomaine(RightPart) || isString(RightPart))){
			IncDom++; // alert(RightPart + ' = Right Part n\'est pas un isName' + IncDom)
		}
	}else{
		IncDom++ ; // alert ( STR + 'N\' est pas isName' + IncDom)
	}
	if(IncDom == 0){
		return true;
	}else{
		return false;
	}
}

// est ldh-str
function isLdhStr(CAR){
	if (!(isLetDigHyp(CAR))){
		return(false) ;
	}else{
		return(true) ;
	}
}

// est let-Dig-Hyp
function isLetDigHyp(CAR){
  //  alert('entre dans isLetDigHyp(CAR)')
	if (!(isA(CAR) || isD(CAR) || (CAR == "-"))){
		// alert ('pas bon...') ;
		return false;
	}else{
		// alert("Cool ! Le char est une lettre, un chiffre ou un \"-\"") ;
		return true;
	}
}
// est un nombre ou une lettre [a..z] && [A..Z]
function isLetDig(CAR){
	if(!(isA(CAR) || isD(CAR))){
		return false;
	}else{
		return true;
	}
}

// est un Name
function isName(STR){
	var IncName = 0 ;
  // Vérifie que le 1er caractère de la chaine sont des [A..Z] ou [a..z]
	  if (! ( isC( STR.charAt(0) ) ) )
		{
			IncName++ ; //alert(IncName + ' ' + STR.charAt(i) + ' n\'est pas un A ')
		}
  // Vérifie que les caractères suivants sont des [a..z] || [A..Z] || [0..9] || "-"
  for (var IndName=1 ; IndName < STR.length ; IndName++)
  {
     if (! isLetDigHyp(STR.charAt(IndName)))
     {
       IncName++ ; //alert(IncName + ' ' + STR.charAt(i) + ' n\'est pas un LetDigHyp ')
     }
  }
  // vérifie que l'incrément est nul
  if (IncName == 0)
  {
    return(true)
  }
  else
  {
    return(false)
  }
}

// est une Chaine de caractères
function isString(STR)
{
  // alert('entre dans isString');
  var IncStr = 0 ;
	// alert("STR.length dans isString = " + STR.length);
  // vérifie chaque caractère de la chaine STR
	for (var IndStr=0; IndStr < STR.length ; IndStr++)
  {
		if (! (isC(STR.charAt(IndStr))) )
    {
      IncStr++ ;
    }
  }
	// test final
  if (IncStr == 0 )
  {
    return(true) ;
  }
  else
  {
    return(false) ;
  }
}

// est Dot-String
function isDotString(STR)
{
  var POINT = STR.indexOf(".");
  if (POINT > 0 )
  {
    var LeftPart = STR.slice(0,POINT);
    var RightPart = STR.slice(POINT + 1,STR.length);
    if ((isString(LeftPart)) && (isDotString(RightPart)))
    {
      return(true)
    }
    else
    {
      return(false)
    }
  }
  else
	{
    if (isString(STR))
    {
      return(true) ;
    }
		else
		{
		  return(false) ;
		}
  }
}



// est un caractère [a..z] | [A..Z]
function isA(CAR)
{
  // alert ("entredans isA(CAR)")
  if (((CAR >= "a") && (CAR <= "z")) ||  ((CAR >= "A") && (CAR <= "Z")))
  {
    // alert ("Le car est une lettre");
    return(true) ;
  }
  else
  {
    // alert ("Le car "+ CAR +"n'est pas une lettre");
    return(false)
  }
}

// Est un caractère Ascii 128 - (special && sp) ?
function isC(CAR)
{
  var IncC = 0;
  if ( (CAR.charCodeAt(0) == 127) || (CAR.charCodeAt(0) < 32) )
  {
    IncC++ ;
  }
  if (!isNotSpecial(CAR))
  {
    IncC++ ;
  }
  if ( IncC == 0)
  {
    return(true)
  }
  else
  {
    return(false)
  }
}

// est un caractère spécial ?
function isNotSpecial(CAR)
{
  // La liste des caractères spéciaux
  var Special = new Array("<",">","(",")","[","]","\\",".",",",";",":","#"," ","'","\"")
  // init des Incréments
  var IncSpecial = 0 ;
  var IncAutre = 0 ;
  for(var IndSpe=0;IndSpe < Special.length ; IndSpe++)
  {
		if (CAR == Special[IndSpe])
    {
      IncSpecial++ ;
    }
  }
	IncAutre+= IncSpecial ;
  if (IncAutre > 0)
  {
    return(false) ;
  }
  else
  {
    return(true) ;
  }
}

// est un Chiffre [0..9]
function isD(CAR)
{
  // alert("entre dans isD")
  if ((CAR >= "0") && (CAR <= "9"))
  {
		return(true)
  }
  else
  {
		return(false)
  }
}


// est une adresse email

function testEmail(chaine)
{
  // prépare es variables
  var IncEmail = 0 ;
	chaine = chaine.toLowerCase() ;
	var Arobace = chaine.indexOf("@") ;
	// Commence les tests : Arobace présente et pas en premier
	if (Arobace > 0 )
	{
    var LocalPart = chaine.slice(0,Arobace) ;
    var Domaine = chaine.slice(Arobace + 1,chaine.length) ;
    if ( !(isLocalPart(LocalPart)) || !(isDomaine(Domaine)) )
    {
      IncEmail++ ;
    }
  }
	else IncEmail++ ;
	if (IncEmail == 0)
	{
	  return(true)
	}
	else
	{
	  return(false)
  }
}
