function gtm_getDetailImpressions(id, event){
   product = {
      'name' : page_data['products'][0]['name'],
      'id':  page_data['products'][0]['id'],
      'price':  page_data['products'][0]['price'],
      'variationName':  '',
      'id_variation': undefined,
      'id_product': page_data['products'][0]['idProduct']
   };

   selected = gtm_getVariation(id);

   additionalData = {};

   if (selected) {
      product['variationName'] = selected['variationName'];
      product['price'] = selected['price'];
      product['id'] = selected['id'];
      product['id_variation'] = selected['idVariation'];
      product['id_product'] = selected['idProduct'];

      additionalData['products'] = [ selected ];
   }

   additionalData['event'] = event;
   dataLayer.push(additionalData);
}

function gtm_getVariation(id_var){
   if (typeof gtm_prva == 'undefined') {
      return false;
   }

   if (gtm_prva[id_var]) {
      return gtm_prva[id_var];
   } else {
      return gtm_prva[Object.keys(gtm_prva)[0]];
   }
}

function old_gtm_getDetailImpressions(id, event){
   product = {
      'name' : page_data['product']['prodName'],
      'id':  page_data['product']['prodId'],
      'price':  page_data['product']['prodPrice'],
      'brand': page_data['product']['prodProducer'],
      'category': page_data['product']['prodCategory'],
      'variant':  '',
      'id_variation': page_data['product']['prodIdVariation'],
      'id_product': page_data['product']['prodIdProduct']
   };

   selected = gtm_getVariation(id);

   if (selected) {
      product['variant'] = selected['prodVariant'];
      product['price'] = selected['prodPrice'];
      product['id'] = selected['prodId'];
      product['id_variation'] = selected['prodIdProduct'];
      product['id_product'] = selected['prodIdVariation'];
   }

   dataLayer.push({
      'event' : event,
      'ecommerce': {
         'detail': {
            'actionField': { 'list' : page_data['product']['prodCategory']},
            'products': [
               product
            ]
         }
      }
   });
}
