function loadcalc(lang)
{
  //alert("Lang is " + lang);
  if (lang==null || lang=="")
    lang='FR';
  init_libelles(lang);
  init_messages(lang);
  //  initprices();
  initarray();
  window.status = local_messages['Bdc'];
}

function init_libelles(lang)
{
  libelle_commande = new Array();
  libelle_paiement = new Array();
  libelle_enc = new Array();
  if (lang=='GB')
  {
    libelle_commande['v1'] = 'ScanNav software';
    libelle_commande['v2'] = 'GRIB Module';
    libelle_commande['v3'] = 'Tidal Currents module';
    libelle_commande['ais'] = 'AIS module';
    libelle_commande['v4'] = 'Box supplement';
    libelle_commande['dongle'] = 'Dongle+CD';
    libelle_commande['maj'] = 'Update';
    libelle_commande['evolog'] = 'Evolog';

    libelle_commande['CDFR03'] = 'Charts CD-Rom CDFR03';
    libelle_commande['CDFR04'] = 'Charts CD-Rom CDFR04';
    libelle_commande['CDFR05'] = 'Charts CD-Rom CDFR05';
    libelle_commande['CDFR06'] = 'Charts CD-Rom CDFR06';
    libelle_commande['CDFR09'] = 'Charts CD-Rom CDFR09';
    libelle_commande['v5'] = 'Charts CD-Rom BACD23';
    libelle_commande['v6'] = 'Charts CD-Rom BACD22';
    libelle_commande['v7'] = 'Charts CD-Rom BACD21';
    libelle_commande['v8'] = 'Charts CD-Rom BACD24';
    libelle_commande['v9'] = 'Charts CD-Rom SHOM01';
    libelle_commande['v10'] = 'Charts CD-Rom SHOM02';
    libelle_commande['v11'] = 'Charts CD-Rom MED01';
    libelle_commande['v12'] = 'Charts CD-Rom MED02';
    libelle_commande['v13'] = 'Charts CD-Rom MED03';
    libelle_commande['v14'] = 'Charts CD-Rom MED04';
    libelle_commande['v15'] = 'Charts CD-Rom MED05';
    libelle_commande['v16'] = 'Charts CD-Rom MED06';
    libelle_commande['v17'] = 'Charts CD-Rom MED07';
    libelle_commande['v18'] = 'Charts CD-Rom MED08';
    libelle_commande['v19'] = 'Charts CD-Rom MED09';
    libelle_commande['v20'] = 'Charts CD-Rom MED10';
    
    libelle_commande['v21'] = 'Atlas UJA-557';
    libelle_commande['v22'] = 'Atlas UJA-558';
    libelle_commande['v23'] = 'Atlas UJA-559';
    libelle_commande['v24'] = 'Atlas UJA-560';
    libelle_commande['v25'] = 'Atlas UJA-561';
    libelle_commande['v26'] = 'Atlas UJA-562';
    libelle_commande['v27'] = 'Atlas UJA-563';
    libelle_commande['v28'] = 'Atlas UJA-564';
    libelle_commande['v29'] = 'Atlas UJA-565';
    
    libelle_paiement[0] = 'Invalid';
    libelle_paiement[1] = 'PayPal';
    libelle_paiement[2] = 'Check';
  }
  else
  {
    libelle_commande['v1'] = 'Module de Base';
    libelle_commande['v2'] = 'Module GRIB';
    libelle_commande['v3'] = 'Module Courants de marées';
    libelle_commande['ais'] = 'Module AIS';
    libelle_commande['v4'] = 'Supplément boite';
    libelle_commande['dongle'] = 'Dongle+CD';
    libelle_commande['maj'] = 'MAJ';
    libelle_commande['evolog'] = 'Evolog';

    libelle_commande['CDFR03'] = 'CD-Rom Cartes CDFR03';
    libelle_commande['CDFR04'] = 'CD-Rom Cartes CDFR04';
    libelle_commande['CDFR05'] = 'CD-Rom Cartes CDFR05';
    libelle_commande['CDFR06'] = 'CD-Rom Cartes CDFR06';
    libelle_commande['CDFR09'] = 'CD-Rom Cartes CDFR09';
    libelle_commande['v5'] = 'CD-Rom Cartes BACD23';
    libelle_commande['v6'] = 'CD-Rom Cartes BACD22';
    libelle_commande['v7'] = 'CD-Rom Cartes BACD21';
    libelle_commande['v8'] = 'CD-Rom Cartes BACD24';
    libelle_commande['v9'] = 'CD-Rom Cartes SHOM01';
    libelle_commande['v10'] = 'CD-Rom Cartes SHOM02';
    libelle_commande['v11'] = 'CD-Rom Cartes MED01';
    libelle_commande['v12'] = 'CD-Rom Cartes MED02';
    libelle_commande['v13'] = 'CD-Rom Cartes MED03';
    libelle_commande['v14'] = 'CD-Rom Cartes MED04';
    libelle_commande['v15'] = 'CD-Rom Cartes MED05';
    libelle_commande['v16'] = 'CD-Rom Cartes MED06';
    libelle_commande['v17'] = 'CD-Rom Cartes MED07';
    libelle_commande['v18'] = 'CD-Rom Cartes MED08';
    libelle_commande['v19'] = 'CD-Rom Cartes MED09';
    libelle_commande['v20'] = 'CD-Rom Cartes MED10';
    
    libelle_commande['v21'] = 'Atlas UJA-557';
    libelle_commande['v22'] = 'Atlas UJA-558';
    libelle_commande['v23'] = 'Atlas UJA-559';
    libelle_commande['v24'] = 'Atlas UJA-560';
    libelle_commande['v25'] = 'Atlas UJA-561';
    libelle_commande['v26'] = 'Atlas UJA-562';
    libelle_commande['v27'] = 'Atlas UJA-563';
    libelle_commande['v28'] = 'Atlas UJA-564';
    libelle_commande['v29'] = 'Atlas UJA-565';
    
    libelle_paiement[0] = 'Invalide';
    libelle_paiement[1] = 'PayPal';
    libelle_paiement[2] = 'Chèque';
  }
  libelle_commande['DVDRWE'] = 'DVDRWE Western Europe';
  libelle_commande['DVDRMED'] = 'DVDRMED Mediterranean sea';
  libelle_commande['DVDRUK'] = 'DVDRUK Unites Kingdom &amp; Ireland';
  libelle_commande['CDCYCSET'] = 'CDCYCSET Caribbean: USVI to Genada';
  libelle_commande['CDBA300'] = 'CDBA300 Caribbean Super Region';
  libelle_commande['CDCYC02'] = 'CDCYC02 Leeward Islands: Angilla to Antigua';
  libelle_commande['DVDRCAMEX'] = 'DVDRCAMEX Mexique et Am&eacute;rique Centrale';
  libelle_commande['DVDRBRAZIL'] = 'DVDRBRAZIL Brazil';
  libelle_commande['CDFR07'] = 'CDFR07 New Caledonia';
  libelle_commande['CDFR08'] = 'CDFR08 French Polynesia';
  libelle_commande['CDZA01'] = 'CDZA01 Angola to Cape Town';
  libelle_commande['CDZA02'] = 'CDZA02 Cap Town to Mozambique';
  
  libelle_commande['NV_MULTICARD'] = "NV_MULTICARD";
	 
  libelle_enc["ENC01"]="Zone 1: Nord de la France - Manche - De Dunkerque &agrave; Caen";
  libelle_enc["ENC02"]="Zone 2: Manche : Caen - Cherbourg - &icirc;les Anglo-Normandes - St Malo";
  libelle_enc["ENC03"]="Zone 3: Bretagne : Roscoff - Brest - Concarneau - G&eacute;n&eacute;rales sud-ouest Angleterre";
  libelle_enc["ENC04"]="Zone 4: Bretagne sud : Lorient - Nantes - Sables d'Olonnes";
  libelle_enc["ENC05"]="Zone 5: Vend&eacute;e Aquitaine Nord-Est Espagne : La Rochelle - Bordeaux - Bilbao";
  libelle_enc["ENC06"]="Zone 6: Sud France : Port Vendres - Marseille - Toulon";
  libelle_enc["ENC07"]="Zone 7: C&ocirc;te d'Azur - Ligure : Toulon - Nice - G&egrave;nes - Lavagna";
  libelle_enc["ENC08"]="Zone 8: Corse - Nord-Est Sardaigne : Bouches de Bonifaccio - Porto Rotondo";
  libelle_enc["ENC09"]="Zone 9: Sardaigne : sans le Nord-Est";
  libelle_enc["ENC10"]="Zone 10: Italie : La Spezia - Livourne - &icirc;le d'Elbe - &icirc;le Giglio - Porto Ercole";
  libelle_enc["ENC11"]="Zone 11: Italie : Civitavecchia - Fiumicino - &icirc;le de Ponza - &icirc;le d'Ischia";
  libelle_enc["ENC12"]="Zone 12: Italie : Naples - Reggio di Calabria";
  libelle_enc["ENC13"]="Zone 13: Sicile Nord et Ouest : Milazzo - &icirc;les Eoliennes - Palerme - Trapani -  Sciacca";
  libelle_enc["ENC14"]="Zone 14: Sicile Sud et Est  et Malte : Porto Empedocle - Licata - Siracusa - Catania - Gozo - Malte";
  libelle_enc["ENC15"]="Zone 15: Espagne Catalogne Bal&eacute;ares : Cap Creux - Barcelone - Castellon de la Plana - Ibiza - Mallorca - Menorca";
  libelle_enc["ENC16"]="Zone 16: Espagne M&eacute;diterran&eacute;e : Valencia - Alicante - Alm&eacute;ria - Motril";
  libelle_enc["ENC17"]="Zone 17: Espagne Gibraltar : Malaga - Gibraltar - Algeciras -  Ceuta - Tarifa - Cap Sao Vicente";
  libelle_enc["ENC18"]="Zone 18: Portugal : Sines - Lisbonne - Aveiro";
  libelle_enc["ENC19"]="Zone 19: Portugal Nord et Nord Espagne : Porto - Vigo - Cap Finist&egrave;re - La Corogne - Santander";

}

