var isBasketLoaded = false;
var SSL = false;
var backToShopURL = new String("home.htm");
var items = new Array();
var nrOfItems = 0;
var versand = 0;
var nachnahme = 0;
var orderitems = new String("");
var orderpaymethod = new String("");
var Client = new customer('','','','','','','','','','','','','','','',0,'',0,'',0);
var Commande = new order('','','','','','','','','');
var orderWindow;
var shipuid_france = new Array();
var shipuid_europe = new Array();
var shipuid_monde = new Array();
var vatitems = new Array();
vatitems[vatitems.length] = new vat(0,'','','aucune','0',0);
vatitems[vatitems.length] = new vat(1,'','','Logiciels et papiers','19,6',0);
vatitems[vatitems.length] = new vat(2,'','','Livres','5,5',0);

function showBasket(location) {
  var pos = location.pathname.lastIndexOf('/');
  if (pos != -1) {
    backToShopURL = location.pathname.substring(pos+1,location.pathname.length);
  }  
  window.main_frame.location = "order0.htm";
}

function getURL(filename) {
  var url = new String(filename);
  if (document.location.protocol == 'https:') {
    window.main_frame.location = url;
  } else {
    window.main_frame.location = url;
  }
}

function browser() {
  var b = new String("unknown");
  if (navigator.appName == "Netscape")
    b = "NN" + navigator.appVersion.charAt(0)
  else if (navigator.appName == "Microsoft Internet Explorer")
         b = "MSIE" + navigator.appVersion.charAt(0);
  return b;         
}

function checknum(str) {
  if (str == "") {
    alert("Veuillez indiquer une valeur comprise entre 0 et 10.")
    return false
  }
  for (var i = 0; i < str.length; i++) {
    var ch = str.substring(i, i + 1)
    if (ch < "0" || ch > "9") {
      alert("Veuillez indiquer une valeur comprise entre 0 et 10.")
      return false
    }
  }
  return true
}

function StringToFloat(str) {
  var s = new String("");
  if (str.indexOf(",") >= 0) {
    s = str.substring(0, str.indexOf(",")) + "." + str.substring(str.indexOf(",")+1, str.length);
  } else s = str;  
  return(parseFloat(s));
}

var eurokurs = StringToFloat('1');

function convdec(str) {
  var s = new String("");
  if (str == 0) {
    return "0.00";
  } else {
    str = "" + Math.round(str * 100);
	if (str.length == 1) {
	  str = "00" + str;
	} else if (str.length == 2) {
	  str = "0" + str;
	}  
	s = str.substring(0, str.length-2) + "." + str.substring(str.length-2, str.length);
	return s;
  }
}

function position(artnr) {
  var j = -1;
  for (var i = 0; i < items.length; i++) {
    if (items[i].artnr == artnr) {
	    j = i;
    }
  }
  return j;  
}

function posname(name) {
  var j = -1;
  for (var i = 0; i < items.length; i++) {
    if (items[i].name == name) {
	    j = i;
    }
  }
  return j;  
}

function getNrOfItems() {
  var j = 0;
  for (var i = 0; i < items.length; i++) {
    j += items[i].qty;
  }  
  return j;  
}

function vat(vid, vstateshort, vstatelong, vname, vvalue, vtotal) {
	this.vid = vid;
	this.vstateshort = vstateshort;
	this.vstatelong = vstatelong;
	this.vname = vname;
	this.vvalue = StringToFloat(vvalue);
	this.vtotal = vtotal;
}

function item(artnr, name, price, image, poids, uid2, poids2, qty) {
	this.artnr = artnr;
	this.name = name;
	this.price = price;
	this.image = image;
	this.poids = poids;
	this.uid2 = uid2;
	this.poids2 = poids2;
	this.qty = qty;
}

function customer(qualite, nomclient, prenom, connuvolodalen, societe, tvaeurope, adresse, codepostal, ville, pays, telephone, mobile, email, sendemail, 
                  livraisonzone, livraisoncout, shiptext, shipuid, paymethod, newsletter)
{
	this.qualite = qualite;
	this.nomclient = nomclient;
	this.prenom = prenom;
	this.connuvolodalen = connuvolodalen;
	this.societe = societe;
	this.tvaeurope = tvaeurope;
	this.adresse = adresse;
	this.codepostal = codepostal;
	this.ville = ville;
	this.pays = pays;
	this.telephone = telephone;
	this.mobile = mobile;
	this.email = email;
	this.sendemail = sendemail;
	this.livraisonzone = livraisonzone;
	this.livraisoncout = livraisoncout;
	this.shiptext = shiptext;
	this.shipuid = shipuid;
	this.paymethod = paymethod;
	this.newsletter = newsletter;
}

function order(paymethod, items, subtotal, delivery, cod, total, euro, vat, paymethodshort) {
	this.paymethod = paymethod;
	this.items = items;
	this.subtotal = subtotal;
	this.delivery = delivery;
	this.cod = cod;
	this.total = total;
	this.euro = euro;      
	this.vat = vat;
	this.paymethodshort = paymethodshort;      
}

function cancelOrder() {
  if (document.location.protocol == 'https:') {
    self.location = '';
  } else {
    for (var i = 0; i < items.length; i++) {
      items[i].qty = 0;
    }
    nrOfItems = 0;
    window.main_frame.location = 'home.htm';
  }
  alert("Votre commande est annulée !");  
}

