 <!--
 
      /* Todo: 
       * AFS-Channels dynamisch nach Kategorien  (search, kategorien, ...)
       *
       */ 
      
      /*
       * This function is required. It processes the google_ads JavaScript object,
       * which contains AFS ads relevant to the user's search query. The name of
       * this function <i>must</i> be <b>google_afs_request_done</b>. If this
       * function is not named correctly, your page will not display AFS ads.
       */

      function google_afs_request_done(google_ads)
      {
          /*
           * Verify that there are actually ads to display.
           */
          var google_num_ads = google_ads.length;
          if (google_num_ads <= 0)
          {
              return;
          }

          /*
           * Extract google results to different Arrays
           */
          var wideAds = new Array() ;  // wide ad unit array
          var narrowAds = new Array();  // narrow ad unit array
           
          for(i = 0; i < google_num_ads; i++)
          {
              if ( google_ads[i].type=="text/wide" )
              {
                wideAds.push(google_ads[i]); 
              }
              else if (google_ads[i].type=="text/narrow" )
              {
                narrowAds.push(google_ads[i]);
              }              
          }
          
          /*
           * Render wide ads into page
           */
          var offset = 0;
          
          // Fetch divs and render ads into
          $each($$('.'+wide_class), function( item ){
            // Add header to Block
            $(item).innerHTML += '<a href="http://services.google.com/feedback/online_hws_feedback" class="ad_header_gl">\n' +
                                 '<span class="ad_header">Google Anzeigen</span></a><br /><ul class="google_afs_ads">\n';
            
            // Render Ads to Block
            for(i = offset; i < wideAds.length && i < (parseInt(offset) + parseInt(3))  ; i++)
            {
                $(item).innerHTML += '<li class="afs_ad"><span class="afs_ads _google_afs_link" onmouseover="javascript:window.status=\'' + wideAds[i].url + '\';return true;" ' +
                                     'onmouseout="javascript:window.status=\'\';return true;">' +
						                         '<a class="google_afs_wide_title" ' + 'href="' + wideAds[i].url + '" target="_blank">' + wideAds[i].line1 + '</a><br />' +
						                         '<a class="google_afs_link" ' + 'href="' + wideAds[i].url + '" target="_blank">' + wideAds[i].visible_url + '</a>' +
						                         '<span class="google_afs_content">' + wideAds[i].line2 + '</span><br />' +
						                         '</span></li>\n';
            }  
            offset = parseInt(offset) + parseInt(3);
            
            // Add footer to Block
            $(item).innerHTML += '</ul><div class="google_ads_advert"><a href="http://www.mobello.de/service/werbung_buchen">Auf dieser Seite werben</a></div>';           
          });
      
          /*
           * Render narrow ads into page
           */
          offset = 0;
          
          // Fetch divs and render ads into
          $each($$('.'+narrow_class), function( item ){
            // Add header to Block
            $(item).innerHTML += '<a href="http://services.google.com/feedback/online_hws_feedback">' +
                                 '<span class="ad_header">Google Anzeigen</span></a><br /><ul class="google_afs_ads">';
            
            // Render Ads to Block
            //alert(narrowAds.length)
            for(i = offset; i < narrowAds.length && i < (parseInt(offset) + parseInt(5))  ; i++)
            {
                $(item).innerHTML += '<li class="afs_ad"><a class="google_afs_link block98" onmouseover="javascript:window.status=\'' + narrowAds[i].url + '\';return true;" ' +
                                     'onmouseout="javascript:window.status=\'\';return true;" ' + 'href="' + narrowAds[i].url + '" target="_blank">' +
						                         '<span class="google_afs_narrow_title">' + narrowAds[i].line1 + '</span><br />' +
						                         '</a></li>';
            }  
            offset = parseInt(offset) + parseInt(3);
            
            // Add footer to Block
            $(item).innerHTML += '</ul><div class="google_ads_advert"><a href="http://www.mobello.de/service/werbung_buchen">Auf dieser Seite werben</a></div>';           
          });          
      }
      
      
      
      
      // wide AFS Ads counten 
      var wide_class = 'google_wide_afs_ad';
      var google_afs_wide_ad_count = 0;  
      
      $each($$('.'+wide_class), function( item ){
        google_afs_wide_ad_count++;
      });

      // wide AFS Ads counten 
      var narrow_class = 'google_narrow_afs_ad';
      var google_narrow_afs_ad_count = 0;  
      
      $each($$('.'+narrow_class), function( item ){
        google_narrow_afs_ad_count++;
      });
      
      //alert( "Wide-AFS-Blöcke:" + google_afs_wide_ad_count);
      //alert( "Narrow-AFS-Blöcke:" + google_narrow_afs_ad_count);
      

      // Wie viele Ads können angezeigt werden ?
      var wnumads = 3 * google_afs_wide_ad_count;
      var nnumads = 5 * google_narrow_afs_ad_count;

      //alert( "Wide-AFS-ADS:" + numads);
      
      
      google_afs_query = GetParam();
      google_afs_ad = 'w' + wnumads + 'n' + nnumads; // specify the number of ads you are requesting
      google_afs_client = 'pub-9884014808731319'; // substitute your client ID
      
      // Todo: AFS-Channels nach Kategorien 
      google_afs_channel = '0611573659'; // enter your custom channel ID
      
      google_afs_hl = 'de'; // enter your interface language if not English
      //google_afs_adtest = 'on';
      google_afs_ie = 'utf8'; // select input encoding scheme
      google_afs_oe = 'utf8'; // select output encoding scheme
      
 -->
