﻿  var googcnt = 0;
  var googwidth = '300';
  var googtype = 'empile';
  // 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 s = '';
      
    // Display ads in a table
    if (googtype == 'empile') {
        s += '<table cellpadding="0" cellspacing="3" width="' + googwidth + '" align="center" class="gads" style="' + googwidth + 'px;">';
    } else {
        s += '<table cellpadding="0" cellspacing="2" width="' + googwidth + '" align="center" class="gads" style="' + googwidth + 'px;">';
    }
 
    if (googtype == 'empile') {
        // 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) {
           googcnt += 1;
            var ggurl = google_ads[i].url;
            while(ggurl.indexOf('\'') > 0)
                ggurl = ggurl.replace('\'', '\\\'');
                
           //s += '<tr class="trgadsads' + googcnt + '"><td class="gadstdlink' + googcnt + '" onclick="javascript:top.location.href=\'' + google_ads[i].url + '\'" onmouseover="window.status=\'http://' + google_ads[i].visible_url + '\';this.className = \'gadstdlink' + googcnt + 'hover\'" onmouseout="window.status=\'\';this.className = \'gadstdlink' + googcnt + '\'" title="' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '">' +
           s += '<tr class="trgadsads' + googcnt + '"><td class="gadstdlink' + googcnt + '" onmouseover="this.className = \'gadstdlink' + googcnt + 'hover\'" onmouseout="this.className = \'gadstdlink' + googcnt + '\'">' +
             '<a class="gadslink' + googcnt + '" onclick="javascript:top.location.href=\'' + ggurl + '\'" onmouseover="window.status=\'http://' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'" title="' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '">' +
             '<span class="gadslinktitle' + googcnt + '">' + google_ads[i].line1 + '</span><br />' +
             '<span class="gadslinkdesc' + googcnt + '">'  + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</span><br />' +
             '<span class="gadslinkurl' + googcnt + '">' + google_ads[i].visible_url +
             '</span><br /></a></td></tr>';
             //alert('empile');
           if (googcnt == 2) 
            googcnt = 0;
          }
        }

        // 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].image_height + '" width="' + google_ads[0].image_width +'" border="0"></a></td></tr>';
        }

        // Print "Ads By Google" -- include link to Google feedback page if available
        s += '<tr class="trgadsby"><td align="left">' +
          '<div class="gadsfeed">';
        
        if (google_info.feedback_url) {
          s += '<a href="' + google_info.feedback_url + '">Annonces Google</a>';
        } else {
          s += 'Annonces Google';
        }
        s += '</div></td></tr>';

        // Finish up anything that needs finishing up
        s += '</table>';
        
        document.write(s);
        return;
    } else {
        //s += '<tr><td><table cellpadding="0" cellspacing="3" width="' + googwidth + '" align="center" style="' + googwidth + 'px;"><tr class="trgadsads' + googcnt + '">';
        s += '<tr>';
        // 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) {
           googcnt += 1;
           var ggurl = google_ads[i].url;
            while(ggurl.indexOf('\'') > 0)
                ggurl = ggurl.replace('\'', '\\\'');
                
           //s += '<td class="gadstdlink' + googcnt + '" onclick="javascript:top.location.href=\'' + google_ads[i].url + '\'" onmouseover="window.status=\'http://' + google_ads[i].visible_url + '\';this.className = \'gadstdlink' + googcnt + 'hover\'" onmouseout="window.status=\'\';this.className = \'gadstdlink' + googcnt + '\'" title="' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '">' +
           s += '<td class="gadstdlink' + googcnt + '" onmouseover="this.className = \'gadstdlink' + googcnt + 'hover\'" onmouseout="this.className = \'gadstdlink' + googcnt + '\'" title="' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '">' +
             '<a class="gadslink' + googcnt + '" onclick="javascript:top.location.href=\'' + ggurl + '\'" onmouseover="window.status=\'http://' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'" title="' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '">' +
             '<span class="gadslinktitle' + googcnt + '">' + google_ads[i].line1 + '</span><br />' +
             '<span class="gadslinkdesc' + googcnt + '">'  + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</span><br />' +
             '<span class="gadslinkurl' + googcnt + '">' + google_ads[i].visible_url +
             '</span><br /></a></td>';
             //alert('normal');
           if (googcnt == 2) 
            googcnt = 0;
          }
          //s += '</tr></table></td></tr>';
          s += '</tr>';
        }
        
        // 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].image_height +  '" width="' + google_ads[0].image_width + '" border="0"></a></td></tr>';
        }

        // Print "Ads By Google" -- include link to Google feedback page if available
        s += '<tr class="trgadsby"><td align="left" colspan="' + google_ads.length + '"><div class="gadsfeed">';
        
        if (google_info.feedback_url) {
          s += '<a href="' + google_info.feedback_url + '">Annonces Google</a>';
        } else {
          s += 'Annonces Google';
        }
        s += '</div></td></tr>';
        
        // Finish up anything that needs finishing up
        s += '</table>';
        
        document.write(s);
        return;
    }
  }