function addToBasket(form) {
    var p_artnr = form.elements[0].value;
    var p_name = form.elements[1].value;
    var p_price = StringToFloat(form.elements[2].value);
    var p_image = form.elements[3].value;	
	var p_poids = form.elements[4].value;
    var p_uid2 = form.elements[5].value;
	var p_poids2 = form.elements[6].value;	
	if (form.elements[7].type == "hidden") {
		var p_qty = parseInt(form.elements[7].value);
	} else {
		var p_qty = parseInt(form.elements[7].options[form.elements[7].selectedIndex].value,10);
	}
    var pos = position(p_artnr);
    if (pos >= 0 ) { 
      if (items[pos].name == p_name) {
        items[pos].qty += p_qty;
      } else {
        items[items.length] = new item(p_artnr, p_name, p_price, p_image, p_poids, p_uid2, p_poids2, p_qty);
      }  
    } else {
		items[items.length] = new item(p_artnr, p_name, p_price, p_image, p_poids, p_uid2, p_poids2, p_qty);
    }
	nrOfItems = getNrOfItems();
}

function deleteFromBasket(artnr) {
  var pos = position(artnr);
  items[pos].qty = 0;
  nrOfItems = getNrOfItems();
  window.main_frame.location="order0.htm";
}

function updateBasket(form) {
  for (var g = 0; g < form.elements.length-1;  g += 2) {
    var h = g + 1; 
    var p_artnr = form.elements[g].value;
    var p_qty = parseInt(form.elements[h].value,10);
    var pos = position(p_artnr);
    if (pos >= 0 ) { 
      items[pos].qty = p_qty;
    }
  }
  nrOfItems = getNrOfItems();
  window.main_frame.location="order0.htm";
}

function setStatus(form) {
  var s = new String("");
  for (var i=0; i<form.elements.length; i++) {
    if (form.elements[i].type == 'radio') {
      var radiofield = form.elements[i];
      var radiovalue = eval('Client.'+radiofield.name);
      if (radiovalue == '' && radiofield.name == 'paymethod') {
	    radiofield.checked = true;
/*	    if (isNaN(form.paymethod.length)) {
		  form.paymethod.checked = true;
		} else {
          form.paymethod[0].checked = true;
		}  */
      } else {
        if (radiofield.value == radiovalue) {radiofield.checked = true;}
      }  
    }
    if (form.elements[i].type == 'select-one') {
      var selectfield = form.elements[i];
      for (var j=0; j<selectfield.length; j++) {
        if (selectfield.name.indexOf('shipping') == 0) {
          var text = Client.shiptext;
        } else {
          var text = eval('Client.'+selectfield.name);
        }  
        if (selectfield.options[j].text == text) {selectfield.options[j].selected = true;}
      }
    }
    if (form.elements[i].type == 'checkbox') {
      var checkboxfield = form.elements[i];
      if (checkboxfield.value == eval('Client.'+checkboxfield.name)) {checkboxfield.checked = true;}
    }  
  }
}

function calculnombrelivres () {
var nblivre = 0;
	for (var i=0; i<items.length; i++) {
		if (items[i].qty > 0) {
			if ((items[i].artnr == '109') || (items[i].artnr == '112') || (items[i].artnr == '113') || (items[i].artnr == '114') || (items[i].artnr == '115')) {
				nblivre += items[i].qty;
			}
		}
	}
	return nblivre;
}

function calculnombrelivresmichelnew () {
var nblivre = 0;
	for (var i=0; i<items.length; i++) {
		if (items[i].qty > 0) {
			if ((items[i].artnr == '114') || (items[i].artnr == '115')) nblivre += items[i].qty
			else if (items[i].artnr == '116') nblivre += 2 * items[i].qty
			else if (items[i].artnr == '117') nblivre += 4 * items[i].qty;
		}
	}
	return nblivre;
}

