var google_ads_disp = 0;
var google_ad_output = 'js';
var google_feedback = 'on';
var google_language='de';

function google_afs_request_done(google_ads) {
	google_afs_gl = 'de';
	google_afs_hl = 'de';
	printResult(google_ads);
}

function google_ad_request_done(google_ads) {printResult(google_ads);}

function printResult(google_ads) {
	/*
	* This function is required and is used to display
	* the ads that are returned from the JavaScript
	* request. You should modify the document.write
	* commands so that the HTML they write out fits
	* with your desired ad layout.
	*/
	var wideAds = '';
	var narrowAds = '';
	var i;

	/*
	* Verify that there are actually ads to display.
	*/
	
	if (google_ads.length == 0) {
		return;
	} else {
		google_ads_disp += google_ads.length;
	}
	
	/*
	* If an image or flash ad is returned, display that ad.
	* Otherwise, build a string containing all of the ads and
	* then use a document.write() command to print that string.
	*/
	if (typeof(google_info) == "undefined") {
		feedback_url = 'https://www.google.com/adsense/support/bin/request.py?contact=afs_violation';
	} else {
		feedback_url = google_info.feedback_url;
	}

	if (google_ads[0].type == "flash") {
		narrowAds += '<a href=\"' + feedback_url + '\" style="color: #808080; font-size: 11px; text-align: right; text-decoration: none;">Google Anzeigen</a><br>' +
					 '<p style="text-align: center; margin: 0 auto;">' + 
		'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
		' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
		google_ad.image_width +	'" HEIGHT="' + 
		google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
		google_ad.image_url + '">' + 
		'<PARAM NAME="quality" VALUE="high">' + 
		'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
		'<EMBED src="' + 
		google_ad.image_url + '" WIDTH="' + 
		google_ad.image_width + '" HEIGHT="' + 
		google_ad.image_height + 
		'" TYPE="application/x-shockwave-flash"' + 
		' AllowScriptAccess="never" ' + 
		' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></p>';
	} else if (google_ads[0].type == "image") {
		narrowAds += '<a href=\"' + feedback_url + '\" style="color: #808080; font-size: 11px; text-align: right; text-decoration: none;">Google Anzeigen</a><br>' +
					 '<p style="text-align: center; margin: 0 auto;"><a target="_blank" href="' + 
		google_ads[0].url + '" target="_top" title="go to ' + 
		google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
		google_ads[0].image_url + '"width="' + 
		google_ads[0].image_width + '"height="' + 
		google_ads[0].image_height + '"></a></p>';
	} else if (google_ads[0].type == "html") {
		narrowAds += google_ads[0].snippet;
	} else {
		if (google_ads.length == 1) {
			if (typeof(google_ads[0].line3) == "undefined") {
				line3 = '';
			} else {
				line3 = google_ads[0].line3;
			}
		}
		/*
		* Partners should adjust text sizes
		* so ads occupy the majority of ad space.
		*/
		feedback = '<a href=\"' + feedback_url + '\" style="color: #808080; font-size: 11px; text-align: right; text-decoration: none;">Google Anzeigen</a><br>';
		 
		ul = '<ul style="float: none; margin-bottom: 20px; list-style-type: none; padding: 0px;">';
		li = '<li onmouseout="this.style.backgroundColor=\'\'" onmouseover="this.style.backgroundColor=\'#eee\'" ' +
						 'style="float: left; padding-bottom: 5px; padding-top: 5px; line-height: 20px; width:100%;"> ';
				
		if (google_ads.length == 1) {
			if (google_ads[0].type=="text/wide") {
				wideAds += ul + li + feedback + renderAdRow(google_ads[0], line3) + '</li></ul>';
			} else {
				narrowAds += ul + li + feedback + renderAdRow(google_ads[0], line3) + '</li></ul>';
			}
		} else if (google_ads.length > 1) {
			wideAds += feedback + ul;
			narrowAds += feedback + ul;
		
			for(i = 0; i < google_ads.length; ++i) {
				if (typeof(google_ads[i].line3) == "undefined") {
					line3 = '';
				} else {
					line3 = google_ads[i].line3;
				}
				
				if (google_ads[i].type=="text/wide") {
					wideAds += li + renderAdRow(google_ads[i], line3) + ' </li>';
				} else {
					narrowAds += li + renderAdRow(google_ads[i], line3) + ' </li>';
				}
			}
			
			wideAds += '</ul>';
			narrowAds += '</ul>';
		}
	}

	if (typeof(google_info) == "undefined") {
	    document.getElementById("afs_bottom").innerHTML = wideAds;
	    document.getElementById("afs_side").innerHTML = narrowAds;
	} else {
		document.write(narrowAds);
	}
	return;
}

function renderAdRow(google_ad_item, line3) {
	return '<a class="navlink" onmouseout="this.className=\'navlink\'" onmouseover="this.className=\'navlinkover\'" ' +
			  'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
			  'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
		   '<div style="color:#000000; font-size: 13.5px; clear:both; width:100%;">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
		   '<div style="margin-top: -4px; clear:both; width:100%;">' + 
				'<a style="color: #808080; text-decoration: none; font-size: 11px;" ' +
			       'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
			       'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url + 
				'</a>' +
		   '</div>';
}