//************************************************************************
//						Gestion JavaScript : BIOOTI
//************************************************************************
// Auteur : Abiotik / jean luc COSTAGLIOLA
// tous droits réservés
// contact : 04 67 57 03 72
//************************************************************************
// --------------------------------------- copyright abiotik 2009

//****************************************
// DESIGNATION RUB 
//****************************************

	var recup = window.document.location;
	var chaine = recup.toString();
	var ChaineVestax = chaine;
	var longueur = chaine.length;
	var resultat = chaine.indexOf('num=');
	chaine = chaine.substring(resultat+4,longueur);	
	var resultat2 = chaine.indexOf('&');
	if(resultat2 < 0){
		extract = chaine.substring(0,longueur);	
	}
	else{
		extract = chaine.substring(0,resultat2);	
	}	
	extract=extract.toString()


//--------------------------------------- designation rub
	
/*	
TABLEAU DE CORRESPONDANCE
PWB / Nom rub / rub abk

11	Soins Visage bio	1
21	Soins Corps bio		2
41	Hygiène bio			3
31	Soins Capillaires	4
51	Maquillage			5
71	Bébé				6
61	Homme				7
91	Santé 				8

*/
	
	
	var designRub = 0; 

	if (extract == 11)
		designRub = 1;
	else if(extract == 21)
		designRub = 2;
  	else if(extract == 41)
		designRub = 3;
  	else if(extract == 31)
		designRub = 4;	
  	else if(extract == 51)
		designRub = 5;		
  	else if(extract == 71)
		designRub = 6;		
  	else if(extract == 61)
		designRub = 7;		
  	else if(extract == 91)
		designRub = 8;		
	else
		designRub = 0;  

	
//*******************************
// gestion BAN ALEA
//*******************************
function banAlea(design,espace,parametres){

	if (eval(design)[0] != ""){
		var designImage, designDbtLien="",designFinLien="" ;
				
		aleaPub = (Math.random()*10/(10/eval(design).length));
		designBan = eval(eval(design)[Math.floor(aleaPub)]).image;
				
		if(eval(eval(design)[Math.floor(aleaPub)]).lien !='0'){
			designDbtLien='<a href="'+eval(eval(design)[Math.floor(aleaPub)]).lien+'">';
			designFinLien='</a>';
		}

	// affichage
		rechercheFormat = designBan.indexOf('.swf');
		if(rechercheFormat > 0){
			document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="100" id="test" align="middle">'
				+'<param name="allowScriptAccess" value="sameDomain" />'
				+'<param name="movie" value="../site/gestionClient/pub/images/'+designBan+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
				+'<embed src="../site/gestionClient/pubs/images/'+designBan+'" quality="high" bgcolor="#ffffff" width="550" height="100" name="test" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>'
				+'</object>');
		}
		else{
			document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'
				+'<td align="'+parametres+'">'+designDbtLien+'<img src="../site/gestionClient/pub/images/'+designBan+'" border="0">'+designFinLien+'</td>'
				+'</tr></table>');
		}	
		
		if(espace != 0)
			espaceur(espace,espace);
	}
}				



//*******************************
// gestion LIGNE GIF
//*******************************

function ligneGif(design,espace,parametres){
	var designImage, designDbtLien="",designFinLien="" ;

	if(eval(design)[0] != ""){

		document.write('<table width="100%" border="0" cellspacing="3" cellpadding="0"><tr>');
		
		for(i=0;i<eval(design).length; i++){
			if(eval(eval(design)[i]).lien !='0'){
				designDbtLien='<a href="'+eval(eval(design)[i]).lien+'">';
				designFinLien='</a>';
			}
			document.write('<td align="center" valign="middle">'+designDbtLien+'<img src="../site/gestionClient/pub/images/'+eval(eval(design)[i]).image+'" border="0">'+designFinLien+'</td>');
		}
		document.write('</tr></table>');
		
		if(espace != 0)		
			espaceur(espace,espace);	
	}
}

	
//*******************************
// Montage commun
//*******************************	
	
	function espaceur(largeur,hauteur){
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'
			+'<td><img src="../site/graph/images/espaceur.gif" width="'+largeur+'" height="'+hauteur+'"></td>'
			+'</tr></table>');
	}




//*******************************
// Montage ACCUEIL
//*******************************	
	//haut
	function montageAccueilPubHaut(){
		banAlea('rub'+designRub+'BanAccueilHaut',1,"center");
		ligneGif('rub'+designRub+'GifAccueilHaut',20,"");		
	}
	
	
	//Bas
	function montageAccueilPubBas(){
		ligneGif('rub'+designRub+'GifAccueilBas',25,"");
		banAlea('rub'+designRub+'BanAccueilBas',25,"center");
	}


//*******************************
// Montage bandeau droit
//*******************************

	function montageBandeauDroit(){
		
		//espaceur(10,10);
		
		banAlea('rub'+designRub+'PubDte0',15,"center");
		banAlea('rub'+designRub+'PubDte1',15,"center");

	}
	
	
	
//*******************************
// Montage ban rayon/gamme
//*******************************	
	
	function montagePubHaut(){
		banAlea('rub'+designRub+'BanHaut',10,"center");
	}
	
	function montagePubBas(){
		banAlea('rub'+designRub+'BanBas',10,"center");
	}








//*********************************************************************
//				GESTION MENU
//*********************************************************************
var memo=1;
var timeout;
var sousGammeOK=1;
// Fonctions gestion calque
function temps(a){
//var memo = a
	timeout = setTimeout('supCalque(memo)',1000);
}

function affCalque(c){
var n=1;
	with (document.getElementById("SG" + memo).style)
		visibility="hidden";
	with (document.getElementById("SG" + c).style)
		visibility="visible";
	memo = c;
//	stopTemps();
}

function stopTemps(){
	clearTimeout(timeout);
}

function supCalque() {
  if (sousGammeOK == 1){
	with (document.getElementById("SG" + memo).style)
		visibility="hidden";
	}
}





//****************************************************************
// FONCTIONS PWB
//****************************************************************

	// RECHERCHE
	//-------------------------------------------------------------------------------
	function verification(){
		if (document.form_search.mot.value == '' || document.form_search.mot.value == 'Recherchez un article')
			alert ('Veuillez entrer au moins un mot a rechercher.');
		else document.form_search.submit();
	}


	// EMAILING
	//-------------------------------------------------------------------------------
	function verif()
	{ 	var stop=0;
		var str='';
		var adresse = document.form_mailing.mail.value;
		var place = adresse.indexOf("@",1);
		var point = adresse.indexOf(".",place+1);
	
		if ((document.form_mailing.mail.value == '') || (document.form_mailing.mail.value == 'Votre E-mail'))
		{	str=str+'\n - Votre E-mail';
			stop=1;
		}
		else
		{	if ((place > -1)&&(adresse.length >2)&&(point > 1)&&(adresse.length > point+2))
			{
			}
			else
			{	if (stop == 0)
				{	stop=1;
					alert('Veuillez saisir une adresse E-mail valide.');
					document.form_mailing.mail.focus();
				}
			}
		}
		
		if (stop==0) {
			//alert(document.form_mailing.action);
			document.form_mailing.action="trait_mailinglist.cfm?code_lg=lg_fr";
			//alert(document.form_mailing.action);
			document.form_mailing.submit();
		}
		else if (str != '') {
			alert('Veuillez saisir : '+str);
		}
	}
