// Google Ads

function google_ad_request_done(google_ads) {

	if (google_ads.length == 0) {
		// We can probably do some third party ad serving at this point
		if (fa_category_name) {
			document.write('<script src="http://ads.funadvice.com/index.php?section=serve&id=40&keyword=' + fa_category_name + '&output=js"></script>');
		}
		return;
	}

	if (google_ads[0].type == 'flash') {
		g_display_flash(google_ad);
	} else if (google_ads[0].type == 'image') {
		g_display_image(google_ad);
	} else if (google_ads[0].type == 'html') {
		g_display_html(google_html);
	} else if (google_ads.length > 0) {
		g_display_text_ads(google_ads);
	}
}

// Display a single text ad
function g_display_text_ad(ad) {

	var html = '<div class="g_ad">';
	html += '<a target="_blank" href="' + ad.url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + ad.visible_url + '\'; return true"><b>' + ad.line1 + '</b></a><br/>';

	if (join_lines) {
		html += '<div class="g_ad_lines">' + ad.line2 + ' ' + ad.line3 + '</div>';
	} else {
		html += '<div class="g_ad_lines">' + ad.line2 + '<br/>' + ad.line3 + '</div>';
	}

	html += '<div class="g_ad_domain"><a href="' + ad.url + '" onmouseout="window.status=\'\'" onmouseover="windowstatus=\'go to' + ad.visible_url + '\'; return true">' + ad.visible_url + '</a></div>';
	html += '</div>';

	return(html);
}

// Display a bunch of ads
function g_display_text_ads(ads) {
	var i;
	var out = '';

	// Prepend ads-by-google
	out += '<div class="g_info"><a href="' + google_info.feedback_url + '\">Ads by Google</a></div>';

	out += '<div class="g_ad_text">';
	for (i = 0; i < ads.length; i++) {
		out += g_display_text_ad(ads[i], join_lines);
	}
 
	out += '</div>';
	document.write(out);
}