function basketpopup() {
var url;
var nblivre;
//	nblivre = calculnombrelivres()
//	if (nblivre == 1) {
//		url = 'basket_popup1.htm';
//	} else if (nblivre > 1) {
//		url = 'basket_popup2.htm';
//	} else {
		url = 'basket_popup.htm';
//	}
	newWin=window.open(url, 'newWindow', 'scrollbars=no,width=400,height=240');
	newWin.focus()
}
/* 
  order0.htm - Etape 1
__________________________________________________________________________*/
function scriptorder0() {
var s = new String("");
var subtotal = 0;
var total = 0;
var nblivre;
	for (var i=0; i<items.length; i++) {
		if (items[i].qty > 0) {
			s += '<tr>';
			s += '<td valign="middle" align="center" bgcolor="#FFFFFF">';
			s += '<input type="hidden" name="artnr" value="' + items[i].artnr + '">';
			s += '<input  class="form_inputpetit type="text" name="quantity" value="' + items[i].qty + '" size="2" maxlength="3" ';
			s += 'onChange="if (!parent.checknum(this.value)) {this.focus(); this.select()}"></td>';
			s += '<td align="left" valign="middle" bgcolor="#FFFFFF" class="boutique-articles">' + items[i].name + '</td>';
			s += '<td align="center" valign="middle" bgcolor="#FFFFFF">';
			if (items[i].image != '') {
				s += '<img src="' + items[i].image + '" width="30">';
			} else {
				s += '&nbsp;';
			}  
			s += '</td>';
			s += '<td align="right" valign="middle" bgcolor="#FFFFFF" class="boutique-articles">' + convdec(items[i].price) + '</td>';
			subtotal = items[i].qty * items[i].price;
			total += subtotal;
			s += '<td align="right" valign="middle" bgcolor="#FFFFFF" class="boutique-articles">' + convdec(subtotal) + '</td>';
			s += '<td align="center"><a href="javascript:parent.deleteFromBasket(\'' + items[i].artnr + '\')"><img src="images/supprime-article.gif" width="32" height="28" border="0"></a></td>\n';
			s += '</tr>';
		}
	}
/*	nblivremichel = calculnombrelivresmichelnew();
	if (nblivremichel == 1) {
		s += '<tr height="42" valign="baseline">';
		s += '<td colspan="5" bgcolor="#0082BF" align="right" valign="middle" class="prixbleu">Economisez les frais de port en achetant un deuxième livre de Michel Dufour<br>Economisez 17 euros et les frais de port en achetant 4 livres de Michel Dufour</td>';
		s += '<td align="center">&nbsp;</td></tr>';
	}
*/	
	s += '<tr height="22" valign="baseline">';
	s += '<td colspan="4" bgcolor="#DEEDF3" align="right" valign="middle" class="boutique-articles">sous-total&nbsp; </td>';
	s += '<td bgcolor="#DEEDF3" align="right" valign="middle" class="boutique-articles">' + convdec(total) + '</td>';
	s += '<td align="center">&nbsp;</td></tr>';
	
	s += '<tr valign="middle">';
	s += '<td align="right" colspan="5" valign="bottom" height="50">';
	s += '<div class="boutique-text">Si vous avez modifié les quantités, cliquez sur&nbsp;</font>';
	s += '<input class="form_bouton" type="button" value="Recalculer" onClick="parent.updateBasket(this.form)">';
	s += '</div></form></td>';
	s += '</tr>';
	return s;
}
/* 
  order1.htm - Etape 2
__________________________________________________________________________*/
function scriptorder1() {
var s = new String("");
var s1 = new String("");
var port = 0;
var portFrance = 0;
var portEurope = 0;
var portMonde = 0;
var poids = 0;
var poids2 = 0;
var uiFrance = 0;
var ui2France = 0;
var uiEurope = 0;
var ui2Europe = 0;
var uiMonde = 0;
var ui2Monde = 0;
var poidsfrancenegatif = 0;

var total = 0;
	for (var i=0; i<vatitems.length; i++) {
		portFrance = 0;
		portEurope = 0;
		portMonde = 0;
		poids = 0;
		poids2 = 0;
	}
	for (var i=0; i<items.length; i++) {
		if (items[i].qty > 0) {
			total += items[i].qty * items[i].price;
			if (items[i].artnr == '118S') {
				poidsfrancenegatif += items[i].qty * items[i].poids;
			}
			poids += items[i].qty * items[i].poids;
			poids2 += items[i].qty * items[i].poids2;
			
			ui2France += parseInt(items[i].uid2.substr(0, 1))
			ui2Europe += parseInt(items[i].uid2.substr(1, 1))
			ui2Monde += parseInt(items[i].uid2.substr(2, 1))			
		}
	}
// France
	
	if (total > 80) portFrance = 0
//	else if (calculnombrelivres() > 1) portFrance = 0
	else portFrance = CalculPortFrance(poids - poidsfrancenegatif) + ui2France * 4 * CalculPortFranceMag(poids2);

// Europe
	portEurope = CalculPortEurope(poids) + ui2Europe * 4 * CalculPortEuropeMag(poids2);
	
// Monde
	portMonde = CalculPortMonde(poids) + ui2Monde * 4 * CalculPortMondeMag(poids2);

	s += '<tr bgcolor="#0082BF">\n';
	s += '<td height="20" colspan="3" valign="center" class="text-blanc">&nbsp;Zone d&rsquo;expédition - Poids de votre commande (' + poids + ' g) + (' + poids2 + ' g)</td>\n';
	s += '</tr>\n';
	
	if ((portFrance == 0) && (portEurope == 0) && (portMonde == 0)) {
		s += '<tr align="left" height="55">\n';
		s += '<td valign="bottom" colspan="3" valign="middle" class="boutique-text">Pas de frais d&rsquo;expédition, cliquez sur le bouton \n';
		s += '<span class="boutique-textgris">Poursuivre votre commande</span> \n';
		s += 'pour indiquer vos coordonnées dans la page suivante.</td>\n';
// France		
		s += '<input type="hidden" name="livraisonzone" value="France">\n';
		var count = 0;
		shipuid_france[count] = 0;
		++count;
		s += '<input type="hidden" name="LivraisonFrance" value="' + convdec(portFrance) + '">\n';
// Europe
		count = 0;
		shipuid_europe[count] = 0;
		++count;
		s += '<input type="hidden" name="LivraisonEurope" value="' + convdec(portEurope) + '">\n';
// Monde
		count = 0;
		shipuid_monde[count] = 0;
		++count;
		s += '<input type="hidden" name="LivraisonMonde" value="' + convdec(portMonde) + '">\n';
		
		s += '</tr>\n';
	} else {
// France
		s += '<tr valign="middle" height="45" bgcolor="#DEEDF3">\n';
		s += '<td class="boutique-text" align="right">\n'; 
		s += 'France <input type="radio" name="livraisonzone" value="France" checked></td>\n';
		s += '<td><img src="images/puce_vide.gif" width="5" height="5"></td>\n';
		s += '<td class="boutique-text">\n';
		var count = 0;
		shipuid_france[count] = 0;
		++count;
		s += '<input type="hidden" name="LivraisonFrance" value="' + convdec(portFrance) + '">\n';
		if (portFrance == 0) { 
			s += convdec(portFrance) + ' € pour livraison en France. Frais de port OFFERT\n';
		} else {
			s += convdec(portFrance) + ' € pour livraison en France\n';
		}
		s += '</td></tr>\n';
//
		s += '<tr height="1" bgcolor="#FFFFFF">\n';
		s += '<td></td>\n'; 
		s += '<td></td>\n';
		s += '<td></td></tr>\n';
// Europe
		s += '<tr valign="middle" height="45" bgcolor="#DEEDF3">\n';
		s += '<td class="boutique-text" align="right">\n';
		s += 'Europe <input type="radio" name="livraisonzone" value="Europe"></td>\n';
		s += '<td><img src="images/puce_vide.gif" width="5" height="5"></td>\n';
		s += '<td class="boutique-text">\n';
		count = 0;
		shipuid_europe[count] = 0;
		++count;
		s += '<input type="hidden" name="LivraisonEurope" value="' + convdec(portEurope) + '">\n';
		s += convdec(portEurope) + ' € pour livraison en Union Européenne, Suisse et DOM-TOM.\n';
		s += '</td></tr>\n';
//		
		s += '<tr height="1" bgcolor="#FFFFFF">\n';
		s += '<td></td>\n'; 
		s += '<td></td>\n';
		s += '<td></td></tr>\n';
// Monde
		s += '<tr valign="middle" height="45" bgcolor="#DEEDF3">\n';
		s += '<td class="boutique-text" align="right">\n';
		s += 'Hors Europe <input type="radio" name="livraisonzone" value="Monde"></td>\n';
		s += '<td><img src="images/puce_vide.gif" width="5" height="5"></td>\n';
		s += '<td class="boutique-text">\n';
		count = 0;
		shipuid_monde[count] = 0;
		++count;
		s += '<input type="hidden" name="LivraisonMonde" value="' + convdec(portMonde) + '">\n';
		s += convdec(portMonde) + ' € pour livraison dans le reste du monde.\n';
		s += '</td></tr>\n';
		
		s += '<tr align="left" valign="top">\n';
		s += '<td height="37" colspan="3" class="boutique-text">Après avoir défini la zone d&rsquo;expédition, cliquez sur le bouton \n';
		s += '<span class="boutique-textgris">Poursuivre votre commande</span> \n';
		s += 'pour indiquer vos coordonnées dans la page suivante.</td>\n';
		s += '</tr>\n';
	}
  
	s += '<tr bgcolor="#FFFFFF"><td height="20" colspan="3"></td></tr>\n';
return s;
}

