function getQueryField(fieldName)
{var i;var s=document.location.search;s=s.substr(1);var fields=s.split("&");for(i=0;i<fields.length;i++)
{var field=fields[i];var p=field.indexOf("=");var name=field.substr(0,p);if(name==fieldName)
return unescape(field.substr(p+1));}
return"";}
function str2Frm(s)
{if(EB_UTF8)
return Base64._utf8_encode(new String(s));else
return s;}
function str2HTML(s)
{var html='';for(var i=0;i<s.length;i++)
{c=s.charAt(i);if(c=='\n')
html+='<br>';else if(c=='|'||c=='¤'||c=='§'||c=='"'||c=='\'')
html+='&#'+s.charCodeAt(i)+';';else
html+=c;}
return html;}
function str2Int(s)
{if(s=='')
return 0;var x=parseInt(s,10);if(isNaN(x))
return 0;else
return x;}
function str2Float(s)
{if(s=='')
return 0.0;var x=parseFloat(s);if(isNaN(x))
return 0.0;else
return x;}
function floatFormat(value,decimal,thousandSeparator)
{var deci=Math.round(Math.pow(10,decimal)*(Math.abs(value)-Math.floor(Math.abs(value))));var val=Math.floor(Math.abs(value));if((decimal==0)||(deci==Math.pow(10,decimal)))
{val=Math.floor(Math.abs(value));deci=0;}
var formatedValue=val+"";var nb=formatedValue.length;for(var i=1;i<4;i++)
{if(val>=Math.pow(10,(3*i)))
formatedValue=formatedValue.substring(0,nb-(3*i))+thousandSeparator+formatedValue.substring(nb-(3*i));}
if(decimal>0)
{var decim="";for(var j=0;j<(decimal-deci.toString().length);j++)
decim+="0";deci=decim+deci.toString();if(deci.length>decimal)
deci=deci.substr(0,decimal);formatedValue=formatedValue+"."+deci;}
if(parseFloat(value)<0)
formatedValue="-"+formatedValue;return formatedValue;}
function float2Str(x)
{return floatFormat(x,2,'');}
function getMoneyStr(x)
{return float2Str(x)+EB_moneySymbol;}
function getMoneyStrDesign(x)
{if(EB_showAllZeros)
return getMoneyStr(x);else
return""+x+EB_moneySymbol;}
function EBusinessService()
{this.recNo=0;this.records=null;this.error="";this.parameters="";this.open=function(query)
{if(xwd.isLocalMode())
{this.error="Accès impossible en prévisualisation.<br>Vous devez publier votre site pour utiliser cette fonctionnalité.";return;}
var url=new String(document.location);var p=url.lastIndexOf("/");if(p==-1)
{this.error="Url error";return;}
url=url.substr(0,p)+"/EBusiness.php";var data="cde="+query+"&"+
this.parameters;var xhr=null;if(window.XMLHttpRequest)
xhr=new XMLHttpRequest();else if(window.ActiveXObject)
xhr=new ActiveXObject("Microsoft.XMLHTTP");xhr.open("POST",url,false);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");try
{xhr.send(data);}
catch(e)
{}
this.recNo=0;var content=xhr.responseText;if(content.substr(0,4)=="$ERR")
{this.error=content.substr(5);this.records=null;}
else
{this.error="";this.records=content.split("\n");}
this.parameters="";}
this.execute=function(query)
{this.open(query);if(this.getError()=="")
this.close();}
this.setParameter=function(parameterName,value)
{this.parameters+=parameterName+"="+value+"&";}
this.getError=function()
{return this.error;}
this.getRecordCount=function()
{if(this.records==null)
{this.error="Pas de données";return 0;}
return this.records.length-2;}
this.eof=function()
{return this.recNo+1>this.getRecordCount();}
this.getFieldIndex=function(fieldName)
{fieldName=fieldName.toUpperCase();var fields=this.records[0].split("\t");for(i=0;i<fields.length;i++)
{if(fieldName==fields[i].toUpperCase())
return i;}
return-1;}
this.getValue=function(fieldName)
{if(this.records==null)
{this.error="Pas de données";return"";}
if(this.eof())
{this.error="Plus de données";return"";}
var ix=this.getFieldIndex(fieldName);if(ix==-1)
{this.error="Champ "+fieldName+" inconnu";return"";}
var record=this.records[this.recNo+1];var values=record.split("\t");return values[ix];}
this.moveNext=function(fieldName)
{this.recNo++;}
this.moveFirst=function(fieldName)
{this.recNo=0;}
this.close=function(fieldName)
{this.recNo=0;this.records=null;this.error="";}}
function Discount(discounts,price)
{this.read=function(i)
{var record=this.records[i].split('§');this.quantity=str2Int(record[0]);this.fixed=(record[1]=='true');this.reduction=str2Float(record[2]);this.price=price}
this.getPrice=function(price)
{if(this.fixed)
return price-this.reduction;else
return price-(price*this.reduction/100);}
this.getPriceStr=function()
{return getMoneyStrDesign(this.getPrice(this.price));}
this.computePrice=function(quantity,price)
{var nprice=price;for(var i=0;i<this.count;i++)
{this.read(i);if(quantity>this.quantity)
nprice=this.getPrice(price);}
return nprice;}
if(typeof(discounts)=='undefined')
discounts="";this.records=discounts.split('¤');this.count=this.records.length-1;this.quantity=0;this.fixed=false;this.reduction=0.0;this.price=0.0}
function Feature(features)
{this.read=function(i)
{var record=this.records[i].split('§');this.name=record[0];this.value=record[1];this.price=str2Float(record[2]);this.weight=str2Float(record[3]);}
this.varName=function()
{var varName=this.name.toLowerCase()
varName=varName.replace(new RegExp("é","g"),"&eacute;");varName=varName.replace(new RegExp("è","g"),"&egrave;");varName=varName.replace(new RegExp("ê","g"),"&ecirc;");varName=varName.replace(new RegExp("ç","g"),"&ccedil;");varName=varName.replace(new RegExp("ô","g"),"&ocirc;");return varName;}
if(typeof(features)=='undefined')
features="";this.records=features.split('¤');this.count=this.records.length-1;this.name='';this.value='';this.price=0.0;this.weight=0.0;}
function Item()
{this.getCountForCat=function(catIx)
{if(typeof(EB_items[catIx])!="undefined")
return EB_items[catIx].length;else
return 0;}
this.read=function(catIx,itemIx)
{var record=EB_items[catIx][itemIx].split('|');this.catIx=catIx;this.itemIx=itemIx;this.id=record[0];this.name=record[1];this.reference=record[2];this.price=str2Float(record[3]);this.state=record[4];this.description=record[5];this.detailLink=record[6];this.weight=str2Float(record[7]);this.tax=str2Float(record[8]);this.priceNotReduced=str2Float(record[9]);this.stock=str2Float(record[10]);this.miniStock=str2Float(record[11]);this.miniQuantitySales=str2Int(record[12]);if(this.miniQuantitySales<1)
this.miniQuantitySales=1;this.maxiQuantitySales=str2Int(record[13]);this.shippingPrice=str2Float(record[14]);this.shippingMode=record[15];this.feature=new Feature(record[16]);this.discount=new Discount(record[17],this.price);this.hasThumb=(record[18]=='true');this.hasImage=(record[19]=='true');this.hasXLImage=(record[20]=='true');if(!this.hasThumb)
{this.thumb='./images/EBusinessEmpty.gif';this.image='./images/EBusinessEmpty.gif';this.XLImage='./images/EBusinessEmpty.gif';}
else
{this.thumb='./images/EB.T.'+catIx+'.'+itemIx+'.jpg';if(!this.hasImage)
this.image=this.thumb;else
this.image='./images/EB.'+catIx+'.'+itemIx+'.jpg';this.XLImage='./images/EB.XL.'+catIx+'.'+itemIx+'.jpg';}}
this.getPriceStr=function()
{return getMoneyStrDesign(this.price);}
this.getPriceNotReducedStr=function()
{return getMoneyStrDesign(this.priceNotReduced);}
this.catIx=0;this.itemIx=0;this.name='';this.reference='';this.price=0.0;this.state='';this.description='';this.detailLink='';this.weight=0;this.tax=0;this.priceNotReduced=0;this.stock=0;this.miniStock=0;this.miniQuantitySales=0;this.maxiQuantitySales=0;this.shippingPrice=0;this.shippingMode=0;this.feature=null;this.discount=null;this.hasThumb=false;this.hasImage=false;this.hasXLImage=false;this.image='';this.thumb='';this.XLImage='';}
function Basket()
{this.load=function()
{var basket=getCookie('basket');if(basket==null)
this.count=0;else
{this.records=basket.split('|');this.count=this.records.length-1;}}
this.read=function(i)
{var record=this.records[i].split('¤');var catIx=record[0];var itemIx=record[1];this.item.read(catIx,itemIx);this.item.catIx=catIx;this.item.itemIx=itemIx;this.item.features=record[2];this.item.price=str2Float(record[3]);this.item.weight=str2Float(record[4]);this.item.count=str2Int(record[5]);}
this.write=function(i)
{this.records[i]=this.item.catIx+'¤'+
this.item.itemIx+'¤'+
this.item.features+'¤'+
this.item.price+'¤'+
this.item.weight+'¤'+
this.item.count;}
this.add=function()
{if(this.count==0)
this.records=new Array();this.write(this.count);this.count++;}
this.find=function(catIx,itemIx,features)
{for(i=0;i<this.count;i++)
{this.read(i);if(catIx==this.item.catIx&&itemIx==this.item.itemIx&&features==this.item.features)
return i;}
return-1;}
this.remove=function(i)
{this.records[i]='';}
this.save=function()
{var basket='';for(i=0;i<this.count;i++)
if(this.records[i]!='')
basket+=this.records[i]+'|';setCookie('basket',basket);}
this.item=new Item();this.load();}
function Payment()
{this.read=function(i)
{var record=this.records[i].split('¤');this.name=record[0];this.type=record[1];this.additionalCost=str2Float(record[2]);this.instruction=record[3];this.instructionInInvoice=(record[4]=='true');this.businessAddress=record[5];this.currencyCode=record[6];this.noShipping=(record[7]=='true');this.title=invoice.getStr(EB_paymentPageTitle+' ('+this.name+')');}
this.records=EB_payments.split('|');this.count=this.records.length-1;this.name='';this.type='';this.additionalCost=0.0;this.instruction='';this.instructionInInvoice=false;this.businessAddress='';this.currencyCode='';}
function Shipping()
{this.read=function(i)
{var record=this.records[i].split('¤');this.type=record[0];this.trigger=str2Float(record[1]);this.price=str2Float(record[2]);}
this.records=EB_shippings.split('|');this.count=this.records.length-1;this.type='';this.trigger='';this.price='';}
function Coupon()
{this.read=function(i)
{var record=this.records[i].split('¤');this.code=unescape(record[0]);this.fixed=(record[1]=='true');this.reduction=str2Float(record[2]);}
this.find=function(code)
{for(var i=0;i<this.count;i++)
{this.read(i);if(!EB_caseCoupon)
{code=code.toUpperCase();this.code=this.code.toUpperCase();}
if(code==this.code)
return true;}
this.fixed=true;this.reduction=0.0;return false;}
this.getDiscount=function(amount)
{if(this.fixed)
return-str2Float(this.reduction);else
return-(str2Float(amount)*(this.reduction/100));}
this.records=EB_coupons.split('|');this.count=this.records.length-1;this.code='';this.fixed=true;this.reduction=0.0;}
function getCountrySelectAll(id,country)
{var s='<select id="'+id+'" style="width:240">';for(i=0;i<EB_countriesAll.length-1;i++)
{var selected='';if(EB_countriesAll[i]==country)
selected='SELECTED';s+='<option '+selected+'>'+EB_countriesAll[i]+'</option>'}
s+='</select>';return s;}
function checkUpload()
{var filename=xwd.getDataFromWeb("./EBusiness.php?cde=getUploadFileName&invoiceID="+invoice.getID());edtOrderFormInput=document.getElementById('edtOrderFormInput'+uploadId);if(edtOrderFormInput!=null)
{if(filename!="")
edtOrderFormInput.value=filename;else
edtOrderFormInput.value='';}}
function upload()
{d=new DialogBox(true);d.setWidth(370);d.setTitle("");d.setCallCancel(checkUpload);d.setUrl("./EBusiness.php?cde=getUpload&invoiceID="+invoice.getID(),70);d.show();d.moveTo(-1,-1);}
function OrderForm()
{this.getClientInfos=function(email,pwd)
{var ws=new EBusinessService();ws.setParameter('email',email);ws.setParameter('pwd',pwd);ws.open('getClientInfos');if(ws.error!='')
return ws.error;setCookie('email',email);setCookie('pwd',pwd);setCookie('orderFormValuesA',ws.getValue('orderFormValuesA'));setCookie('orderFormValuesF',ws.getValue('orderFormValuesF'));return ws.error;}
this.saveClientInfos=function()
{if(getCookie('email')==null)
return'';var ws=new EBusinessService();ws.setParameter('email',getCookie('email'));ws.setParameter('pwd',getCookie('pwd'));ws.setParameter("orderFormValuesA",str2Frm(getCookie('orderFormValuesA')));ws.setParameter("orderFormValuesF",str2Frm(getCookie('orderFormValuesF')));ws.open('saveClientInfos');return ws.error;}
this.read=function(i)
{var oFValuesA=getCookie('orderFormValuesA');if(oFValuesA==null)
oFValuesA='';var valuesA=oFValuesA.split('|');var oFValuesF=getCookie('orderFormValuesF');if(oFValuesF==null)
oFValuesF='';var valuesF=oFValuesF.split('|');var record=this.records[i].split('¤');this.cursor=i;this.title=record[0];this.varName=record[1];this.type=record[2];this.required=record[3]=='true'||record[3]==-1;this.valueA=valuesA[i];if(typeof(this.valueA)=='undefined')
this.valueA='';this.valueF=valuesF[i];if(typeof(this.valueF)=='undefined')
this.valueF='';if(this.type=='E'&&getCookie('email')!=null)
{if(this.valueA=='')
this.valueA=getCookie('email');if(this.valueF=='')
this.valueF=getCookie('email');}}
this.getFormValueA=function(varName)
{for(var i=0;i<this.count;i++)
{this.read(i);if(this.varName==varName)
return this.valueA;}
return"";}
this.getFormValueF=function(varName)
{for(var i=0;i<this.count;i++)
{this.read(i);if(this.varName==varName)
return this.valueF;}
return"";}
this.getHTMLInput=function(value)
{var id='edtOrderFormInput'+this.cursor;switch(this.type)
{case'C':if(invoice.country!='')
return invoice.country;else
return getCountrySelectAll(id,value);break;case'N':return'<input type="text" size="10" id="'+id+'" value="'+value+'">';break;case'U':var s='<input type="text"  id="'+id+'"  style="width:220" DISABLED>';s+='<input type="button" value="..." onclick="upload()"  style="width:20">';uploadId=this.cursor;return s;return'<input type="file"  id="'+id+'" value="'+value+'">';break;case'T':var reg=new RegExp("(<br>)","g");return'<textarea id="'+id+'" rows="8" style="width:240">'+value.replace(reg,"\n")+'</textarea>';break;default:return'<input type="text"  id="'+id+'" value="'+value+'" style="width:240">';}
return"";}
this.getInput=function()
{var id='edtOrderFormInput'+this.cursor;return document.getElementById(id);}
this.getInputValue=function()
{var input=this.getInput();if(this.type=='C')
return input.options[input.selectedIndex].text;else
return input.value;}
this.records=EB_orderForm.split('|');this.count=this.records.length-1;this.title='';this.type='';this.required=false;}
function Invoice()
{this.getID=function()
{var invoiceID=getCookie('invoiceID');if(invoiceID==null)
invoiceID="";if(invoiceID=="")
{invoiceID='CDE-'+new Date().getTime().toString(16).toUpperCase();setCookie('invoiceID',invoiceID);}
return invoiceID;}
this.getStr=function(s)
{return s.replace(new RegExp("(%s)","g"),this.getID());}
this.getDiscount=function()
{return this.coupon.getDiscount(this.sAmount);}
this.coupon=new Coupon();this.sAmount=0.0;this.weight=0.0;this.shipping=0.0;this.amount=0.0;this.country='';this.additionalCost=0.0;this.payment=null;}
function getPaypalItem(n,itemName,itemCount,itemPrice)
{var s='<input type="hidden" name="item_name_'+n+'"  value="'+itemName+'">\n';s+='<input type="hidden" name="quantity_'+n+'" value="'+itemCount+'">\n';s+='<input type="hidden" name="amount_'+n+'" value="'+itemPrice+'">\n';return s;}
function sendToPaypal()
{var s='<html><head>\n';s+='</head><body>\n';s+='<form id="frm" action="https://www.paypal.com/cgi-bin/webscr" method="post">\n';s+='<input type="hidden" name="cmd" value="_cart">\n';s+='<input type="hidden" name="upload" value="1">\n';s+='<input type="hidden" name="business" value="'+invoice.payment.businessAddress+'">\n';s+='<input type="hidden" name="invoice" value="'+invoice.getID()+'">\n';s+='<input type="hidden" name="currency_code" value="'+invoice.payment.currencyCode+'">\n';var of=new OrderForm();s+='<input type="hidden" name="first_name" value="'+of.getFormValueA("ofFirstName")+'">\n';s+='<input type="hidden" name="last_name" value="'+of.getFormValueA("ofLastName")+'">\n';s+='<input type="hidden" name="address1" value="'+of.getFormValueA("ofAddress")+'">\n';s+='<input type="hidden" name="zip" value="'+of.getFormValueA("ofZip")+'">\n';s+='<input type="hidden" name="city" value="'+of.getFormValueA("ofCity")+'">\n';s+='<input type="hidden" name="country" value="FR">\n';s+='<input type="hidden" name="H_PhoneNumber" value="'+of.getFormValueA("ofPhone")+'">\n';s+='<input type="hidden" name="email" value="'+of.getFormValueA("ofEmail")+'">\n';var basket=new Basket();for(var i=0;i<basket.count;i++)
{basket.read(i);s+=getPaypalItem(i+1,basket.item.name,basket.item.count,basket.item.price);}
if(invoice.shipping>0)
{s+=getPaypalItem(i+1,'Frais de port',1,invoice.shipping);i++;}
if(invoice.additionalCost>0)
{s+=getPaypalItem(i+1,'Cout additionnel',1,invoice.additionalCost);i++;}
if(invoice.getDiscount()<0)
s+='<input type="hidden" name="discount_amount_cart" value="'+(-invoice.getDiscount())+'">\n';s+='</form>';s+='<script>document.getElementById("frm").submit();</script>\n';s+='</body></html>';var win=window.open('','');win.document.write(s);win.document.close();}
function sendToMoneyBookers()
{var s='<html><head>\n';s+='</head><body>\n';s+='<form id="frm" action="https://www.moneybookers.com/app/payment.pl" method="post">\n';s+='<input type="hidden" name="pay_to_email" value="'+invoice.payment.businessAddress+'">\n';s+='<input type="hidden" name="status_url" value="'+invoice.payment.businessAddress+'">\n';s+='<input type="hidden" name="language" value="FR">\n';s+='<input type="hidden" name="amount" value="'+invoice.amount+'">\n';s+='<input type="hidden" name="currency" value="'+invoice.payment.currencyCode+'">\n';s+='<input type="hidden" name="detail1_description" value="Commande n°:">\n';s+='<input type="hidden" name="detail1_text" value="'+invoice.getID()+'">\n';var of=new OrderForm();s+='<input type="hidden" name="firstname" value="'+of.getFormValueA("ofFirstName")+'">\n';s+='<input type="hidden" name="lastname" value="'+of.getFormValueA("ofLastName")+'">\n';s+='<input type="hidden" name="address" value="'+of.getFormValueA("ofAddress")+'">\n';s+='<input type="hidden" name="postal_code" value="'+of.getFormValueA("ofZip")+'">\n';s+='<input type="hidden" name="city" value="'+of.getFormValueA("ofCity")+'">\n';s+='<input type="hidden" name="country" value="FR">\n';s+='<input type="hidden" name="PhoneNumber" value="'+of.getFormValueA("ofPhone")+'">\n';s+='<input type="hidden" name="pay_from_email" value="'+of.getFormValueA("ofEmail")+'">\n';s+='</form>\n';s+='<script>document.getElementById("frm").submit();</script>\n';s+='</body></html>';var win=window.open('','');win.document.write(s);win.document.close();}
function sendInvoice()
{xwd.hide();if(xwd.isLocalMode(true))
return;var s='';if(EB_UTF8)
s+='<form id="frmSend" action="./EBusiness.php" method="post" accept-charset="utf-8">\n';else
s+='<form id="frmSend" action="./EBusiness.php" method="post">\n';s+='<input type="hidden" name="cde" value="sendInvoice">\n';s+='<input type="hidden" name="invoiceID" value="'+str2Frm(invoice.getID())+'">\n';s+='<input type="hidden" name="moneySymbol" value="'+str2Frm(EB_moneySymbol)+'">\n';var account=getCookie('email');if(account==null)
account='';s+='<input type="hidden" name="account" value="'+str2Frm(account)+'">\n';var basket=new Basket();s+='<input type="hidden" name="basketCount" value="'+str2Frm(basket.count)+'">\n';for(var i=0;i<basket.count;i++)
{basket.read(i);s+='<input type="hidden" name="basket'+i+'" value="'+str2Frm(basket.item.reference+'¤'+
basket.item.name+'¤'+
basket.item.features+'¤'+
float2Str(basket.item.discount.computePrice(basket.item.count,basket.item.price))+'¤'+
basket.item.count)+'">\n';}
s+='<input type="hidden" name="emailCmd" value="'+str2Frm(EB_emailCmd)+'">\n';s+='<input type="hidden" name="amount" value="'+str2Frm(float2Str(invoice.amount))+'">\n';s+='<input type="hidden" name="sAmount" value="'+str2Frm(float2Str(invoice.sAmount))+'">\n';s+='<input type="hidden" name="shipping" value="'+str2Frm(float2Str(invoice.shipping))+'">\n';s+='<input type="hidden" name="reductionValue" value="'+str2Frm(float2Str(invoice.getDiscount()))+'">\n';s+='<input type="hidden" name="reductionCode" value="'+str2Frm(invoice.coupon.code)+'">\n';s+='<input type="hidden" name="additionalCost" value="'+str2Frm(float2Str(invoice.additionalCost))+'">\n';s+='<input type="hidden" name="orderForm" value="'+str2Frm(EB_orderForm)+'">\n';s+='<input type="hidden" name="orderFormValuesA" value="'+str2Frm(getCookie('orderFormValuesA'))+'">\n';s+='<input type="hidden" name="orderFormValuesF" value="'+str2Frm(getCookie('orderFormValuesF'))+'">\n';s+='<input type="hidden" name="paymentName" value="'+str2Frm(invoice.payment.name)+'">\n';if(invoice.payment.instructionInInvoice)
s+='<input type="hidden" name="paymentInstruction" value="'+str2Frm(invoice.getStr(invoice.payment.instruction))+'">\n';s+='</form>\n';var lbBusinessZAC=document.getElementById('lbBusinessZAC');lbBusinessZAC.innerHTML=s;xwd.openForm('frmSend');if(invoice.payment.type=='PP')
sendToPaypal();else if(invoice.payment.type=='MB')
sendToMoneyBookers();setCookie('invoiceID','');if(EB_clearBasketAfterSend)
{setCookie('basket','');writeBasketCaption();}}
function showOrderForm3()
{var s='<table border="0" width="700" height="430" style="color:'+EB_txtColor+';">';s+='<tr><td align="center">'+invoice.getStr(EB_payementPageMsg)+'</td></tr>';s+='<tr><td align="center">'+invoice.getStr(invoice.payment.instruction)+'</td></tr>';s+='<tr><td valign="bottom" align="right">';s+='<input type="button" value="<< Précédent" onclick="showOrderForm1()">';s+='<input type="button" value="Envoyer"    onclick="sendInvoice()">';s+='</td></tr>';s+='</table>';xwd.hide();xwd.show(s,invoice.payment.title);}
function showOrderForm2()
{var s='<table border="0" width="700" height="430" style="color:'+EB_txtColor+';">';s+='<tr><td align="center">'+invoice.getStr(EB_payementPageMsg)+'</td></tr>';s+='<tr><td align="center">Saisir les informations de facturation suivante:</td></tr>';s+='<tr><td valign="top"><form><table width="100%" style="color:'+EB_txtColor+';">';var of=new OrderForm();for(var i=0;i<of.count;i++)
{of.read(i);if(of.type!='U')
{s+='<tr>';s+='<td align="right">'+of.title+' : </td>';s+='<td>'+of.getHTMLInput(of.valueF)+'</td>';s+='</tr>';}}
s+='</table></form>';s+='</td></tr>';s+='<tr><td valign="bottom" align="right">';s+='<input type="button" value="<< Précédent"  onclick="showOrderForm1()">';s+='<input type="button" value="Suivant >>"  onclick="validOrderForm(2)">';s+='</td></tr>';s+='</table>';xwd.hide();xwd.show(s,invoice.payment.title);}
function orderInputError(edtInput,msg)
{var xwd2=new XWD();xwd2.alert(msg,'Erreur');edtInput.focus();edtInput.style.color=EB_titleColor;edtInput.style.backgroundColor='red';}
function validOrderForm(num)
{var xwd2=new XWD();var of=new OrderForm();var orderFormValues='';for(var i=0;i<of.count;i++)
{of.read(i);var edtInput=of.getInput();if(edtInput!=null)
{var value=of.getInputValue();edtInput.style.color='';edtInput.style.backgroundColor='';if(value=='')
{if(of.required)
{orderInputError(edtInput,'Valeur obligatoire pour <b>['+of.title+']</b>','Erreur');return;}}
else
{if(of.type=="E")
{if(!xwd2.isGoodValue('email',value,false))
{orderInputError(edtInput,'Adresse Email incorrecte pour <b>['+of.title+']</b>','Erreur');return;}}
else if(of.type=="N")
{if(!xwd2.isGoodValue('numeric',value,false))
{orderInputError(edtInput,'<b>['+of.title+']</b> non numérique','Erreur');return;}}}}
orderFormValues+=str2HTML(value)+'|';}
if(num==1)
{setCookie('orderFormValuesA',orderFormValues);if(document.getElementById('ckSameAddress').checked)
{setCookie('orderFormValuesF',orderFormValues);showOrderForm3();}
else
showOrderForm2();}
else
{setCookie('orderFormValuesF',orderFormValues);showOrderForm3();}
if(EB_clientWorkSpace)
{err=of.saveClientInfos();if(err!='')
xwd2.alert(err);}}
function showOrderForm1()
{var s='<table border="0" width="700" height="430" style="color:'+EB_txtColor+';">';s+='<tr><td align="center">'+invoice.getStr(EB_payementPageMsg)+'</td></tr>';s+='<tr><td align="center">Saisir les informations de livraison suivante:</td></tr>';s+='<tr><td valign="top"><form><table width="100%" style="color:'+EB_txtColor+';">';var of=new OrderForm();var uploader=false;for(var i=0;i<of.count;i++)
{of.read(i);s+='<tr>';s+='<td align="right">'+of.title+' : </td>';if(of.type=="U")
uploader=true;s+='<td>'+of.getHTMLInput(of.valueF)+'</td>';s+='</tr>';}
s+='</table></form>';s+='</td></tr>';s+='<tr><td align="center">';s+='<input id="ckSameAddress" type="checkbox" checked>Adresse de facturation identique';s+='</td></tr>';s+='<tr><td valign="bottom" align="right">';s+='<input type="button" value="<< Précédent"   onclick="showBasket()">';s+='<input type="button" value="Suivant >>"   onclick="validOrderForm(1)">';s+='</td></tr>';s+='</table>';xwd.hide();xwd.show(s,invoice.payment.title);if(uploader)
checkUpload();}
var xwdpl=null;function sendPwd()
{var xwd2=new XWD();var email=document.getElementById('emailLost');if(!xwd2.isGoodValue('email',email.value,false))
{xwd2.alert('Adresse Email incorrecte pour','Erreur');return;}
var ws=new EBusinessService();ws.setParameter('email',email.value);ws.open('sendPwd');if(ws.error!='')
xwdpl.alert(ws.error);else
xwdpl.alert('Mot de passe envoyé');}
function pwdLost()
{if(xwdpl==null)
xwdpl=new XWD();var s='<form>\n';s+='Adresse email :<br>\n';s+='<input type="texte" id="emailLost" value=""><br><br>\n';s+='<center><input type="button" value="Envoyer" onclick="sendPwd()"></center>\n';s+='</form>\n';xwdpl.show(s,'Mot de passe perdu');}
function logon()
{var xwd2=new XWD();var email=document.getElementById('email');if(!xwd2.isGoodValue('email',email.value,false))
{xwd2.alert('Adresse Email incorrecte pour','Erreur');return;}
var pwd=document.getElementById('pwd');var of=new OrderForm();var err=of.getClientInfos(email.value,pwd.value);if(err!='')
xwd2.alert(err,'Erreur');else
showOrderForm1();}
function newAccount()
{var xwd2=new XWD();var email=document.getElementById('newemail');if(!xwd2.isGoodValue('email',email.value,false))
{xwd2.alert('Adresse Email incorrecte pour','Erreur');return;}
var pwd=document.getElementById('newpwd');if(pwd.value.length<8)
{xwd2.alert('Le mot de passe doit avoir 8 caractères minimum','Erreur');return;}
var cpwd=document.getElementById('cpwd');if(pwd.value!=cpwd.value)
{xwd2.alert('Les mots de passe doivent être identiques','Erreur');return;}
var ws=new EBusinessService();ws.setParameter('email',email.value);ws.setParameter('pwd',pwd.value);ws.open('newAccount');if(ws.error!="")
xwd2.alert(ws.error,'Erreur');else
{setCookie('email',email.value);setCookie('pwd',pwd.value);showOrderForm1();}}
function showOrderForm0()
{var s='<form><table border="0" width="700" height="430" style="color:'+EB_txtColor+';">';s+='<tr><td align="center"><table border="0" width="330" style="color:'+EB_txtColor+';">';s+='<tr><td align="center" style="background:'+EB_color1+';color:'+EB_titleColor+'" align="center"><b>Vous avez déjà un compte</b></td></tr>';s+='<tr style="background:'+EB_color3+';height:230" valign="top" ><td>';s+='<br>&nbsp;&nbsp;Entrez votre adresse email :<br>';s+='&nbsp;&nbsp;<input type="text" id="email"><br><br>';s+='&nbsp;&nbsp;Entrez votre mot de passe :<br>';s+='&nbsp;&nbsp;<input type="password" id="pwd"><br><br>';s+='&nbsp;&nbsp;Si vous avez oublié votre mot de passe,<a href="javascript:pwdLost();">cliquez ici.<a>';s+='</td></tr>';s+='<tr><td align="right">';s+='<input type="button" value="Identifiez-vous" onclick="logon()">';s+='</td></tr></table>';s+='</td><td><table border="0" width="330" style="color:'+EB_txtColor+';">';s+='<tr><td align="center" style="background:'+EB_color1+';color:'+EB_titleColor+'" align="center"><b>Vous êtes nouveau, créer un compte</b></td></tr>';s+='<tr style="background:'+EB_color3+';height:230" valign="top" ><td>';s+='<br>&nbsp;&nbsp;Entrez votre adresse email :<br>';s+='&nbsp;&nbsp;<input type="text" id="newemail"><br><br>';s+='&nbsp;&nbsp;Entrez votre mot de passe :<br>';s+='&nbsp;&nbsp;<input type="password" id="newpwd"><br><br>';s+='&nbsp;&nbsp;Confirmez votre mot de passe :<br>';s+='&nbsp;&nbsp;<input type="password" id="cpwd"><br>';s+='</td></tr>';s+='<tr><td align="right">';s+='<input type="button" value="Créez votre compte" onclick="newAccount()">';s+='</td></tr></table>';s+='</td></tr></table></form>';xwd.hide();xwd.show(s,invoice.payment.title);}
function validCommand()
{var xwd2=new XWD();var cbxPaymentType=document.getElementById('cbxPaymentType');if(cbxPaymentType.selectedIndex==-1)
{xwd2.alert('Mode de payment obligatoire','Erreur');return;}
var cbxCountry=document.getElementById('cbxCountry');if(cbxCountry!=null)
invoice.country=cbxCountry.options[cbxCountry.selectedIndex].text;if(cbxCountry!=null&&invoice.country=='')
{xwd2.alert('Pays obligatoire','Erreur');return;}
var ckConditionsSalesLink=document.getElementById('ckConditionsSalesLink');if(ckConditionsSalesLink!=null)
{if(!ckConditionsSalesLink.checked)
{xwd2.alert('Lecture des conditions de ventes obligatoire','Erreur');return;}}
invoice.payment=new Payment();invoice.payment.read(cbxPaymentType.selectedIndex-1);if(EB_clientWorkSpace&&getCookie('orderFormValuesA')==null)
showOrderForm0();else
showOrderForm1();}
function computeBasket()
{invoice.weight=0;invoice.sAmount=0;invoice.shipping=0;invoice.additionalCost=0;var count=0;var btnValidCommand=document.getElementById('btnValidCommand');var basket=new Basket();btnValidCommand.disabled=false;for(var i=0;i<basket.count;i++)
{var edtItemCount=document.getElementById('edtItemCount'+i);basket.read(i);basket.item.count=str2Int(edtItemCount.value);count+=basket.item.count;if(basket.item.count<basket.item.miniQuantitySales||(basket.item.maxiQuantitySales>0&&basket.item.count>basket.item.maxiQuantitySales))
{edtItemCount.style.color=EB_titleColor;edtItemCount.style.backgroundColor='red';btnValidCommand.disabled=true;}
else
{edtItemCount.style.color='';edtItemCount.style.backgroundColor='';}
var itemPrice=basket.item.discount.computePrice(basket.item.count,basket.item.price);var itemAmount=basket.item.count*itemPrice;invoice.weight+=basket.item.count*basket.item.weight;if(EB_shippingMode=='F'||(EB_shippingMode=='M'&&basket.item.shippingMode))
invoice.shipping+=basket.item.shippingPrice;basket.write(i);invoice.sAmount+=itemAmount;var lbItemPrice=document.getElementById('lbItemPrice'+i);lbItemPrice.innerHTML=getMoneyStr(itemPrice)+'&nbsp;&nbsp;';var lbItemAmount=document.getElementById('lbItemAmount'+i);lbItemAmount.innerHTML=getMoneyStr(itemAmount)+'&nbsp;&nbsp;';}
basket.save();if(EB_shippingMode=='C'||EB_shippingMode=='M')
{var shippings=new Shipping();for(i=0;i<shippings.count;i++)
{shippings.read(i);if(shippings.type==EB_shippingType)
{if(shippings.type=='W'&&invoice.weight>shippings.trigger)
invoice.shipping=shippings.price;else
if(shippings.type=='C'&&count>shippings.trigger)
invoice.shipping=shippings.price;else
if(shippings.type=='P'&&invoice.sAmount>shippings.trigger)
invoice.shipping=shippings.price;}}}
var cbxPaymentType=document.getElementById('cbxPaymentType');var paymentIndex=cbxPaymentType.selectedIndex-1;var payment=new Payment();if(paymentIndex>-1)
{payment.read(paymentIndex);invoice.additionalCost=payment.additionalCost;}
var cbxCountry=document.getElementById('cbxCountry');if(cbxCountry!=null)
invoice.additionalCost+=str2Float(cbxCountry.options[cbxCountry.selectedIndex].value);if(payment.noShipping)
invoice.shipping=0;invoice.amount=str2Float(invoice.sAmount)+str2Float(invoice.shipping)+invoice.additionalCost+invoice.getDiscount();document.getElementById('lbSAmount').innerHTML=getMoneyStr(invoice.sAmount)+'&nbsp;&nbsp;';if(invoice.coupon.count>0)
{document.getElementById('lbReduction').innerHTML=getMoneyStr(invoice.getDiscount())+'&nbsp;&nbsp;';var s='Code de remise :';if(!invoice.coupon.fixed)
s+=' ( '+invoice.coupon.reduction+'% )';document.getElementById('lbReductionI').innerHTML=s+'&nbsp;';}
document.getElementById('lbAdditionalCost').innerHTML=getMoneyStr(invoice.additionalCost)+'&nbsp;&nbsp;';document.getElementById('lbShipping').innerHTML=getMoneyStr(invoice.shipping)+'&nbsp;&nbsp;';document.getElementById('lbAmount').innerHTML=getMoneyStr(invoice.amount)+'&nbsp;&nbsp;';}
function deleteItem(n)
{var basket=new Basket();basket.remove(n);basket.save();xwd.hide();showBasket();writeBasketCaption();}
function getCountrySelect()
{var s='<select id="cbxCountry" onChange="computeBasket()">';s+='<option></option>';for(i=0;i<EB_countries.length-1;i++)
{var selected='';var wCountry=EB_countries[i];i++;var wTax=EB_countries[i]
if(wCountry==invoice.country)
selected='SELECTED';s+='<option '+selected+' value="'+wTax+'">'+wCountry+'</option>'}
s+='</select>';return s;}
function changeItemCount(n,step)
{var edtItemCount=document.getElementById('edtItemCount'+n);if(edtItemCount!=null)
{edtItemCount.value=str2Int(edtItemCount.value)+step;if(str2Int(edtItemCount.value)<1)
edtItemCount.value=1;computeBasket();}}
function showBasket()
{var basket=new Basket();if(basket.count==0)
{xwd.alert('Le panier est vide !','Erreur');return;}
var i=0;var s='<form>';s+='<table border="0" width="700" style="font-size:10pt;font-family:Arial;text-align:center;font-weight:bold;color:'+EB_titleColor+';">';s+='<tr style="height:30px;background:'+EB_color1+';">';s+='<td width="330">Article</td>';s+='<td width="90">Quantité</td>';s+='<td width="80">Prix</td>';s+='<td width="80">Total</td>';s+='<td width=""></td>';s+='</tr>';s+='</table>';s+='<div style="overflow-y:auto;overflow-x:hidden;height: 200px;width:720px">';s+='<table border="0" width="700" style="font-size:10pt;font-family:Arial;color:'+EB_txtColor+';">';var alternate=false;for(i=0;i<basket.count;i++)
{basket.read(i);if(alternate)
{bgColor=EB_color2;alternate=false;}
else
{bgColor=EB_color3;alternate=true;}
alernate=!alternate;s+='<tr bgcolor="'+bgColor+'" height="30">';s+='<td width="330">';if(basket.item.reference!='')
{s+=basket.item.reference;if(basket.item.name!='')
s+='<br>';}
s+=basket.item.name;s+='<p style="font-size:9px;margin-bottom:0">'+basket.item.features+'</p></td>';s+='<td width="90" align="center">';s+='<input type="button" value="-" onclick="changeItemCount('+i+',-1)" style="width:15">';s+='<input id="edtItemCount'+i+'" type="text" value="'+basket.item.count+'" size="3" onchange="computeBasket()" onkeyup="computeBasket()">';s+='<input type="button" value="+" onclick="changeItemCount('+i+',1)" style="width:15">';s+='</td>';s+='<td width="80" align="right" id="lbItemPrice'+i+'"></td>';s+='<td width="80" align="right" id="lbItemAmount'+i+'"></td>';s+='<td><input type="button" value="Supprimer" onclick="deleteItem('+i+')"></td>';s+='</tr>';}
s+='</tr></table>';s+='</div>';s+='<table border="0" width="590" style="font-size:10pt;font-family:Arial;color:'+EB_titleColor+';font-weight:bold">';s+='<tr style="background:'+EB_color1+'">';s+='<td width="498" align="right">Sous total&nbsp;</td>';s+='<td align="right" id="lbSAmount"></td>';s+='</tr>';s+='<tr style="background:'+EB_color1+'">';if(invoice.coupon.count>0)
{s+='<td align="right" id="lbReductionI"></td>';s+='<td align="right" id="lbReduction"></td>';s+='</tr>';s+='<tr style="background:'+EB_color1+'">';}
s+='<td align="right">Frais de port&nbsp;</td>';s+='<td align="right" id="lbShipping"></td>';s+='</tr>';s+='<tr style="background:'+EB_color1+'">';s+='<td align="right">Coût additionnel&nbsp;</td>';s+='<td align="right" id="lbAdditionalCost"></td>';s+='</tr>';s+='<tr style="background:'+EB_color1+'">';s+='<td align="right">Total&nbsp;</td>';s+='<td align="right" id="lbAmount"></td>';s+='</tr>';s+='</table>';s+='<table border="0" width="700" style="color:'+EB_txtColor+';">';if(EB_conditionsSalesLink!='')
{s+='<tr><td align="right">';s+="J\'ai lu et j\'accepte les conditions :";s+='</td><td>';s+='<input id="ckConditionsSalesLink" type="checkbox">&nbsp;&nbsp;';s+='<a href="'+EB_conditionsSalesLink+'" target="_new">Conditions de ventes</a>';s+='</td></tr>';}
if(EB_countries.length>1)
{s+='<tr><td align="right">';s+='Pays : ';s+='</td><td>';s+=getCountrySelect();s+='</td></tr>';}
s+='<tr><td align="right" height="35">';s+='Type de paiement: ';s+='</td><td>';s+='<select id="cbxPaymentType" onChange="computeBasket()">';var payment=new Payment();s+='<option></option>';for(i=0;i<payment.count;i++)
{payment.read(i);var selected="";if(payment.count==1)
selected='SELECTED';s+='<option '+selected+'>'+payment.name+'</option>';}
s+='</select>';s+='</td></tr>';s+='<tr><td valign="bottom" align="right" colspan="2">';if(invoice.coupon.count>0)
{s+='Code de remise :';s+='<input type="input" id="edtCoupon">';s+='<input type="button" id="btnCoupon" value="Utiliser remise" onclick="validCoupon()">';}
s+='<input type="button" id="btnValidCommand" value="Valider la commande" onclick="validCommand()">';s+='<input type="button" value="Poursuivre mes achats" onclick="xwd.hide()">';s+='</td></tr>';s+='</table>';s+='</form>';xwd.hide();xwd.show(s,'Panier');computeBasket();}
function validCoupon()
{var edtCoupon=document.getElementById('edtCoupon');if(invoice.coupon.find(edtCoupon.value))
{edtCoupon.style.color=EB_txtColor;edtCoupon.style.backgroundColor=EB_titleColor;}
else
{var xwd2=new XWD();xwd2.alert('Code de remise non valide','Erreur');edtCoupon.focus();edtCoupon.style.color=EB_titleColor;edtCoupon.style.backgroundColor='red';}
computeBasket();}
function getBasketCount()
{var basket=new Basket();return basket.count;}
function getBasketCaption()
{var count=getBasketCount();var s='';if(count==0)
s='Vide';else if(count==1)
s='Un article';else
s=count+' articles';return s;}
function writeBasketCaption()
{for(var i=0;i<captionsBasket.length;i++)
{var layer=document.getElementById(captionsBasket[i]);if(layer!=null)
layer.innerHTML=getBasketCaption();}}
function addBasketCaption(id)
{captionsBasket[captionsBasket.length]=id;writeBasketCaption();}
function addToBasket(catIx,itemIx,itemCount,itemOptions)
{var basket=new Basket();var item=new Item();item.read(catIx,itemIx);var price=item.price;var weight=item.weight;var features='';var elements=itemOptions.split('|');for(var i=0;i<elements.length-1;i++)
{var cbxFeature=document.getElementById('cbxFeature'+i);var opt=cbxFeature.options[cbxFeature.selectedIndex];features+=elements[i]+':'+opt.text+' ';var values=opt.value.split('|');if(values[0]!='')
price+=str2Float(values[0]);if(values[1]!='')
weight+=str2Float(values[1]);}
var ix=basket.find(catIx,itemIx,features);if(ix==-1)
{basket.add();ix=basket.count-1;}
else if(EB_appendIntoBasket)
itemCount+=basket.item.count;if(basket.count>EB_maxItem)
{xwd.hide();xwd.alert('Trop d\'articles dans le panier','Erreur');return;}
basket.item.catIx=catIx;basket.item.itemIx=itemIx;basket.item.features=features;basket.item.price=price;basket.item.weight=weight;basket.item.count=itemCount;basket.write(ix);basket.save();xwd.hide();if(EB_showNewMsg)
{if(ix!=-1)
msg="L\'article est déja dans le panier, la quantitée a été modifiée";else
msg="Article ajouté au panier";xwd.alert('<center>'+msg+'<br><br>'+getBasketCaption()+'<center>');}
writeBasketCaption();if(EB_showBasketAfterAdd)
showBasket();}
function addToBasketFromShowItem(catIx,itemIx,itemOptions)
{var edtItemCount=document.getElementById('edtItemCount');var itemCount=1;if(edtItemCount!=null)
itemCount=str2Int(edtItemCount.value);addToBasket(catIx,itemIx,itemCount,itemOptions);}
function addToBasketFromShowCat(catIx,itemIx)
{var edtItemCount=document.getElementById('edtItemCountFC'+catIx+'_'+itemIx);var itemCount=1;if(edtItemCount!=null)
itemCount=str2Int(edtItemCount.value);addToBasket(catIx,itemIx,itemCount,'');}
function computeItem(catIx,itemIx)
{var item=new Item();item.read(catIx,itemIx);var lbItemPrice=document.getElementById('lbItemPrice');if(lbItemPrice==null)
return;var i=0;var sAmount=0;while(document.getElementById('cbxFeature'+i)!=null)
{var cbxFeature=document.getElementById('cbxFeature'+i);var opt=cbxFeature.options[cbxFeature.selectedIndex];var values=opt.value.split('|');if(values[0]!='')
sAmount+=str2Float(values[0]);i++;}
var s='';if(EB_showCombinedPrices)
s=getMoneyStr(item.price+sAmount);else
{s=item.getPriceStr()+'<br>';if(sAmount>0)
s+='<br>+( '+getMoneyStr(sAmount)+' )';}
lbItemPrice.innerHTML=s;}
function getDiscountText(discount)
{var s='';if(discount.count>0)
{s+='<b>Tarif dégressif suivant quantité :</b><br>';var i=0;while(i<discount.count)
{discount.read(i++);if(i<discount.count)
{s+=(discount.quantity+1)+'&nbsp;à&nbsp;';var dp=discount.getPriceStr();discount.read(i);s+=discount.quantity+'&nbsp;:&nbsp;<b>'+dp+'</b>,&nbsp;&nbsp; ';}
else
s+='Supérieur à '+discount.quantity+'&nbsp;:&nbsp;<b>'+discount.getPriceStr()+'</b>';}}
return s;}
function showItem(catIx,itemIx)
{var item=new Item();item.read(catIx,itemIx);var cbxFeatures="";if(item.feature.count>0)
{cbxFeatures='<table border="0" style="font-size:10pt;font-family:Arial;color:'+EB_txtColor+';">';var feature=item.feature;var oldName="";var nextName="";var itemOptions="";var j=0;var isCbx=false;for(var i=0;i<feature.count;i++)
{if(i<feature.count)
{feature.read(i+1);nextName=feature.name;}
else
nextName="";feature.read(i);if(feature.name!=oldName)
{if(oldName!=""&&isCbx)
cbxFeatures+='</select></td></tr>';isCbx=feature.name==nextName;if(isCbx)
cbxFeatures+='<tr><td align="right">'+feature.name+' : </td><td><select id="cbxFeature'+j+'" onchange="computeItem('+catIx+','+itemIx+')">';else
cbxFeatures+='<tr><td align="right">'+feature.name+' : </td><td><b>'+feature.value+'</b></td></tr>';j++;itemOptions+=feature.name+'|';oldName=feature.name;}
if(isCbx)
cbxFeatures+='<option value="'+feature.price+'|'+feature.weight+'">'+feature.value+'</option>';}
cbxFeatures+='</table>';}
var price='<p id="lbItemPrice"></p>';if(item.state!='')
price+='<br>'+item.state;var s='<form><table border="0" height="300" width="700" style="font-size:10pt;font-family:Arial;color:'+EB_txtColor+';">';s+='<tr valign="top" >';s+='<td width="220"><img src="'+item.image+'"></td>';s+='<td colspan="2">'+item.name+'<br><br><b>'+item.reference
s+='</b><br><br><div style="overflow-y: auto;height:200">'+item.description+'</div></td>';s+='</tr>';var discount=item.discount;if(discount.count>0)
{s+='<tr>';s+='<td colspan="2" valign="top">';s+=getDiscountText(discount);s+='<br><br></td>';s+='</tr>';}
if(item.feature.count>0)
s+='<tr height="50">';else
s+='<tr>';if((EB_showAddToBasketBtn||EB_showBasketBtn)&&item.price>0)
{s+='<td rowspan="2" valign="top">'+cbxFeatures+'</td>';s+='<td rowspan="2" valign="center" width="100" align="center" bgcolor="'+EB_color1+'"><b>';if(item.priceNotReduced>0)
s+='<strike><font color="red">'+item.getPriceNotReducedStr()+'</font></strike><br>';s+=price+'</b></td>';s+='<td align="right">';if(EB_showAddToBasketBtn&&item.state.indexOf('!')==-1)
{s+='<input id="edtItemCount" type="text" value="'+item.miniQuantitySales+'" size="2">&nbsp;&nbsp;';s+='<input type="button" value="Ajouter au panier" onclick="addToBasketFromShowItem('+catIx+','+itemIx+',\''+itemOptions+'\')"></td>';}
s+='</tr>';s+='<tr valign="bottom"><td align="right">';if(item.detailLink!="")
s+='<input type="button" value="Voir détail" onclick="window.open(\''+item.detailLink+'\')">';if(EB_showBasketBtn)
s+='<input type="button" value="Voir mon panier" onclick="showBasket()">';if(EB_showAddToBasketBtn||EB_showBasketBtn)
s+='<input type="button" value="Poursuivre mes achats" onclick="xwd.hide()">';else
s+='<input type="button" value="Fermer" onclick="xwd.hide()">';s+='<td>';}
else
{s+='<td rowspan="2" colspan="2" valign="top">'+cbxFeatures+'</td>';s+='</tr>';s+='<tr valign="bottom"><td align="right">';if(item.detailLink!="")
s+='<input type="button" value="Voir détail" onclick="window.open(\''+item.detailLink+'\')">';s+='<input type="button" value="Fermer" onclick="xwd.hide()">';s+='<td>';}
s+='</tr></table></form>';xwd.show(s,'Détail');computeItem(catIx,itemIx);}
function showItemById(catId,itemId)
{var catIx=getEBusinessCategoryIx(catId);var msg=categoryValidStr(catIx);if(msg!="")
{xwd.alert(msg);return;}
var item=new Item();for(var i=0;i<item.getCountForCat(catIx);i++)
{item.read(catIx,i);if(itemId==item.id)
{showItem(catIx,i);return;}}}
function getEBusinessCategoryIx(catId)
{for(var i=0;i<EB_cats.length;i++)
if(EB_cats[i]==catId)
return i;return null;}
function categoryValidStr(catIx)
{if(catIx==null)
return"Catégorie non définie";var item=new Item();if(item.getCountForCat(catIx)==0)
return"Pas d\'article dans cette catégorie";return"";}
function categoryValid(catIx)
{var msg=categoryValidStr(catIx);if(msg!="")
{document.write(msg);return false;}
else
return true;}
var EB_shows=new Array();function getNewVShow(div)
{var vshow=new Object();vshow.div=div;vshow.show=null;EB_shows[EB_shows.length]=vshow;return vshow;}
function getVShow(div)
{for(var i=0;i<EB_shows.length;i++)
if(EB_shows[i].div==div)
return EB_shows[i];return null;}
function showEBusinessItemsByCat(div,catId,itemRef)
{if(div=="")
return;var vshow=getVShow(div);if(vshow==null)
return;if(getQueryField("CDE")=="showEBusinessItemsByCat"&&div==getQueryField("DIV")&&!vshow.loaded)
{catId=getQueryField("CATID");vshow.loaded=true;}
var catIx=getEBusinessCategoryIx(catId);if(!categoryValid(catIx))
return;if(typeof(itemRef)=="undefined")
itemRef="";var item=vshow.item;var out="";for(var i=0;i<item.getCountForCat(catIx);i++)
{item.read(catIx,i);if(itemRef==""||itemRef==item.reference)
{out+=vshow.getItemHTML(vshow);if(itemRef!="")
break;}}
out+='<div id="lbBusinessZAC" style="display:none"></div>';document.getElementById(div).innerHTML=out;}
function showEBusinessItemsByCatBO(div)
{if(div=="")
return;var vshow=getVShow(div);if(vshow==null)
return;showEBusinessItemsByCat(div,vshow.catId,vshow.itemRef);}
function showEBusinessItemsByIxBO(div,catIx,itemIx)
{if(div=="")
return;var vshow=getVShow(div);if(vshow==null)
return;var item=vshow.item;item.read(catIx,itemIx);var out=vshow.getItemHTML(vshow);out+='<div id="lbBusinessZAC" style="display:none"></div>';document.getElementById(div).innerHTML=out;}
function filterSort(a,b)
{if(a.name<b.name)
return-1;if(a.name>b.name)
return 1;return 0;}
function showEBusinessItemsBySummaryBO(div)
{if(div=="")
return;var vshow=getVShow(div);if(vshow==null)
return;var item=vshow.item;var out='<div style="'+item.textFont+'">';for(var catIx=0;catIx<EB_cats.length;catIx++)
{var items=new Array();for(var i=0;i<item.getCountForCat(catIx);i++)
{item.read(catIx,i);j=items.length;witem=new Item();witem.name=item.name;witem.catIx=item.catIx;witem.itemIx=item.itemIx;items[j]=witem;}
items=items.sort(filterSort);if(items.length>0)
{out+='<b>'+EB_catsName[catIx]+'</b><br>';for(i=0;i<items.length;i++)
out+='&nbsp;&nbsp;&nbsp;<a style="'+item.textFont+'text-decoration:underline" href="javascript:showItem('+items[i].catIx+','+items[i].itemIx+')">'+items[i].name+'</a><br>';}}
out+='</div><div id="lbBusinessZAC" style="display:none"></div>';document.getElementById(div).innerHTML=out;}
function showEBusinessItemsByAZBO(div,filter)
{if(div=="")
return;var vshow=getVShow(div);if(vshow==null)
return;var filters=new Array();var item=vshow.item;var items=new Array();var car;var out='';for(var catIx=0;catIx<EB_cats.length;catIx++)
{for(var i=0;i<item.getCountForCat(catIx);i++)
{item.read(catIx,i);car=item.name.substr(0,1).toUpperCase();filters[car]=true;if(filters[car]==true&&filter=="")
filter=car;if(item.name.substr(0,1).toUpperCase()==filter)
{j=items.length;witem=new Item();witem.name=item.name;witem.catIx=item.catIx;witem.itemIx=item.itemIx;items[j]=witem;}}}
items=items.sort(filterSort);out+='<table style="'+item.textFont+'" border="0" width="100%">';out+='<tr><td><a style="'+item.textFont+'" href="javascript:showEBusinessItemsByCatBO(\''+div+'\')">&lt;&lt;</a></td><td>';for(i=65;i<91;i++)
if(filters[String.fromCharCode(i)]==true)
out+='<b><a style="'+item.textFont+'text-decoration:underline" href="javascript:showEBusinessItemsByAZBO(\''+div+'\',\''+String.fromCharCode(i)+'\')">'+String.fromCharCode(i)+'</a></b> ';else
out+=String.fromCharCode(i)+' ';out+="&nbsp;&nbsp;";for(i=48;i<58;i++)
if(filters[String.fromCharCode(i)]==true)
out+='<a style="'+item.textFont+'text-decoration:underline" href="javascript:showEBusinessItemsByAZBO(\''+div+'\',\''+String.fromCharCode(i)+'\')">'+String.fromCharCode(i)+'</a> ';else
out+=String.fromCharCode(i)+' ';out+='</td></tr><tr valign="top"><td width="50" align="center"><h1>'+filter+'</h1></td><td><br><br>';for(i=0;i<items.length;i++)
out+='<a style="'+item.textFont+'text-decoration:underline" href="javascript:showItem('+items[i].catIx+','+items[i].itemIx+')">'+items[i].name+'</a><br>';out+="</td></tr></table>";out+='<div id="lbBusinessZAC" style="display:none"></div>';document.getElementById(div).innerHTML=out;}
function showEBusinessItemsFindBO(div,toFind)
{if(div=="")
return;var vshow=getVShow(div);if(vshow==null)
return;var catIx=getEBusinessCategoryIx(vshow.catId);var item=vshow.item;var out="";var n=0;if(toFind=="")
out="<b>Valeur obligatoire pour la recherche</b>";else
{for(catIx=0;catIx<EB_cats.length;catIx++)
{catId=EB_cats[catIx];for(var i=0;i<item.getCountForCat(catIx);i++)
{item.read(catIx,i);var feature=item.feature;var features="";for(var j=0;j<feature.count;j++)
{feature.read(j);features+=feature.value+' ';}
if
(item.name.toLowerCase().indexOf(toFind)!=-1||item.description.toLowerCase().indexOf(toFind)!=-1||features.toLowerCase().indexOf(toFind)!=-1)
{out+=vshow.getItemHTML(vshow);n++;}}}
if(n==0)
out="<b>Aucun résulat disponible pour votre recherche</b><br>"+out;else if(n==1)
out="<b>Un article trouvé</b><br>"+out;else
out="<b>"+n+" articles trouvés</b><br>"+out;}
out+='<div id="lbBusinessZAC" style="display:none"></div>';document.getElementById(div).innerHTML=out;}
function InitEBusiness()
{for(var i=0;i<EB_cats.length;i++)
document.write('<script src="EBusinessCatData'+EB_cats[i]+'.js" type="text/javascript"></script>');document.close();if(!EB_useCommand)
{EB_showNewMsg=false;EB_showAddToBasketBtn=false;EB_showBasketAfterAdd=false;EB_showBasketBtn=false;EB_showNewMsg=false;}}
var invoice=new Invoice();var captionsBasket=new Array();InitEBusiness();

