// Javascript file

// Correctif de l'affichage des images PNG dans IE5.5 et IE6 (transparent pour les autres navigateurs).
// V1.1 par Brice de Villeneuve, http://www.boursica.com/
// Licence : freeware, librement utilisable du moment que vous laissez ces commentaires dans votre source.
// Mettre ce script dans le head et dans les balises IMG ajouter simplement : onload='setpng(this)'
// Si l'image n'est pas visible (display:none par exemple), appeler la fonction juste après l'affichage de l'image
// dans un javascript avec, par exemple, un setpng(document.getElementById('idDeMonImage');

function setpng(img) { 

	if (document.all && (IEver=parseFloat(navigator.appVersion.split("MSIE")[1])) && (IEver>=5.5) && (IEver<7) && document.body.filters && img)
	{
		imgName=img.src.toUpperCase();
		
		if (imgName.substring(imgName.length-3,imgName.length)=="PNG") img.outerHTML="<span "+(img.id?"id='"+img.id+"' ":"")+(img.className?"class='"+img.className+"' ":"")+(img.title?"title=\""+img.title+"\" ":"")+"style=\"width:"+img.width+"px;height:"+img.height+"px;"+(img.align=="left"?"float:left;":(img.align=="right"?"float:right;":""))+(img.parentElement.href?"cursor:hand;":"")+"display:inline-block;"+img.style.cssText+";"+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.src+"',sizingMethod='scale');\"></span>";
		
	}
	
}

anim = false;		// l'animation des produits n'a pas encore été jouée

// FONCTIONS POSITIONNEMENT CSS		// FONCTIONS POSITIONNEMENT CSS		// FONCTIONS POSITIONNEMENT CSS		// FONCTIONS POSITIONNEMENT CSS

function CssCorrections() {

	if (navigator.appName == "Netscape")
	{
		//alert("Netscape !");
		document.getElementById("infos").style.marginTop = "-20px";
	}
}

// FONCTIONS DES MENUS LISTES	// FONCTIONS DES MENUS LISTES	// FONCTIONS DES MENUS LISTES	// FONCTIONS DES MENUS LISTES

// POUR L'APPARITION DES TITRES DES MENUS

function Show_menus() {
	
	//	alert('Fonction Show_menus()');
		
	anim = true;
	
	if	(document.all)	// si IE
	{
		//alert('Explorer');
		
		document.all.titre_menu1.style.display = "inline";
		document.all.titre_menu2.style.display = "inline";
		document.all.titre_menu3.style.display = "inline";
		document.all.titre_menu4.style.display = "inline";
		document.all.titre_menu5.style.display = "inline";
		document.all.titre_menu6.style.display = "inline";
		document.all.titre_menu7.style.display = "inline";
		document.all.titre_menu8.style.display = "inline";
		document.all.titre_menu9.style.display = "inline";
	}
	else
	{
		titre_menu1 = document.getElementById("titre_menu1");
		titre_menu2 = document.getElementById("titre_menu2");
		titre_menu3 = document.getElementById("titre_menu3");
		titre_menu4 = document.getElementById("titre_menu4");
		titre_menu5 = document.getElementById("titre_menu5");
		titre_menu6 = document.getElementById("titre_menu6");
		titre_menu7 = document.getElementById("titre_menu7");
		titre_menu8 = document.getElementById("titre_menu8");
		titre_menu8 = document.getElementById("titre_menu9")
		
		titre_menu1.style.height = "0px";
		titre_menu1.style.display = "inline";
		
		titre_menu2.style.height = "0px";
		titre_menu2.style.display = "inline";
		
		titre_menu3.style.height = "0px";
		titre_menu3.style.display = "inline";
		
		titre_menu4.style.height = "0px";
		titre_menu4.style.display = "inline";
		
		titre_menu5.style.height = "0px";
		titre_menu5.style.display = "inline";
		
		titre_menu6.style.height = "0px";
		titre_menu6.style.display = "inline";
		
		titre_menu7.style.height = "0px";
		titre_menu7.style.display = "inline";
		
		titre_menu8.style.height = "0px";
		titre_menu8.style.display = "inline";
		
		titre_menu9.style.height = "0px";
		titre_menu9.style.display = "inline";
	}
	
	timer = window.setInterval("Apparition()",10);
	
}

size = 0;