function CalculPortFrance (poids) {
	if (poids == 0) v = 0
	else if (poids <= 250) v = 2.40
	else if (poids <= 500) v = 3.25
	else if (poids <= 1000) v = 4.20
	else if (poids <= 2000) v = 5.50
	else if (poids <= 3000) v = 6.40
	else v = poids * 0.003;
return v;
}

function CalculPortEurope (poids) {
	if (poids == 0) v = 0
	else if (poids <= 250) v = 4.10
	else if (poids <= 500) v = 6.10
	else if (poids <= 1000) v = 8.75
	else if (poids <= 2000) v = 12.60
	else if (poids <= 3000) v = 16.00
	else v = poids * 0.006;	
return v;
}

function CalculPortMonde (poids) {
	if (poids == 0) v = 0
	else if (poids <= 250) v = 5.60
	else if (poids <= 500) v = 7.35
	else if (poids <= 1000) v = 10.80
	else if (poids <= 2000) v = 16.95
	else if (poids <= 3000) v = 40.00	
	else v = poids * 0.014;
return v;
}

function CalculPortFranceMag (poids) {
	if (poids == 0) v = 0
	else if (poids <= 250) v = 0.60		//faux
	else if (poids <= 500) v = 3.25		//faux
	else if (poids <= 1000) v = 4.20	//faux
	else if (poids <= 2000) v = 5.50	//faux
	else if (poids <= 3000) v = 6.40	//faux
	else v = poids * 0.003;				//faux
return v;
}

function CalculPortEuropeMag (poids) {
	if (poids == 0) v = 0
	else if (poids <= 250) v = 1.50
	else if (poids <= 500) v = 6.10			//faux
	else if (poids <= 1000) v = 8.75		//faux
	else if (poids <= 2000) v = 12.60		//faux
	else if (poids <= 3000) v = 16.00		//faux
	else v = poids * 0.006;					//faux
return v;
}

