
/*
 * Product Page Zone 1
 */
function example_zpf(a_product_ids,
                     zone,
                     symbolic,
                     target_id,
                     category,
                     rec_attributes,
                     target_attributes,
                     target_header_txt,
                     div_id,
                     b_display_target)
{
   var html = zone + "_zp: No recommendations returned";

   if (symbolic !== '_NR_'){
      // attribute indicies for example
      var i_description = 0;
      var i_image_url   = 2;
      var i_href        = undefined;
      var i_score       = undefined;
      var i_price       = undefined;

      // special case.  Over ride of the header text passed from the configuration file
      target_header_txt = "<span class=\"suggestion\">May We Also Suggest...</span>";

      var div_recs    = '';
      var n_recs      = a_product_ids.length;
      var div_title   = target_header_txt + '<hr noshade="noshade">';
      var div_table   = '<div class="io_recs_table">';
      var image_table = '';
      var lines       = [];
      var width       = 100 / n_recs;

      // 0 product description 
      // 1 price
      // 2 image path
      // 3 not defined
      // 4 not defined

      // for Chris
      if (b_display_target){
         rec_attributes.unshift(target_attributes);
         n_recs++;
      }

      // Recommendations
      for (var ii=0; 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 image_description = rec_attributes[ii][0];               // product description
         var selected_href     = 'http://www.homeofficesolutions.com/product-exec/product_id';                                  // 
         var price             = '$' + rec_attributes[ii][1];         // 
         var n_stars           = 2 + Math.floor(Math.random() * 3);   // 
         var category          = rec_attributes[ii][1];               // 
         var image_url         = rec_attributes[ii][i_image_url];     // image url
         var alt_description   = image_description;
         var prod_id_row       = '';

         if (b_display_target){
            prod_id_row = rec_prod_id;                                                                                                                                                                                              

            if (ii === 0){
               image_description = 'Targeter Item' + image_description;
            }                                                           
         }

         if (!rec_attributes[ii][2]){
            alt_description   = 'No Image Available';
         }

         //lines.push('<div>');
         lines.push('<div style="float:left; padding-top:5px; width:400px;"><a style="text-decoration:none" href="' + selected_href + '/' + rec_prod_id + '/pn/' + image_description + '" onclick="javascript:setCrossSellCookie(\'crossSell\', \'' + rec_prod_id + '\', \'6000\');"><IMG SRC="' + image_url + '" ALT="' + alt_description + '" height="75" align="left" style="border: medium none; cursor: pointer; padding-right: 10px" /><br />' + image_description + ' ' + price + '<\/a></div><br style="clear:both;" />');
         //lines.push('</div>');
      }

      // make a text string
      html = div_recs + div_title + div_table + image_table + lines.join("\n") + '<\/div\>';
   }

   document.getElementById(div_id).innerHTML= html;
}



/*
 * Shopping Cart Zone 1
 */
function cart_zpf(a_product_ids,
                     zone,
                     symbolic,
                     target_id,
                     category,
                     rec_attributes,
                     target_attributes,
                     target_header_txt,
                     div_id,
                     b_display_target){
   var html = zone + "_zp: No recommendations returned";

   if (symbolic !== '_NR_'){
      // attribute indicies for example
      var i_description = 0;
      var i_image_url   = 2;
      var i_href        = undefined;
      var i_score       = undefined;
      var i_price       = undefined;

      // special case.  Over ride of the header text passed from the configuration file
      target_header_txt = "You Might Also Consider...";

      var div_recs    = '';
      var n_recs      = a_product_ids.length;
      var div_title   = target_header_txt + '<hr noshade="noshade">';
      var div_table   = '<div class="io_recs_table" style="text-align:center;">';
      var image_table = '';
      var lines       = [];
      var width       = 100 / n_recs;

      // for Chris
      if (b_display_target){
         rec_attributes.unshift(target_attributes);
         n_recs++;
      }

      // Recommendations
	  // 0 product description 
      // 1 price
      // 2 image path
      // 3 not defined
      // 4 not defined
      for (var ii=0; 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 image_description = rec_attributes[ii][0];               // product description
         var selected_href     = 'http://www.homeofficesolutions.com/product-exec/product_id';                                  // 
         var price             = '$' + rec_attributes[ii][1];         // 
         var n_stars           = 2 + Math.floor(Math.random() * 3);   // 
         var category          = rec_attributes[ii][1];               // 
         var image_url         = rec_attributes[ii][i_image_url];     // image url
         var alt_description   = image_description;
         var prod_id_row       = '';

         if (b_display_target){
            prod_id_row = rec_prod_id;                                                                                                                                                                                              

            if (ii === 0){
               image_description = 'Targeter Item' + image_description;
            }                                                           
         }

         if (!rec_attributes[ii][2]){
            alt_description   = 'No Image Available';
         }

         lines.push('<div style="padding-top:10px; width:200px; float:left; text-align:center;"><a style="text-decoration:none" href="' + selected_href + '/' + rec_prod_id + '/pn/' + image_description + '" onclick="javascript:setCrossSellCookie(\'crossSell\', \'' + rec_prod_id + '\', \'6000\');"><IMG SRC="' + image_url + '" ALT="' + alt_description + '" height=100 style="border: medium none; cursor: pointer;" /><br />');
         lines.push(' ' + image_description + '<br />' + price + '<\/a></div>');
      }

      // make a text string
      html = div_recs + div_title + div_table + image_table + lines.join("\n") + '<\/div\>';
   }

   document.getElementById(div_id).innerHTML= html;
}

function PDPZ1_zp(a,b,c,d,e,f,g,h){
   example_zpf(a,b,c,d,e,f,g,h,'io_zone_1',false);
}

function CartPage_zp(a,b,c,d,e,f,g,h)  {
   cart_zpf(a,b,c,d,e,f,g,h,'io_zone_2',false); 
}