/*============================================================================*/

/**
 *
 * @author      Erwan Lef+¨vre <erwan.lefevre@aposte.net>
 * @copyright   Erwan Lef+¨vre 2010
 * @license     Creative Commons - Paternit+© 2.0 France - http://creativecommons.org/licenses/by/2.0/fr/
 * @version     1.0
 * @see			http://webbricks.org/bricks/pageDim/
 *
 * @thanksTo	http://www.bonneville.be/post/Javascript-Hauteur-Navigateur-clientHeight-offsetHeight-scrollHeight-body-documentElement
 */


/** 
 * pageDim() 
 * -----------------------------------------------------------------------------
 * retourne les dimentions de la page
 *
 * @return		{Object}		{'w','h'}
 */


function pageDim() {
	var w, h;
	
	// firefox is ok
	h = document.documentElement.scrollHeight;
	w = document.documentElement.scrollWidth;
	
	// now IE 7 + Opera with "min window"
	if ( document.documentElement.clientHeight > h ) { h  = document.documentElement.clientHeight; }
	if ( document.documentElement.clientWidth > w ) { w  = document.documentElement.clientWidth; }
	
	// last for safari
	if ( document.body.scrollHeight > h ) { h = document.body.scrollHeight; }
	if ( document.body.scrollWidth > w ) { w = document.body.scrollWidth; }

	return {'w':w, 'h':h} ;
}

function posXY(elem) {
   var tabPosition = Array();
   tabPosition[0] = elem.offsetLeft;
   tabPosition[1] = elem.offsetTop;
   
   while(elem.offsetParent) {
      elem = elem.offsetParent; // récursivité
      tabPosition[0] += elem.offsetLeft;
      tabPosition[1] += elem.offsetTop;
   }
   return tabPosition;
}

function ShowMainMenu(iddiv)
{
    var dim                 = pageDim() ;
    var target              = document.getElementById(iddiv) ;
    target.style.display    = 'block' ;
    //target.style.position   = 'absolute' ;
    target.style.marginTop   = '-1px' ;
    
    var pos = posXY(target) ;
    
    if(dim.w<(500+pos[0]))
    {
      target.style.right = 0 ;
    }
    //alert(dim.w+' '+(500+pos[0])) ;
    
    
      
                                                             
    
}

function HideMainMenu(iddiv)
{
    var target              = document.getElementById(iddiv) ;
    target.style.display    = 'none' ;
    target.style.position   = 'absolute' ;
}

function SetImage(id_img,src)
{
  try
  {
  var img = document.getElementById(id_img) ;
  img.src=src ;
  }
  catch(e){}
}


