/********************************************************************/
/*  Les Méthodes de livraison                                       */
/********************************************************************/

function fCMethodeLivraisonDoNothing()
{
  return 0;
}

/********************************************************************/
/*                                                                  */
/*  La Classe                                                       */
/*                                                                  */
/********************************************************************/

function CMethodeLivraison(methode)
{
  this.methode=methode;
  
  // En Fonction de la Méthode de livraison, on "Route" les Méthode
  // vers celle chargées de gérer le cas

  switch(methode)
  {
    case 'F':                 // Par Fixe
      this.Fixe=null;
      
      this.GetSelection=fCMethodeLivraisonFixeGetSelection;
      this.Selectionner=fCMethodeLivraisonDoNothing;
      this.Ajouter=fCMethodeLivraisonFixeAjouter;
      break;

    case 'Z':                 // Par Zones
      this.zones=new Array();
      this.selected=-1;
      
      this.GetSelection=fCMethodeLivraisonZoneGetSelection;
      this.Selectionner=fCMethodeLivraisonZoneSelectionner;
      this.Ajouter=fCMethodeLivraisonZoneAjouter;
      break;

    case 'ZP':                 // Par Zones
      this.zones=new Array();
      this.selected=-1;
      
      this.GetSelection=fCMethodeLivraisonZonePoidsGetSelection;
      this.Selectionner=fCMethodeLivraisonZonePoidsSelectionner;
      this.Ajouter=fCMethodeLivraisonZonePoidsAjouter;
      break;


    case 'GP':                // Par Grilles de poids
      this.Grille=new Array();
    
      this.GetSelection=fCMethodeLivraisonGrilleGetSelection;
      this.Selectionner=fCMethodeLivraisonDoNothing;
      this.Ajouter=fCMethodeLivraisonGrilleAjouter;

      this.TrouverGrille=fCMethodeLivraisonGrilleTrouver;
      break;


    case 'ZGP':
      this.zones=new Array();
      this.selected=-1;

      this.GetSelection=fCMethodeLivraisonZonesGrillesGetSelection;
      this.AjouterZone=fCMethodeLivraisonZonesGrillesAjouterZone;
      this.AjouterGrille=fCMethodeLivraisonZonesGrillesAjouterGrille;
      this.Selectionner=fCMethodeLivraisonZoneSelectionner;

//      this.TrouverGrille=fCMethodeLivraisonZonesGrillesTrouver;
      break;
  }
  
  this.GetMontantHT=fCMethodeLivraisonTrouverMontantHT;
  this.GetMontantTTC=fCMethodeLivraisonTrouverMontantTTC;
  this.GetMontantTVA=fCMethodeLivraisonTrouverMontantTVA;
  this.GetMontantFranco=fCMethodeLivraisonTrouverMontantFranco;
//  this.GetPanier=fCMethodeLivraisonTrouverPanier;
  this.Debug=fCMethodeLivraisonDebug;
}

function fCMethodeLivraisonDebug()
{
  document.write('Methode de livraison : '+this.methode+'<BR>\n');
}

function fCMethodeLivraisonTrouverMontantHT()
{
  var S=this.GetSelection();
  if(S==null)
    return 0;
    
  C=GetPanier();
  if(C.GetMontantHT()>=S.franco)
    return 0;
  return S.GetMontantHT();
}

function fCMethodeLivraisonTrouverMontantTTC()
{
  var S=this.GetSelection();
  if(S==null)
    return 0;

  C=GetPanier();
  if(C.GetMontantHT()>=S.franco)
    return 0;
  return S.GetMontantTTC();
}

function fCMethodeLivraisonTrouverMontantTVA()
{
  var S=this.GetSelection();
  if(S==null)
    return 0;

  C=GetPanier();
  if(C.GetMontantHT()>=S.franco)
    return 0;
  return S.GetMontantTVA();
}

function fCMethodeLivraisonTrouverMontantFranco()
{
  var S=this.GetSelection();
  if(S==null)
    return 0;
  return S.GetMontantFranco();
}