var image_prefix  = 'https://ssl.geburtstagsgeschenk-online.de/shop/catalog/images/product_images/thumbnail_images';
var link_prefix = 'https://ssl.geburtstagsgeschenk-online.de/shop/catalog/product_info.php?info=p';
var html = zone + "_zp: No recommendations returned";

var i_href        = undefined;
var i_score       = undefined;
var i_price       = undefined;

/**
 * Home Page Zone1
 **/
function homepage1_zpfs(a_product_ids, zone, symbolic, target_id, category, rec_attributes, target_attributes, target_header_txt, ab_test_id, div_id, b_display_target)
{
   if (symbolic !== '_NR_')
   {
      var i_description = 0;
      var i_image_url   = 3;
     
      var div_recs    = '<div class="io_hpz1_recs"\>';
      var n_recs      = a_product_ids.length;
      var div_title   = '<div class="io_recs_title">HPZ1 -- Home Page Zone 1<\/div>';
      var div_table   = '<div class="io_recs">';
   
      var lines       = [];
      var width       = 100 / n_recs;

      if (b_display_target)
      {
         rec_attributes.unshift(target_attributes);         // push target onto front of rec_attributes array
         n_recs++;
      }

      // Recommendations
      for (var ii=1; ii < n_recs; ii++)
      {
         var rec_prod_id       = b_display_target ? (ii == 0 ? target_id : a_product_ids[ii - 1]) : a_product_ids[ii];

         var selected_href     = link_prefix + rec_prod_id;      // - not passed - href for image

         var image_description = rec_attributes[ii][i_description];                 // product description
         var image_url         = image_prefix + rec_attributes[ii][i_image_url];    // image url

         var alt_description   = image_description;
         if (!image_description)
         {
            alt_description   = 'No Image Available';
            image_description   = '&nbsp;';
         }
         lines.push('<div class="recs_hor"><a href="' + selected_href + '"><img src="' + image_url + '?wid=128 + alt="' + alt_description + '"" /></a><br />');
         lines.push('<a class="rec_links" align="center" href="' + selected_href + '">' + image_description + '</a>')
         lines.push('</div>')
      }
      // make a text string
      html = div_recs + div_title + lines.join("\n") + '<\/TR\><\/TABLE\><\/div\><\/div\>';
   }
   document.getElementById(div_id).innerHTML= html;
}

/**
 * Landing Page Zone 1 	LPZ1
 */
function landingpage_zpfs(a_product_ids, zone, symbolic, target_id, category, rec_attributes, target_attributes, target_header_txt, ab_test_id, div_id, b_display_target)
{
   if (symbolic !== '_NR_')
   {
      var i_description = 0;
      var i_image_url   = 3;
     
      var div_recs    = '<div class="io_lpz1_recs"\>';
      var n_recs      = a_product_ids.length;
      var div_title   = '<div class="io_ggo_title">Top Selling Items<\/div>';
      var div_table   = '<div class="io_recs">';
   
      var lines       = [];
      var width       = 100 / n_recs;

      if (b_display_target)
      {
         rec_attributes.unshift(target_attributes);         // push target onto front of rec_attributes array
         n_recs++;
      }

      // Recommendations
      for (var ii=1; ii < 6; ii++)
      {
         var rec_prod_id       = b_display_target ? (ii == 0 ? target_id : a_product_ids[ii - 1]) : a_product_ids[ii];

         var selected_href     = link_prefix + rec_prod_id;      // - not passed - href for image

         var image_description = rec_attributes[ii][i_description];                 // product description
         var image_url         = image_prefix + rec_attributes[ii][i_image_url];    // image url

         var alt_description   = image_description;
         if (!image_description)
         {
            alt_description   = 'No Image Available';
            image_description   = '&nbsp;';
         }
         lines.push('<div class="recs_hor"><a href="' + selected_href + '"><img src="' + image_url + '?wid=128 + alt="' + alt_description + '"" /></a><br />');
         lines.push('<a class="rec_links" align="center" href="' + selected_href + '">' + image_description + '</a>')
         lines.push('</div>')
      }
      // make a text string
      html = div_recs + div_title + lines.join("\n") + '<\/TR\><\/TABLE\><\/div\><\/div\>';
   }
   document.getElementById(div_id).innerHTML= html;
}

/**
 * Categorie Page Zone1
 */
function categoriePage_zpfs(a_product_ids, zone, symbolic, target_id, category, rec_attributes, target_attributes, target_header_txt, ab_test_id, div_id, b_display_target)
{
   if (symbolic !== '_NR_')
   {
      var i_description = 0;
      var i_image_url   = 3;
     
      var div_recs    = '<div class="io_lpz1_recs"\>';
      var n_recs      = a_product_ids.length;
      var div_title   = '<div class="io_ggo_title">Kategorie Top-Seller<\/div>';
      var div_table   = '<div class="io_recs">';
   
      var lines       = [];
      var width       = 100 / n_recs;

      if (b_display_target)
      {
         rec_attributes.unshift(target_attributes);         // push target onto front of rec_attributes array
         n_recs++;
      }

      // Recommendations
      for (var ii=1; ii < 6; ii++)
      {
         var rec_prod_id       = b_display_target ? (ii == 0 ? target_id : a_product_ids[ii - 1]) : a_product_ids[ii];

         var selected_href     = link_prefix + rec_prod_id;      // - not passed - href for image

         var image_description = rec_attributes[ii][i_description];                 // product description
         var image_url         = image_prefix + rec_attributes[ii][i_image_url];    // image url

         var alt_description   = image_description;
         if (!image_description)
         {
            alt_description   = 'No Image Available';
            image_description   = '&nbsp;';
         }
         lines.push('<div class="recs_hor"><a href="' + selected_href + '"><img src="' + image_url + '?wid=128 + alt="' + alt_description + '"" /></a><br />');
         lines.push('<a class="rec_links" align="center" href="' + selected_href + '">' + image_description + '</a>')
         lines.push('</div>')
      }
      // make a text string
      html = div_recs + div_title + lines.join("\n") + '<\/TR\><\/TABLE\><\/div\><\/div\>';
   }
   document.getElementById(div_id).innerHTML= html;
}

/**
 * 
 */
function HPZ1_zp(a,b,c,d,e,f,g,h,i)  
{
   homepage1_zpfs(a,b,c,d,e,f,g,h,i,'hpz1',true);
}

function LPZ1_zp(a,b,c,d,e,f,g,h,i)  
{
   landingpage_zpfs(a,b,c,d,e,f,g,h,i,'lpz1',true);
}

function CTZ1_zp(a,b,c,d,e,f,g,h,i)  
{
   categoriePage_zpfs(a,b,c,d,e,f,g,h,i,'ctz1',true);
}