function Apparition() {

	size = size + 2;
	
	titre_menu1.style.height = size+"px";
	titre_menu2.style.height = size+"px";
	titre_menu3.style.height = size+"px";
	titre_menu4.style.height = size+"px";
	titre_menu5.style.height = size+"px";
	titre_menu6.style.height = size+"px";
	titre_menu7.style.height = size+"px";
	titre_menu8.style.height = size+"px";
	titre_menu9.style.height = size+"px";
	
	if	(size == 18)
	{
		window.clearInterval(timer);
	}
}

function Show_menus_fixe() {

		titre_men1 = document.getElementById("titre_menu1");
		titre_men2 = document.getElementById("titre_menu2");
		titre_men3 = document.getElementById("titre_menu3");
		titre_men4 = document.getElementById("titre_menu4");
		titre_men5 = document.getElementById("titre_menu5");
		titre_men6 = document.getElementById("titre_menu6");
		titre_men7 = document.getElementById("titre_menu7");
		titre_men8 = document.getElementById("titre_menu8");
		titre_men9 = document.getElementById("titre_menu9");
		
		titre_men1.style.display = "inline";
		titre_men2.style.display = "inline";
		titre_men3.style.display = "inline";
		titre_men4.style.display = "inline";
		titre_men5.style.display = "inline";
		titre_men6.style.display = "inline";
		titre_men7.style.display = "inline";
		titre_men8.style.display = "inline";
		titre_men9.style.display = "inline";
}

// POUR L'APPARITION ET DISPARITION DES ITEMS DE MENUS

visible1 = false;
visible2 = false;
visible3 = false;
visible4 = false;
visible5 = false;
visible6 = false;
visible7 = false;
visible8 = false;
visible9 = false;

timer1 = null;
timer2 = null;
timer3 = null;
timer4 = null;
timer5 = null;
timer6 = null;
timer7 = null;
timer8 = null;
timer9 = null;

function Show1() {

	clearInterval(timer1);
	
	if (visible1 == false)
	{
		document.getElementById("menu1").style.display = "block";
		visible1 = true;
	}
}

function Hide1() {

	if (visible1 == true)
	{
		//window.setTimeout(function() {document.getElementById("menu1").style.display = "none";},250);
		
		timer1 = setInterval(function() {document.getElementById("menu1").style.display = "none";visible1 = false;clearInterval(timer1);},250);
	}
}

///////

function Show2() {

	clearInterval(timer2);
	
	if (visible2 == false)
	{
		document.getElementById("menu2").style.display = "block";
		visible2 = true;
	}
}

function Hide2() {

	if (visible2 == true)
	{
		timer2 = setInterval(function() {document.getElementById("menu2").style.display = "none"; visible2 = false; clearInterval(timer2);},250);
	}
}

///////

function Show3() {

	clearInterval(timer3);
	
	if (visible3 == false)
	{
		document.getElementById("menu3").style.display = "block";
		visible3 = true;
	}
}

function Hide3() {

	if (visible3 == true)
	{
		timer3 = setInterval(function() {document.getElementById("menu3").style.display = "none"; visible3 = false; clearInterval(timer3);},250);
	}
}

///////

function Show4() {

	clearInterval(timer4);
	
	if (visible4 == false)
	{
		document.getElementById("menu4").style.display = "block";
		visible4 = true;
	}
}

function Hide4 () {

	if (visible4 == true)
	{		
		timer4 = setInterval(function() {document.getElementById("menu4").style.display = "none"; visible4 = false; clearInterval(timer4);},250);
	}
}

///////

function Show5() {

	clearInterval(timer5);
	
	if (visible5 == false)
	{
		document.getElementById("menu5").style.display = "block";
		visible5 = true;
	}
}

function Hide5() {

	if (visible5 == true)
	{		
		timer5 = setInterval(function() {document.getElementById("menu5").style.display = "none"; visible5 = false; clearInterval(timer5);},250);
	}
}

///////

function Show6() {

	clearInterval(timer6);
	
	if (visible6 == false)
	{
		document.getElementById("menu6").style.display = "block";
		visible6 = true;
	}
}

function Hide6() {

	if (visible6 == true)
	{
		timer6 = setInterval(function() {document.getElementById("menu6").style.display = "none"; visible6 = false; clearInterval(timer6);},250);
	}
}

///////

function Show7() {

	clearInterval(timer7);
	
	if (visible7 == false)
	{
		document.getElementById("menu7").style.display = "block";
		visible7 = true;
	}
}

function Hide7() {

	if (visible7 == true)
	{
		timer7 = setInterval(function() {document.getElementById("menu7").style.display = "none"; visible7 = false; clearInterval(timer7);},250);
	}
}