function init_messages(lang)
{
  local_messages = new Array();
  if (lang=='GB')
  {
    local_messages['Bdc'] = 'ScanNav order sheet';
    local_messages['port'] = ' + Transportation fee';
    local_messages['nomincorrect'] = "  - The \"Last Name\" field must be filled\n"; 
    local_messages['emailincorrect'] = "  - The \"Email\" field must be filled\n";
    local_messages['paiementincorrect'] = "  - You must choose a payment facility\n"; 
    local_messages['commandevide'] = "  - Your order is Empty\n"; 
    local_messages['inconnu'] = "Unknown" ;
    local_messages['mauvaisecommande'] = "Your order has not been taken in account as it misses the following fields:\n";
  }
  else
  {
    local_messages['Bdc'] = 'Bon de commande ScanNav';
    local_messages['port'] = ' + Port';
    local_messages['nomincorrect'] = "  - Le champ \"Nom\" doit être renseigné\n"; 
    local_messages['emailincorrect'] = "  - Le champ \"E.mail\" doit être renseigné\n"; 
    local_messages['paiementincorrect'] = "  - Vous devez choisir un mode de paiement\n"; 
    local_messages['commandevide'] = "  - Votre commande est vide\n"; 
    local_messages['inconnu'] = "inconnu" ;
    local_messages['mauvaisecommande'] = "Votre commande n'a pas été prise en compte, car elle comporte les erreurs suivantes:\n";
  }
}
function initprices_old()
{
  prices = new Array();
  prices['void'] = 0;
  prices['NWE-BACD01'] = 119;
  prices['NWE-BACD02'] = 119;
  prices['NWE-BACD03'] = 119;
  prices['NWE-BACD04'] = 119;
  prices['NWE-BACD05'] = 119;
  prices['NWE-BACD06'] = 119;
  prices['NWE-BACD11'] = 119;
  prices['NWE-BACD12'] = 119;
  prices['NWE-BACD13'] = 119;
  prices['NWE-BACD14'] = 119;
  prices['NWE-BACD15'] = 119;
  prices['NWE-BACD16'] = 119;
  prices['NWE-BACD17'] = 119;
  prices['NWE-BACD18'] = 119;
  prices['NWE-BACD19'] = 119;

  prices['PAC-CDFR7'] = 399;
  prices['PAC-CDFR8'] = 399;
  prices['PAC-CP77'] = 149;
  prices['PAC-NZCD701'] = 79;
  prices['PAC-NZCD702'] = 96;
  prices['PAC-NZCD703'] = 79;
  prices['PAC-NZCD704'] = 79;
  prices['PAC-NZCD705'] = 96;
  prices['PAC-NZCD706'] = 96;
  prices['PAC-NZCD78'] = 149;
  prices['PAC-NZCD79'] = 149;

// CDs Nauticard
  prices['CDNI-EF'] = 139;
  prices['CDNI-01'] = 129;
  prices['CDNI-02'] = 139;
  prices['CDNI-01-B1'] = 139;
  prices['CDNI-01-B2'] = 129;
  prices['CDNI-03'] = 139;
  prices['CDNI-01-C'] = 139;
  prices['CDNI-SET'] = 650;
  prices['CDNI-MP'] = 129;


  // MED03
  prices['v13'] = 119;

  // Nouveaux CDs  
  prices['DVDRWE'] = 169;
  prices['DVDRMED'] = 169;
  prices['DVDRUK'] = 169;
  prices['CDCYCSET'] = 169;
  prices['CDBA300'] = 229;
  prices['CDCYC02'] = 99;
  prices['DVDRCAMEX'] = 169;
  prices['CDFR07'] = 399;
  prices['CDFR08'] = 399;
  prices['CDZA01'] = 129;
  prices['CDZA02'] = 129;

  // Packs ENCs
  prices['ENCPACK'] = 140;
  showchoiceprice();
  
  // Zones Navionics
  prices['NV_MULTICARD'] = 60;
  prices['EU_GOLDXL9'] = 238;
  prices['RU_GOLDXL9'] = 478;
  prices['SA_GOLDXL9'] = 238;
  prices['NA_GOLDXL9'] = 238;
  prices['AF_GOLDXL9'] = 238;
  prices['AS_GOLDXL9'] = 238;
  prices['EU_PLATXL3'] = 358;
  prices['SA_3D_XL3'] = 358;
  prices['NA_PLATXL3'] = 358;
  prices['AF_PLATXL3'] = 358;
  prices['OC_PLATXL3'] = 358;
  prices['EU_PLAT+XL3'] = 358;
  prices['NA_PLAT+XL3'] = 298;
  prices['FR_SMALL2'] = 155;
  prices['UK_SMALL2'] = 155;
  prices['SP_SMALL2'] = 155;
  prices['CM_SMALL2'] = 155;
  prices['EM_SMALL2'] = 155;
  prices['NW_SMALL2'] = 155;
  prices['BE_SMALL2'] = 155;
  // Exceptions Navionics
  prices['2XG'] = 298;
  prices['37XG'] = 478;
  prices['38XG'] = 478;
  prices['39XG'] = 478;
  prices['40XG'] = 478;
}

