window.addEvent('domready', function() {

  // ------------------------------------------------------------------------------------------------------------------------
  // Template de création des lignes pour la gestion des colis via l'édition de commandes

  Mooml.register('packageEntry', function(params) {
    div(
       {'class':'packageLine'}
      ,input({ type:'text' , value:params.number , 'class':'packageNumber', 'style':'width:200px' })
      
      //,input({ type:'button' , value:'Suppr.', 'class':'packageDelete', onmouseup:'this.getParent().destroy()' })
      
      ,div({ 'class':'ek-button ek-button-color ek-button-color-small ek-widget' , 'style':'margin-top:1px'},
         a({ 'class':'ek-button-link' , 'href':'javascript:void(0)' , 'onmouseup':'this.getParent().getParent().destroy()' },
            span({ 'class':'left'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
           ,span({ 'class':'center'}, 
              span({ 'style':"background: url("+wwwroot+"/media/system/img/icons/no-10px.png) 0px 0px no-repeat;height: 17px;float: left;margin-top:3px;padding-left: 12px;" }
              )
            )
           ,span({ 'class':'right'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
         )
      )      
    );
  });
  
  
  // ------------------------------------------------------------------------------------------------------------------------
  // Template de création des lignes pour la gestion des colis via l'édition de commandes

  Mooml.register('packageEntryNotEmpty', function(params) {
    div(
       {'class':'packageLine'}
      ,input({ type:'text' , value:params.number , 'class':'packageNumber', 'style':'width:200px' })
      
      //,input({ type:'button' , value:'Suppr.', 'class':'packageDelete', onmouseup:'this.getParent().destroy()' })
      
      ,div({ 'class':'ek-button ek-button-color ek-button-color-small ek-widget' , 'style':'margin-top:1px'},
         a({ 'class':'ek-button-link' , 'href':'javascript:void(0)' , 'onmouseup':'this.getParent().getParent().destroy()' },
            span({ 'class':'left'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
           ,span({ 'class':'center'},
              span({ 'style':"background: url("+wwwroot+"/media/system/img/icons/no-10px.png) 0px 0px no-repeat;height: 17px;float: left;margin-top:3px;padding-left: 14px;" }
              ),
              span('Supprimer ce numéro', {'style':'font-weight:bold; padding-left:15px;'}
              )
            )
           ,span({ 'class':'right'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
         )
      )
      
      //EX URL de la Poste : http://www.coliposte.net/gp/services/main.jsp?m=10003005&colispart=67890
      ,div({ 'class':'ek-button ek-button-color ek-button-color-small ek-widget' , 'style':'margin-top:1px; margin-left:5px;'},
         a({ 'class':'ek-button-link' , 'href':'http://www.coliposte.net/gp/services/main.jsp?m=10003005&colispart='+params.number, 'target':'_blank' },
            span({ 'class':'left'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
           ,span({ 'class':'center'}, 
              span({ 'style':"background: url("+wwwroot+"/media/system/img/icons/search-10px.png) 0px 0px no-repeat;height: 17px;float: left;margin-top:3px;padding-left: 12px;" }
              ),
              span('Vérifier ce numéro sur le site de la Poste', {'style':'padding-left:15px;'})
            )
           ,span({ 'class':'right'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
         )
      )   
    );
  });
  

  // ------------------------------------------------------------------------------------------------------------------------
  // Template de création des lignes pour l'association des zones / types d'envoi
  
  //<widget:textInput small="1" value="" id="mini-weight" name="mini-weight" style="width:70px; text-align:center;" />

  Mooml.register('shippingEntryWithDelete', function(params)  {
    tr(
      {'class':'shippingLine', 'style':'border:1px solid #ccc;'}
      ,td(
        input({ type:'text' , value:params.trid , 'class':'shippingNumber', 'style':'display:none;' })
      )
      ,td(
        span('Mini : ')
        ,input({ type:'text' , value:params.minweight , 'class':'shippingNumber ek-input-text-small', 'style':'width:50px' })
        ,span('&nbsp;&nbsp;gr.')
      )
      ,td(
        span('Maxi : ')
        ,input({ type:'text' , value:params.maxweight , 'class':'shippingNumber ek-input-text-small', 'style':'width:50px' })
        ,span('&nbsp;&nbsp;gr.')
      )
      ,td(
        span('Tarif : ')
        ,input({ type:'text' , value:params.tarif , 'class':'shippingNumber ek-input-text-small', 'style':'width:50px; text-align:right;' })
        ,span('&nbsp;&nbsp;&euro;')
      )
      ,td(
        span('D&eacute;lai : ')
        ,input({ type:'text' , value:params.delai , 'class':'shippingNumber ek-input-text-small', 'style':'width:30px; text-align:right;' })
        ,span('&nbsp;&nbsp;H')
      )
      ,td(      
        div({ 'class':'ek-button ek-button-color ek-button-color-small ek-widget' , 'style':'margin-top:1px;'},
          a({ 'class':'ek-button-link' , 'href':'javascript:void(0)' , 'onmouseup':'this.getParent().getParent().getParent().destroy()' },
            span({ 'class':'left'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
            ,span({ 'class':'center'}, 
              span({ 'style':"background: url("+wwwroot+"/media/system/img/icons/no-10px.png) 0px 0px no-repeat;height: 17px;float: left;margin-top:3px;padding-left: 12px;" })
            )
            ,span({ 'class':'right'}, 
              img({ src:wwwroot+'/media/system/img/spacer.gif' })
            )
          )
        )
      )
    );
  });

  Mooml.register('shippingEntry', function(params)  {
    tr(
      {'class':'shippingLine'}
      ,td(
        input({ type:'text' , value:params.trid , 'class':'shippingNumber ek-input-text-small', 'style':'display:none;' })
      )
      ,td(
        span('Mini : ')
        ,input({ type:'text' , value:params.minweight , 'class':'shippingNumber ek-input-text-small', 'style':'width:50px' })
        ,span('&nbsp;&nbsp;gr.')
      )
      ,td(
        span('Maxi : ')
        ,input({ type:'text' , value:params.maxweight , 'class':'shippingNumber ek-input-text-small', 'style':'width:50px' })
        ,span('&nbsp;&nbsp;gr.')
      )
      ,td(
        span('Tarif : ')
        ,input({ type:'text' , value:params.tarif , 'class':'shippingNumber ek-input-text-small', 'style':'width:50px; text-align:right;' })
        ,span('&nbsp;&nbsp;&euro;')
      )
      ,td(
        span('D&eacute;lai : ')
        ,input({ type:'text' , value:params.delai , 'class':'shippingNumber ek-input-text-small', 'style':'width:30px; text-align:right;' })
        ,span('&nbsp;&nbsp;H')
      )
      ,td(
        div({ 'class':'ek-help', 'style':'float:left; padding-left:4px;'},
          a({ 'class':'ek-tips'
            , 'rel':'<div style="font-size:14px;">Information</div>Cette association est utilis&eacute;e par une commande'
            , 'href':'javascript:void(0)'}, 
            img({ src:wwwroot+'/media/system/img/admin/help.png' })
          )
        )
      )     
    );
  });


});