//************************************************************************
//						Gestion JavaScript : AlloMarket
//************************************************************************
// 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 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

101	Chaussures Minceur (1)
1	Santé & Bien-être(2)
11	Beauté & Minceur(3)
91	Forme & Fitness(4)
21	Maison Pratique(5)
151	Vu à la TV(6)
61	Erotique(7)
111	Les Bonnes Affaires(8)
121	Patch(9)
131	Sauna et minceur (10)
*/

	if (extract == 101)
		designRub = 1;
	else if(extract == 1)
		designRub = 2;
  	else if(extract == 11)
		designRub = 3;
	else if(extract == 91)
		designRub = 4;		
	else if(extract == 21)
		designRub = 5;
  	else if(extract == 151)
		designRub = 6;
	else if(extract == 61)
		designRub = 7;
  	else if(extract == 111)
		designRub = 8;
  	else if(extract == 131)
		designRub = 9;	
  	else if(extract == 121)
		designRub = 10;		
	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="http://www.e-commerce-abk.com/alloMarket/pub/'+designBan+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
				+'<embed src="http://www.e-commerce-abk.com/alloMarket/pub/'+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="http://www.e-commerce-abk.com/alloMarket/pub/'+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="http://www.e-commerce-abk.com/alloMarket/MV/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/gestionClient/pub/espaceur.gif" width="'+largeur+'" height="'+hauteur+'"></td>'
			+'</tr></table>');
	}

	function montageImageSimple(designImage,lien){
		var dbtLienImage='', finLienImage='';
		
		if(lien != 0){
			dbtLienImage='<a href="'+lien+'">';
			finLienImage='</a>';		
		}
	
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'
			+'<td align="center">'+dbtLienImage+'<img src="../site/gestionClient/pub/'+designImage+'" border="0">'+finLienImage+'</td>'
			+'</tr></table>');		
	}




//*******************************
// Montage bandeau droit
//*******************************

	function montageBandeauDroit(){

	// pub permanente
				document.write('<div><img src="../site/gestionClient/vignette/images/espaceur.gif" height="5" border="0"></div>'			
					+'<div><a href="liste_produits.cfm?type=54&code_lg=lg_fr&num=11"><img src="http://www.e-commerce-abk.com/alloMarket/pub/pubVetMinceur.gif" border="0"></a></div>');	
	
	
	//affichage vignettes BS
	//************************
			if (eval('rub'+designRub+'MV').image != ""){
				var designImage, designLien;
				//titre
				document.write('<div><img src="../site/gestionClient/vignette/images/espaceur.gif" height="10" border="0"></div>'			
					+'<div><img src="../site/graph/images/MVtitre_CoinAffaires.gif"></div>');
				
				for(i=0; i<eval('rub'+designRub+'MV').image.length; i++){
					designImage = eval(eval('rub'+designRub+'MV').image[i]).image;
					designLien = eval(eval('rub'+designRub+'MV').image[i]).lien;
					//alert(designImage);
					document.write('<div><a href="'+designLien+'"><img src="http://www.e-commerce-abk.com/alloMarket/MV/images/'+designImage+'" border="0"></a></div>');
					
					if(i+1 < eval('rub'+designRub+'MV').image.length)
						document.write('<div><img src="../site/graph/images/MVseperateur.gif"></div>');
				}
				document.write('<div><img src="../site/graph/images/MVfin.gif"></div>'
					+'<div><img src="../site/gestionClient/vignette/images/espaceur.gif" height="5" border="0"></div>');
			}		
		
	//affichage Pubs droites
	//************************
				
				document.write('<div><img src="../site/gestionClient/vignette/images/espaceur.gif" height="5" border="0"></div>'			
					+'<div><img src="../site/graph/images/pubsDteTitre_destockage.gif"></div>');		
				
				banAlea('rub'+designRub+'PubDroit1',10,"center");		
				banAlea('rub'+designRub+'PubDroit2',10,"center");
				banAlea('rub'+designRub+'PubDroit3',10,"center");
				banAlea('rub'+designRub+'PubDroit4',10,"center");

				document.write('<div><img src="../site/graph/images/pubsDteTitre_fin.gif"></div>'
					+'<div><img src="../site/gestionClient/vignette/images/espaceur.gif" height="25" border="0"></div>');								
				
	}



