var google_adnum = 0;
function format_flash(info, ad){
	return '<a href=\"' + info.feedback_url + '\" style="color:000000; font-weight:bold;">Ads by Google</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="' +
		ad.image_width + '" HEIGHT="' +
		ad.image_height + '"> <PARAM NAME="movie" VALUE="' +
		ad.image_url + '">' +
		'<PARAM NAME="quality" VALUE="high">' +
		'<PARAM NAME="AllowScriptAccess" VALUE="never">' +
		'<EMBED src="' +
		ad.image_url + '" WIDTH="' +
		ad.image_width + '" HEIGHT="' +
		ad.image_height +
		'" TYPE="application/x-shockwave-flash"' +
		' AllowScriptAccess="never" ' +
		' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
}
function format_image(info, ad){
	return '<a href=\"' + info.feedback_url + '\" style="color:000000; font-weight:bold;">Ads by Google</a><br> <a href="' +
		ad.url + '" target="_top" title="go to ' +
		ad.visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		ad.visible_url + '\';return true"><img border="0" src="' +
		ad.image_url + '"width="' +
		ad.image_width + '"height="' +
		ad.image_height + '"></a>';
}
function format_line(obj){
	return '<li><a href="' + obj.url + '">' +
		'<span class="gad_title">' + obj.line1 + '</span>' +
		'<span class="gad_url">' + obj.visible_url + '</span></a>' +
		'<span class="gad_text">' + obj.line2 + '&nbsp;' + obj.line3 + '</span>' +
		'</li>';
}
function google_ad_request_done(google_ads) {
	if (google_ads.length == 0) {
		return;
	}
	var s = '';
	if (google_ads[0].type == "flash") {
		s = format_flash(google_info, google_ad);
	} else if (google_ads[0].type == "image") {
		s = format_image(google_info, google_ads[0]);
	} else if (google_ads[0].type == "html") {
		s = google_ads[0].snippet;
	} else {
		s += '<div class="gad" id="'+target_id+'"><p><a href=\"' + google_info.feedback_url + '\">Ads by Google</a></p><ul>';
		for( var i=0, len=google_ads.length; i<len; i++ ){
			s += format_line(google_ads[i]);
		}
		s += "</ul></div>";
		if (google_ads[0].bidtype == "CPC") {  /* insert this snippet for each ad call */
			google_adnum += google_ads.length;
		}
	}
	document.write(s);
}