function encentry(ref)
{
  document.write ('<tr><td> <div align="center">'+ref+'</div></td>');
  document.write ('<td>'+libelle_enc[ref]+'</td>');
  document.write ('<td><div align="right">140</div></td>');
  document.write ('<td><input type="checkbox" name="'+ref+'" border="0" onClick="count()"></td><tr>');
}
function maptechentry(ref)
{
      document.write ('<td>'+libelle_commande[ref]+'</td>');
      document.write ('<td><div align="right">'+prices[ref]+'</div></td>');
      document.write ('<td><input type="checkbox" name="'+ref+'" border="0" onClick="count()"></td>');
}
function othermaptechchoices()
{
  document.write ('<option value="void">--- selectionnez une r&eacute;f&eacute;rence ---</option>');
}
function othermaptechchoices2()
{
  document.write ('<option value="void">--- selectionnez une r&eacute;f&eacute;rence ---</option>');
  document.write ('<option value="NWE-BACD01">NW Europe - BACD01</option>');
  document.write ('<option value="NWE-BACD02">NW Europe - BACD02</option>');
  document.write ('<option value="NWE-BACD03">NW Europe - BACD03</option>');
  document.write ('<option value="NWE-BACD04">NW Europe - BACD04</option>');
  document.write ('<option value="NWE-BACD05">NW Europe - BACD05</option>');
  document.write ('<option value="NWE-BACD06">NW Europe - BACD06</option>');
  document.write ('<option value="NWE-BACD11">NW Europe - BACD11</option>');
  document.write ('<option value="NWE-BACD12">NW Europe - BACD12</option>');
  document.write ('<option value="NWE-BACD13">NW Europe - BACD13</option>');
  document.write ('<option value="NWE-BACD14">NW Europe - BACD14</option>');
  document.write ('<option value="NWE-BACD15">NW Europe - BACD15</option>');
  document.write ('<option value="NWE-BACD16">NW Europe - BACD16</option>');
  document.write ('<option value="NWE-BACD17">NW Europe - BACD17</option>');
  document.write ('<option value="NWE-BACD18">NW Europe - BACD18</option>');
  document.write ('<option value="NWE-BACD19">NW Europe - BACD19</option>');
  document.write ('<option value="CDNI-EF">Nauticard - CDNI-EF</option>');
  document.write ('<option value="CDNI-01">Nauticard - CDNI-01</option>');
  document.write ('<option value="CDNI-02">Nauticard - CDNI-02</option>');
  document.write ('<option value="CDNI-01-B1">Nauticard - CDNI-01-B1</option>');
  document.write ('<option value="CDNI-01-B2">Nauticard - CDNI-01-B2</option>');
  document.write ('<option value="CDNI-03">Nauticard - CDNI-03</option>');
  document.write ('<option value="CDNI-01-C">Nauticard - CDNI-01-C</option>');
  document.write ('<option value="CDNI-SET">Nauticard - CDNI-SET</option>');
  document.write ('<option value="CDNI-MP">Nauticard - CDNI-MP</option>');
  document.write ('<option value="PAC-CDFR7">Pacifique - CDFR7</option>');
  document.write ('<option value="PAC-CDFR8">Pacifique - CDFR8</option>');
  document.write ('<option value="PAC-CP77">Pacifique - CP77</option>');
  document.write ('<option value="PAC-NZCD701">Pacifique - NZCD701</option>');
  document.write ('<option value="PAC-NZCD702">Pacifique - NZCD702</option>');
  document.write ('<option value="PAC-NZCD703">Pacifique - NZCD703</option>');
  document.write ('<option value="PAC-NZCD704">Pacifique - NZCD704</option>');
  document.write ('<option value="PAC-NZCD705">Pacifique - NZCD705</option>');
  document.write ('<option value="PAC-NZCD706">Pacifique - NZCD706</option>');
  document.write ('<option value="PAC-NZCD78">Pacifique - NZCD78</option>');
  document.write ('<option value="PAC-NZCD79">Pacifique - NZCD79</option>');
}
var nmt_chkvar = new Array();
function InitNewMaptechChoices()
{
  nmt_chkvar['DVDRWE'] = document.calc.DVDRWE;
  nmt_chkvar['DVDRMED'] = document.calc.DVDRMED;
  nmt_chkvar['DVDRUK'] = document.calc.DVDRUK;
  nmt_chkvar['CDCYCSET'] = document.calc.CDCYCSET;
  nmt_chkvar['CDBA300'] = document.calc.CDBA300;
  nmt_chkvar['CDCYC02'] = document.calc.CDCYC02;
  nmt_chkvar['DVDRCAMEX'] = document.calc.DVDRCAMEX;
  nmt_chkvar['CDFR07'] = document.calc.CDFR07;
  nmt_chkvar['CDFR08'] = document.calc.CDFR08;
  nmt_chkvar['CDZA01'] = document.calc.CDZA01;
  nmt_chkvar['CDZA02'] = document.calc.CDZA02;
}
var enc_chkvar = new Array();
function InitENCChoices()
{
  enc_chkvar['ENC01'] = document.calc.ENC01;
  enc_chkvar['ENC02'] = document.calc.ENC02;
  enc_chkvar['ENC03'] = document.calc.ENC03;
  enc_chkvar['ENC04'] = document.calc.ENC04;
  enc_chkvar['ENC05'] = document.calc.ENC05;
  enc_chkvar['ENC06'] = document.calc.ENC06;
  enc_chkvar['ENC07'] = document.calc.ENC07;
  enc_chkvar['ENC08'] = document.calc.ENC08;
  enc_chkvar['ENC09'] = document.calc.ENC09;
  enc_chkvar['ENC10'] = document.calc.ENC10;
  enc_chkvar['ENC11'] = document.calc.ENC11;
  enc_chkvar['ENC12'] = document.calc.ENC12;
  enc_chkvar['ENC13'] = document.calc.ENC13;
  enc_chkvar['ENC14'] = document.calc.ENC14;
  enc_chkvar['ENC15'] = document.calc.ENC15;
  enc_chkvar['ENC16'] = document.calc.ENC16;
  enc_chkvar['ENC17'] = document.calc.ENC17;
  enc_chkvar['ENC18'] = document.calc.ENC18;
  enc_chkvar['ENC19'] = document.calc.ENC19;
}


