
Number.prototype.format=function(precision){dec='.';thou=',';for(var i=0;i<arguments.length;i++){if(i==0)precision=arguments[i];if(i==1)dec=arguments[i];if(i==2)thou=arguments[i];}
o=this.toFixed(precision);o=o.toString();parts=o.split('.');var cnum=parts[0],parr=[],j=cnum.length,m=Math.floor(j/3),n=cnum.length%3||3;for(var i=0;i<j;i+=n){if(i!=0){n=3;}
parr[parr.length]=cnum.substr(i,n);m-=1;}
fnum=parr.join(thou);o=(precision==0?fnum:fnum+dec+parts[1]);return o;}
function number_format(number,precision){dec_sep=".";th_sep=",";for(var i=0;i<arguments.length;i++){if(i==0)number=arguments[i];if(i==1)precision=arguments[i];if(i==2)dec_sep=arguments[i];if(i==3)th_sep=arguments[i];}
return new Number(number).format(precision,dec_sep,th_sep);}
function GetHRObject()
{var HttpReq;if(typeof(XMLHttpRequest)!='undefined')
{HttpReq=new XMLHttpRequest();}
else
{try
{HttpReq=new ActiveXObject('Microsoft.XMLHTTP');}
catch(e)
{HttpReq=null;}}
return HttpReq;}
function UpdateBasket()
{var HttpReq=GetHRObject();if(!HttpReq)
{return;}
HttpReq.onreadystatechange=function()
{if(HttpReq.readyState==4&&HttpReq.status==200)
{Data=HttpReq.responseText.split(';');var basket=$('basket');basket.className=basket.className.replace(/ o(n|ff)/,'')+' on';$('BasketProdCount').getElement('a').setHTML(number_format(Data[0],0,',',' ')+' article'+(Data[0]<=1?'':'s'));$('BasketAmount').setHTML(number_format(Data[1],2,',',' ')+' &euro;');}}
HttpReq.open('GET','/request/BasketUpdate.php');HttpReq.send(null);}
function ChangeAmount(ItemID,Qte,Name)
{var HttpReq=GetHRObject();if(!HttpReq)
{document.location.href='/panier.nt.html?op=prodmod&prod='+ItemID+'&qte='+Qte;return;}
HttpReq.onreadystatechange=function()
{if(HttpReq.readyState==4&&HttpReq.status==200)
{if(HttpReq.responseText=='OK')
{var BasketMsgHold=document.createElement("div");BasketMsgHold.style.backgroundColor='#999999';BasketMsgHold.style.width='340px';BasketMsgHold.style.height='200px';BasketMsgHold.id='ProdBasketAlert';BasketMsgHold.style.position='absolute';BasketMsgHold.style.zIndex='2000';var BasketMsg=document.createElement("div");BasketMsg.style.width='340px';BasketMsg.style.height='200px';BasketMsg.style.position='relative';BasketMsg.style.background='URL(/images/gui/main/BskPopBg.jpg) center no-repeat #FFFFFF';BasketMsg.style.border='2px solid #333333';BasketMsg.style.left='-5px';BasketMsg.style.top='-5px';var HTML=''
+'<div style="background:url(/images/gui/main/FooterBarBg.gif) center; padding:3px; color:#FFFFFF; font-weight:bold;">Panier</div>'
+'<div>'
+'<table width="100%" border="0" cellspacing="0" cellpadding="2">'
+'<tr>'
+'<td height="70" colspan="3" style="vertical-align:middle;" style="color:#333333;">';if(Name)
{HTML+='<div style="margin-left:16px;font-size:14px; font-weight:bold;">'+Name+'</div>'
+'<div style="margin-left:16px;">Cet article a bien &eacute;t&eacute; ajout&eacute; &agrave; votre panier.</div>'
+'<div style="margin-left:16px;">Quantité ajoutée : <span style="color:#B71800">'+Qte+'</span></div>';}
HTML+='</td>'
+'</tr>'
+'<tr>'
+'<td width="30%" height="48" style="text-align:center;vertical-align:top;">'
+'<a href="#" onclick="ProdAlertValidate(true); return false;">'
+'<img src="/images/gui/main/BskIcoStay.gif" width="44" height="37" border="0" alt="Rester sur la page" title="Rester sur la page" />'
+'</a>'
+'</td>'
+'<td width="40%" height="48" style="vertical-align:top;"">&nbsp;</td>'
+'<td width="30%" height="48" style="text-align:center;vertical-align:top;">'
+'<a href="#" onclick="ProdAlertValidate(false); return false;">'
+'<img src="/images/gui/main/BskIcoBasket.gif" width="44" height="37" border="0" alt="Visualiser votre panier" title="Visualiser votre panier" />'
+'</a>'
+'</td>'
+'</tr>'
+'<tr>'
+'<td style="text-align:center;padding-left:20px;line-height:12px;">Rester sur la page</td>'
+'<td>&nbsp;</td>'
+'<td style="text-align:center;padding-right:20px;line-height:12px;">Visualiser votre panier</td>'
+'</tr>'
+'</table>'
+'</div>';BasketMsg.innerHTML=HTML;BasketMsgHold.appendChild(BasketMsg);document.body.appendChild(BasketMsgHold);if(navigator.appName=="Microsoft Internet Explorer")
{ScrollY=document.documentElement.scrollTop+document.body.scrollTop;ScrollX=document.documentElement.scrollLeft+document.body.scrollLeft;}
else
{ScrollY=window.pageYOffset;ScrollX=window.pageXOffset;}
var View={width:(window.innerWidth?window.innerWidth:(document.documentElement&&document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.clientWidth),height:(window.innerHeight?window.innerHeight:(document.documentElement&&document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight)}
hasFlash=false;flashs=document.getElementsByTagName('object');for(var i=0;i<flashs.length;i++){if(flashs[i].parentNode.className.match(/^asset (.*)wide$/)){hasFlash=true;break;}}
BasketMsgHold.style.left=(View.width/2-BasketMsgHold.offsetWidth/2+ScrollX)+'px';BasketMsgHold.style.top=(View.height/2-BasketMsgHold.offsetHeight/2+ScrollY)+'px';if(hasFlash&&document.documentElement.scrollTop<180){BasketMsgHold.style.marginTop=(187-document.documentElement.scrollTop)+'px';}
UpdateBasket();}}}
HttpReq.open('GET','/request/ItemAmount.php?ref='+ItemID+'&qte='+Qte,true);HttpReq.send(null);}
function ProdAlertValidate(Stay)
{ProdAlert=document.getElementById('ProdBasketAlert');ProdAlert.parentNode.removeChild(ProdAlert);if(!Stay)
document.location.href='/panier.html';}
function ProdListUpdate(Cat,Sort,SortOrder,Page,ShowVisuals)
{PlcElem=document.getElementById('Plc');PlcElem.innerHTML='<img src="/images/gui/main/Reload.gif" width="16" height="16" align="top" alt="" /> En cours de chargement ...';var HttpReq=GetHRObject();if(HttpReq)
Url='/request/ProdList.php?ref='+Cat;else
Url=document.location.pathname+'?';Filters=document.getElementsByName('Filter');for(i=0;i<Filters.length;i++)
{F=Filters[i];if(F.type=='checkbox')
{if(F.checked)
Url+='&f['+F.id.substr(6)+']='+F.value;}
else
{Url+='&f['+F.id.substr(6)+']='+F.value;}}
Brands=document.getElementById('FilterBrand');if(Brands)
Url+='&fb='+Brands.value;Price=document.getElementById('FilterPriceValue');Url+='&fp='+Price.value;SfObj=document.getElementById('FilterSF');if(SfObj)
Url+='&sf='+SfObj.value;Url+='&sort='+Sort+'&so='+SortOrder;Url+='&p='+Page;ProdList=document.getElementsByName('comp');for(var i=0;i<ProdList.length;i++)
{if(ProdList[i].checked==true)
{Url+='&prodlist[]='+ProdList[i].value;}}
if(!HttpReq)
{document.location.href=Url;return;}
HttpReq.onreadystatechange=function()
{if(HttpReq.readyState==4&&HttpReq.status==200)
{if(HttpReq.responseText)
{ProdSpace=document.getElementById('ProdListArea');ProdSpace.innerHTML=HttpReq.responseText;}}}
HttpReq.open('GET',Url,true);HttpReq.setRequestHeader('X-Requested-With','XmlHttpRequest');HttpReq.send(null);}
function ProdListPpp(Cat,Ppp)
{PlcElem=document.getElementById('Plc');PlcElem.innerHTML='<img src="/images/gui/main/Reload.gif" width="16" height="16" align="top" alt="" /> En cours de chargement ...';var HttpReq=GetHRObject();if(HttpReq)
Url='/request/ProdList.php?ref='+Cat+'&n='+Ppp;else
Url=document.location.pathname+'?n='+Ppp;ProdList=document.getElementsByName('comp');for(var i=0;i<ProdList.length;i++)
{if(ProdList[i].checked==true)
{Url+='&prodlist[]='+ProdList[i].value;}}
if(!HttpReq)
{document.location.href=Url;return;}
HttpReq.onreadystatechange=function()
{if(HttpReq.readyState==4&&HttpReq.status==200)
{if(HttpReq.responseText)
{ProdSpace=document.getElementById('ProdListArea');ProdSpace.innerHTML=HttpReq.responseText;}}}
HttpReq.open('GET',Url,true);HttpReq.send(null);}
function ProdListView(Cat,ViewType)
{PlcElem=document.getElementById('Plc');PlcElem.innerHTML='<img src="/images/gui/main/Reload.gif" width="16" height="16" align="top" alt="" /> En cours de chargement ...';var HttpReq=GetHRObject();if(HttpReq)
Url='/request/ProdList.php?ref='+Cat+'&v='+ViewType;else
Url=document.location.pathname+'?v='+ViewType;ProdList=document.getElementsByName('comp');for(var i=0;i<ProdList.length;i++)
{if(ProdList[i].checked==true)
{Url+='&prodlist[]='+ProdList[i].value;}}
if(!HttpReq)
{document.location.href=Url;return;}
HttpReq.onreadystatechange=function()
{if(HttpReq.readyState==4&&HttpReq.status==200)
{if(HttpReq.responseText)
{ProdSpace=document.getElementById('ProdListArea');ProdSpace.innerHTML=HttpReq.responseText;}}}
HttpReq.open('GET',Url,true);HttpReq.send(null);}
function FilterBrand(Ev,Cat,BrandID)
{var Multi=Ev.ctrlKey;var SrcElement=(window.event?Ev.srcElement:Ev.target);var BrandFilter=document.getElementById('FilterBrand');var BrandList=BrandFilter.value.split(',');BrandState=false;BrandIndex=0;if(BrandList.length)
{for(i=0;i<BrandList.length;i++)
{if(BrandList[i]==BrandID)
{BrandState=true;BrandIndex=i;break;}}}
if(Multi)
{SelBrand=document.getElementById('Brand'+BrandID);if(BrandState)
{BrandList.splice(BrandIndex,1);SelBrand.className='ProdFilterBrOff';if(SelBrand.parentNode.className.match(/^Brand/i))
{SelBrandLabel=document.getElementById('BrandLabel'+BrandList[i]);SelBrandLabel.className='ProdFilterBrLabelOff';}}
else
{BrandList.push(BrandID);SelBrand.className='ProdFilterBrOn';if(SrcElement.parentNode.className.match(/^Brand/i))
{SelBrandLabel=document.getElementById('BrandLabel'+BrandList[i]);SelBrandLabel.className='ProdFilterBrLabelOn';}}}
else
{if(BrandList.length)
{for(i=0;i<BrandList.length;i++)
{if(!BrandList[i])
continue;SelBrand=document.getElementById('Brand'+BrandList[i]);if(SelBrand==null)
continue;SelBrand.className='ProdFilterBrOff';if(SelBrand.parentNode.className.match(/^Brand/i))
{SelBrandLabel=document.getElementById('BrandLabel'+BrandList[i]);SelBrandLabel.className='ProdFilterBrLabelOff';}}}
SelBrand=document.getElementById('Brand'+BrandID);if(BrandState)
{SelBrand.className='ProdFilterBrOff';BrandList=new Array();if(SrcElement.parentNode.className.match(/^Brand/i))
{SelBrandLabel=document.getElementById('BrandLabel'+BrandID);SelBrandLabel.className='ProdFilterBrLabelOff';}}
else
{SelBrand.className='ProdFilterBrOn';BrandList=new Array(BrandID);if(SrcElement.parentNode.className.match(/^Brand/i))
{SelBrandLabel=document.getElementById('BrandLabel'+BrandID);SelBrandLabel.className='ProdFilterBrLabelOn';}}}
BrandFilter.value=BrandList.toString();ProdListUpdate(Cat);}
function SfSwitch(Obj,CodeSf,Field,Val,Cat)
{var SfHidden=document.getElementById('FilterSF');if(Obj.className=='SfHL')
{Obj.className='Sf';SfHidden.value=null;}
else
{SfPh=document.getElementById('SfPH');SfList=SfPh.childNodes;for(i=0;i<SfList.length;i++)
{if(SfList[i].nodeType==1)
SfList[i].className='Sf';}
Obj.className='SfHL';SfHidden.value=CodeSf+';'+Field+';'+Val;}
ProdListUpdate(Cat);}
function ProdComp(ProdList,SortField,SortOrder)
{var HttpReq=GetHRObject();if(!HttpReq)
return false;Url='/request/Compare.html?sf='+SortField+'&'+'so='+SortOrder;if(!ProdList)
{ProdList=document.getElementsByName('comp');if(ProdList.length<2)
return false;ProdCount=0;for(i=0;i<ProdList.length;i++)
{if(ProdList[i].checked)
{ProdCount++;Url=Url+'&'+'p[]='+ProdList[i].value;}}
if(ProdCount<=1)
{alert('Vous devez sélectionner au moins 2 produits');return;}}
else
{for(i=0;i<ProdList.length;i++)
{if(ProdList[i])
{ProdCount++;Url=Url+'&'+'p[]='+ProdList[i];}}}
Exists=document.getElementById('CompArea');if(Exists)
Exists.parentNode.removeChild(Exists);if(!ProdCount)
return;if(navigator.appVersion.match(/MSIE/))
{SelList=document.getElementsByTagName('select');for(i=0;i<SelList.length;i++)
SelList[i].style.display='none';SelList=document.getElementsByTagName('object');for(i=0;i<SelList.length;i++)
SelList[i].style.display='none';}
var CompArea=document.createElement("div");CompArea.id='CompArea';document.getElementById('section').appendChild(CompArea);CompArea.innerHTML='<div style="margin:auto; width:100%; padding:20% 0; text-align:center;"><img src="/images/gui/main/Reload.gif" width="16" height="16" align="top" alt="" /><span style="font-weight:bold;font-size:14px;padding:5px 5px 15px 5px;color:#515151;text-align:left;height:34px;">En cours de chargement ...</span></div>';HttpReq.onreadystatechange=function()
{if(HttpReq.readyState==4&&HttpReq.status==200)
{if(HttpReq.responseText)
{Space=document.getElementById('CompArea');Space.innerHTML=HttpReq.responseText;}}}
HttpReq.open('GET',Url,true);HttpReq.send(null);}
function ProdCompClose()
{if(navigator.appVersion.match(/MSIE/))
{SelList=document.getElementsByTagName('select');for(i=0;i<SelList.length;i++)
SelList[i].style.display='';SelList=document.getElementsByTagName('object');for(i=0;i<SelList.length;i++)
SelList[i].style.display='';}
CompAreaElem=document.getElementById('CompArea');if(CompAreaElem)
CompAreaElem.parentNode.removeChild(CompAreaElem);}
function ProdCompHide(Cell)
{Table=document.getElementById('ProdCmpTable');ElemList=getElementsByClassName(Cell,'',Table);for(i=0;i<ElemList.length;i++)
ElemList[i].parentNode.removeChild(ElemList[i]);TrList=Table.getElementsByTagName('tr');document.getElementById('ProdCounter').innerHTML=TrList[1].cells.length-1;if(TrList[1].cells.length==2)
document.getElementById('ProdCounterLabel').innerHTML='produit';if(TrList[1].cells.length==1)
ProdCompClose();}
function ProdCompSort(Field,Order)
{Table=document.getElementById('ProdCmpTable');if(!Table)
return;TrList=Table.getElementsByTagName('tr');if(TrList.length==0)
return;ProdList=Array();for(i=0;i<TrList[1].cells.length;i++)
{Dt=TrList[1].cells[i].className.match(/CmpCell(.*)/);if(!Dt)
continue;ProdList.push(Dt[1]);}
if(ProdList.length==0)
return;ProdComp(ProdList,Field,Order);}