function CalculPortMondeMag (poids) {
	if (poids == 0) v = 0
	else if (poids <= 250) v = 2.00
	else if (poids <= 500) v = 7.35			//faux
	else if (poids <= 1000) v = 10.80		//faux
	else if (poids <= 2000) v = 16.95		//faux
	else if (poids <= 3000) v = 40.00		//faux
	else v = poids * 0.014;					//faux
return v;
}

function processOrderStep1(form) {
	for (var i=0; i<form.elements.length; i++) {
		if (form.elements[i].name == 'livraisonzone') {
			if (form.elements[i].type == 'radio') {
				if (form.elements[i].checked == true) {
					Client.livraisonzone = form.elements[i].value;
					switch (Client.livraisonzone) {
					case 'France' :
						Client.livraisoncout = form.LivraisonFrance.value;
						Client.shiptext = "Livraison en France";
						break;
					case 'Europe' :
						Client.livraisoncout = form.LivraisonEurope.value;
						Client.shiptext = "Livraison en Europe";
						break;
					case 'Monde' :
						Client.livraisoncout = form.LivraisonMonde.value;
						Client.shiptext = "Livraison hors Europe";
						break;
					}
				}
			} else {
				Client.livraisonzone = "France"
				Client.livraisoncout = form.LivraisonFrance.value;
				Client.shiptext = "Livraison locale";
			}
		}
	}
	
	Client.paymethod = 'CarteBancaire';
	nachnahme = 0;
	window.main_frame.location = 'order2.htm';
}
/* 
  order2.htm - Etape 3
__________________________________________________________________________*/

function showOrderItems() {
var s = new String("");
var versand = StringToFloat(Client.livraisoncout);
var subtotal = 0;
var total = 0;
	Commande.items = '';
	for (var i=0; i<vatitems.length; i++) {vatitems[i].vtotal = 0}
		for (var i=0; i<items.length; i++) {
			if (items[i].qty > 0) {
				s += '<tr bgcolor="#FFFFFF" valign="middle" class="boutique-articles" height="30">'; 
				s += '<td align="center">' + items[i].qty + '</td>';
				s += '<td align="left">(' + items[i].artnr + ') ' + items[i].name + '</td>';
				s += '<td align="right">' + convdec(items[i].price) + ' €&nbsp;</td>';
				subtotal = items[i].qty * items[i].price;
				if (items[i].uid > 0) {
				for (var j=0; j<vatitems.length; j++) {
					if (vatitems[j].vid == items[i].uid) {
						vatitems[j].vtotal += subtotal - (subtotal / (1 + (vatitems[j].vvalue / 100)));
					}
				}  
			}
			total += subtotal;
			s += '<td align="right">' + convdec(subtotal) + ' €&nbsp;</td>';
			s += '</tr>';

			if (Commande.items != '') {Commande.items += '#';}
			Commande.items += items[i].qty + '__' + items[i].artnr + '__' + items[i].name + '__' + convdec(items[i].price) + '__' + convdec(subtotal);
		}
	}    
/*	
	if (calculnombrelivres() > 1) {
		s += '<tr valign="middle" bgcolor="#DEEDF3" class="boutique-articles" height="24">';
		s += '<td colspan="3" align="right">Remise offre spéciale 2 livres&nbsp;</td>';
		s += '<td align="right">' + convdec(-9) + ' €&nbsp;</td>';
		s += '</tr>';
		total -= 9;
	}
*/	
// Sous-total

	s += '<tr valign="middle" bgcolor="#DEEDF3" class="boutique-articles" height="24">';
	s += '<td colspan="3" align="right">Sous-total&nbsp;</td>';
	s += '<td align="right">' + convdec(total) + ' €&nbsp;</td>';
	s += '</tr>';
	Commande.subtotal = 'Sous-total :__' + convdec(total);

// Frais de port
	if (Client.shipuid > 0) {
		for (var j=0; j<vatitems.length; j++) {
			if (vatitems[j].vid == Client.shipuid) {
				vatitems[j].vtotal += Client.livraisoncout - (Client.livraisoncout / (1+(vatitems[j].vvalue / 100)));
			}
		}  
	}
	s += '<tr valign="middle" bgcolor="#DEEDF3" class="boutique-articles" height="24">';
	s += '<td colspan="3" align="right">+ Port et emballage&nbsp;</td>';
	s += '<td align="right">' + convdec(versand) + ' €&nbsp;</td>';
	s += '</tr>';
	Commande.delivery = '+ Port et emballage :__' + convdec(versand);
  
// Total
	s += '<tr valign="middle" bgcolor="#DEEDF3" class="boutique-articles" height="24">';
	s += '<td colspan="3" align="right">Total TTC&nbsp;</td>';
	s += '<td align="right">' + convdec(total+versand) + ' €&nbsp;</td>';
	s += '</tr>';
	Commande.total = 'Total TTC :__' + convdec(total+versand);

	var eurototal = (total+versand) / eurokurs;
	return s;
}