function showchoiceprice()
{
  try
  {
    document.calc.punit1.value = prices[document.calc.select1.value];
    document.calc.punit2.value = prices[document.calc.select2.value];
    document.calc.punit3.value = prices[document.calc.select3.value];
    document.calc.punit4.value = prices[document.calc.select4.value];
  }
  catch(err)
  {
  }
}

var choices_punit = new Array();
var choices_chkvar = new Array();
var choices_sel = new Array();
function initarray()
{
  try
  {
    choices_punit[1] = document.calc.punit1;
    choices_chkvar[1] = document.calc.chkvar1;
    choices_sel[1] = document.calc.select1;
    choices_punit[2] = document.calc.punit2;
    choices_chkvar[2] = document.calc.chkvar2;
    choices_sel[2] = document.calc.select2;
    choices_punit[3] = document.calc.punit3;
    choices_chkvar[3] = document.calc.chkvar3;
    choices_sel[3] = document.calc.select3;
    choices_punit[4] = document.calc.punit4;
    choices_chkvar[4] = document.calc.chkvar4;
    choices_sel[4] = document.calc.select4;
  }
  catch(err)
  {
  }
}

function changechoice(i)
{
  if (prices[choices_sel[i].value] != 0) {
    choices_chkvar[i].checked = true;
  } else {
    choices_chkvar[i].checked = false;
  }
  showchoiceprice();
  count();
}