///////

function Show8() {

	clearInterval(timer8);
	
	if (visible8 == false)
	{
		document.getElementById("menu8").style.display = "block";
		visible8 = true;
	}
}

function Hide8() {

	if (visible8 == true)
	{
		timer8 = setInterval(function() {document.getElementById("menu8").style.display = "none"; visible8 = false; clearInterval(timer8);},250);
	}
}

///////

function Show9() {

	clearInterval(timer9);
	
	if (visible9 == false)
	{
		document.getElementById("menu9").style.display = "block";
		visible9 = true;
	}
}

function Hide9() {

	if (visible9 == true)
	{
		timer9 = setInterval(function() {document.getElementById("menu9").style.display = "none"; visible9 = false; clearInterval(timer9);},250);
	}
}


function Show_fiche_infos() {

	var flashMovie = getFlashMovieObject("fiche_infos_swf");
	flashMovie.Play();
}

function Show_fiche_infos_txt() {
	
	document.getElementById("fiche_infos_txt").style.display = "inline";
}


/////// FONCTIONS SUR LA FICHE PRODUIT

function getFlashMovieObject(movieName) {
	
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
	{
		return document.embeds[movieName]; 
	}
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}


deja_vu = false;
//alert(deja_vu);
old = null;
old_num = null;
num = null;

function Show_fiche(nbr) {

	num = nbr;
		
	// remise en noir du nom produit precedent et mise en rouge du nom produit actuel
	
	if (old_num != null)
	{
		document.getElementById("nom_produit0"+old_num).style.color = "#000000";
		document.getElementById("nom_produit0"+old_num).style.fontWeight = "normal";
	}
	
	document.getElementById("nom_produit0"+nbr).style.color = "red";
	document.getElementById("nom_produit0"+nbr).style.fontWeight = "bold";
	
	// apparition de la fiche
	
	if (deja_vu == false)
	{
		//alert('test');
		var flashMovie = getFlashMovieObject("fiche_swf");
		flashMovie.Play();
		
		window.setTimeout(function() {document.getElementById('fiche0'+nbr).style.display = "inline";},1300);

		deja_vu = true;
		old = "fiche0"+nbr;
		old_num = nbr;
	}
	else	// si l'anim d apparition de la fiche a déja été jouée, donc s'il y a déjà une fiche visible
	{
		if (old != null)
		{
			//timer_alpha = window.setInterval("Disparition_txt()",10);
			
			// enlever les quatre lignes de code ci-dessous si on réaffiche la ligne précédente
			
			document.getElementById("fiche0"+old_num).style.display = "none";
			
			window.setTimeout(function() {document.getElementById('fiche0'+num).style.display = "inline";},400);	
			
			old = "fiche0"+num;
			old_num = num;
		}
	}
}

alpha = 100;

function Disparition_txt() {

	//alert(alpha);
	
	alpha = alpha - 10;
	
	if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
	{
		//alert('test1');
    	document.getElementById("fiche0"+old_num).style.MozOpacity = alpha/100;
	}
	
	if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4)
    {
		//alert("test2");
		document.getElementById("fiche0"+old_num).filters.alpha.opacity = alpha;
	}
		
	if	(alpha <= 0)
	{
		//alert('fin');
		window.clearInterval(timer_alpha);
			
		document.getElementById("fiche0"+old_num).style.display = "none";		// on ne voit plus le texte mais il est tjs la, donc on l'enleve
		
		if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)	// on le remet a 100% pr la prochaine fois
		{ 
			//alert('test1');
			document.getElementById("fiche0"+old_num).style.MozOpacity = 100/100;
		}
		
		if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4)
		{
			//alert("test2");
			document.getElementById("fiche0"+old_num).filters.alpha.opacity = 100;
		}
		
		// on affiche la nouvelle
		
		window.setTimeout(function() {document.getElementById('fiche0'+num).style.display = "inline";},1300);	
		
		old = "fiche0"+num;
		old_num = num;
	}
}

//// FONCTIONS SUR LE FORMULAIRE


