// JavaScript Document 
<!-- 
function MM_swapImgRestore() { //v3.0 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; 
} 
 
function MM_preloadImages() { //v3.0 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); 
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) 
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} 
} 
 
function MM_findObj(n, d) { //v4.01 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
  if(!x && d.getElementById) x=d.getElementById(n); return x; 
} 

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}
// FONCTION D'OUVERTURE DE POPUP A LA DIMENSION DE L'IMAGE
function twPopupImage(img, titre, auteur) {
  // Compatible IE5+ / NN6+ / Mozilla
  oFenetre = window.open('','Image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no');
  oFenetre.document.write("<html><head><title>"+titre+"</title></head>");
 oFenetre.document.write("<script type=\"text/javascript\">function twAjustePopUp() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+40); window.focus();} else { setTimeout('twAjustePopUp()',1000) } }</"+"script>");
 oFenetre.document.write("<body onload='twAjustePopUp()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
 oFenetre.document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><tr><td valign='middle' align='center'>");
 oFenetre.document.write("<img src='"+img+"' border='0' alt='"+auteur+"' title='"+auteur+"'>");
 oFenetre.document.write("</td></tr></table></body></html>");
 oFenetre.document.close();
} 

<!--
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
 
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); 
    if (val) { nm=val.name; if ((val=val.value)!="") { 
	
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->

function MM_validateFormMsg() { //v4.0 
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormMsg.arguments; 

  for (i=0; i<(args.length-2); i+=4) { test=args[i+2];msgchamp=args[i+3]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") { 
      if (test.indexOf('isEmail')!=-1) { 
		p=val.indexOf('@'); 
        if (p<1 || p==(val.length-1)) errors+='- '+msgchamp+' must contain an e-mail address.\n'; 
      	} 
	  else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- Invalid '+msgchamp+' (be sure to enter only numbers)\n'; 
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); 
          min=test.substring(8,p); max=test.substring(p+1); 
          if (val<min || max<val) errors+='- Invalid '+msgchamp+' (be sure to enter number between '+min+' and '+max+'.\n'; 
    } } } else if (test.charAt(0) == 'R') errors += '- '+msgchamp+' is required.\n'; } 
  } if (errors) alert('Sorry, we could not process your request due to the following error(s):\n'+errors); 
  document.MM_returnValue = (errors == ''); 
}

function ValidateFormCompte(form)
	{
	MM_validateFormMsg('last_name','','R','Last Name','first_name','','R','First Name','address','','R','Address','city','','R','City','phone','','R','Phone','zipcode','','R','Zipcode','last_name2','','R','Shipping Last Name','first_name2','','R','Shipping First Name','address2','','R','Shipping Address','city2','','R','Shipping City','zipcode2','','R','Shipping Zipcode','password','','R','Password','email','','RisEmail','E-mail');
	retour=document.MM_returnValue;
	if (retour==true)
		{
		if(form.password.value != form.password2.value) {
			retour=false;
        	alert("Les deux mots de passe que vous avez saisis ne correspondent pas.");
		}else{
			retour=true;
			if (form.password.value.length < 4)
				{
				retour=false;
				alert ("Your password must have at least 4 characters.");
				}
			else
				{
				retour=true;
				}
			// CONTROLE SUR LES CONDITIONS DE VENTES
			/*if (document.forms[0].elements["conditions_de_vente"].checked==false)
			{
			retour=false;
			alert('Vous devez avoir pris connaissance des conditions de vente');
			}else{
			retour=true;
			}*/
		}
	}else{
	retour=false;
	}
return retour;
}

function MM_swapImage() { //v3.0 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) 
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} 
} 
 
function MM_reloadPage(init) {  //reloads the window if Nav4 resized 
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { 
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} 
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); 
} 
MM_reloadPage(true); 
 
