// 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) {

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

    var firstAdUnit = '';
    var secondAdUnit = '';
      
    // Display ads in a table
    var s = '<table>';
 
    firstAdUnit = secondAdUnit = s;
    
    // For text ads, display each ad in turn.
    // In this example, each ad goes in a new row in the table.
    if (google_ads[0].type == 'text') { 
      for(i = 0; i < google_ads.length; ++i) {
       s = '<tr><td>' +
         '<a style="cursor:pointer;cursor:hand" onclick="javascript:top.location.href=\'' + google_ads[i].url + '\'" onmouseover="this.className=\'hover\'; window.status=\'Visita ' + google_ads[i].visible_url + '\'" onmouseout="this.className=\'\'; window.status=\'\'">' +
         '<span class="titoli">' + google_ads[i].line1 + '</span><br />' +
         '<span class="testo">'  + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</span><br />' +
	 '</a><br /></td></tr>';
       if(i == 1) {
         firstAdUnit += s;
       } else {
         secondAdUnit += s;
       }
      }
    }

    // Print "Ads By Google" -- include link to Google feedback page if available
    s = '<tr><td>';
    s += '<div class="google">';
    
    if (google_info.feedback_url) {
      s += '<a href="' + google_info.feedback_url + '">Annunci Google</a>';
    } else {
      s += 'Annunci Google';
    }
    s += '</div></td></tr>';
    firstAdUnit += s;

    // For an image ad, display the image; there will be only one .
    if (google_ads[0].type == 'image') {
      s = '<tr><td align="center">' +
        '<a href="' + google_ads[0].url + '" style="text-decoration: none">' +
        '<img src="' + google_ads[0].image_url + 
        '" height="' + google_ads[0].height + 
        '" width="' + google_ads[0].width +
        '" border="0"></a></td></tr>';
      firstAdUnit = s;
    }

    // Finish up anything that needs finishing up
    s = '</table>';
    firstAdUnit += s;
    secondAdUnit += s;
    
    document.getElementById("box-google-alto").innerHTML += firstAdUnit;
    if (google_ads[0].type != 'image')
      document.getElementById("box-google-sinistra").innerHTML += secondAdUnit;

    return;
}
