function convert(id,h,l,p)
  {
  ch=document.getElementById('M'+id).innerHTML;
  if (ch.indexOf("cm")!=-1)
  {   	
	  document.getElementById('H'+id).innerHTML=Math.round(h/2.54)+' inches';
	  document.getElementById('L'+id).innerHTML=Math.round(l/2.54)+' inches';
	  document.getElementById('P'+id).innerHTML=Math.round(p/2.54)+' inches';
	  document.getElementById('M'+id).innerHTML=document.getElementById('M'+id).innerHTML.replace("in","cm");
  }
  else
  {
	  document.getElementById('H'+id).innerHTML=h+' cm';
	  document.getElementById('L'+id).innerHTML=l+' cm';
	  document.getElementById('P'+id).innerHTML=p+' cm';
	  document.getElementById('M'+id).innerHTML=document.getElementById('M'+id).innerHTML.replace("cm","in");

  }
  	  
  }

//------(Sauve user et password courants)
function ecrit_user()
    {
    ecrit_cookie("LOGIN",document.IDENT.USER.value); 
    ecrit_cookie("PASSWORD",document.IDENT.MOT_DE_PASSE_WEB_PROSPECT.value); 
    }

//------(Sauve user et password courants)
function lit_user()
    {
    document.IDENT.USER.value=lit_cookie("LOGIN"); 
    document.IDENT.MOT_DE_PASSE_WEB_PROSPECT.value=lit_cookie("PASSWORD"); 
    }

//-------(recherche cookie)
function lit_cookie(cook)
   {
   var ch;
   ch=document.cookie+";"
   nul=ch.indexOf(cook+"=");
   if (nul!=-1)
      return unescape(ch.substr(nul+cook.length+1,ch.indexOf(";",nul+1)-nul-cook.length-1));
   else
      return "";
   }      

//-------(ecriture cookie)
function ecrit_cookie(cook,valeur)
{

  if (cook) {
     var today = new Date();
     var expiration = new Date(today.getTime() + 730 * 24 * 60 * 60 * 1000);
     document.cookie=cook+"="+escape(valeur)+"; expires="+expiration.toGMTString();
   }
}
   


//-------(Ltrim et rtrim)
function LRtrim(chaine) {
  do
    {if (chaine.substr(0,1)==" ") 
		chaine=chaine.substr(1);
	else
		{break;}
	}
  while (1==1);
    
  do
    {if (chaine.substr(chaine.length-1,1)==" ") 
		chaine=chaine.substr(0,chaine.length-1);
	else
		{break;}
	}
  while (1==1);
  return chaine;
}       


function format_nom(ch){
     var nul=""; 
     var nom=LRtrim(ch.value.toUpperCase());
     for (i=0;i<nom.length;i++)
     {
	if (nom.substr(i,1)>="A" & nom.substr(i,1)<="Z")
  		{nul=nul+nom.substr(i,1);}
     }
     ch.value=nul;
}


function format_alpha(ch){
     ch.value=LRtrim(ch.value);    
}

function format_Ualpha(ch){
     ch.value=LRtrim(ch.value.toUpperCase());    
}


//------------(Conversion des premieres lettres du prenom en maj)
function format_prenom(champ) {
    var valeur,pos,abr;
    valeur=LRtrim(champ.value.toLowerCase());
    valeur=valeur.substr(0,1).toUpperCase()+valeur.substr(1);
    abr=valeur.substr(0,1);
    pos=valeur.indexOf(" ");
    if (pos!=-1)
       {abr=abr+valeur.substr(pos+1,1).toUpperCase();
       valeur=valeur.substr(0,pos+1)+valeur.substr(pos+1,1).toUpperCase()+valeur.substr(pos+2);
       }
    else
       {pos=valeur.indexOf("-");
       if (pos!=-1)
		{abr=abr+valeur.substr(pos+1,1).toUpperCase();
		valeur=valeur.substr(0,pos+1)+valeur.substr(pos+1,1).toUpperCase()+valeur.substr(pos+2);}
       }
    champ.value=valeur;
}



function format_cp(ch){
     var nul=""; 
     var nom=ch.value.toUpperCase();
     for (i=0;i<nom.length;i++)
     {
	if (nom.substr(i,1)>="0" & nom.substr(i,1)<="9")
  		{nul=nul+nom.substr(i,1);}
     }
     ch.value=nul;   
}


function format_tel(ch){
     var nul=""; 
     var nom=ch.value.toUpperCase();
     for (i=0;i<nom.length;i++)
     {
	if (nom.substr(i,1)>="0" & nom.substr(i,1)<="9")
  		{nul=nul+nom.substr(i,1);}
     }
     ch.value=nul;
}