function showOrder2Form() {
  var s = new String("");
  
// Client.nomclient='Paget';
// Client.prenom='Olivier';
// Client.adresse='21, route de Laire';
// Client.codepostal='25200';
// Client.ville='Montbéliard';
// Client.pays='France';
// Client.email='paget.olivier@wanadoo.fr';    
// Client.telephone='06 89 67 68 29';
  Client.connu='Internet';
  Client.newsletter='Oui';
  
 // Qualité  
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">';
  s += '<td align="right">Qualité&nbsp;</td>';
  s += '<td align="left"><input type="radio" name="qualite" value="M." checked>M. <input type="radio" name="qualite" value="Mme">Mme <input type="radio" name="qualite" value="Mlle">Mlle</td>';
  s += '</tr>';

// nomclient
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Nom&nbsp;</td>\n';
  s += '<td><input type="text" name="nomclient" size="40" class="form_input" value="' + Client.nomclient + '" ';
  s += 'onChange="parent.validate(window, form1, this, \'isNotEmpty\', \'Nom\')">\n';
  s += '<img src="images/li_cross_grey666666.gif" width="8" height="10"></td>\n';
  s += '</tr>\n';
  
// prenom
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Prénom&nbsp;</td>\n';
  s += '<td><input type="text" name="prenom" size="40" class="form_input" value="' + Client.prenom + '" ';
  s += 'onChange="parent.validate(window, form1, this, \'isNotEmpty\', \'Prénom\')">\n';
  s += '<img src="images/li_cross_grey666666.gif" width="8" height="10"></td>\n';
  s += '</tr>\n';

// adresse
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Adresse&nbsp;</td>\n';
  s += '<td><input type="text" name="adresse" size="40" class="form_input" value="' + Client.adresse + '" ';
  s += 'onChange="parent.validate(window, form1, this, \'isNotEmpty\', \'Adresse\')">\n';
  s += '<img src="images/li_cross_grey666666.gif" width="8" height="10"></td>\n';
  s += '</tr>\n';

// Code postal
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Code postal&nbsp;</td>\n';
  s += '<td><input type="text" name="codepostal" size="40" class="form_input" value="' + Client.codepostal + '" ';
  s += 'onChange="parent.validate(window, form1, this, \'isNotEmpty\', \'Code postal\')">\n';
  s += '<img src="images/li_cross_grey666666.gif" width="8" height="10"></td>\n';
  s += '</tr>\n';
  
// Ville
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Ville&nbsp;</td>\n';
  s += '<td><input type="text" name="ville" size="40" class="form_input" value="' + Client.ville + '" ';
  s += 'onChange="parent.validate(window, form1, this, \'isNotEmpty\', \'Ville\')">\n';
  s += '<img src="images/li_cross_grey666666.gif" width="8" height="10"></td>\n';
  s += '</tr>\n';

// Pays
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Pays&nbsp;</td>\n';
  s += '<td><input type="text" name="pays" size="40" class="form_input" value="' + Client.pays + '" ';
  s += 'onChange="parent.validate(window, form1, this, \'isNotEmpty\', \'Pays\')">\n';
  s += '<img src="images/li_cross_grey666666.gif" width="8" height="10"></td>\n';
  s += '</tr>\n';

// Société
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Société&nbsp;</td>\n';
  s += '<td><input type="text" name="societe" size="40" class="form_input" value="' + Client.societe + '"</td>';
  s += '</tr>\n';

// TVA Europe
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Numéro TVA intracommunautaire&nbsp;</td>\n';
  s += '<td><input type="text" name="tvaeurope" size="40" class="form_input" value="' + Client.tvaeurope + '"</td>';
  s += '</tr>\n';

// telephone
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Téléphone&nbsp;</td>\n';
  s += '<td><input type="text" name="telephone" size="40" class="form_input" value="' + Client.telephone + '"</td>';
  s += '</tr>\n';
  
// Mobile
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Mobile&nbsp;</td>\n';
  s += '<td><input type="text" name="mobile" size="40" class="form_input" value="' + Client.mobile + '"</td>';
  s += '</tr>\n';
  
// E-Mail
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">E-mail&nbsp;</td>\n';
  s += '<td><input type="text" name="email" size="40" class="form_input" value="' + Client.email + '" ';
  s += 'onChange="parent.validate(window, form1, this, \'isNotEmpty\', \'E-mail\')">\n';
  s += '<img src="images/li_cross_grey666666.gif" width="8" height="10"></td>\n';
  s += '</tr>\n';

// Connu Volodalen
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Comment avez-vous connu Volodalen ?&nbsp;</td>\n';
  s += '<td class="boutique-articles">\n';
  s += '<select name="connuvolodalen" size="1" class="form_select" value="' + Client.connuvolodalen + '">';
  s += '<option value="Internet">Par Internet</option>';
  s += '<option value="Presse">Par la presse</option>';
  s += '<option value="Course">Sur des courses</option>';
  s += '<option value="Relations">Par relations</option>';
  s += '<option value="Autre">Autre</option>';
  s += '</select>';
  s += '</td>\n';
  s += '</tr>\n';
//  s += '<input type="text" name="connuvolodalen" size="30" value="' + Client.connuvolodalen + '"></font></td></tr>\n';

// Newsletter
  s += '<tr valign="center" height="24" bgcolor="#EEEEEE" class="boutique-text">\n';
  s += '<td align="right">Inscription à la newsletter Volodalen (gratuit)&nbsp;</td>\n';
  if (Client.newsletter == 'Oui') {
	s += '<td><input type="checkbox" name="newsletter" class="form_checkbox" checked="CHECKED"></td>\n';
  } else {
    s += '<td><input type="checkbox" name="newsletter" class="form_checkbox"></td>\n';
  }
  s += '</tr>\n';

  return s;
}

