// This function displays the ad results.
// It must be defined above the script that calls show_ads.js
// to guarantee that it is defined when show_ads.js makes the call-back.

function google_ad_request_done(google_ads) {

  if (window.oh_google_color_fblink == null)
    oh_google_color_fblink = "#000000";
  if (window.oh_google_color_border == null)
    oh_google_color_border = "#dddddd";
  if (window.oh_google_color_bg == null)
    oh_google_color_bg = "#ffffff";

  // Proceed only if we have ads to display!
  if (google_ads.length < 1 )
    return;

  var newHTML = '';

  // Print "Ads By Google" -- include link to Google feedback page if available
  newHTML += '<table width="' + oh_google_ad_width + 
    '" style="border: 0; background-color: ' + oh_google_color_border + '"> ' +
    '<tr><td class="adsense" align="left">';
  if (google_info.feedback_url) {
    newHTML += '<a style="font-size: 70%; color:' + oh_google_color_fblink + 
      '" href="' + google_info.feedback_url + '">Ads by Gooooooogle&nbsp;</a>';
  } else {
    newHTML += '<span style="font-size: 70%; color:' + oh_google_color_fblink + 
      '">Ads By Goooooooogle</span>';
  }
  newHTML += '</td></tr>';  
  newHTML += '</table>';

  // Display ads in a table
  newHTML += '<table cellpadding="2" width="' + oh_google_ad_width +
    '" style="border: 1px solid ' + oh_google_color_border + 
    '; background-color: ' + oh_google_color_bg + '; ">';

  var num_up = oh_google_num_up || 2;
  for(i = 0; i < google_ads.length; ) {
    newHTML += '<tr>'; 
    for (var j = 0; j < num_up; i++, j++) {
      newHTML += '<td class="adsense">'
      if (google_ads.length == 1)
          newHTML += '<span style="font-size: larger">';
      newHTML += '<a class="adsense" style="text-decoration: none" href="' +  
        google_ads[i].url + '" onmouseout="window.status=\'\'" ' +
        'onmouseover="window.status=\'go to ' + google_ads[i].visible_url + 
        '\'; return true"> <span style="font-weight: bolder; font-size: 85%">' + 
        google_ads[i].line1 + '</span><br />' + 
        '<span style="font-size: 70%; color: black">' + 
        google_ads[i].line2 + '<br /> ' + google_ads[i].line3 + '</span> <br />';
      if (google_ads.length == 1)
          newHTML += '</span>';

      // Always show the url.
      newHTML +=
        '<a href="' + google_ads[i].url + 
        '"  style="font-size: 70%; color: green" ' +
        'onmouseout="window.status=\'\'" ' +
        'onmouseover="window.status=\'go to ' + google_ads[i].visible_url +
        '\'; return true">' + google_ads[i].visible_url + '</a>';
      newHTML += '</td>';
    }
    newHTML += '</tr>';
  }

/*
  // Show ads in a single column.
  // Invoke if specified, or if there's an odd number of ads.
  if ((oh_google_num_up == 1) || (google_ads.length % 2 == 1)) {
    for(i = 0; i < google_ads.length; ++i) {
      newHTML += '<tr><td class="adsense"><a class="adsense" href="' +  
        google_ads[i].url + '" style="text-decoration: none">' +
        '<span style="font-weight: bolder; font-size: 85%">' + 
        google_ads[i].line1 + '</span><br>' +

        '<span style="font-size: 70%; color: black">' + 
        google_ads[i].line2 + ' ' + google_ads[i].line3 + '</span>';  

      if (oh_google_show_url == 1) {
        newHTML += '<br><span style="font-size: 70%; color: green">' + 
          google_ads[i].visible_url + '</span>';
      }
      newHTML += '</a></td></tr>';
    }
    newHTML += '</table>';
  }

  // Show ads paired up in two columns.
  else if (google_ads.length % 2 == 0) {
    for(i = 0; i < google_ads.length; i = i+2) {
      newHTML += '<tr>';
      for (j = 0; j < 2; ++j) {
        newHTML += '<td width="50%" class="adsense"><a class="adsense" href="' +  
        google_ads[i+j].url + '" style="text-decoration: none">' + 
        '<span style="font-weight: bolder; font-size: 85%">' + 
        google_ads[i+j].line1 + '</span><br>' +
        '<span style="font-size: 70%; color: black">' + 
        google_ads[i+j].line2 + ' <br> ' + google_ads[i+j].line3 + '</span>';

        if (oh_google_show_url == 1) {
          newHTML += '<br /><span style="font-size: 70%; color: green">' + 
            google_ads[i+j].visible_url + '</span>';
        }
        newHTML += '</a></td>';
      }
      newHTML += '</tr>';
    }
    newHTML += '</table>';
  }
*/

    newHTML += '</table>';

  document.write(newHTML);
}