function format_code(ch){
     var nul=""; 
     var nom=ch.value.toUpperCase();
     for (i=0;i<nom.length;i++)
     {
	if (nom.substr(i,1)>="0" & nom.substr(i,1)<="9")
  		{nul=nul+nom.substr(i,1);}
     }
     ch.value=nul;
     INSCRIPTION.NOM.focus();
}


function control_email(ch)
{
<!--- si la valeur ne contient pas @ --->
        if (ch.value.indexOf("@")==-1 || ch.value=="votre@email.com" || ch.value=="your@email.com")   
        {       
    		if (ch.value=="votre@email.com" || ch.value=="your@email.com") ch.value="";
	        return x_alert(error_email,ch);
        }
        else
        {
                longueur = ch.value.length;
                position = ch.value.indexOf("@");
                left_str = ch.value.substring(0,position);
                right_str = ch.value.substring(position+1,longueur);
                left_len = left_str.length;
                right_len = right_str.length;

<!--- si la valeur gauche ou droite du @ est vide --->
                if ((left_len==0) || (right_len==0))
                {
                return x_alert(error_email,ch);
                }
                else
                {
<!--- s'il n'y a pas de point --->
                        if (right_str.indexOf(".")==-1)
                        {
                        return x_alert(error_email,ch);
                        }
                        else
                        {
                                right_longueur = right_str.length;
                                right_position = right_str.lastIndexOf(".");
                                l_right_str = right_str.substring(0,right_position);
                                r_right_str = right_str.substring(right_position+1,right_longueur);
                                l_right_len = l_right_str.length;
                                r_right_len = r_right_str.length;

<!--- s'il y a au moins 2 lettres après le point --->
                                if ((r_right_len < 2)||(r_right_len > 4))
                                {
                                return x_alert(error_email,ch);
                                }
                                else
                                {
<!--- s'il y a au moins 1 lettre après le point --->
                                        if (l_right_len==0)
                                        {
                                        return x_alert(error_email,ch);
                                        }
                                }
                        }
                }
        }
return true;
}

//------(Ie ou pas)
function ie()
	{	
	   if (navigator.userAgent.indexOf('MSIE')>0) 
	   		return true;
	   else
	   		return false;
	}


//------(Texte déroulant en bas écran)
espace="                                                                                                                                                                                  ";
if (status_text)
	{
	status_text+=espace.substring(0,status_text.length*2+4)
	status_place=status_text.length;
	status_deroul();
	}

function status_deroul(){
    if (status_place == status_text.length) 
      {status_place = 0; tim=4000;}
    else
       tim=110;   
    if (status_place < status_text.length){
	  	window.status = status_text.substring(status_place,status_text.length) + status_text.substring(1,status_place);
		status_place++;
	}
	setTimeout("status_deroul()", tim);
}

var tmp_ch;
var tmp_ch_b;
var tmp_ch_c;
var nocancel;
var time_cancel;

function x_alert(err,ch)
{
 
 if (ch)
 	{
 	 if (tmp_ch) cancel_alert();
	 tmp_ch=ch;
	 if (ch!=-1)
	 	 {
	 	 tmp_ch_b=ch.style.borderStyle;
		 tmp_ch_c=ch.style.borderColor;
		 ch.style.borderStyle="double";
		 ch.style.borderColor="#FF0000";
		 ch.focus();
		 }
	}
  if (document.getElementById('TEXTE_MENU'))
  	{
	  tmp_TEXTE_MENU=TEXTE_MENU.innerHTML;
	  TEXTE_MENU.innerHTML="<table width=100% border=0><tr><td><div class='ERROR'><table width=540><tr><td width=30><img src='images/erreurs.gif'></td><td>"+err+"</td></tr></table></div></td></tr></table>";
	}
 time_cancel=setTimeout("cancel_alert();",3000);	
 return false;
}

function cancel_alert()
{
 clearTimeout(time_cancel);
 if (!tmp_ch) return;
 if (!nocancel)
	{
	 document.getElementById('TEXTE_MENU').innerHTML=tmp_TEXTE_MENU;
	 if (tmp_ch!=-1)
		{
		tmp_ch.style.borderStyle=tmp_ch_b;
		tmp_ch.style.borderColor=tmp_ch_c;
		tmp_ch=null;
		}
	 }
 else
 	nocancel=0;	 
}

//----------(gestion barre outils dynamique en survol images)
var tempo,href;
var BARREMENU_B1;
function getTop(Obj)
    {
    if (Obj.offsetParent) return Obj.offsetTop+getTop(Obj.offsetParent); else return Obj.offsetTop;
    }
