var random_number = Math.random(); // create random number
var advert_randomness = .5; // 50%
// // 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.
var google_adnum = 0;
function google_ad_request_done(google_ads) {

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

  var s = '';
  if (random_number < advert_randomness){ // A/B TEST, VERSION A
    // Display ads in a table
    s += '<table cellpadding="5" class="google_table">';

    // Print "Ads By Google" include link to Google feedback page if available
    s += '<tr><td style="text-align:left;font-size:8pt;background-color: transparent !important;">';

    if (google_info.feedback_url) {
      s += '<a href="' + google_info.feedback_url + '" target="_blank" style="color:#000;line-height:20px;"><strong>Google-Anzeigen</strong></a>';
    } else {
      s += 'Google-Anzeigen';
    }

    s += '</td></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) {
        s += '<tr><td style="text-align:left;">' +
          '<a style="text-decoration:none;text-decoration: underline;font-weight:700;cursor: pointer;" onclick="window.open(\'' + google_ads[i].url + '\');" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">' +
          '' + google_ads[i].line1 + '</a><br />' +
          '<div style="font-size: 11px;line-height: 13px;">'  + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</div>' +
          '<a style="font-size: 11px;line-height: 13px;" onclick="window.open(\'' + google_ads[i].url + '\');" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">' +
          google_ads[i].visible_url +
          '</a><div class="xtraline" style="margin-bottom: 0px;"></div></td></tr>';

      }
    }

    if (google_ads[0].bidtype == "CPC") {  /* insert this snippet for each ad call */
      google_adnum = google_adnum + google_ads.length;
    }

    // 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" target="_blank">' +
        '<img src="' + google_ads[0].image_url +
        '" height="' + google_ads[0].height +
        '" width="' + google_ads[0].width +
        '" border="0"></a></td></tr>';
    }

    if (google_ads[0].type == "html") {
      s += '<tr><td align="center">'+google_ads[0].snippet+'</td></tr>';
    }

    // Finish up anything that needs finishing up
    s += '</table>';
  } else { // A/B TEST, VERSION B
     // Display ads in a table
    s += '<table cellpadding="5" class="google_table">';

    // Print "Ads By Google" include link to Google feedback page if available
    s += '<tr><td style="text-align:left;font-size:8pt;background-color: transparent !important;">';

    if (google_info.feedback_url) {
      s += '<a href="' + google_info.feedback_url + '" target="_blank" style="color:#000;line-height:20px;"><strong>Google-Anzeigen</strong></a>';
    } else {
      s += 'Google-Anzeigen';
    }

    s += '</td></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) {
        s += '<tr><td style="text-align:left;">' +
          '<a style="text-decoration:none;text-decoration: underline;font-weight:700;cursor: pointer;" onclick="window.open(\'' + google_ads[i].url + '\');" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">' +
          '' + google_ads[i].line1 + '</a><br />' +
          '<div style="font-size: 11px;line-height: 13px;">'  + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</div>' +
          '<a style="font-size: 11px;line-height: 13px;" onclick="window.open(\'' + google_ads[i].url + '\');" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">' +
          google_ads[i].visible_url +
          '</a><div class="xtraline" style="margin-bottom: 0px;"></div></td></tr>';

      }
    }

    if (google_ads[0].bidtype == "CPC") {  /* insert this snippet for each ad call */
      google_adnum = google_adnum + google_ads.length;
    }

    // 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" target="_blank">' +
        '<img src="' + google_ads[0].image_url +
        '" height="' + google_ads[0].height +
        '" width="' + google_ads[0].width +
        '" border="0"></a></td></tr>';
    }

    if (google_ads[0].type == "html") {
      s += '<tr><td align="center">'+google_ads[0].snippet+'</td></tr>';
    }

    // Finish up anything that needs finishing up
    s += '</table>';
  } // A/B TEST END

  document.write(s);
  return;
}