function oncheck_boite()
{
  try
  {
    if (document.calc.v4.checked) {
      document.calc.dongle.checked = false;
      document.calc.dongle2.checked = false;
    }
  }
  catch(err)
  {
  }
  count();
}
function oncheck_dongle()
{
  try
  {
    if (document.calc.dongle.checked) {
      document.calc.dongle2.checked = false;
      document.calc.v4.checked = false;
    }
  }
  catch(err)
  {
  }
  count();
}
function oncheck_dongle2()
{
  if (document.calc.dongle2.checked) {
    document.calc.dongle.checked = false;
    document.calc.v4.checked = false;
  }
  count();
}
function oncheck_evolog()
{
  if (document.calc.evolog.checked) {
    document.calc.maj1.checked = false;
    document.calc.maj2.checked = false;
  }
  count();
}
function oncheck_maj1()
{
  if (document.calc.maj1.checked) {
    document.calc.maj2.checked = false;
    document.calc.evolog.checked = false;
  }
  count();
}
function oncheck_maj2()
{
  if (document.calc.maj2.checked) {
    document.calc.maj1.checked = false;
    document.calc.evolog.checked = false;
  }
  count();
}

var ncds = 0;
var pp_pcabord=0;
function count()
{
//Modules
var prixbase = 120;//ScanNav
var prixgrib = 60;//Meteo
var prixcourants = 60;//Maree
var prixAIS = 60;//AIS
var totalmodules = 0;

var prixdongle = 45; // Dongle+Boite
var prixdongle2 = 80; // Mise à jour Dongle+Boite
var prixboite = 25;//Box
var totalboite = 0;

var prixmaj1 = 0; //30; // Mise à jour en même temps qu'un module
var prixmaj2 = 25; //60; // Mise à jour sans module supplémentaire
var prixevolog = 25; // Abonnement annuel
var totalmaj = 0;

// CD Maptech
//var ncds = 0;
ncds = 0;
var prixcd = 119;
var prixport = 8;
var totalport = 0;

//Zones maree
var natlas = 0;
var prixatlas = 40;
var portatlas = 0;

var commande = "";

 // calcul
 //scannav
 if (document.calc.v1.checked){
   totalmodules += prixbase;
   commande += libelle_commande['v1'] + ', ';
 }
 
 //Grib
 if (document.calc.v2.checked){
   totalmodules += prixgrib;
   commande += libelle_commande['v2'] + ', ';
 }
 
 //Maree
 if (document.calc.v3.checked) {
   totalmodules += prixcourants;
   commande += libelle_commande['v3'] + ', ';
 }

 //Module AIS
 if (document.calc.ais.checked) {
   totalmodules += prixAIS;
   commande += libelle_commande['ais'] + ', ';
 }
 
 //Dongle
 try
 {
   if (document.calc.dongle2.checked) {
     if (totalmodules != 0)
     {
       document.calc.dongle2.checked=false;
       document.calc.dongle.checked=true;
     }
   }
   if (document.calc.dongle.checked) {
     totalboite += prixdongle;
     commande += libelle_commande['dongle'] + ', ';
     document.calc.v4.checked = false;
   }
   else if (document.calc.dongle2.checked) {
     totalboite += prixdongle2;
     commande += libelle_commande['dongle'] + ', ';
     // le dongle au delà de 6 mois  inclu la mise à jour
     document.calc.maj1.checked = false;
     document.calc.maj2.checked = false;
     document.calc.evolog.checked = false;
     document.calc.v4.checked = false;
   }
 }
 catch(err)
 {
 }
 //Box
 if (document.calc.v4.checked) {
   totalboite += prixboite;
   commande += libelle_commande['v4'] + ', ';
 }
 
 try // Pour anciens cds non présent
 {
   // Anciens CDs Maptech
   if (document.calc.CDFR03.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['CDFR03'] + ', ';
   }
   
   if (document.calc.CDFR04.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['CDFR04'] + ', ';
   }
   if (document.calc.CDFR09.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['CDFR09'] + ', ';
   }
   if (document.calc.v5.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v5'] + ', ';
   }
   if (document.calc.v6.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v6'] + ', ';
   }
   if (document.calc.v7.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v7'] + ', ';
   }
   if (document.calc.v8.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v8'] + ', ';
   }
   if (document.calc.v9.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v9'] + ', ';
   }
   if (document.calc.v10.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v10'] + ', ';
   }
   if (document.calc.v11.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v11'] + ', ';
   }
   if (document.calc.v12.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v12'] + ', ';
   }
   // Prix special pour cd MED03
   // if (document.calc.v13.checked) {
   //   ncds = ncds+ 1;
   //   commande += libelle_commande['v13'] + ', ';
   // }
   if (document.calc.v14.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v14'] + ', ';
   }
   if (document.calc.v15.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v15'] + ', ';
   }
   if (document.calc.v16.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v16'] + ', ';
   }
   if (document.calc.v17.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v17'] + ', ';
   }
   if (document.calc.v18.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v18'] + ', ';
   }
   if (document.calc.v19.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v19'] + ', ';
   }
   if (document.calc.v20.checked) {
     ncds = ncds+ 1;
     commande += libelle_commande['v20'] + ', ';
   } 
 }
 catch(err)
 {
   //Handle errors here
 }
 var totalcd = ncds * prixcd; 

 //Zones de courants
 if (document.calc.v21.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v21'] + ', ';
 }
 if (document.calc.v22.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v22'] + ', ';
 }
 if (document.calc.v23.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v23'] + ', ';
 }
 if (document.calc.v24.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v24'] + ', ';
 }
 if (document.calc.v25.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v25'] + ', ';
 }
 if (document.calc.v26.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v26'] + ', ';
 }
 if (document.calc.v27.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v27'] + ', ';
 }
 if (document.calc.v28.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v28'] + ', ';
 }
 if (document.calc.v29.checked) {
   natlas = natlas+ 1;
   commande += libelle_commande['v29'] + ', ';
 }
 
 var totalatlas = natlas * prixatlas;

// Cds des listes à prix variables
/*
// Prix special pour cd MED03
 if (document.calc.v13.checked) {
   ncds = ncds+ 1;
   totalcd += prices['v13'];
   commande += libelle_commande['v13'] + ', ';
 }
*/

 try // Multicard reader
 {
   if (document.calc.vmulticard.checked) {
     ncds = ncds+ 1;
     totalcd += prices['NV_MULTICARD'];
     commande += libelle_commande['NV_MULTICARD'] + ', ';
   }
 }
 catch(err)
 {
   //Handle errors here
 }
 try // checkbox Navionics
 {
   if (document.calc.chkvar1.checked && (document.calc.punit1.value>0)) {
     ncds = ncds+ 1;
     totalcd += prices[document.calc.select1.value];
     commande += document.calc.select1.value + '('+ document.calc.selsup1.value +'), ';
   } 
   if (document.calc.chkvar2.checked && (document.calc.punit2.value>0)) {
     ncds = ncds+ 1;
     totalcd += prices[document.calc.select2.value];
     commande += document.calc.select2.value + '('+ document.calc.selsup2.value +'), ';
   } 
   if (document.calc.chkvar3.checked && (document.calc.punit3.value>0)) {
     ncds = ncds+ 1;
     totalcd += prices[document.calc.select3.value];
     commande += document.calc.select3.value + '('+ document.calc.selsup3.value +'), ';
   } 
   if (document.calc.chkvar4.checked && (document.calc.punit4.value>0)) {
     ncds = ncds+ 1;
     totalcd += prices[document.calc.select4.value];
     commande += document.calc.select4.value + '('+ document.calc.selsup4.value +'), ';
   } 
 }
 catch(err)
 {
   //Handle errors here
 }
 // Nouveaux CDs Maptech
 for (var i in nmt_chkvar) {
   if (nmt_chkvar[i].checked)
   {
     ncds = ncds+ 1;
     totalcd += prices[i];
     commande += i + ', ';
   }
 }
 // Packs ENC
 var totalenc = 0;
 for (var i in enc_chkvar) {
   if (enc_chkvar[i].checked)
   {
     totalenc += prices['ENCPACK'];
     commande += i + ', ';
   }
 }
 // Mises à jour
try
{
  if (document.calc.maj2.checked)
  {
    document.calc.maj1.checked=false;
    document.calc.evolog.checked=false;
    if (totalmodules != 0)
    {
      document.calc.maj1.checked=true;
      document.calc.maj2.checked=false;
    }  
  }
  if (document.calc.evolog.checked)
  {
    document.calc.maj1.checked=false;
    document.calc.maj2.checked=false;
    if (totalmodules != 0)
    {
      document.calc.maj1.checked=true;
      document.calc.evolog.checked=false;
    }  
  }
  if (document.calc.maj2.checked)
  {
    totalmaj = prixmaj2;
    commande += libelle_commande['maj'] + ', ';
  }
  else if (document.calc.maj1.checked)
  {
    totalmaj = prixmaj1;
    commande += libelle_commande['maj'] + ', ';
  }
  else if (document.calc.evolog.checked)
  {
    totalmaj = prixevolog;
    commande += libelle_commande['evolog'] + ', ';
  }
}
catch (err)
{
}

 //Port 
 if ((ncds != 0) | (totalboite != 0)) {
  totalport = prixport;
  commande += local_messages['port'];
 }
 document.calc.commande.value = commande;
 document.calc.port.value = totalport;
 document.calc.total.value = totalmodules + totalmaj + totalboite + totalcd + totalatlas + totalport + totalenc;
 document.calc.prix.value = document.calc.total.value;
 if ((totalcd+totalport) > (totalmodules + totalmaj + totalboite + totalatlas + totalenc))
 {
   pp_pcabord = 1;
 }
 else
 {
   pp_pcabord=0;
 }
}