function processOrderStep2(form) {
  for (var i=0; i<form.qualite.length; i++) {
    if (form.qualite[i].checked) {Client.qualite = form.qualite[i].value;}
  }
  Client.nomclient = form.nomclient.value;
  Client.prenom = form.prenom.value;
  Client.connuvolodalen = form.connuvolodalen.value;
  Client.adresse = form.adresse.value;
  Client.codepostal = form.codepostal.value;
  Client.ville = form.ville.value;
  Client.pays = form.pays.value;
  Client.societe = form.societe.value;
  Client.tvaeurope = form.tvaeurope.value;
  Client.telephone = form.telephone.value;
  Client.mobile = form.mobile.value;
  Client.email = form.email.value;
  if (form.newsletter.checked == true) {
    Client.newsletter = 'Oui';
  } else {
    Client.newsletter = 'Non';
  }
  window.main_frame.location = 'order3.htm';
}

function valeursForm() {
var s = new String("");
var sref=new String("");
var sdes=new String("");  
var versand = StringToFloat(Client.livraisoncout);
var subtotal = 0;
var total = 0;
var plan = false;
	for (var i=0; i<vatitems.length; i++) {vatitems[i].vtotal = 0}
	for (var i=0; i<items.length; i++) {
		if (items[i].qty > 0) {
			if (i>0) {
				sref += '+';
				sdes += '+';
			}
			sref += items[i].qty + 'x' + items[i].artnr;
			sdes += items[i].qty + 'xRef.' + items[i].artnr;
			subtotal = items[i].qty * items[i].price;
			if (items[i].artnr.charAt(0) == '2') {
			plan = true;
			}
			if (items[i].uid > 0) {
				for (var j=0; j<vatitems.length; j++) {
					if (vatitems[j].vid == items[i].uid) {
					vatitems[j].vtotal += subtotal - (subtotal / (1+(vatitems[j].vvalue / 100)));
					}
				}  
			}
			total += subtotal;
		}
	}
/*	
	if (calculnombrelivres() > 1) {
		total -= 9;
	}
*/	
	var eurototal = (total + versand) / eurokurs;
	if (versand>0) { 
		sref += '+Port';
		sdes += '+Port';
	}
	var stotal = convdec(eurototal);
	s += '<input type="hidden" name="QUA" value="' + Client.qualite + '">'; 
	s += '<input type="hidden" name="PRE" value="' + Client.prenom + '">';    
	s += '<input type="hidden" name="NOM" value="' + Client.nomclient + '">';
	s += '<input type="hidden" name="ADR" value="' + Client.adresse + '">';
	s += '<input type="hidden" name="CPO" value="' + Client.codepostal + '">';
	s += '<input type="hidden" name="VIL" value="' + Client.ville + '">';
	s += '<input type="hidden" name="PAY" value="' + Client.pays + '">';
	s += '<input type="hidden" name="SOC" value="' + Client.societe + '">';
	s += '<input type="hidden" name="TVA" value="' + Client.tvaeurope + '">';
	s += '<input type="hidden" name="TEL" value="' + Client.telephone + '">';
	s += '<input type="hidden" name="MOB" value="' + Client.mobile + '">';
	s += '<input type="hidden" name="MAI" value="' + Client.email + '">';
	s += '<input type="hidden" name="CON" value="' + Client.connuvolodalen + '">';
	s += '<input type="hidden" name="NEW" value="' + Client.newsletter + '">';
	if (plan == true) {
		s += '<input type="hidden" name="PLA" value="O">';
	} else {
		s += '<input type="hidden" name="PLA" value="N">';
	}
	s += '<input type="hidden" name="DES" value="' + sdes + '">';  
	s += '<input type="hidden" name="REF" value="' + sref + '">';
	//  s+='<input type="hidden" name="TOT" value="'+stotal.replace(".","")+'">';
	s += '<input type="hidden" name="TOT" value="' + remplacecar(stotal,".","") + '">';
	s += '<input type="hidden" name="POR" value="' + versand + '">';
	return s;
}

function remplacecar(str,s1,s2) {
  var s = new String("");
  var i;
  var l;
  var c;
  l = str.length
  if (l > 0) {
    for (var i=0; i<l; ++i) {
	  c = str.charAt(i);
	  if (c == s1) {
	    s += s2;
      } else {
	  	s += c;
	  }	
    }
  } 
  return s;
}