//*******************************
// Montage bandeau gauche
//*******************************

	function montageEmailing(){	

		// emailing inscription
		
		document.write('<img src="../site/gestionClient/pub/espaceur.gif" height="8" width="5">'

			+'<div><img src="../site/graph/images/titreG_ventePrivee2.gif" width="190" height="27"></div>'
			+'<div style=" background-image: URL(../site/graph/images/blocG_fond1.gif);">'
			+'<div style=" background-image: URL(../site/graph/images/blocG_fond2.gif); background-repeat : no-repeat; background-position: bottom; padding-bottom: 12px;"> '
			+'<div class="texteVP" style="padding-bottom: 0px;"><b>INSCRIVEZ-VOUS et recevez en exclusivité nos offres: </b></div>'
			+'<div class="texteVP">'
			+'• Destockages<br>'
			+'• Ventes Flash<br>'
			+'• Offres Spéciales<br>'
			+'</div>'

			+'<table width="100%" border="0" cellspacing="0" cellpadding="0">'
			+'<form name="form_mailing" action="trait_mailinglist.cfm?code_lg=lg_fr" method="post">'
			+'<tr>'
			+'<td align="center">'
			+'<INPUT type=hidden value=1 name=abonne><input type="text" name="mail" class="rechercheABK" size="23" value="Entrez votre E-mail" onfocus="focusMotValueVP(this.id);" onblur="blurMotValueVP(this.id);"></td>'
			+'<td><div style="margin-top: 2px;"><A onclick=verif(); href="#"><img src="../site/graph/images/boutOK_VP.gif" border="0"></a></div></td>'
			+'</tr>'
			+'</form>'
			+'</table>'
		
			+'</div></div>');
	}	
	
	
	function montageBandeauGauche(){		
		
		// pub totem
		
		document.write('<div><img src="../site/gestionClient/pub/espaceur.gif" height="15" width="5"></div>'); 
		banAlea('rub'+designRub+'PubGauche1',15,"center");
		
		// divers
		
		document.write('<div><a href="http://www.fia-net.com/annuaire/7948/allomarket.html" target="_blank"><img src="../site/graph/images/AvisClientSansNote.gif" border="0"></a></div>'         
			+'<div><img src="../site/gestionClient/pub/espaceur.gif" height="15" width="5"></div>' 
			
			+'<div><img src="../site/graph/images/titreFBook_Twitter.gif"></div>'
			+'<table border="0" cellspacing="0" cellpadding="0"><tr>'
			+'<td><a href="http://www.facebook.com/pages/AlloMarket/203356193520" target="_blank"><img src="../site/graph/images/logoFaceBook.gif" border="0" alt="Rejoignez-nous sur Facebook"></a></td>'
			+'<td><a href="http://twitter.com/allomarket" target="_blank"><img src="../site/graph/images/logoTwitter.gif" border="0" alt="Rejoignez-nous sur Twitter"></a></td>'
			+'</tr></table>'
			+'<div><img src="../site/gestionClient/pub/espaceur.gif" height="15" width="5"></div>' 					
			
			+'<div><img src="../site/graph/images/txtContractuel.gif"></div>' 
			+'<div><img src="../site/gestionClient/pub/espaceur.gif" height="25" width="5"></div>');

	}



//*******************************
// Montage appel ban aléa Haute/basse Accueil
//*******************************

	function montageBanAccueilHaut(){
		
		espaceur(10,10);
		
		banAlea('rub0BanHautAccueil',10,"center");
		ligneGif('rub0GifHautAccueil',10,"center");
		
	}

	function montageBanAccueilBas(){
		espaceur(10,10);
		ligneGif('rub0GifBasAccueil',10,"center");
		banAlea('rub0BanBasAccueil',10,"center");
		espaceur(15,15);
		
	}




//*******************************
// Montage appel ban aléa Haute/basse standards et rubriques
//*******************************

	function montageBanHaut(){
		//espaceur(10,10);		
		//banAlea('rub'+designRub+'BanHaut',10,"center");
	}
	
	function montageBanBas(){
		banAlea('rub'+designRub+'BanBas',10,"center");		
	}



//*******************************
// FAVORIS IE et FF
//*******************************
		  
	function favoris() { 
		if ( navigator.appName != 'Microsoft Internet Explorer' ) { 
			window.sidebar.addPanel("AlloMarket - Le Télé Achat Discount","http://www.allomarket.com/",""); 
		} 
		else { 
			window.external.AddFavorite("http://www.allomarket.com/","AlloMarket - Le Télé Achat Discount"); 
		} 
	} 





//*******************************
// Montage Fiche Produit
//*******************************

function insertFicheProduit(affichBout){
	// bout CDE
	if(affichBout==1){
		espaceur(5,5);
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'
			+'<td><a href="#" onclick="IsNumeric();return false;"><img src="../site/graph/images/boutCDE.gif" border="0"></a></td>'
			+'</tr></table>	<br>');
	}
}	


	// 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();
	}

	function focusMotValue()
	{
		if (document.form_search.mot.value == 'Recherchez un article')
			document.form_search.mot.value='';
	}
	function blurMotValue()
	{
		if (document.form_search.mot.value == '')
			document.form_search.mot.value='Recherchez un article';
	}
	
	
	
	

	//-------------------------------------------------------------------------------
	// EMAILING
	//-------------------------------------------------------------------------------

	function focusMotValueVP()
	{
		if (document.form_mailing.mail.value == 'Entrez votre E-mail')
			document.form_mailing.mail.value='';
	}
	function blurMotValueVP()
	{
		if (document.form_mailing.mail.value == '')
			document.form_mailing.mail.value='Entrez votre E-mail';
	}



	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 == 'Entrez 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) {
			document.form_mailing.submit();
		}
		else if (str != '') {
			alert('Veuillez saisir : '+str);
		}
	}
	
	
	