/*============================================================================*/

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 ;
	}
	  
	
	jQuery.ajax(
		{ 
			url: '/ajax.php',
      type: "POST", 
			data: ({ 	ACTION:'SEARCH',
	  						Type:Type,
	  			      		SCH:schtext,
							Options:Options
						 }),
			error: function()
			{
				alert('Erreur de communication serveur');
			},

			success: function(message, textStatus, jqXHR)
			{
        if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
				html+=PopUpHTML(0,"Résultat de la recherche","schresult",500);
				html+='<center>Cliquez sur une réponse ou fermez cette fenêtre pour recommencer.</center>';
				
				rep=message.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'+message); return; }
					if(data[2]*1>0)
					{
						html+='<BR>';
						if(data[1]=='Location') 
							html+='<div class="popup_titre">Location</div>\n';
						else if(data[1]=='VenteM') 
							html+='<div class="popup_titre">Vente matériel</div>\n';
						else if(data[1]=='VenteO') 
							html+='<div class="popup_titre">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( document.getElementById(\'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; }
	jQuery.ajax(
		{ 
			url: '/ajax.php',
      type: "POST",
      data: ({ 	ACTION:'SENDPASSWORD',
	  						EMail:EMail
						 }),
			error: function()
			{
				alert('Erreur de communication serveur');
			},

			success: function(message, textStatus, jqXHR)
			{
				if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
				if(message=="OK")
				{
					Message('Mot de passe envoyé à '+EMail); return;
				}
				else if(message=="INVALID")
				{
					MotDePasseOublie('Mauvais E-Mail. Veuillez recommencer',EMail); return; 
				}
				else if(message=="NOK")
				{
					MotDePasseOublie('Cet E-Mail n\'est pas dans notre base d\'utilisateurs',EMail); return;
				}
				else if(message=="ERROR")
				{
					msg=message.split(':',2);
					MotDePasseOublie('Impossible d\'envoyer le message\n'+msg[1],EMail); return; 
				}
				else alert('ERREUR INTERNE\n'+message);
				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='';
	var form = document.getElementById(idform) ;
	if( form && (form.EMail) ) EMail=form.EMail.value;
	if( form && (form.Password) ) Password=form.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;
	}
	jQuery.ajax(
		{ 
			url: '/ajax.php',
      type: "POST",
      method:'post', 
			data: ({ 	
                ACTION:'LOGIN',
	  						EMail:EMail,
	  			      Password:Password
						 }),
			error: function()
			{
				alert('Erreur de communication serveur');
			},

			success: function(message, textStatus, jqXHR)
			{
				if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
				rep=message.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>"+message);
				}
				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
	{
		jQuery.ajax(
		{ 
			url: '/ajax.php',
      type: "POST",
      method:'post', 
			data: ({ 	ACTION:'ADDNEWSLETTER',
	  						EMail:EMail
						 }),
			error: function()
			{
				alert('Erreur de communication serveur');
			},

			success: function(message, textStatus, jqXHR)
			{
				if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
				rep=message.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(message=="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>"+message);
				}
			}
	
		});	

	}
	return false;
}


function ProduitsFavoris(IDUser,IDPreference,Refresh)
{
	var html='',rep,row=0,nr=0,data,info,deletelink;

	if(!IDUser) { Message("Aucun produit dans vos favoris"); return; }
	jQuery.ajax(
	{ 
		url: '/ajax.php',
      type: "POST",
    data: ({ 	ACTION:'GETFAVORIS',
  						IDUser:IDUser,
						IDPreference:IDPreference
						 }),
		error: function()
		{
			alert('Erreur de communication serveur');
		},

		success: function(message, textStatus, jqXHR)
		{
			if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
			html+=PopUpHTML(0,"Vos favoris","schresult",620);
			html+='<center>Cliquez sur un produit pour le visualiser dans le catalogue.</center>';
			rep=message.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'+message); 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]+'\',\''+Refresh+'\')"><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';*/
						html+='<LI><A class="popup" HREF="'+info[2]+'">'+info[4]+'</a>'+(info[3]?' <I>(Réf. '+info[3]+')</I>':'')+' '+deletelink+'</LI>\n';
						nr++;
					}
					html+'</UL>\n';
				} else row++;
			}
			html+='<BR>';
			html+=PopUpHTML(1);
			
			if(Refresh)
			{
			 AfficheBlocProduitsFavoris('',IDUser) ;
			}
			
			if(nr)	ShowPopUp('popup',html); else Message("Aucun favori défini");
			
			
		}
	
	});	
}

function AddFavoris(IDUser,Type,ID,Refresh)
{
	if((!Type)||(!(ID*1))||(!(IDUser*1))) { Message('Vous devez être identifié pour sauvegarder vos favoris.'); return false; }
  
	jQuery.ajax(
	{ 
		url: '/ajax.php',
      type: "POST", 
		data: ({ 	ACTION:'ADDFAVORIS',
  						IDUser:IDUser,
						Item:Type,
						IDValeur:ID
						 }),
		error: function()
		{
			alert('Erreur de communication serveur');
		},

		success: function(message, textStatus, jqXHR)
		{
			if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
			rep=message.split('\t');
			if(rep[0]!="OK")
			{
				Message("Impossible d'ajouter le produit à vos favoris.<BR>"+message);
				return;
			}
			Message("Le produit a été ajouté à vos favoris");
			
			if(Refresh)
			 AfficheBlocProduitsFavoris('',IDUser) ;
		}
	
	});	
}



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 envoyer cette page à 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+'\',document.getElementById(\'envoyerami\').EMail.value,document.getElementById(\'envoyerami\').Destinataires.value,document.getElementById(\'envoyerami\').Nom.value,document.getElementById(\'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 prénom et 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; }
	jQuery.ajax(
		{ 
			url: '/ajax.php',
      type: "POST", 
			data: ({ 	ACTION:'SENDURL',
							URL:URL,
	  						EMail:EMail,
							Destinataires:Destinataires,
							Nom:Nom,
							Message:MSG
						 }),
			error: function()
			{
				alert('Erreur de communication serveur');
			},

			success: function(message, textStatus, jqXHR)
			{
				if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
				if(message=="OK")
				{
					Message('Cette page a été envoyée à '+Destinataires); return;
				}
				else if(message=="INVALID")
				{
					EnvoyerURL(URL,'Votre adresse E-Mail est invalide. Veuillez recommencer',EMail,Destinataires,Nom,MSG); return; 
				}
				else if(message=="DINVALID")
				{
					EnvoyerURL(URL,'Mauvaise adresse E-Mail destinataire. Veuillez recommencer',EMail,Destinataires,Nom,MSG); return; 
				}
				else if(message=="ERROR")
				{
					msg=message.split(':',2);
					EnvoyerURL(URL,'Impossible d\'envoyer le MSG\n'+msg[1],EMail,Destinataires,Nom,MSG); return; 
				}
				else alert('ERREUR INTERNE\n'+message);
				return;
			}
	
		});	
	return false;		
}

function IndicePopUp(id)
{
	var html='',rep,row=0,nr=0,data,info;
	
	if(!id) { Message('Requête incorrecte'); return false; }
	
	jQuery.ajax(
		{ 
			url: '/indices/vindice.php',
      type: "POST",
      data: ({ ID:id , x:1 }),
			error: function()
			{
				alert('Erreur de communication serveur');
			},
      
			success: function(message, textStatus, jqXHR)
			{
				if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
				html+=PopUpHTML(0,"INDICE","indice_result",620);
				html+=message ;
				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;	
  
}

function InitVideoOnDiv(iddiv,filename,imagename,width,height,autoplay)
{
	var html='';
	var flashvars='';
	
	if(autoplay) autoplay=1 ;
	else autoplay=0 ;
	
	flashvars+='flv=/files/'+filename;
    flashvars+='&amp;autoplay='+autoplay;
	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;wmode=transparent' ;
	
	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+='<param name="wmode" value="transparent" />' ;
	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+'" wmode="transparent" />\n';
	html+='</embed>\n';
  	html+='</object>\n' ;
	
	var d=document.getElementById(iddiv);
	if(d) d.innerHTML=html;	
}

	
function setCookie(nom, valeur, expire, chemin, domaine, securite){
   		document.cookie = nom + ' = ' + escape(valeur) + '  ' +
             ((expire == undefined) ? '' : ('; expires = ' + expire.toGMTString())) +
             ((chemin == undefined) ? '' : ('; path = ' + chemin)) +
             ((domaine == undefined) ? '' : ('; domain = ' + domaine)) +
             ((securite == true) ? '; secure' : '');
 }

function getElementsByClass( searchClass, domNode, tagName) { 
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) { 
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1) 
			el[j++] = tags[i];
	} 
	return el;
} 


function ShowTarifs(id_obj,type,id_pro,id_part,oclass)
{
	if(!type) return false ;
	
	var d = document ;
	if(!id_pro) var id_pro	= 'bloc-tarif-pro' ;
	if(!id_part) var id_part = 'bloc-tarif-part' ;
	if(!oclass) var oclass = 'onglet-tarifs' ;
	var o = d.getElementById(id_obj) ;
	
	var ONGLETS = getElementsByClass(oclass,null,'a') ;
	for(var i=0 ; i<ONGLETS.length ; i++)
	{
		ONGLETS[i].className = ONGLETS[i].className.replace(/ active/,'') ;
	}
	o.className+=' active' ;
	
	switch(type)
	{
		case 'pro' :
					d.getElementById(id_part).style.display = 'none' ;
					d.getElementById(id_pro).style.display = 'block' ;
					setCookie('LOXAMAffTarif',0,null,'/') ;	
			break ;
		case 'part' :
					d.getElementById(id_pro).style.display = 'none' ;
					d.getElementById(id_part).style.display = 'block' ;
					setCookie('LOXAMAffTarif',1,null,'/') ;	
					
			break ;
	}
}

function ShowOnglet(id_onglet,id_content,class_onglet,class_content)
{
	var d = document ;
  var onglet = d.getElementById(id_onglet) ;
  var content = d.getElementById(id_content) ;
	
	var ONGLETS = getElementsByClass(class_onglet,null,'a') ;
	for(var i=0 ; i<ONGLETS.length ; i++)
	{
		ONGLETS[i].className = ONGLETS[i].className.replace(/ active/,'') ;
	}
	
  var CONTENT = getElementsByClass(class_content,null,'div') ;
	for(var i=0 ; i<CONTENT.length ; i++)
	{
		CONTENT[i].style.display = 'none' ;
	}
	
	onglet.className+=' active' ;
	content.style.display = 'block' ; 

}

function StorePrefTarifs(type)
{
	switch(type)
	{
		case 'pro' :
					setCookie('LOXAMAffTarif',0,null,'/') ;	
			break ;
		case 'part' :
					setCookie('LOXAMAffTarif',1,null,'/') ;	
			break ;
	}
}

function ToggleDisplay(iddiv,type)
{
  if(!type) type="" ;
  switch(type)
  {
    case 'slide' : jQuery('#'+iddiv).slideToggle() ; break ;
    default : jQuery('#'+iddiv).toggle() ;
  }
}

function ToggleClass(iddiv,classname)
{
  jQuery('#'+iddiv).toggleClass(classname) ;
}

function AfficheBlocProduitsFavoris(iddiv,IDUser,IDPreference)
{
	var html_top='',html_bottom='',html='',rep,row=0,nr=0,data,info,deletelink;
	if(!iddiv) iddiv='bloc-favoris' ;
  
  var target = jQuery('#'+iddiv) ;
  
  if(!iddiv || !target.attr('id')=='undefined') return
  if(!IDUser) { return; }
	jQuery.ajax(
	{ 
		url: '/ajax.php',
      type: "POST",
    data: ({ 	ACTION:'GETFAVORIS',
  						IDUser:IDUser,
						IDPreference:IDPreference
						 }),
		error: function()
		{
			alert('Erreur de communication serveur');
		},

		success: function(message, textStatus, jqXHR)
		{
			if(jqXHR.status!=200) alert('ERROR('+jqXHR.status+'): '+message);
			
		
			html_top+='<table width="162" border="0" cellpadding="0" cellspacing="0" class="centrer">';
			html_top+='  <tr><td><img src="/images/bloc-favoris.jpg" width="162" height="37" alt="Mes favoris" title="Mes favoris"></td></tr>';
			html_top+='  <tr><td align="left">';
			html_top+='      <div class="minblocmain favlist">';
			html_top+='  	     <ul class="list2">';

			rep=message.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'+message); 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;
            html+='<li><a href="'+info[2]+'">'+info[4].toLowerCase()+'</a></li>' ; 
						nr++;
					}
					/*html+'</ul>\n';*/
				} else row++;
			}
			html_bottom+='        </ul>';
			html_bottom+='			</div>';
		  html_bottom+=' </td></tr>';
		  html_bottom+=' <tr><td><img src="/images/bloc-bottm.jpg" width="162" height="2" alt=""></td></tr>';
	    html_bottom+='</table><br>';
			if(nr) target.html(html_top+html+html_bottom) ;
			else target.html(html_top+'<li>Aucun produit dans vos favoris</li>'+html_bottom) ;
		}
	
	});	
}