if (random_number < advert_randomness){ // A/B TEST, VERSION A

  // placement values are appended to google_ad_channel separated by comma
  var advert_placement = {
    buero: "7004255117",
    programmierung: "3233933558",
    private_finanzen: "8999924887",
    wissensoftware: "5101936532",
    games_fun: "8605898484",
    grafik_design: "7002097457",
    system_administration: "4403146245",
    dateien_verwalten: "8246298635",
    internet_kommunikation: "4403146245",
    tools_utilities: "1589744599",
    player_multimedia: "6519490160",
    hobbysoftware: "5078666880",
    startseite: "3720667645"
  };

  var advert_link_unit = {
    google_ad_client : "pub-6486941980817876",
    google_ad_slot : "8608328414",
    google_ad_region : "8608328414",
    google_ad_width : 728,
    google_ad_height : 15,
    google_skip : google_adnum,
    google_encoding : "utf-8",
    google_language : 'de'
  };

  var advert_skyscraper = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 6,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "text_image_html_flash",
    google_ad_channel : "9111207865",
    google_ad_region : "9111207865",
    google_image_size : "160x600",
    google_encoding : "utf-8",
    google_kw_type : "broad"
  };

  var advert_rectangle_sidebar = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 3,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "image_html",
    google_ad_channel :"7636601875",
    google_ad_region :"7636601875",
    google_image_size : "300x250",
    google_encoding : "utf8",
    google_kw_type : "broad"
  };

  var advert_rectangle_software_list = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 3,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "text_image_html_flash",
    google_ad_channel :"3008526785",
    google_ad_region :"3008526785",
    google_image_size : "300x250",
    google_encoding : "utf8",
    google_kw_type : "broad"
  };

  var advert_rectangle_software_detail = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 3,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "text",
    google_ad_channel :"9121599688",
    google_ad_region :"9121599688",
    google_image_size : "300x250",
    google_encoding : "utf8",
    google_kw_type : "broad"
  };

  var advert_rectangle_author = {
    google_ad_client : "pub-6486941980817876",
    google_ad_slot : "2569875831",
    google_ad_region : "2569875831",
    google_ad_width : 300,
    google_ad_height : 250,
    google_skip : google_adnum
  };

} else { // A/B TEST, VERSION B
  // placement values are appended to google_ad_channel separated by comma
  var advert_placement = {
    buero: "7004255117",
    programmierung: "3233933558",
    private_finanzen: "8999924887",
    wissensoftware: "5101936532",
    games_fun: "8605898484",
    grafik_design: "7002097457",
    system_administration: "4403146245",
    dateien_verwalten: "8246298635",
    internet_kommunikation: "4403146245",
    tools_utilities: "1589744599",
    player_multimedia: "6519490160",
    hobbysoftware: "5078666880",
    startseite: "3720667645"
  };

  var advert_link_unit = {
    google_ad_client : "pub-6486941980817876",
    google_ad_slot : "8608328414",
    google_ad_region : "8608328414",
    google_ad_width : 728,
    google_ad_height : 15,
    google_skip : google_adnum,
    google_encoding : "utf-8",
    google_language : 'de'
  };

  var advert_skyscraper = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 6,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "text_image_html_flash",
    google_ad_channel : "9111207865",
    google_ad_region : "9111207865",
    google_image_size : "160x600",
    google_encoding : "utf-8",
    google_kw_type : "broad"
  };

  var advert_rectangle_sidebar = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 3,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "image_html",
    google_ad_channel :"7636601875",
    google_ad_region :"7636601875",
    google_image_size : "300x250",
    google_encoding : "utf8",
    google_kw_type : "broad"
  };

  var advert_rectangle_software_list = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 3,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "text_image_html_flash",
    google_ad_channel :"3008526785",
    google_ad_region :"3008526785",
    google_image_size : "300x250",
    google_encoding : "utf8",
    google_kw_type : "broad"
  };

  var advert_rectangle_software_detail = {
    google_ad_client : "pub-6486941980817876",
    google_max_num_ads : 3,
    google_feedback : "on",
    google_ad_output : "js",
    google_language : 'de',
    google_ad_type  : "text",
    google_ad_channel :"9121599688",
    google_ad_region :"9121599688",
    google_image_size : "300x250",
    google_encoding : "utf8",
    google_kw_type : "broad"
  };

  var advert_rectangle_author = {
    google_ad_client : "pub-6486941980817876",
    google_ad_slot : "2569875831",
    google_ad_region : "2569875831",
    google_ad_width : 300,
    google_ad_height : 250,
    google_skip : google_adnum
  };
} // A/B TEST END