function goPayPal()
{
  return;
}

function paypalurl()
{
  if (pp_pcabord>0)
    payto='gerard%40pelletier.com';
  else
    payto='lombard%2Dmarc%40wanadoo%2Efr';

  theURL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_ext-enter&redirect_cmd=_xclick&first_name=&last_name=&business=' + payto + '&amount='+document.calc.prix.value+'&currency_code=EUR&item_name='+document.calc.commande.value+'&item_number';
  return theURL;

}

function openPayPal()
{
  if (!IsValidForm())
    return;
  params = 'scrollbars=yes,resizable=yes';
//  theURL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_ext-enter&amp;redirect_cmd=_xclick&amp;first_name=&amp;last_name=&amp;business=lombard%2Dmarc%40wanadoo%2Efr&amp;amount='+document.calc.prix.value+'%2E00&amp;currency_code=EUR&amp;item_name='+document.calc.commande.value+'&amp;item_number';
  theURL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_ext-enter&redirect_cmd=_xclick&first_name=&last_name=&business=lombard%2Dmarc%40wanadoo%2Efr&amount='+document.calc.prix.value+'&currency_code=EUR&item_name='+document.calc.commande.value+'&item_number';
  theURL = paypalurl();
  winName = 'paypal';
  fenetre = window.open(theURL,winName,params);
  fenetre.focus();
  document.paypalalreadyopened = true;
  if (document.submitalreadyopened!=true)
  {
    //alert("openPaypal->SubmitForm()");
    SubmitForm();
  }
}

