var afc_ad_count = 0;

function render_google_ads(google_ads, afc_ad_type){
	var s = '';
	var i;
	
	var sMainDivStyle		 		 = '';
	var sTextAdLineSeperator = '<br />';
	var sTextAdDivClass		 	 = '';
	var sTextAdStyle		 		 = '';
	var sImgAdDivClass		 	 = '';
	var sImgAdStyle		 			 = '';
	var sFeebackColor				 = '666666';
	var sFeebackClass				 = 'fs_xs';

	if (google_ads.length == 0) {
	return;
	}
	
	switch (afc_ad_type) {
		case "leaderboard":
						if (google_ads.length == 1){
							sTextAdStyle 				 = 'width: 800px;';
							sTextAdDivClass 		 = 'fs_xxl fl_l ma_s_r';
							sTextAdLineSeperator = '&nbsp;';
						} else if (google_ads.length == 2) {
							sTextAdStyle 		= 'width: 400px;';
							sTextAdDivClass = 'fs_xl fl_l ma_s_r';
						} else if (google_ads.length == 3) {
							sTextAdStyle 		= 'width: 260px;';
							sTextAdDivClass = 'fs_l fl_l ma_s_r';
						} else {
							sTextAdStyle 		= 'width: 200px;';
							sTextAdDivClass = 'fs_s fl_l ma_s_r';
						}
						break;
		case "skyscraper":
						sTextAdDivClass = 'fs_l pa_m_t pa_s_b ma_s_l ma_s_r';
						sFeebackClass	  = 'fs_xs pa_s_l';
						if (google_ads.length < 5){
							sMainDivStyle 	= 'height: 600px;';
						}
						
						if ((google_ads[0].type == "flash") || (google_ads[0].type == "image") || (google_ads[0].type == "html"))
						sFeebackColor = 'FFFFFF';
						break;
		default:
						sTextAdLineSeperator = '&nbsp;';
						sTextAdDivClass 		 = 'ad_unit pa_s_b pa_m_l';
						sTextAdStyle				 = 'font-size: 12px; line-height: 18px;';
						sImgAdStyle			 		 = 'margin:auto; text-align: center;';
						sFeebackClass				 = 'fs_xs pa_m_l';
						break;
	}
	
	if (google_ads[0].type == "flash") {

	  s += '<div style="' + sImgAdStyle + '"><a href=\"' +
		google_info.feedback_url + '\" style="color:#' + sFeebackColor + ';" target="_blank" class="' + sFeebackClass + '">Google-Anzeigen</a><br>' +
		'<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>';
		s += '</div>';

	} else if (google_ads[0].type == "image") {

	 s += '<div style="' + sImgAdStyle + '"><a href=\"' +
		google_info.feedback_url + '\" style="color:#' + sFeebackColor + ';" target="_blank" class="' + sFeebackClass + '">Google-Anzeigen</a><br> <a href="' +
		google_ads[0].url + '"  target="_blank" 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>';
		s += '</div>';

	} else if (google_ads[0].type == "html") {
		s += '<div style="' + sImgAdStyle + '">' + google_ads[0].snippet + '</div>';
	} else {
		if (google_ads.length == 1) {
		  s += '<div class="bg_2" style="' + sMainDivStyle + '"><div style="overflow: hidden;" class=""><a href=\"' +
			google_info.feedback_url + '\" style="color:#' + sFeebackColor + ';" target="_blank" class="' + sFeebackClass + '">Google-Anzeigen</a><br> <div class="' + sTextAdDivClass + '" style="' + sTextAdStyle + '"><a style="text-decoration:none" href="' +
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true" target="_blank"> <span class="fc_3 bold"> <b>' +
			google_ads[0].line1 + '</b></span></a><br /> <span style="color:#727272;font-size:11px;">' +
			google_ads[0].line2 + sTextAdLineSeperator +
			google_ads[0].line3 + '</span>' + sTextAdLineSeperator + ' <span><a class="fc_4" href="' +
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true" target="_blank">' +
			google_ads[0].visible_url + '</span></a></div></div></div>';
		} else if (google_ads.length > 1) {
		  s += '<div class="bg_2" style="' + sMainDivStyle + '"><div style="overflow: hidden;" class=""><a href=\"' + google_info.feedback_url + '\" style="color:#' + sFeebackColor + ';" target="_blank" class="' + sFeebackClass + '">Google-Anzeigen</a><br>'
			for(i = 0; i < google_ads.length; ++i) {
				s += '<div class="' + sTextAdDivClass + '" style="' + sTextAdStyle + '"><a style="text-decoration:none" href="' +
				google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
				google_ads[0].visible_url + '\';return true" target="_blank"> <span class="fc_3 bold"> <b>' +
				google_ads[i].line1 + '</b></span></a><br /> <span style="color:#727272;">' +
				google_ads[i].line2 + sTextAdLineSeperator +
				google_ads[i].line3 + '</span><br /> <span><a class="fc_4" href="' +
				google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
				google_ads[i].visible_url + '\';return true" target="_blank">' +
				google_ads[i].visible_url + '</span></a><br></div>';
			}
			s += '</div></div>';
		}
		
		if (google_ads[0].bidtype == "CPC")
		{
			afc_ad_count = afc_ad_count + google_ads.length;
		}
  }

  document.write(s);
  return;
}