function MM_showHideLayers() { //v6.0 
  var i,p,v,obj,args=MM_showHideLayers.arguments; 
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; 
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } 
    obj.visibility=v; } 
} 
 
function MM_openBrWindow(theURL,winName,features) { //v2.0 
  window.open(theURL,winName,features); 
} 
 
function MM_goToURL() { //v3.0 
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false; 
  var Obj_sel=args[0]+"."+args[1]; 
  var Elt_sel=eval(args[0]+"."+args[1]+".selectedIndex");	 
  if (Elt_sel != 0) 
	  for (i=2; i<(args.length-1); i+=2)   
	  	{ 
		var val_liste=eval(Obj_sel+".options["+Elt_sel+"].value"); 
		var url=args[i]+".location='"+args[i+1]+"&id="+val_liste+"'";  
		eval(url); 
		} 
} 

function AfficheCalqueBlock(calque,type)
	{
	if (type==1)
		{ eval("document.getElementById('"+calque+"').style.display = 'block';"); 
		//eval("MM_showHideLayers('"+calque+"','','show');"); 
		}
	else
		{ eval("document.getElementById('"+calque+"').style.display = 'none';"); 
		//eval("MM_showHideLayers('"+calque+"','','hide');"); 
		}

	}

function suppression(id, redir, msg)
    {
    if(confirm('Voulez-vous vraiment supprimer ' + msg +' !'))
       	document.location.href=redir+'&supp=1&id='+id;
    }
function bouton() 
{
var args=bouton.arguments;
window.location.replace(args[0]);
}
function supprapide(msg) 
    { 
    if(confirm('Voulez-vous vraiment suprimer '+msg+' !')) 
		{ document.form1.submit(); } 
    } 

function chcat(liste) { 
  var n=liste.options[liste.selectedIndex].value; 
  if (n==-1) this.window.location='news_liste.php'; 
  else  this.window.location='news_liste.php?SearchWhere='+n; 
} 
function chcat2(liste,choix) { 
  var n=liste.options[liste.selectedIndex].value; 
  if (n==-1) this.window.location=choix; 
  else  this.window.location=choix+'?SearchWhereEtat='+n; 
} 
function chcat3(liste,choix) { 
  var n=liste.options[liste.selectedIndex].value; 
  if (n==-1) this.window.location=choix; 
  else  this.window.location=choix+'?SearchWhereRubrique='+n; 
} 
function chetat(liste) { 
  var n=liste.options[liste.selectedIndex].value; 
  if (n==-1) this.window.location='news_liste.php'; 
  else  this.window.location='news_liste.php?SearchWhere='+n; 
}
var offsetfrommouse=[10,20]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.

var defaultimageheight = 40;	// maximum image size.
var defaultimagewidth = 40;	// maximum image size.
var CoordX=0; var CoordY=0;

function showtrail(imagename,title,posleft,postop){
	i = imagename
	t = title
	timer = setTimeout("ChargementPhoto('"+i+"',t,"+posleft+","+postop+");",100);
}

function register_position()
	{  
     mouse_x = 0;  mouse_y = 0;  
     document.onmousemove = position;  
	}  
function position(evt)
	{  
     if(!evt) evt = window.event;      
     mouse_x = evt.clientX;  mouse_y = evt.clientY;
    CoordX=mouse_x;CoordY=mouse_y;
    }

