var arrTopAds = new Array();
var arrBottomAds = new Array();

var skip_ads_cnt = 0;

function google_ad_request_done(google_ads)
{
		if(google_ads.length == 0){
			return;				
		}

		var iTop = 0;
		var iBottom = 0;
									
		for(i=0;i < google_ads.length; ++i){
			if(i < 5){
				arrTopAds[iTop] = google_ads[i];iTop++;
			}else{
				arrBottomAds[iBottom] = google_ads[i];iBottom++;}
		}
		
		skip_ads_cnt = google_ads.length;

		return;
}

function google_afs_request_done(google_ads)
{
	google_ad_request_done(google_ads)
}


function showTopAdLine()
{
		var arrAds = arrTopAds;
		var s;
		
		if(arrAds.length>0){
			if (arrTopAds[0].type == "image"){
	
					s = '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="inseratcontainer">';
					s += '<tr>';
					s += '<td>';
					s += '<a href="' + arrTopAds[0].url + '" target="_blank" title="go to ' + arrTopAds[0].visible_url + '"><img style="border:none;" src="' + arrTopAds[0].image_url + '" width="' + arrTopAds[0].image_width + '" height="' + arrTopAds[0].image_height + '"></a>';
					s += '</td></tr>';
					s += '</table>';
			}else{
				s = '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="inseratcontainer">';
				s += '<tr>';
				s += '<td>';
				s += '<table border=0 cellpadding=0 cellspacing=0 width=100%>';
				s += '<tr><td width="100%" align="left"><a style="font-size:12px;color:#000000;cursor:pointer;cursor:hand;text-decoration:none;" href="http://services.google.com/feedback/online_hws_feedback">Google Anzeigen</a></td></tr>';
				s += '<tr height=1><td bgcolor="#008200"></td></tr>';
				
				for(i=0; i < arrAds.length; ++i){
						s += tplAdLineMiddle(arrAds[i], i);
				}
				
				s += '</table>';
				s += '</td>';
				s += '</tr>';
				s += '</table>';
			}
			$('#adsLineTop').html(s);
		}
}


function showBottomAdLine()
{
		var arrAds = arrBottomAds;
		var s;

		if(arrAds.length>0){
			s = '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="inseratcontainer">';
			s += '<tr>';
			s += '<td>';
			s += '<table border=0 cellpadding=0 cellspacing=0 width=100%>';
			s += '<tr><td width="100%" align="left"><a style="font-size:12px;color:#000000;cursor:pointer;cursor:hand;text-decoration:none;" href="http://services.google.com/feedback/online_hws_feedback">Google Anzeigen</a></td></tr>';
			s += '<tr height=1><td bgcolor="#008200"></td></tr>';
			
			for(i=0; i < arrAds.length; ++i){
					s += tplAdLineMiddle(arrAds[i], i);
			}
			
			s += '</table>';
			s += '</td>';
			s += '</tr>';
			s += '</table>';
			
			$('#adsLineBottom').html(s);
		}
}



function tplAdLineMiddle(arrAdLine, id)
{
	var s;
	s = '<tr height="48" onmouseover="this.style.backgroundColor=\'#E9FFE9\';document.getElementById(\'bottom'+id+'\').style.color=\'#FF0000\';window.status=\'gehe zu ' + arrAdLine.visible_url + '\'" onmouseout="this.style.backgroundColor=\'#FFFFFF\';document.getElementById(\'bottom'+id+'\').style.color=\'#0000CC\';window.status=\'\'">';
	s += '<td width="100%" style="background-image:url(http://' + window.location.hostname + '/images/line.gif);background-position:bottom;background-repeat:repeat-x;" align="left" valign="middle"><a id="bottom'+id+'" style="font-size:17px;color:#0000cc;cursor:hand;text-decoration:underline" href="' + arrAdLine.url +
			'" target="_blank" onmouseover="window.status=\'gehe zu ' + arrAdLine.visible_url + '\'" onmouseout="window.status=\'\'"><b>' + arrAdLine.line1 + '</b></a>';

	s += '<font style="font-size:13px;color:#000;text-decoration:none" >&nbsp;&nbsp;' + arrAdLine.line2 + '&nbsp;</font>';

	s += '<font style="font-size:13px;color:#000;text-decoration:none" >' + arrAdLine.line3 + '&nbsp;</font>';

	s += '<nobr><a style="font-size:13px;color:#666666;cursor:pointer;cursor:hand;text-decoration:none" href="' + arrAdLine.url +
			'" target="_blank" onmouseover="window.status=\'gehe zu ' + arrAdLine.visible_url + '\'" onmouseout="window.status=\'\'">' + arrAdLine.visible_url + '</a></nobr>';

	s += '</td></tr>';
	
	return s;
}