function IsValidForm()
{
  typepaiement=-1;
  count();
  msg = "";
  if (document.calc.nom.value == "")
  {
    msg += local_messages['nomincorrect'];
  }
  if (document.calc.email.value == "")
  {
    msg += local_messages['emailincorrect'];
  }
  for (var i=0; i< document.calc.Optionpaiement.length; i++)
  {
    if (document.calc.Optionpaiement[i].checked)
    {
      typepaiement=document.calc.Optionpaiement[i].value;
      break;
    }
  } 
  if (typepaiement == -1)
  {
    msg += local_messages['paiementincorrect'];
  }
  if (document.calc.total.value == 0)
  {
    msg += local_messages['commandevide'];
  }
  if (msg == "")
  {
    return true;
  }
  else
  {
    //msg += "commande = '" +  document.calc.commande.value + "'\n" ;
    alert(local_messages['mauvaisecommande']+msg);
    return false;
  }
}

function CheckAndSubmit()
{
 try
 {
  if (IsValidForm())
  {
    SubmitForm();
  }
 }
 catch (e)
 {
   alert("Erreur CheckAndSubmit()\n" + e);
 }
 return false; // pour pas que le submit soit appellé une 2eme fois
}
function SubmitForm()
{
 try
 {
  var date = new Date();
  document.calc.date.value = date;
  if (typepaiement == -1)
  {
    msg += local_messages['inconnu'];
  }
  else
  {
    document.calc.paiement.value = libelle_paiement[typepaiement];
  }
  /*
    msg += "nom = '" +  document.calc.nom.value + "'\n" ;
    msg += "email = '" +  document.calc.email.value + "'\n" ;
    msg += "commande = '" +  document.calc.commande.value + "'\n" ;
    if (typepaiement != -1)
    {
      msg += "OptionPaiement = '" +  typepaiement + ":" + libelle_paiement[typepaiement] + "'\n" ;
    }
    msg += "total = '" +  document.calc.total.value + "'\n" ;
    msg += "Date = '" +  document.calc.date.value + "'\n" ;
    alert("résultat ok\n" + msg );
  */
  document.submitalreadyopened=true;
  if (typepaiement==1 && document.paypalalreadyopened != true)
  {
    openPayPal();
  }
  document.calc.submit();
  //alert("retour submit ok\n" );
 }
 catch (e)
 {
   alert("Erreur SubmitForm()\n" + e);
 }
  return false; // pour pas que le submit soit appellé une 2eme fois  
}

