function replace_googleAd(el,html){
	var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
	if (html!="") {
	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") {
		adClr = '<div style="clear:both"></div>';
		for (i=0; i<ads.length; i++) {
			adLn = '<div class="goo-ads-con"><a target="_blank" style="text-decoration:none; margin-bottom:2px; display:block" href="' + ads[i].url + '" ' + 'onmouseout="window.status=\'\'" ' +
			'onmouseover="window.status=\'перейти на сайт: ' + ads[i].visible_url + '\';return true;" >' +
			'<span>' + ads[i].line1 + '</span></a>' +
			'<span>' + ads[i].line2 + '&nbsp;' + 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:#b2b2b2; font-size:12px; line-height: 10px; text-decoration:underline;">' + ads[i].visible_url + '</span><br>' +
			'</a></div>';
			
 
			if (i < 2) {
				ad1 += adLn;
				if(i == 1  || 1 == ads.length){
					ad1 += adClr;
				}
			} else{
				ad2 += adLn;
				if((i+1)%2 == 0 || (i+1) == ads.length){
					ad2 += adClr;				
				}				
			}
			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;
