function renderGoogle(google_ads, container, linkedLabel, label, type) {
	
    var type = type || 'afc';
	var google_num_ads = google_ads.length;
	 
    if (google_num_ads <= 0) {
    	return;
    }
    
    var ads     = '';
    
    for (var i = 0; i < google_num_ads; i++) {
    	
    	var first = (i == 0);
    	
    	ads = ads + renderGoogleAd(google_ads[i], first, type);
    }    

    if (ads != '') {

    	adBlock = '<ul id="gads" class="gAdsContainer">' + ads + '</ul>';

	    if (document.getElementById(container)) {
	    	document.getElementById(container).innerHTML = adBlock;
	    }
    }
    
    return;
}

function renderGoogleAd(google_ad, first, type) {
	
    var ad =  '';
    var attrib = '';
    var logClickFn = (type == 'afs') ? 'logAfs()' : 'logAfc()';
    
    if (google_ad.line3) {
    	google_ad.line2 = google_ad.line2 + ' ' + google_ad.line3;
    }
    
    
    if (first) {
    	ad +=  '<li class="notice"><span>Anzeigen</span></li>';
    }
    
    switch (google_ad.type) {

        // Ad-Type image
        case "image":
            ad += '<a' + attrib + ' href="' + google_ad.url + '" title="go to ' + google_ad.visible_url + '" target="_blank">';
            ad +=   '<img src="' + google_ad.image_url + '" width="' + google_ad.image_width + '" height="' + google_ad.image_height + '" alt="" />';
            ad += '</a>';
            break;

        // Ad-Type flash
        case "flash":
            ad += '<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 + '">';
            ad +=   '<param name="movie" value="' + google_ad.image_url + '" />';
            ad +=   '<param name="quality" value="high" />';
            ad +=   '<param name="AllowScriptAccess" value="never" />';
            ad +=   '<param name="wmode" value="transparent" />';
            ad += '</object>';
            break;

        // Ad-Type html
        case "html":
            ad += google_ad.snippet;
            break;

       // Ad-Type text
        default:
            ad +=  '<li class="ad"><a class="full" target="_blank" ' + attrib + ' rel="nofollow" href="' + google_ad.url + '" onmousedown="' + logClickFn + ';">';
            ad +=   '<span class="head">' + google_ad.line1 + '</span>';
            ad +=   '<span class="text">' + google_ad.line2 + '</span>';
            ad +=   '<span class="url">' + google_ad.visible_url + '</span>';
            ad +=  '</a></li>'
    }
    
    return ad;
}