//OBSOLETE Pour compatibilite au cas ou
function CheckValid()
{
  // alert("Coucou\n" );
  return CheckAndSubmit();
}
function OldCheckValid()
{
  count();
  msg = "";
  if (document.calc.nom.value == "")
  {
    msg += local_messages['nomincorrect'];
  }
  if (document.calc.email.value == "")
  {
    msg += local_messages['emailincorrect'];
  }
  var typepaiement=-1;
  for (var i=0; i< document.calc.Optionpaiement.length; i++)
  {
    if (document.calc.Optionpaiement[i].checked)
    {
      typepaiement=document.calc.Optionpaiement[i].value;
      break;
    }
  } 
  if (typepaiement == -1)
  {
    msg += local_messages['paiementincorrect'];
  }
  if (document.calc.total.value == 0)
  {
    msg += local_messages['commandevide'];
  }
  if (msg == "")
  {
    var date = new Date();
    document.calc.date.value = date;
    if (typepaiement == -1)
    {
      msg += local_messages['inconnu'];
    }
    else
    {
      document.calc.paiement.value = libelle_paiement[typepaiement];
    }
    /*
    msg += "nom = '" +  document.calc.nom.value + "'\n" ;
    msg += "email = '" +  document.calc.email.value + "'\n" ;
    msg += "commande = '" +  document.calc.commande.value + "'\n" ;
    if (typepaiement != -1)
    {
      msg += "OptionPaiement = '" +  typepaiement + ":" + libelle_paiement[typepaiement] + "'\n" ;
    }
    msg += "total = '" +  document.calc.total.value + "'\n" ;
    msg += "Date = '" +  document.calc.date.value + "'\n" ;
    alert("résultat ok\n" + msg );
    */
    document.submitalreadyopened=true;
    if (typepaiement==1 && document.paypalalreadyopened != true)
    {
	openPayPal();
    }
    document.calc.submit();
    //alert("retour submit ok\n" );
    return false; // pour pas que le submit soit appellé une 2eme fois
  }
  else
  {
    //msg += "commande = '" +  document.calc.commande.value + "'\n" ;
    alert(local_messages['mauvaisecommande']+msg);
    return false;
  }
}