function initDateInput()
{
  jQuery('.date-chooser').each(function()
  {
    var dChooser = jQuery('.datechooser' ,this).get() ;
    var currentInputID = jQuery(dChooser).attr('id') ;

    jQuery(dChooser).attr('autocomplete','off') ;
    dChooser.DateChooser = new DateChooser() ;
    dChooser.DateChooser.setAllowedDays(['1','2','3','4','5','6']);
    dChooser.DateChooser.setIcon('/images/calendar.jpg', currentInputID, true);
    dChooser.DateChooser.setUpdateField( currentInputID,'d/m/Y' ) ;
    var deux_jours = 172800000 ;
    var new_date = new Date().getTime()+deux_jours ;
    dChooser.DateChooser.setEarliestDate(new Date(new_date));
    jQuery(dChooser).click( function(){ jQuery(this).parent().find('.calendaricon')[0].click() ; return false ; } ) ;
  }) ;
}

/*******************************************************************************
 *
 * Fonctions gestion du sélecteur de période
 *
 ******************************************************************************/
function initDateChooser(dElt,type)
{
    var currentInputID = jQuery(dElt).attr('id') ;
    dElt.DateChooser = new DateChooser() ;
    if(type=='begin')
      dElt.DateChooser.setAllowedDays(['1','2','3','4','5','6']);
    else
      dElt.DateChooser.setAllowedDays(['0','1','2','3','4','5']);
    dElt.DateChooser.setIcon('/images/calendar.jpg', currentInputID, true);
    dElt.DateChooser.setUpdateField( currentInputID,'d/m/Y' ) ;
    

    var deux_jours = 172800000 ;
    /*dElt.DateChooser.setEarliestDate(new Date());*/
    var new_date = new Date().getTime()+deux_jours ;
    dElt.DateChooser.setEarliestDate(new Date(new_date));
    
    if(jQuery(dElt).val()!='')
    {
      var DATEPART = jQuery(dElt).val().split('/') ;
      dElt.DateChooser.setSelectedDate( new Date(DATEPART[2],DATEPART[1]-1,DATEPART[0]) ) ;
      dElt.DateChooser.updateFields();
    }
    jQuery(dElt).click( function(){ jQuery(this).parent().find('.calendaricon')[0].click() ; return false ; } ) ;

    return dElt ;
}