function remove_loading() {
var targelem = document.getElementById('loader_container');
var targephoto = document.getElementById('preview_temp_load');
//targephoto.style.padding="5px;";
targephoto.style.border="thin solid #000000";
targephoto.style.background='#ffffff';
targephoto.style.display="block";
targephoto.style.visibility='visible';

targelem.style.display='none';
targelem.style.visibility='hidden';
//var t_id = setInterval(animate,60);
}
/*
function ChargementPhoto(imagename,title,posleft,postop)
	{
	newHTML = '<div class="border_preview" style="width:<?=$longueurdiv?>px;height:50px">';
	newHTML = newHTML + '<div id="loader_container" style="position:absolute;z-index:120; width:0px;height:0px;background-color: #ffffff; layer-background-color: #ffffff;"></div>';
	//newHTML = newHTML + '<div id="loader_container" style="position:absolute;z-index:120; width:80px;height:50px;background-color: #ffffff; layer-background-color: #ffffff; border: 1px solid #000000;"text-align:center;vertical-align:middle;" align="center"><br><br><br><br><br><br><img src="/images/pictos/ajax-loader.gif" border="0"><br><font face="Verdana" size="2">chargement de la photo en cours...</font></div>';
	//document.getElementById('previewdiv').innerHTML=HTMLLoading;	
	//HTMLImgCharge = '<h2 class="title_h2">'+title+'</h2>';
    newHTML = newHTML + '<div id="preview_temp_load" style="position:absolute;z-index:0;display:none;"><img onload="javascript:remove_loading();" src="' + imagename + '" id="imgsel" border="0"></div>';
	newHTML = newHTML + '</div>'; 
	//affichage(newHTML,HTMLImgCharge);
	//document.getElementById('previewdiv').innerHTML	= newHTML;	
	//timer = setTimeout("affichage(newHTML,HTMLImgCharge);",500);
	affichage(newHTML,posleft,postop);
	}

function affichage(newHTML,posleft,postop)
	{
	document.getElementById("previewdiv").style.left = posleft;
	document.getElementById("previewdiv").style.top = postop;
	//document.getElementById("previewdiv").style.visibility= "visible";
	document.getElementById("previewdiv").style.display="block";
	document.getElementById('previewdiv').innerHTML	= newHTML;
	document.onmousemove=followmouse; 	
	}
function effcalque() 
	{
	//document.getElementById("previewdiv").style.visibility='hidden';
	document.getElementById("previewdiv").style.display="none";
	}
*/
function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]
	var targepreview = document.getElementById('previewdiv');

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = e.pageX - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){
			ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	targepreview.style.left=xcoord+"px"
	targepreview.style.top=ycoord+"px"
}

function number_format(a, b, c, d) {
	// number_format(number, decimals, comma, formatSeparator)
	a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
	e = a + '';
	f = e.split('.');
	if(!f[0]) f[0] = '0';
	if(!f[1]) f[1] = '';
	if(f[1].length < b){
		g = f[1];
		for(i = f[1].length + 1; i <= b; i++) {
			g += '0';
		}
		f[1] = g;
	}
	if(d != '' && f[0].length > 3) {
		h = f[0];
		f[0] = '';
		for(j = 3; j < h.length; j += 3) {
			i = h.slice(h.length - j, h.length - j + 3);
			f[0] = d + i +  f[0] + '';
		}
		j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
		f[0] = j + f[0];
	}
	c = (b <= 0) ? '': c;
	return f[0] + c + f[1];
}

<!--FORMULAIRE ECOMMERCE-->
function affectechamp(chpdest,chporig)
	{
	eval("document.commande."+chpdest+".value=document.commande."+chporig+".value");
	}
function MAJchps()
	{
	if (document.commande.livraison.checked) {effacer();}
	else {retablir();}
	}
function effacer()
	{
	document.commande.first_name2.value='';
	document.commande.last_name2.value='';
	document.commande.company2.value='';	
	document.commande.address2.value='';
	document.commande.zipcode2.value='';
	document.commande.city2.value='';
	}
function retablir()
	{
	document.commande.first_name2.value=document.commande.first_name.value;
	document.commande.last_name2.value=document.commande.last_name.value;
	document.commande.company2.value=document.commande.company.value;	
	document.commande.address2.value=document.commande.address.value;
	document.commande.zipcode2.value=document.commande.zipcode.value;
	document.commande.city2.value=document.commande.city.value;
	}
function cdg(pdf)
	{
	window.open(pdf);	
	}
//--> 