function Verif_form(F,lg) {

	control = true		// variable booleenne globale true si tt ok ds form
	
	chaine_fr = "Merci de corriger les entrees suivantes:\n\n";
	chaine_nl = "Dank u om deze informatie te verbeteren:\n\n";
	chaine_gb = "Thanks to correct these information:\n\n";
	
// VERIFICATION DU CHAMP SOCIETE

	var A = "<>@#'\"\\(§!)_$*¤=:/;";

	if	( (Caract_sp(F.soci.value,A) == false) || (F.soci.value =="") )
	{
		chaine_fr = chaine_fr + "- Societe\n";
		chaine_nl = chaine_nl + "- Vennootschap\n";
		chaine_gb = chaine_gb + "- Company\n";
		
		//Vider(F.soci);
		
		control = false;
	}

// VERIFICATION DU CHAMP NOM / PRENOM
	
	var A = "1234567890&<>@#\'\"§!)_$*¤=+:/;.,?";

	if	( (Caract_sp(F.nom.value,A) == false) || (F.nom.value =="") )
	{
		chaine_fr = chaine_fr + "- Nom / Prenom\n";
		chaine_nl = chaine_nl + "- Naam / Voornam\n";
		chaine_gb = chaine_gb + "- Fist name / last name\n";
		
		//Vider(F.nom);
		
		control = false;
	}

// VERIFICATION DU CHAMP FONCTION
	
	var A = "1234567890&<>@#\'\"§!)_$*¤=+:/;.,?";

	if	( (Caract_sp(F.fonction.value,A) == false) || (F.fonction.value =="") )
	{
		chaine_fr = chaine_fr + "- Fonction\n";
		chaine_nl = chaine_nl + "- Functie\n";
		chaine_gb = chaine_gb + "- Function\n";
		chaine_sp = chaine_sp + "- Función\n";
		chaine_de = chaine_de + "- Funktion\n";
		
		//Vider(F.nom);
		
		control = false;
	}
	
// VERIFICATION DU CHAMP MAIL
	
	if	(Verif_mail(F.mail.value,A) == false)
	{
		chaine_fr = chaine_fr + "- Email\n";
		chaine_nl = chaine_nl + "- Email\n";
		chaine_gb = chaine_gb + "- Email\n";
		
		//Vider(F.mail);
		
		control = false;
	}

// VERIFICATION DU CHAMP OBJET

	var A = "<>@#\\(§!)_$*¤=:/;";

	if	( (Caract_sp(F.objet.value,A) == false) || (F.objet.value =="") )
	{
		chaine_fr = chaine_fr + "- Objet\n";
		chaine_nl = chaine_nl + "- Objet\n";
		chaine_gb = chaine_gb + "- Subjet\n";
		
		//Vider(F.objet);
		
		control = false;
	}

// VERIFICATION DU CHAMP CONTENU

	if  (document.getElementById("textarea").value == "")
	{
		chaine_fr = chaine_fr + "- Contenu\n";
		chaine_nl = chaine_nl + "- Inhoud\n";
		chaine_gb = chaine_gb + "- Content\n";
		
		control = false;
	}

// ENVOI OU NON ENVOI DU FORMULAIRE

	if	(control == true)
	{
		F.submit();
	}
	else
	{
		if	(lg == "fr")
		{
			alert(chaine_fr);
		}
		
		if	(lg == "nl")
		{
			alert(chaine_nl);
		}
		
		if	(lg == "gb")
		{
			alert(chaine_gb);
		}
		
	}
	
}

function Vider(x)
{
	//alert(x.value);
	
	x.value = "";
}

function Caract_sp(x, caract)
{
	//alert(caract);
	
	var ok = true;				// ok est a true si pas de caract spéciaux
	
	var tab = caract.split("");
	
	var i;
	
	for	(i=0; i<tab.length; i++)
	{
		//alert(x.indexOf(tab[i]));
		if	(x.indexOf(tab[i]) != -1)
		{
			ok = false;
		}
	}
	
	return ok;
	
}

function Verif_mail(x)
{
	//alert(x);
	
	var at;
	var pt;
	var ok = true;
	var A = "<>@#'\"\\(§!)$*¤=+:/;";
	var user;
	var msg;
	
	at = x.indexOf("@");
	//alert(at);
	
	pt = x.lastIndexOf(".");
	//alert(pt);
	
	//alert(pt - at - 1);
	//alert((x.length) - pt - 1);

	if	( (pt - at - 1 == 0) || (at < 1) || ((x.length) - pt - 1 < 2) || ((x.length) - pt - 1 > 3) )
	{
		ok = false;
	}
	
	user = x.substring(0,at);
	msg = x.substring((at+1),pt);
	//alert(user);
	//alert(msg);
	
	if	( (Caract_sp(user,A) == false) || (Caract_sp(msg,A) == false) )
	{
		ok = false;
	}
	
	return ok;
}

function SetToFalse() {

	deja_vu = false;
}