function initPeriodChooser()
{
  jQuery('.period-chooser').each(function()
  {
    var dChooserBegin = jQuery('.datechooser-begin' ,this).get() ;
    var dChooserEnd   = jQuery('.datechooser-end' ,this).get() ;

    jQuery(dChooserBegin).attr('autocomplete','off') ;
    jQuery(dChooserEnd).attr('autocomplete','off') ;

    dChooserBegin = initDateChooser(dChooserBegin,"begin") ;
    dChooserEnd   = initDateChooser(dChooserEnd,"end") ;
    if( jQuery(dChooserBegin).val()!='' )
    {
      var DATEPART = jQuery(dChooserBegin).val().split('/') ;
      dChooserEnd.DateChooser.setEarliestDate(new Date(DATEPART[2],DATEPART[1]-1,DATEPART[0]));
      dChooserEnd.DateChooser.updateFields();
    }

    dChooserBegin.DateChooser.setUpdateFunction( function(oDate){ CheckDateBegin(dChooserBegin,dChooserEnd,oDate) }) ;
    dChooserEnd.DateChooser.setUpdateFunction( function(oDate){ CheckDateEnd(dChooserBegin,dChooserEnd,oDate) }) ;
  }) ;
}

function CheckDateBegin(eltBegin,eltEnd,oDate)
{
  var deb = eltBegin ;
  var fin = eltEnd ;

  var current_day = oDate.getDay() ;
  if(current_day=='6' || current_day=='0' )
  {
    jQuery('#note-loc-board').fadeIn() ;
    jQuery('#note-loc-board #note-loc-we').show() ;
  }

  if (typeof(EstFerie) == 'function')
  {
    if(EstFerie(oDate))
    {
      jQuery('#note-loc-board').fadeIn() ;
      jQuery('#note-loc-board #note-loc-ferie').show() ;
    }
  }
  
  if(deb && fin)
  {
  	CheckDate(deb,oDate) ;
    CheckPeriod(deb,fin) ;
    fin.DateChooser.setEarliestDate( oDate );
    fin.DateChooser.updateFields();
  }
}