function showCustomerData() {
  var s = new String("");
  
  s += '<table width="100%" border="0" cellspacing="1" cellpadding="1" class="boutique-articles" valign="center" bgcolor="#F0F0F0">';
  
  s += '<tr height="18">';
  s += '<td align="right">Nom&nbsp;</td>';
  s += '<td align="left"><b>&nbsp;' + Client.qualite + '&nbsp;' + Client.prenom + '&nbsp;' + Client.nomclient + '</b></td>';
  s += '</tr>';
 
  s += '<tr height="18">';
  s += '<td align="right">Adresse&nbsp;</td>';
  s += '<td align="left"><b>&nbsp;' + Client.adresse + '</b></td>';
  s += '</tr>';
  
  s += '<tr height="18">';
  s += '<td align="right">&nbsp;</td>';
  s += '<td align="left"><b>&nbsp;' + Client.codepostal + '&nbsp;' + Client.ville + ', ' + Client.pays + '</b></td>';
  s += '</tr>';

  if (Client.telephone != '') {
	s += '<tr height="18">';
    s += '<td align="right">Téléphone&nbsp;</td>';
    s += '<td align="left"><b>&nbsp;' + Client.telephone + '</b></td>';
    s += '</tr>';
  }

  if (Client.mobile != '') {
	s += '<tr height="18">';
    s += '<td align="right">Mobile&nbsp;</td>';
    s += '<td align="left"><b>&nbsp;' + Client.mobile + '</b></td>';
    s += '</tr>';
  }
  
  if (Client.societe != '') {
	s += '<tr height="18">';
    s += '<td align="right">Société&nbsp;</td>';
    s += '<td align="left"><b>&nbsp;' + Client.societe + '</b></td>';
    s += '</tr>';
  }

  if (Client.tvaeurope != '') {
	s += '<tr height="18">';
    s += '<td align="right">TVA intracommunautaire&nbsp;</td>';
    s += '<td align="left"><b>&nbsp;' + Client.tvaeurope + '</b></td>';
    s += '</tr>';
  }

  s += '<tr height="18">';
  s += '<td align="right">E-mail&nbsp;</td>';
  s += '<td align="left"><b>&nbsp;' + Client.email + '</b></td>';
  s += '</tr>';

  s += '<tr height="18">';
  s += '<td align="right">Abonnement à la Newsletter&nbsp;</td>';
  s += '<td align="left"><b>&nbsp;' + Client.newsletter + '</b></td>';
  s += '</tr>';  

  s += '<tr height="18">';
  s += '<td align="right">Expédition&nbsp;</td>';
  s += '<td align="left"><b>&nbsp;' + Client.shiptext + '</b></td>';
  s += '</tr>';

  s += '</table>';  
  return s;
}

function stringf(str,width,align) {
  var s = new String("");
  var i = width - str.length;
  if (i > 0) {
    for (var j=0; j<i; ++j) {
      s += " ";
    }
  } else {
    str = str.substring(0, width);
  }  
  if (align == "left") s = str + s
  else s += str;
  return s;
}

function convertMessage(msg) {
  var s = new String("");
  var startpos = 0;
  var i = msg.indexOf('#',startpos);
  while (i != -1) {
    s += msg.substring(startpos,i) + '\n';
    startpos = i + 1;
    i = msg.indexOf('#',startpos);
  }
  s += msg.substring(startpos,msg.length);
  return s;
}

function convertLF(msg) {
  var s = new String("");
  var startpos = 0;
  var i = msg.indexOf('\n',startpos);
  while (i != -1) {
    s += msg.substring(startpos,i) + '#';
    startpos = i + 1;
    i = msg.indexOf('\n',startpos);
  }
  s += msg.substring(startpos,msg.length);
  return s;
}

function printImprimer() {
  var s = new String("");
	s += '<form name="form3" method="post">\n';
	s += '<input class="form_bouton" type="button" value="Imprimer la commande" onClick="print()">\n';	
	s += '</form>\n';
  return s;
}

function printOrderButton() {
var s = new String("");
	s += '<table width="620" border="0" cellspacing="0" cellpadding="0">\n';
	s += '<tr>';
	s += '<form name="form2" method="post">\n';
	
	s += '<td align="left"><input class="form_bouton" type="button" value="Retourner dans la boutique" onclick="self.location=\'home.htm\';"></td>\n';
	s += '<td align="right"><input class="form_bouton" type="button" value="Poursuivre la commande" onclick="self.location=\'order1.htm\';"></td>\n';
	
	s += '</form>\n';
	s += '</tr>';
	s += '</table>\n';
	return s;          
}

function formArticle (artnr, name, price, imageproduit, poids, uid2, poids2, quantite) {
var s = new String("");
	s += '<input type="HIDDEN" name="artnr" value="' + artnr + '">\n';
	s += '<input type="HIDDEN" name="name" value="' + name + '">\n';
	s += '<input type="HIDDEN" name="price" value="' + price + '">\n';
	s += '<input type="HIDDEN" name="image1" value="' + imageproduit + '">\n';
	s += '<input type="HIDDEN" name="poids" value="' + poids + '">\n';
	s += '<input type="HIDDEN" name="uid2" value="' + uid2 + '">\n';
	s += '<input type="HIDDEN" name="poids2" value="' + poids2 + '">\n';

	if (quantite == 1) {
		s += '<input type="HIDDEN" name="quantity" value="1">\n';
	} else {
		s += '<span class="text-produitliste">Quantit&eacute;\n';
		s += '<select name="quantity" class="form_inputpetit">\n';
		s += '<option value="1">1</option>\n';
		s += '<option value="2">2</option>\n';
		s += '<option value="3">3</option>\n';
		s += '<option value="4">4</option>\n';
		s += '<option value="5">5</option>\n';
		s += '<option value="6">6</option>\n';
		s += '<option value="7">7</option>\n';
		s += '<option value="8">8</option>\n';
		s += '<option value="9">9</option>\n';
		s += '<option value="10">10</option>\n';
		s += '</select>\n';
		s += '</span>\n';
	}
return s;
}


// the following codeline must be the last one !!!
isBasketLoaded = true;

