// -------------------- SWAPIMAGE --------------------
function swapImage(which,img) {
	eval('document.'+which+'.src = "'+img+'"');
}
var sdap = (document.all) ? true : false;

function getelem(idm){
	return elem = sdap ? document.all[idm] : document.getElementById(idm);
}
// -------------------- MENU --------------------
window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';setTimeout('montre()',6000);}
}

// -------------------- CARTE --------------------
window.onload=carte;
function carte(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('region'+i)) {document.getElementById('region'+i).style.display='none';}
	}
if (d) {d.style.display='block';}

}

window.onload=map;
function map(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('zone'+i)) {document.getElementById('zone'+i).style.display='none';}
	}
if (d) {d.style.display='block';}

}


// -------------------- OPENWINDOW --------------------
function openWindow(url,nom,dimx,dimy,type) {
	featur0 = "top=20,left=20,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+ dimx + ",height=" + dimy;
  featur1 = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+ dimx + ",height=" + dimy;
	featur2 = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+ dimx + ",height=" + dimy;
	props = eval('featur'+type);
	window.open(url,nom,props);
}

// -------------------- FORM --------------------
msgError = new Array();

function languageIndex(langue)
{	
	if(langue=="en") return 'anglais';
	if(langue=="es") return 'espagnol';
  if(langue=="de") return 'allemand';
	return 'francais';
}

var francais = languageIndex("fr");
var anglais =languageIndex("en");
var espagnol =languageIndex("es");
var allemand =languageIndex("de");

msgError[francais]=new Array();
msgError[anglais]=new Array();
msgError[espagnol]=new Array();
msgError[allemand]=new Array();

/******* Messages d'erreur ********/

msgError[francais][1] = 'La saisie de votre nom est obligatoire ';
msgError[anglais][1] = 'You must key in your name';
msgError[espagnol][1] = '¡Indique su nombre !';
msgError[allemand][1] = 'Die Angabe Ihres Namens ist obligatorisch';

msgError[francais][2] = 'Veuillez saisir votre prénom.';
msgError[anglais][2] = 'You must key in your first name';
msgError[espagnol][2] = '¡Indique su apellido !';
msgError[allemand][2] = 'Bitte geben Sie Ihren Vornamen an';

msgError[francais][3] = 'Veuillez saisir votre fonction.';
msgError[anglais][3] = 'You must key in your function';
msgError[espagnol][3] = '¡Indique su posición !';
msgError[allemand][3] = 'Bitte geben Sie Ihre Funktion an';

msgError[francais][4] = 'Veuillez saisir le nom de votre société.';
msgError[anglais][4] = 'You must key in the name of your company';
msgError[espagnol][4] = '¡Indique su empresa !';
msgError[allemand][4] = 'Bitte geben Sie den Namen Ihres Unternehmens an';

msgError[francais][5] = 'Veuillez saisir votre adresse.';
msgError[anglais][5] = 'You must key in your address';
msgError[espagnol][5] = '¡Indique su dirección !';
msgError[allemand][5] = 'Bitte geben Sie Ihre Adresse an';

msgError[francais][6] = 'Veuillez saisir votre pays.';
msgError[anglais][6] = 'You must key in your country';
msgError[espagnol][6] = '¡Indique su país !';
msgError[allemand][6] = 'Bitte geben Sie Ihr Land an';

msgError[francais][7] = 'Veuillez saisir votre numéro de téléphone.';
msgError[anglais][7] = 'You must key in your phone number';
msgError[espagnol][7] = '¡Indique su número de teléfono !';
msgError[allemand][7] = 'Bitte geben Sie Ihre Telefonnummer an';

msgError[francais][8] = 'Veuillez saisir votre numéro de fax.';
msgError[anglais][8] = 'You must key in your fax number';
msgError[espagnol][8] = '¡Indique su número de fax !';
msgError[allemand][8] = 'Bitte geben Sie Ihre Faxnummer an';

msgError[francais][9] = 'Veuillez vérifier que votre adresse e-mail est correctement saisie ';
msgError[anglais][9] = 'Please check that your e-mail address has been keyed in correctly';
msgError[espagnol][9] = '¡Indique su e-mail !';
msgError[allemand][9] = 'Bitte überprüfen Sie die Richtigkeit Ihrer Emailadresse';

msgError[francais][10] = 'Veuillez saisir un message';
msgError[anglais][10] = 'You must key in a message';
msgError[espagnol][10] = '¡Indique su consulta !';
msgError[allemand][10] = 'Bitte geben Sie hier Ihre Nachricht ein';


function formError(langue,error)
{
	alert(msgError[langue][error]);
	return false;
}

function mailValide(emailAdress)
{
	var ind;
	var indbis;
	var len;
	var sub;
	var check;
	//emailAdress = Trim(emailAdress);
	len = emailAdress.length;
	ind = emailAdress.indexOf("@");
	if(ind==-1) return false;
	sub = emailAdress.substring(++ind,len-ind);
	if(ind!=-1)
	{
		indbis = emailAdress.substring(ind+1,emailAdress.length).indexOf(".");
	}
	if (indbis<1) return false;
	//if (ind == sub.length-1) return false;
	sub = " \"~&#'{([`\\^)]}=+$%!§:;,?*/<>éèàçùâêîôûäïüöë";
	for (i = 0; i<len;i++)
	{	
		check = emailAdress.charAt(i);
		if (sub.indexOf(check) != -1) return false;
	}
	return true;
	
}

function nonVide(texte)
{	
	return (texte.length>0);
}

function checkContact(langue)
{

	langue=languageIndex(langue);
	var objFormulaire = document.formulaire;

	if(!nonVide(objFormulaire.nom.value)) return formError(langue,1);
	if(!nonVide(objFormulaire.prenom.value)) return formError(langue,2);
	if(!nonVide(objFormulaire.fonction.value)) return formError(langue,3);
	if(!nonVide(objFormulaire.societe.value)) return formError(langue,4);
	if(!nonVide(objFormulaire.adresse.value)) return formError(langue,5);
	if(!nonVide(objFormulaire.pays.value)) return formError(langue,6);	
	if(!nonVide(objFormulaire.tel.value)) return formError(langue,7);
	if(!nonVide(objFormulaire.fax.value)) return formError(langue,8);
	if(!nonVide(objFormulaire.email.value)) return formError(langue,9);
	if(!mailValide(objFormulaire.email.value)) return formError(langue,9);
	if(!nonVide(objFormulaire.message.value)) return formError(langue,10);
	document.formulaire.submit(); return true;
	
}