function CheckDateEnd(eltBegin,eltEnd,oDate)
{
  var fin = eltBegin ;
	var deb = eltEnd ;

  var current_day = oDate.getDay() ;
  if(current_day=='6' || current_day=='0' )
  {
    jQuery('#note-loc-board').fadeIn() ;
    jQuery('#note-loc-board #note-loc-we').show() ;
  }

  if (typeof(EstFerie) == 'function')
  {
    if(EstFerie(oDate))
    {
      jQuery('#note-loc-board').fadeIn() ;
      jQuery('#note-loc-board #note-loc-ferie').show() ;
    }
  }

  if(deb && fin)
  {
    CheckDate(fin,oDate) ;
    CheckPeriod(deb,fin) ;
  }
}

function CheckPeriod(deb,fin)
{
  if(fin.value && deb.value)
	{
    var datePartDeb = deb.value.split('/') ;
		var debDate = datePartDeb[2]+datePartDeb[1]+datePartDeb[0] ;
    var datePartFin = fin.value.split('/') ;
		var finDate = datePartFin[2]+datePartFin[1]+datePartFin[0] ;

		if( debDate > finDate )
		{
			alert('La date de début de chantier doit être antèrieure à celle de fin.') ;
		}
	}
	return true ;
}

function CheckDate(dateInput,d)
{
	var dToday = new Date();
	var dayToday   = dToday.getDate() ;
	var monthToday = dToday.getMonth()+1 ;
	var yearToday  = dToday.getFullYear() ;

  var todayString = yearToday+''+(monthToday>9?monthToday:'0'+monthToday)+''+(dayToday>9?dayToday:'0'+dayToday) ;
  var dateString  = d.getPHPDate('Ymd') ;

  if(dateString)
  {
    if(dateString<todayString)
		{
      //dateInput.value = (dayToday>9?dayToday:'0'+dayToday)+'/'+(monthToday>9?monthToday:'0'+monthToday)+'/'+yearToday ;
      dateInput.DateChooser.setEarliestDate( new Date(yearToday,monthToday-1,dayToday) );
      dateInput.DateChooser.updateFields();
      alert('La date doit être supèrieure à la date d\'aujourd\'hui.') ;
    }
  }
  return true ;
}
/******************************************************************************/
