
function PressePut(content)
{
	if (content!="")	elem('celRight').innerHTML = '<a href="'+ff+content+'.pdf" border="0" target="_blank"><img src="'+ff+content+'.jpg" border="0" /></a>';
	else				elem('celRight').innerHTML = '&nbsp;';
}
function BuildHoverLink()
{
	// ff est globale
	var links,i,path,p,name;
	links = document.getElementsByTagName('a');
	for (i=0 ; i<links.length ; i++)
	{
		path = links[i].pathname;
		p = path.indexOf(ff);
		if (p>=0)
		{
			p += ff.length;
			links[i].mypathname = ''+ff+path.substring(p,path.lastIndexOf("."));
			links[i].onmouseover = function() 
									{
										var img = this.mypathname;
										elem('celRight').innerHTML = '<img src="'+img+'.jpg" border="0" />';
									};
			links[i].onmouseout = function() 
									{
										elem('celRight').innerHTML = '&nbsp;';
									};
			links[i].target = "_blank";
		}
	}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
function zoomphoto(type,photoname,num,promopic)
{
	window.open("pop_zoom.php?type="+type+"&pr="+photoname+"&num="+num+"&promopic="+promopic,"ZOOM"+photoname,"menubar=no, status=no, scrollbars=yes, menubar=yes, width=620, height=800");
}
function elem(truc)
{
	return(document.getElementById(truc));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
function _valideTxt(txtfield,good,bad)
{
	if (txtfield.value=="")
	{
		txtfield.className = bad;
		return(1);
	}
	txtfield.className = good;
	return(0);
}
function _valideNum(txtfield,good,bad)
{
	if (txtfield.value=="" || txtfield.value<1)
	{
		txtfield.className = bad;
		return(1);
	}
	txtfield.className = good;
	return(0);
}
function _valideEmail(txtfield,good,bad)
{
	var mail = /^[\w\-]+(\.[\w\-]+)*@[\w\-]+(\.[\w\-]+)*\.[\w\-]{2,}$/;
	if (txtfield.value=="" || !mail.test(txtfield.value))
	{
		txtfield.className = bad;
		return(1);
	}
	txtfield.className = good;
	return(0);
}
function _valideChk(chkfield,good,bad)
{
	if (chkfield.checked==false)
	{
		chkfield.className = bad;
		return(1);
	}
	chkfield.className = good;
	return(0);
}
//----------------------------------------------------------------------------------------------------------------------------------------------
function ValideRegister(frm,good,bad)
{
	var err=0;
	err += _valideTxt(frm.CTC_fname,good,bad);
	err += _valideTxt(frm.CTC_lname,good,bad);
	err += _valideEmail(frm.CTC_email,good,bad);
	err += _valideTxt(frm.pwd1,good,bad);
	if (frm.pwd1.value != frm.pwd2.value)
	{
		alert('La confirmation du mot de passe a échoué.');
		frm.pwd2.className = bad;
		frm.pwd2.value = "";
		err ++;
	}
	else frm.pwd2.className = good;
	err += _valideTxt(frm.CTC_telpriv,good,bad);
	if (err>0)	return(false);
	return(true);
}
function ValideRegister_adr(frm,good,bad)
{
	var err=0;
	err += _valideTxt(frm.ADR_adress,good,bad);
	err += _valideTxt(frm.ADR_codepost,good,bad);
	err += _valideTxt(frm.ADR_town,good,bad);
	err += _valideNum(frm.ADR_p_zonegeo,good,bad);
	if (err>0)	return(false);
	return(true);
}
function ValideRegister_pro(frm,good,bad)
{
	var err=0;
	err += _valideTxt(frm.STE_name,good,bad);
	err += _valideTxt(frm.STE_siret,good,bad);
	err += _valideTxt(frm.STE_tvaintra,good,bad);
	if (err>0)	return(false);
	return(true);
}
function ValideCGV(frm,good,bad)
{
	err = 0;
	err += _valideChk(frm.chkCGV,good,bad);
	if (err>0)
	{
		alert('Merci de bien vouloir consulter les Conditions Générales de Vente\net confirmer que vous les acceptez.');
		return(false);
	}
	return(true);
	
}
function ValideContact(frm,good,bad)
{
	var err=0;
	err += _valideTxt(frm.txtLname,good,bad);
	err += _valideTxt(frm.txtEmail,good,bad);
	err += _valideTxt(frm.txtCodepost,good,bad);
	err += _valideTxt(frm.txtMess,good,bad);
	if (err>0)	return(false);
	return(true);
}
//----------------------------------------------------------------------------------------------------------------------------------------------
var Modfied=false;
function initChanged()	{	Modified = false;	}
function Changed()		{	Modified = true;	}
function chkChanged()
{
	if (!Modified)	return(true);
	return(confirm("Abandonner les modifications ?"));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
//-- LIB
//-------------------------------------------------------------------------------------------------------------------------------------------------
function debug(obj)
{
	var result = "";
	var lines = 0;
	var perbox = 15;
	var contenu = "";
	for (var i in obj)
	{
		result += "objet." + i + " = " + obj[i] + "\n";
		lines ++;
		if (lines>perbox)
		{
			result += "\n\nContinuer ?";
			if (!confirm(result))	return;
			lines = 0;
			result = "";
		}
	}
	if (lines)	alert(result);
	else		alert('');
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
function chkCookies()
{
	SetCookie('cookie_test','something');
	var res=GetCookie('cookie_test');
	if (res=='something')
	{
		DelCookie('cookie_test');
//alert('cookie ok');
		return;
	}
	else
	{
		document.location.replace("nocookie.php");
	}
}
function SetCookie(name, value)
{
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	if (expires!==null)	
	{
		expires = Date(expires);
	}
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
//alert('cookie set : '+name+'='+value);		
}
function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie(name)
{
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen)
	{
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)	
		{
//alert('cookie get : '+name+' ('+getCookieVal (j)+')');	
			return getCookieVal(j);
		}
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
	}
	return("");
}
function DelCookie(name)
{
	if (document.cookie.indexOf(name)!=-1)
	{
		var date_exp = new Date();
		date_exp.setTime(date_exp.getTime()-(1000));
		SetCookie(name,'',date_exp);
//alert('cookie del : '+name);		
	}
}
function MyEncode(str)
{
	res = "";
	for ( i=0 ; i<str.length ; i++)
	{
		c = str.charAt(i);
		d = str.charCodeAt(i);
		if (d<0x0030)					res = res+"&#"+d+";";
		else if (d>0x0039 && d<0x0041)	res = res+"&#"+d+";";
		else if (d>0x005A && d<0x0061)	res = res+"&#"+d+";";
		else if (d>0x007A)				res = res+"&#"+d+";";
		else							res = res+c;
	}
//	alert(res);
//	alert(escape(res));
	return(escape(res));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
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_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_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_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];}
}

