function findPosY(obj,p)
{
	var curtop = 0;
	if (document.getElementById || document.all)
	{
		while ((obj.offsetParent)&&(obj!=p))
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if ((document.layers) && ((obj)&&(obj.y))) curtop += obj.y;
	return curtop;
}

function findPosX(obj,p)
{
	var curpos = 0;
	if (document.getElementById || document.all)
	{
		while ((obj.offsetParent)&&(obj!=p))
		{
			curpos += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if ((document.layers) && ((obj)&&(obj.x))) curpos += obj.x;
	return curpos;
}

// Show/Hide div  => l'objet doit exister pas de verification faite

function ShowHide(idobj,t)
{
	if(t*1)
	{
		if(document.layers)
		{
			document.layers[idobj].visibility='show';
		}
		else if ((document.all)&&(document.all[idobj]))
		{
			var obj=document.all[idobj];
			if(obj.style) obj=obj.style;
			obj.visibility='visible';
		}
		else 
		{
			var obj=document.getElementById(idobj);
			if(obj.style) obj=obj.style;
			obj.visibility='visible';
		}
	}
	else
	{
		if(document.layers)
		{
			document.layers[idobj].visibility='hide';
		}
		else if ((document.all)&&(document.all[idobj]))
		{
			var obj=document.all[idobj];
			if(obj.style) obj=obj.style;
			obj.visibility='hidden';
		}
		else 
		{
			var obj=document.getElementById(idobj);
			if(obj.style) obj=obj.style;
			obj.visibility='hidden';
		}
	}
}


// Show Onglets en utilisant l'array global Onglets[groupe][n°onglet]  identifians onglets img_onglet_X_Y

function ShowOnglet(id,n)
{
	var i=0,idimg;
	
	if( (n<0) || (!Onglets[id]) || (n<0) || (n>=Onglets[id].length) ) return;
	var max=Onglets[id].length;
	for(i=0;i<max;i++)  // if ( $(Onglets[id][i].id) )
	{
		idimg='img-onglet-'+id+'-'+i;
		if(i==n)
		{
			ShowHide(Onglets[id][i].id,1);
	 		$(idimg).src=Onglets[id][i].imgon;
		}	
		else
		{
			ShowHide(Onglets[id][i].id,0);
	 		$(idimg).src=Onglets[id][i].imgoff;
		} 
	}
}


function SwapOnOff(id,status,path)
{
	if(!path) path="/images/home";
	document.images[id].src=path+"/"+id+"_"+(status?"sel":"off")+".gif";
}

function InitVideoPlayer(iddiv,width,height)
{
  if(NbrVideos<=0) return;
	var html='';
	var flashvars='';
	
	flashvars+='flv='+Videos[0].fichier;
    flashvars+='&amp;startimage='+Videos[0].image ;
	flashvars+='&amp;width='+width ;
	flashvars+='&amp;height='+height ;
	flashvars+='&amp;showstop=1' ;
	flashvars+='&amp;showiconplay=1' ;
	flashvars+='&amp;showvolume=1' ;
	flashvars+='&amp;buffermessage=Chargement _n_' ;
	flashvars+='&amp;playeralpha=50' ;
	flashvars+='&amp;buttonovercolor=686868' ;
	flashvars+='&amp;sliderovercolor=FFFFFF' ;
	flashvars+='&amp;buttoncolor=ffffff' ;
	flashvars+='&amp;skin=' ;
	flashvars+='&amp;margin=0' ;
	flashvars+='&amp;ondoubleclick=fullscreen' ;
	
	
	html+='<object id="VideoPlayer" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" data="flash/player_flv_maxi.swf" width="'+width+'" height="'+height+'">\n' ;
	html+='<param name="movie" value="flash/player_flv_maxi.swf?'+Math.random()+'" />\n' ;
	html+='<param name="FlashVars" value="'+flashvars+'" />\n' ;
	html+='<param name="allowFullScreen" value="true" />' ;
	html+='<embed name="VideoPlayer" src="flash/player_flv_maxi.swf?'+Math.random()+'"	quality="high" width="'+width+'" height="'+height+'" name="video_0" align="middle" allowScriptAccess="sameDomain"	allowFullScreen="true"	type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+flashvars+'"/>\n';
	html+='</embed>\n';
  html+='</object>\n' ;
	
	var d=document.getElementById(iddiv);
	if(d) d.innerHTML=html;	
}

function getFlashObject(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 {
         return document.getElementById(movieName);
     }
}

function PlayVideo(id)
{
  if((id<0)||(id>=NbrVideos)) return;
  
  var vplayer = getFlashObject('VideoPlayer') ;
  if(!vplayer) return ;
  
  vplayer.SetVariable("player:jsStop", "");
  vplayer.SetVariable("player:jsUrl", Videos[id].fichier );
  vplayer.SetVariable("player:jsStartImage", Videos[id].image);
  vplayer.SetVariable("player:jsPlay", "");
  
}

/*
function PlayVideo(id,iddiv)
{
	if((id<0)||(id>=NbrVideos)) return;
	var html='';
	var flashvars='';
	
	/*flashvars+='fpFileURL='+Videos[id].fichier;
	flashvars+='&fpAction=play';
	flashvars+='&defaultEndAction=previewImage';
	flashvars+='&defaultEndAction=previewImage';
	*/
//	flashvars+='&cpScrubberPosition=1x1';
	
//	prompt('',flashvars);
	/*
	html+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="220" height="140"	id="video_'+id+'" align="middle">\n';
	html+='<param name="allowScriptAccess" value="sameDomain" />\n';
	html+='<param name="allowFullScreen" value="false" />\n';
	html+='<param name="movie" value="mcmp_0.8.swf" />\n';
	html+='<param name="quality" value="high" />\n';
	html+='<param name="bgcolor" value="#000000" />\n';
	html+='<param name="FlashVars" value="'+flashvars+'">\n';
	html+='<embed src="mcmp_0.8.swf"	quality="high" bgcolor="#000000" width="220" height="140" name="video_'+id+'" align="middle" allowScriptAccess="sameDomain"	allowFullScreen="false"	type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+flashvars+'"/>\n';
	html+='</embed></object>\n';
	*/
	/*
	flashvars+='flv='+Videos[id].fichier;
	/*flashvars+='autoload=1' ;*/
	/*flashvars+='&amp;fpAction=play';
	flashvars+='&amp;defaultEndAction=previewImage';
	flashvars+='&amp;defaultEndAction=previewImage';
	*/
	/*
  html+='<object id="monFlash" type="application/x-shockwave-flash" data="flash/player_flv_maxi.swf" width="220" height="140">\n' ;
	html+='<param name="movie" value="player_flv_maxi.swf" />\n' ;
	html+='<param name="FlashVars" value="'+flashvars+'&amp;width=220&amp;height=140" />\n' ;
	html+='<p>Texte alternatif</p>\n' ;
  html+='</object>\n' ;
	
	
	var d=document.getElementById(iddiv);
	if(d) d.innerHTML=html;
}
*/

// *********** Activer un calque lié à un bouton

function Activate(id)
{
	var sboutons='opt_description,opt_caracteristiques,opt_consommables,opt_garanties,opt_transport';
	var	boutons=sboutons.split(',');
	var i=0,nbr=boutons.length;
	
	if(id=='') for(i=0;(i<nbr)&&(id=='');i++)
	{
		var d=document.getElementById('btn'+i);
		if(d) id=boutons[i];
	}
	
	for(i=0;i<nbr;i++)
	{
		var d=document.getElementById('btn'+i);
		if(d)
		{
			if(id==boutons[i])
			{
				if($('btn'+i+'_left'))   $('btn'+i+'_left').src='/images/box_buttons/button_2_left.gif';
				if($('btn'+i+'_right'))  $('btn'+i+'_right').src='/images/box_buttons/button_2_right.gif';
				if($('btn'+i+'_center')) $('btn'+i+'_center').background='/images/box_buttons/button_2_bg.gif';
				$('displayoption').innerHTML=$(boutons[i]).innerHTML;
//				ShowHide(''+boutons[i],1);
			}
			else
			{
				if($('btn'+i+'_left'))   $('btn'+i+'_left').src='/images/box_buttons/button_3_left.gif';
				if($('btn'+i+'_right'))  $('btn'+i+'_right').src='/images/box_buttons/button_3_right.gif';
				if($('btn'+i+'_center')) $('btn'+i+'_center').background='/images/box_buttons/button_3_bg.gif';
//				ShowHide(''+boutons[i],0);
			}
		}
	}
}

function ReinitSearchInput(obj,txt)
{
	if(!obj) return;
	obj.value=(txt?txt:'Recherche')+'\t';
	obj.style.color='#555555';
	return false;
}

function FocusSearchInput(obj)
{
	if((!obj)||(!obj.value)) return;
	obj.value='';
	obj.style.color='#000000';
}

function SearchPopUp(schtext,Type,Options)
{
	var html='',rep,row=0,nr=0,data,info;
	
	if(schtext.indexOf('\t')>0) schtext='';
	if((!schtext)&&((!Options)||(Options==''))) { Message('Veuillez saisir un texte à chercher'); return false; }
	
	switch(Type)
	{
		case 'VenteM,VenteO' :
		case 'VenteO,VenteM' :
		case 'VenteO' :
		case 'VenteM' : Type += ',Location' ; break ;
		case 'Location' :  Type += ',VenteM,VenteO' ;break ;
	}
	
	new Ajax.Request('/ajax.php',
		{ 
			method:'post', 
			parameters: { 	ACTION:'SEARCH',
	  						Type:Type,
	  			      		SCH:schtext,
							Options:Options
						 },
			onFailure: function()
			{
				alert('Erreur de communication serveur');
			},

			onComplete: function(transport)
			{
				if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
				html+=PopUpHTML(0,"Resultat de la recherche","schresult",500);
				html+='<center>Cliquez sur une réponse ou fermez cette fenêtre pour recommencer.</center>';
				
				rep=transport.responseText.split('\n');
				
				while(row<500)
				{
					data=rep[row++].split("\t",3);
					if(data[0]=="EXIT") break;
					if((data[0])&&(data[0]!="BEGIN")) { alert('ERROR IN BEGIN='+data[0]+'\nREP='+rep[row-1]+'\n'+transport.responseText); return; }
					if(data[2]*1>0)
					{
						html+='<BR>';
						if(data[1]=='Location') 
							html+='<div class="popup_titre">Catalogue location</div>\n';
						else if(data[1]=='VenteM') 
							html+='<div class="popup_titre">Catalogue vente matériel</div>\n';
						else if(data[1]=='VenteO') 
							html+='<div class="popup_titre">Catalogue vente outillage</div>\n';
						html+'<UL class="popup_recherche_items">\n';
						while(row<500)
						{
							info=rep[row++].split("\t",5);
							if(info[0]=='END') break; 
							html+='<LI><A class="popup" HREF="'+info[2]+'">'+info[4]+'</a>'+(info[3]?' <i>('+info[3]+')</i>':'');
							html+='</LI>\n';
							nr++;
						}
						html+'</UL><BR>\n';
					} else row++;
				}
				html+='<BR>';
				html+=PopUpHTML(1);
				if(nr)	ShowPopUp('popup',html); else Message("Aucune reponse correspond à votre recherche");
			}
	
		});	
	return false;
}


/////////////////////////////////////////
// MOT DE PASSE OUBLIE                 //
/////////////////////////////////////////

function MotDePasseOublie(msg,EMail)
{
	var html='';
	html+=PopUpHTML(0,"Mot de passe oublié","mdpoublie",410);
	html+='Indiquez ci-dessous l\'adresse email sous laquelle vous vous êtes précédemment enregistré.<BR>Vous recevrez un email vous indiquant la marche à suivre pour récupérer votre accès.<BR>';
	if(msg) html+='<center><span class="popup_errormsg">'+msg+'</span></center>';
	html+='<form name="mdpoublie" id="mdpoublie" onSubmit="return SendMotDePasseOublie($(\'mdpoublie\').EMail.value)">\n';
	html+='<table border="0" cellspacing="2" cellpadding="2">\n';
	html+='<TR>\n';
	html+='<TD colspan=2>Votre adresse email:</td>\n';
	html+='<TD><INPUT TYPE=TEXT NAME="EMail" VALUE="'+(EMail?EMail:'')+'" style="width:150px"></td>\n';
	html+='<TD><INPUT TYPE=SUBMIT VALUE="Ok" class="popup_button"></td>\n';
	html+='</tr>\n';
	html+='</table></form>\n';
	html+=PopUpHTML(1);
	ShowPopUp('popup',html);
}

function SendMotDePasseOublie(EMail)
{
	if(!EMail) { MotDePasseOublie('Veuillez saisir votre E-Mail',EMail); return; }
	new Ajax.Request('/ajax.php',
		{ 
			method:'post', 
			parameters: { 	ACTION:'SENDPASSWORD',
	  						EMail:EMail
						 },
			onFailure: function()
			{
				alert('Erreur de communication serveur');
			},

			onComplete: function(transport)
			{
				if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
				if(transport.responseText=="OK")
				{
					Message('Mot de passe envoyé à '+EMail); return;
				}
				else if(transport.responseText=="INVALID")
				{
					MotDePasseOublie('Mauvais E-Mail. Veuillez recommencer',EMail); return; 
				}
				else if(transport.responseText=="NOK")
				{
					MotDePasseOublie('Cet E-Mail n\'est pas dans notre base d\'utilisateurs',EMail); return;
				}
				else if(transport.responseText=="ERROR")
				{
					msg=transport.responseText.split(':',2);
					MotDePasseOublie('Impossible d\'envoyer le message\n'+msg[1],EMail); return; 
				}
				else alert('ERREUR INTERNE\n'+transport.responseText);
				return;
			}
	
		});	
	return false;		
}

function CaddySaveAndGo(e)
{
	document.caddy.etape.value=e;
	if((document.caddy.CMD)&&(document.caddy.CMD.value=='VALIDECOMMANDE')) document.caddy.CMD.value='';
	document.caddy.submit();
}


function Login(idform,page)
{
	var	EMail='',Password='';
	if( ($(idform)) && ($(idform).EMail) ) EMail=$(idform).EMail.value;
	if( ($(idform)) && ($(idform).Password) ) Password=$(idform).Password.value;
	if(EMail.indexOf('\t')>0) EMail='';
	if(Password.indexOf('\t')>0) Password='';
	
	if((!EMail)||(!Password))
	{
		Message("Veuillez saisir votre E-Mail et votre mot de passe pour vous identifier.");
		return false;
	}
	new Ajax.Request('/ajax.php',
		{ 
			method:'post', 
			parameters: { 	ACTION:'LOGIN',
	  						EMail:EMail,
	  			      		Password:Password
						 },
			onFailure: function()
			{
				alert('Erreur de communication serveur');
			},

			onComplete: function(transport)
			{
				if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
				rep=transport.responseText.split('\t');
				if(rep[0]=="UNKNOWN")
				{
					Message("Mauvais utilisateur ou mot de passe");
				}				
				else if(rep[0]!="OK")
				{
					Message("Impossible de vous identifier à cause d'une erreur interne.<BR>"+transport.responseText);
				}
				else
				{
					var URL='/login.php?IDUser='+rep[1]+'&md5='+rep[2]+'&page='+page;
					top.location=URL;
				}
			}
	
		});	
	return false;	
}


function AddNewsletter(EMail)
{
	if(!EMail)
	{
		Message("Veuillez saisir votre E-Mail");
	}
	else
	{
		new Ajax.Request('/ajax.php',
		{ 
			method:'post', 
			parameters: { 	ACTION:'ADDNEWSLETTER',
	  						EMail:EMail
						 },
			onFailure: function()
			{
				alert('Erreur de communication serveur');
			},

			onComplete: function(transport)
			{
				if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
				rep=transport.responseText.split('\t');
				if(rep[0]=="OK")
				{
					Message("<IMG SRC=\"http://idtag.idcontact.net/getdata.php?IDE=9&PAGE=newsletter-ok\" BORDER=0>Votre inscription s'est bien déroulée.<BR>Vous recevrez la newsletter LOXAM");
				}
				else if(transport.responseText=="INVALID")
				{
					Message('Mauvais E-Mail.<BR>Veuillez recommencer'); return; 
				}
				else if(rep[0]=="EXISTS")
				{
					Message("Vous êtes déjà inscrit<BR>à la newsletter LOXAM");
				}				
				else
				{
					Message("Impossible de vous inscrire.<BR>"+transport.responseText);
				}
			}
	
		});	

	}
	return false;
}


function ProduitsFavoris(IDUser,IDPreference)
{
	var html='',rep,row=0,nr=0,data,info,deletelink;

	if(!IDUser) { Message("Aucun produit dans vos favoris"); return; }
	new Ajax.Request('/ajax.php',
	{ 
		method:'post', 
		parameters: { 	ACTION:'GETFAVORIS',
  						IDUser:IDUser,
						IDPreference:IDPreference
						 },
		onFailure: function()
		{
			alert('Erreur de communication serveur');
		},

		onComplete: function(transport)
		{
			if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
			html+=PopUpHTML(0,"Vos favoris","schresult",620);
			html+='<center>Cliquez sur un produit pour le visualiser dans le catalogue.</center>';
			rep=transport.responseText.split('\n');
			while(row<500)
			{
				if(!rep[row]) break;
				data=rep[row++].split("\t",3);
				if(data[0]=="EXIT") break;
				if((data[0])&&(data[0]!="BEGIN")) { alert('ERROR IN BEGIN='+data[0]+'\nREP='+rep[row-1]+'\n'+transport.responseText); return; }
				if(data[2]*1>0)
				{
					html+='<BR>';
					if(data[1]=='Location') 
						html+='<div class="popup_titre">Catalogue location</div>\n';
					else if(data[1]=='Vente') 
						html+='<div class="popup_titre">Catalogue Vente matériel/outillage</div>\n';
					html+'<UL class="popup_recherche_items">\n';
					while(row<500)
					{
						info=rep[row++].split("\t",6);
						if(info[0]=='END') break; 
						deletelink='<A HREF="javascript:ProduitsFavoris(\''+IDUser+'\',\''+info[1]+'\')"><IMG SRC="/images/delete.gif" border=0 ALT="Supprimer ce produit de mes favoris"></A>';
						caddylink='<A HREF="'+info[5]+'"><IMG SRC="/images/icn_mini_ajouter.gif" border=0 ALT="Ajouter à votre panier"></A>';
						html+='<LI><A class="popup" HREF="'+info[2]+'">'+info[4]+'</a>'+(info[3]?' <I>(Réf. '+info[3]+')</I>':'')+' '+caddylink+deletelink+'</LI>\n';
						nr++;
					}
					html+'</UL>\n';
				} else row++;
			}
			html+='<BR>';
			html+=PopUpHTML(1);
			if(nr)	ShowPopUp('popup',html); else Message("Aucun favori défini");
		}
	
	});	
}

function AddFavoris(IDUser,Type,ID)
{
	if((!Type)||(!(ID*1))||(!(IDUser*1))) return;
	new Ajax.Request('/ajax.php',
	{ 
		method:'post', 
		parameters: { 	ACTION:'ADDFAVORIS',
  						IDUser:IDUser,
						Item:Type,
						IDValeur:ID
						 },
		onFailure: function()
		{
			alert('Erreur de communication serveur');
		},

		onComplete: function(transport)
		{
			if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
			rep=transport.responseText.split('\t');
			if(rep[0]!="OK")
			{
				Message("Impossible d'ajouter le produit à vos favoris.<BR>"+transport.responseText);
				return;
			}
			Message("Le produit a été ajouté à vos favoris");
		}
	
	});	
}



var VideoListScroll=0,VideoListScrollForce=0,VideoListScrollG=0;
var VideoListScrollTO;

function ScrollVideoList(force,g,iddiv)
{
	VideoListScrollForce=force;
	VideoListScrollG=g;
	scrollTrigger(iddiv);

}

function scrollTrigger(iddiv)
{
	var sign=0,nsign=0;
	
	c=document.getElementById(iddiv);
	var windowwidth=c.offsetWidth;
	cnt=document.getElementById(iddiv+'_content');
	var contentwidth=cnt.offsetWidth;

	// alert('scroll='+VideoListScroll+' winwidth='+windowwidth+' cntwidth='+contentwidth);
	
	VideoListScroll+=VideoListScrollForce;
	if(VideoListScrollForce) sign=VideoListScrollForce/Math.abs(VideoListScrollForce); 
	VideoListScrollForce+=(VideoListScrollG*1.0/10);
	if(VideoListScrollForce) nsign=VideoListScrollForce/Math.abs(VideoListScrollForce); 
	
	if((!VideoListScrollForce)||((sign!=nsign)&&(sign))||(Math.abs(VideoListScrollForce)<0.1))
	{
	 	VideoListScrollG=0;
		VideoListScrollForce=0;
	}
	
	if(VideoListScroll<0)
	{ 
		VideoListScroll=0; 
		VideoListScrollForce=0;
		VideoListScrollG=0; 
	}
	else if(VideoListScroll>contentwidth-windowwidth)
	{
		VideoListScroll=contentwidth-windowwidth;
		VideoListScrollForce=0; 
		VideoListScrollG=0; 
	}
	

	c.scrollLeft=VideoListScroll;
	if(VideoListScrollForce) VideoListScrollTO=setTimeout("scrollTrigger('"+iddiv+"')",30);
//	$('force').innerHTML='scroll='+VideoListScroll+' force='+VideoListScrollForce+' G='+VideoListScrollG;
	
}


////////////////////////////////////////////
// TOOLBAR FUNCTIONS                      //
////////////////////////////////////////////

var _taille_mode = 0;

function ChangerTaille(pas)
{
//	var sobj=$('maincontent');
	
	_taille_mode+=pas;
	if(_taille_mode<0) _taille_mode=0;
	if(_taille_mode>2) _taille_mode=2;
	document.getElementById('mycss').href = '/css/stylescssDYN.php?ADDSIZE='+_taille_mode;
	return;
}

function PrintPage()
{
	if( typeof Prototype == 'object')
	{
		w = open('Impression') ;
		w.document.open();
		
		var html = '<html>' ;
		html += '<head>' ;
		html += '<title>Impression</title>' ;
		html += '<link rel="stylesheet" type="text/css" href="/css/styles_print.css" media="all">' ;
		html += '</head>' ;
		html += '<body>' ;
		html += '<img src="/images/logo_loxam_print.gif" alt="">' ;
		html += $('maincontent_0').innerHTML ;
		html += '</body></html>' ;
		w.document.write(html) ;
		w.document.close();
		w.print();w.close();
	}
	else
	{
		window.print() ;
	}
}

function EnvoyerURL(URL,msg,EMail,Destinataires,Nom,Message)
{
	var html='';
	html+=PopUpHTML(0,"Envoyer cette page à un ami","mdpoublie",420);
	html+='Remplissez le formulaire ci-dessous pour evoyer cette à un ou plusieurs amis.<BR><BR>';
	
	if(msg) html+='<center><span class="popup_errormsg">'+msg+'</span></center>';
	html+='<form name="envoyerami" id="envoyerami" onSubmit="return SendURL(\''+URL+'\',$(\'envoyerami\').EMail.value,$(\'envoyerami\').Destinataires.value,$(\'envoyerami\').Nom.value,$(\'envoyerami\').Message.value)">\n';
	html+='<table border="0" cellspacing="0" cellpadding="0">\n';

	html+='<TR>\n';
	html+='<TD>Destinataires :<BR><INPUT style="width:380px" TYPE=TEXT NAME="Destinataires" VALUE="'+(Destinataires?Destinataires:'')+'"><BR><span class="popup_info">Indiquez jusqu\'à 10 adresses séparées par des virgules</span></td>\n';
	html+='</tr>\n';

	
	html+='<TR>\n';
	html+='<TD>Votre nom :&nbsp;<BR><INPUT style="width:380px" TYPE=TEXT NAME="Nom" VALUE="'+(Nom?Nom:'')+'"></td>\n';
	html+='</tr>\n';

	html+='<TR>\n';
	html+='<TD>Votre adresse email :<BR><INPUT style="width:380px" TYPE=TEXT NAME="EMail" VALUE="'+(EMail?EMail:'')+'" style="width:150px"></td>\n';
	html+='</tr>\n';
	
	html+='<TR>\n';
	html+='<TD>Votre message :<BR><TEXTAREA NAME="Message" style="width:380px; height:50px">'+(Message?Message:'')+'</TEXTAREA></td>\n';
	html+='</tr>\n';

	html+='<TR><td align=center><INPUT TYPE=SUBMIT VALUE="Envoyer" class="popup_button"></td></tr>\n';

	html+='</table></form>\n';
	html+=PopUpHTML(1);
	ShowPopUp('popup',html);
}

function SendURL(URL,EMail,Destinataires,Nom,MSG)
{
	if(!EMail) 			{ EnvoyerURL(URL,'Veuillez saisir votre E-Mail',EMail,Destinataires,Nom,MSG); return; }
	if(!Destinataires) 	{ EnvoyerURL(URL,'Veuillez saisir un ou plsieurs adresses E-Mail destinataires',EMail,Destinataires,Nom,MSG); return; }
	new Ajax.Request('/ajax.php',
		{ 
			method:'post', 
			parameters: { 	ACTION:'SENDURL',
							URL:URL,
	  						EMail:EMail,
							Destinataires:Destinataires,
							Nom:Nom,
							Message:MSG
						 },
			onFailure: function()
			{
				alert('Erreur de communication serveur');
			},

			onComplete: function(transport)
			{
				if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
				if(transport.responseText=="OK")
				{
					Message('Cette page a été envoyée à '+Destinataires); return;
				}
				else if(transport.responseText=="INVALID")
				{
					EnvoyerURL(URL,'Votre adresse E-Mail est invalide. Veuillez recommencer',EMail,Destinataires,Nom,MSG); return; 
				}
				else if(transport.responseText=="DINVALID")
				{
					EnvoyerURL(URL,'Mauvaise adresse E-Mail destinataire. Veuillez recommencer',EMail,Destinataires,Nom,MSG); return; 
				}
				else if(transport.responseText=="ERROR")
				{
					msg=transport.responseText.split(':',2);
					EnvoyerURL(URL,'Impossible d\'envoyer le MSG\n'+msg[1],EMail,Destinataires,Nom,MSG); return; 
				}
				else alert('ERREUR INTERNE\n'+transport.responseText);
				return;
			}
	
		});	
	return false;		
}

function IndicePopUp(id)
{
	var html='',rep,row=0,nr=0,data,info;
	
	if(!id) { Message('Requête incorrecte'); return false; }
	
	new Ajax.Request('/indices/vindice.php',
		{ 
			method:'post', 
			parameters: { ID:id , x:1 },
			onFailure: function()
			{
				alert('Erreur de communication serveur');
			},
      
			onComplete: function(transport)
			{
				if(transport.status!=200) alert('ERROR('+transport.status+'): '+transport.responseText);
				html+=PopUpHTML(0,"INDICE","indice_result",620);
				html+=transport.responseText ;
				html+='<BR>';
				html+=PopUpHTML(1);
				ShowPopUp('popup',html);
			}
	
		});	
	return false;
}


function SubmitRechercheMetier()
{
	if(document.RECHERCHEMETIER.IDMetier.value)
	{
		url='location/liste_metiers.php?IDMetier='+document.RECHERCHEMETIER.IDMetier.value+'&ISPOPUP=1';
		PopUpPage('Métiers',url,800,550);
	}
	else
	{
		Message('Veuillez choisir un métier');
	}
}


function OpenListeMetiers(id,ListeRubriquesMetier)
{
	var obj=document.getElementById('lmpos'+id);
	var PosY=findPosY(obj,popup);
	var PosX=findPosX(obj,popup);
	
	if(!id)
	{
		$('metiersmenu').visibility='Hidden';
		return;
	}
	
	var scroll=0,i=0;
	data=ListeRubriquesMetier.split('\|');
	
	if($('popup_scroll').pageYOffset) scroll=$('popup_scroll').pageYOffset;
	else if($('popup_scroll').scrollTop) scroll=$('popup_scroll').scrollTop;
	PosY-=scroll;
	
	var html=''
	html+='<table border="0" cellspacing="0" cellpadding="0" width="'+(popup.offsetWidth-50-PosX)+'">\n';
	html+='<tr><td BGCOLOR="#888888" colspan=2><IMG SRC="/images/1.gif" width=1 height=2 border=0></td></tr>\n';
	html+='<tr>';
	html+='<td width="100%"></td>';
	html+='<td BGCOLOR="#8888FF" nowrap>';
	for(i=0;i<data.length;i++) if (data[i])
	{
		info=data[i].split(':',2);
		html+='<li><A class="metiers" HREF="'+info[0]+'">'+info[1]+'</A></li>\n';
	}
	html+='</td>';
	html+='</tr>';
	html+='</table>';
	
	$('metiersmenu').style.left=PosX;
	$('metiersmenu').style.top=PosY+14;
	$('metiersmenu').innerHTML=html;
	$('metiersmenu').visibility='Visible';
	

}


function PopUpImage(img,titre,description)
{
	var html='';
	
	html+=PopUpHTML(0,titre?titre:'Image','message',400);
	html+='<CENTER><table border="0" cellspacing="0" cellpadding="4" align="center">\n';
	html+='<TR>\n';
	html+='<td align="CENTER"><IMG SRC="'+img+'" BORDER=0></td>\n';
	html+='</tr>\n';
	if(description)
	{
		html+='<TR>\n';
		html+='<td align="CENTER">'+description+'</td>\n';
		html+='</tr>\n';
	}
	html+='</table></center>';
	html+=PopUpHTML(1);
	$('popup').innerHTML=html;
	ShowPopUp('popup');
}


//*************** PLAY VIDEO ON DIV ******************/

function PlayVideoOnDiv(iddiv,filename,imagename,width,height)
{
	var html='';
	var flashvars='';

	flashvars+='flv=/files/'+filename;
    flashvars+='&amp;startimage=/'+imagename;
	flashvars+='&amp;width='+width ;
	flashvars+='&amp;height='+height ;
	flashvars+='&amp;showstop=1' ;
	flashvars+='&amp;showiconplay=1' ;
	flashvars+='&amp;showvolume=1' ;
	flashvars+='&amp;buffermessage=Chargement _n_' ;
	flashvars+='&amp;playeralpha=50' ;
	flashvars+='&amp;buttonovercolor=686868' ;
	flashvars+='&amp;sliderovercolor=FFFFFF' ;
	flashvars+='&amp;buttoncolor=ffffff' ;
	flashvars+='&amp;skin=' ;
	flashvars+='&amp;margin=0' ;
	flashvars+='&amp;ondoubleclick=fullscreen' ;
	flashvars+='&amp;autoplay=1' ;
	
	html+='<object id="VideoPlayer" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" data="flash/player_flv_maxi.swf" width="'+width+'" height="'+height+'">\n' ;
	html+='<param name="movie" value="flash/player_flv_maxi.swf?'+Math.random()+'" />\n' ;
	html+='<param name="FlashVars" value="'+flashvars+'" />\n' ;
	html+='<param name="allowFullScreen" value="true" />' ;
	html+='<embed name="VideoPlayer" src="flash/player_flv_maxi.swf?'+Math.random()+'"	quality="high" width="'+width+'" height="'+height+'" name="video_0" align="middle" allowScriptAccess="sameDomain"	allowFullScreen="true"	type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+flashvars+'"/>\n';
	html+='</embed>\n';
  	html+='</object>\n' ;
	
	var d=document.getElementById(iddiv);
	if(d) d.innerHTML=html;	
  
}