function getLeft(Obj)
    {
    if (Obj.offsetParent) return Obj.offsetLeft+getLeft(Obj.offsetParent); else return (Obj.offsetLeft);
    }
function getWidth(Obj)
    {
    if (Obj.offsetParent) return Obj.offsetWidth+getWidth(Obj.offsetParent); else return (Obj.offsetWidth);
    }
var Obj;
var ref;
var des; 
var temp;   
var FLG_DEL=0;
function set(Ob,re,de,tim)
    {
    Obj=Ob;
    ref=re;
    des=de;
    set1();
//    temp=setTimeout('set1()',tim);
    }
    
function set1()
{

	clearTimeout(tempo);
	if (ie())
		{
		document.getElementById('BARREMENU').style.pixelTop=y_souris;//Math.max(0,getTop(Obj)+3);
		document.getElementById('BARREMENU').style.pixelLeft=Math.max(0,getLeft(Obj)+Obj.offsetWidth-document.getElementById('BARREMENU').offsetWidth-3);
		}
	else
		{
		document.getElementById("BARREMENU").style.top=y_souris;//Math.max(getTop(Obj)+3);
		document.getElementById('BARREMENU').style.left=x_souris;//Math.max(getLeft(Obj)+Obj.offsetWidth-document.getElementById('BARREMENU').offsetWidth-3);
		}
	
	document.getElementById('BARREMENU').style.zIndex=9;	
	if (des.substr(0,1)=="#") 
		{
		document.getElementById('BARREMENU_TXT').innerHTML=des.substr(1);
		document.getElementById('I_GAL').src='images/close.gif';
		document.getElementById('A_GAL').title=	document.getElementById('DEL_GAL').title;
		FLG_DEL=-1;
		}
	else
		{	
		document.getElementById('BARREMENU_TXT').innerHTML=des;	
		document.getElementById('I_GAL').src='images/prendre.gif';
		document.getElementById('A_GAL').title=	document.getElementById('ADD_GAL').title;
		FLG_DEL=0;
		}

	
	BARREMENU_B1=ref;
}
function barremenu_zoom()
{popupnr("externe.php?url=pages/oeuvre.php&det="+BARREMENU_B1+"&pxdet=x&close=1","oeuvre",'toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,copyhistory=0,menuBar=0',738,400);}

function buy_open(ID)
{popupnr("externe.php?url=pages/oeuvre.php&det="+ID+"&pxdet=x&close=1&buy=1","oeuvre",'toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,copyhistory=0,menuBar=0',738,400);}

var IMG_CURRENT=0;
function print_oeuvre(DET,IMG,FP)
{
if (!FP) FP=1;
popupnr("print.php?url=pages/oeuvre.php&det="+DET+"&pxdet=x&print="+FP+"&numimg="+IMG,"print_oeuvre",'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,menuBar=0',800,700);
}

function print_presse(lien)
{popupnr(lien,"print_presse",'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,menuBar=0',800,700);}

function mail_presse(lien)
{popupnr(lien,"mail_presse",'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,menuBar=0',800,700);}


function forum()
{popupnr("forum/index.php","forum",'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,menuBar=0',800,700);}


function ajoute_galerie(DET,ETAT,SES_GAL)
{
if (!DET) DET=BARREMENU_B1;
if (!ETAT) ETAT=1;
if (SES_GAL) SES_GAL="&ses_gal="+SES_GAL; else SES_GAL="";
popupnr("externe.php?url=pages/oeuvre.php&det="+DET+"&pxdet=x&close=1&ajoute="+ETAT+SES_GAL,"oeuvre_ajoute",'toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=1,copyhistory=0,menuBar=0',738,550);
}


function popupnr(mylink, windowname,opt,w,h)
{
	mywin=window.open('',windowname,opt+',width='+w+',height='+h);
	
	mywin.location=mylink;
	mywin.focus();
}

function unset(Obj)
{
	if (ie()==true)
		{
		if (event.offsetY>0 && event.offsetY+1<Obj.offsetHeight && event.offsetX>0 && event.offsetX+1<Obj.offsetWidth) return;
		}
	else
		{
		return;
		}

	tempo=setTimeout('unset1()',500)
}	

function unset1()
	{
	BARREMENU.style.zIndex=-1;
	BARREMENU.style.posTop=-999;
	BARREMENU.style.posLeft=-999;
	}


function capture_souris(evt)
{
	if(!evt) evt = window.event;	
	x_souris = evt.clientX+document.body.scrollLeft;
	y_souris = evt.clientY+document.body.scrollTop;	
}


var x_souris,y_souris;
document.onmousemove = capture_souris;

