function replace_googleAd(el,html){
	var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
	var newEl = oldEl.cloneNode(false);
		newEl.innerHTML = html;
		oldEl.parentNode.replaceChild(newEl, oldEl);
	return newEl;
}
 
function afcLinks(ads)
{
	var ad1 = '';
	var ad2 = '';
 
	if (ads.length == 0){ return; }
 
	if (ads[0].type == "text") {
		for (i=0; i<ads.length; i++) {
			adLn = '<a target="_blank" style="text-decoration:none; margin-bottom:2px; display:block; width:230px;" href="' + ads[i].url + '" ' + 'onmouseout="window.status=\'\'" ' +
			'onmouseover="window.status=\'перейти на сайт: ' + ads[i].visible_url + '\';return true;" >' +
			'<span style="font-size:12px; font-weight:bold; text-decoration:underline;">' + ads[i].line1 + '</span></a>' +
			'<span style="color:#000000;">' + ads[i].line2 + '<br>' + ads[i].line3 + '</span><br>' +
			'<a target="_blank" style="text-decoration:none; margin-bottom:10px; display:block; width:230px;" href="' + ads[i].url + '" ' + 'onmouseout="window.status=\'\'" ' +
			'onmouseover="window.status=\'перейти на сайт: ' + ads[i].visible_url + '\';return true;" >' +
			'<span style="color:#6f7894; font-size:10px; line-height: 11px; text-decoration:underline;">' + ads[i].visible_url + '</span><br>' +
			'</a>';
 
			if (i < 3) {
				ad1 += adLn;
			} else {
				ad2 += adLn; 
				}
				
			ad_offset++;
		}
	}
		if (document.getElementById('afc_block_1')){ replace_googleAd('afc_block_1',ad1); }
		if (document.getElementById('afc_block_2')){ replace_googleAd('afc_block_2',ad2); }
		
	return;
}

var ad_offset = 0;