var googleAdBlocks = new Array();
var googleAds = new Array();
var googleCurAdPos = 0;
var googleNumAds = 0;
var googleIsXML = false;

var googleNumAiduAds = 0;

//Wird von Google aufgerufen und übergibt die Ads
function google_ad_request_done(google_ads) {

	googleAds = google_ads;

}

//Fügt einen neuen Ad-Block hinzu
function googleAddAdBlock(googleBlockAdId, googleBlockNumAds, googleBlockAdDisplayModus) {
	googleAdBlocks[googleAdBlocks.length] = new Array();

	googleAdBlocks[googleAdBlocks.length-1]['googleAdId']			= googleBlockAdId;
	googleAdBlocks[googleAdBlocks.length-1]['googleNumAds']			= googleBlockNumAds;
	googleAdBlocks[googleAdBlocks.length-1]['googleAdDisplayModus']	= googleBlockAdDisplayModus;

	googleNumAds+= googleBlockNumAds;
}

//Schreibt alle Ad-Blöcke
function googleWriteAds() {
	for(var i = 0; i < googleAdBlocks.length; i++) {
		googleWriteAdBlock(googleAdBlocks[i].googleAdId, googleAdBlocks[i].googleNumAds, googleAdBlocks[i].googleAdDisplayModus);
	}
}

//Schreibt einen Ad-Block
function googleWriteAdBlock(googleBlockAdId, googleBlockNumAds, googleBlockAdDisplayModus) {
	var adString = '';
	var i;

	if (googleAds.length == 0) {
		return;
	}

	if (googleAds[0].type == "image") {

		adString += '<a href="' + googleAds[0].url + '" target="_top" title="go to ' + googleAds[0].visible_url + '"><img border="0" src="' + googleAds[0].image_url + '"width="' + googleAds[0].image_width + '"height="' + googleAds[0].image_height + '"></a>';

	} else {

		googleBlockNumAds+= googleCurAdPos;
		//adString += '<div style="text-align:right;font-weight:bold;font-size:10px">Google Anzeigen</div>';

		switch(googleBlockAdDisplayModus) {

			case "footer":

				adString+= '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
				for(i = googleCurAdPos; i < googleAds.length && i < googleBlockNumAds; i++) {

					adString+=
					'<tr onmouseover="this.style.backgroundColor=\'#E5ECF9\';"  onmouseout="this.style.backgroundColor=\'#F5F7FD\';">' +
						'<td>' +
							'<div class="google_adsense_anzeigen">' +
								'<a href="' + googleAds[i].url + '" onmouseover="self.status=\'' + googleAds[i].visible_url + '\'; return true;" onmouseout="self.status=\'\'; return true;" target="_blank">' +
									'<span class="head">';
										if(googleIsXML == false) adString+= '<strong>';
										adString+= googleAds[i].line1;
										if(googleIsXML == false) adString+= '</strong>';
									adString+= '</span><br>' +
									'<span class="text">' + googleAds[i].line2 + ' ' + googleAds[i].line3 + '</span><br>' +
									'<span class="url">' + googleAds[i].visible_url + '</span></a>' +
								'</a>' +
							'</div>' +
						'</td>' +
					'</tr>';
					if((googleAds.length - 1) != i && (googleBlockNumAds - 1) != i) adString+= '<tr><td background="/img/pt/dot_google.gif" style="padding:0px; height:1px;"></td></tr>';

				}
				adString+= '</table>';

				break;

			case "skyscraper":

				adString+= '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
				//if(googleCurAdPos < googleAds.length) adString+= '<tr><td style="padding-right:5px;" align="right"><small>Anzeigen</small></td></tr>'
				for(i = googleCurAdPos; i < googleAds.length && i < googleBlockNumAds; i++) {

					adString+=
					'<tr onmouseover="this.style.backgroundColor=\'#F5F7FD\';"  onmouseout="this.style.backgroundColor=\'#EEF2F7\';">' +
						'<td style="padding:5px;">' +
							'<div class="google_adsense_anzeigen">' +
								'<a href="' + googleAds[i].url + '" onmouseover="self.status=\'' + googleAds[i].visible_url + '\'; return true;" onmouseout="self.status=\'\'; return true;" target="_blank">' +
									'<span class="head2">';
										if(googleIsXML == false) adString+= '<strong>';
										adString+= googleAds[i].line1;
										if(googleIsXML == false) adString+= '</strong>';
									adString+= '</span><br>' +
									'<span class="text">' + googleAds[i].line2 + ' ' + googleAds[i].line3 + '</span><br>' +
									'<span class="url">' + googleAds[i].visible_url.substr(0, 20) + '</span></a>' +
								'</a>' +
							'</div>' +
						'</td>' +
					'</tr>';

				}
				adString+= '</table>';

				break;

		}

		googleCurAdPos = i;

	}

	document.getElementById(googleBlockAdId).innerHTML = adString;
	return;
}


function googleWriteAiduAd(googleAiduAdId, googleAiduAdModus, googleAiduAdType, googleAiduAdKeyword, googleAiduAdKeyword2) {

	//Als ersatz ein normaler ad mehr
	googleAddAdBlock(googleAiduAdId, 1, 'footer');

	/*var googleAiduAd = new Array();
	var adString = false;

	googleNumAiduAds+= 1;

	switch(googleAiduAdModus) {

		case "regio":

			googleAiduAd['title']		= googleAiduAdType + ' ' + googleAiduAdKeyword;
			googleAiduAd['text']		= 'Buchen Sie hier bis zu 50% billiger durch den Preisvergleich aller großen Reiseveranstalter!';
			googleAiduAd['visible_url']	= 'www.AIDU.de/' + googleAiduAdType + '-' + googleAiduAdKeyword.replace(/ /, '-');
			googleAiduAd['url']			= 'http://www.aidu.de/' + googleAiduAdType + '-' + googleAiduAdKeyword.replace(/ /, '-') + '.html';
			break;

		case "hotel":

			googleAiduAd['title']		= googleAiduAdKeyword + ' billig buchen';
			googleAiduAd['text']		= 'Sparen Sie bei Ihrer ' + googleAiduAdKeyword + ' Buchung bis zu 50% durch den Vergleich aller großen Veranstalter!';
			googleAiduAd['visible_url']	= 'www.AIDU.de/' + googleAiduAdKeyword.replace(/ /, '-');
			if(googleAiduAdType == 'TT') { //Traveltainment
				googleAiduAd['url']		= 'http://www.aidu.de/hotel-' + googleAiduAdKeyword.replace(/ /, '-') + '.html';
			} else { //Travelnow
				googleAiduAd['url']		= 'http://www.aidu.de/hotels-' + googleAiduAdKeyword2.replace(/ /, '_') + ',' + googleAiduAdKeyword.replace(/ /, '_') + '.htm';
			}
			break;

		default:
		case "normal":

			googleAiduAd['title']		= googleAiduAdType + ' bis zu 50% billiger';
			googleAiduAd['text']		= 'Sparen Sie bei Ihrer Reise bis zu 50% durch den kostenlosen Preisvergleich aller großen Veranstalter!';
			googleAiduAd['visible_url']	= 'www.AIDU.de/' + googleAiduAdType;
			googleAiduAd['url']			= 'http://www.aidu.de/';
			break;

	}

	adString=
	'<table border="0" cellpadding="5" cellspacing="0" width="100%">' +
		'<tr onmouseover="this.style.backgroundColor=\'#E5ECF9\';"  onmouseout="this.style.backgroundColor=\'#F5F7FD\';">' +
			'<td>' +
				'<div class="google_adsense_anzeigen">' +
					'<a href="' + googleAiduAd.url + '" onmouseover="self.status=\'' + googleAiduAd.visible_url + '\'; return true;" onmouseout="self.status=\'\'; return true;" target="_blank">' +
						'<img src="/img/ic/tipp_ad.gif" align="absmiddle" border="0"> <span class="head"><strong>' + googleAiduAd.title + '</strong></span><br>' +
						'<span class="text">' + googleAiduAd.text + '</span><br>' +
						'<span class="url"><strong>' + googleAiduAd.visible_url + '</strong></span></a>' +
					'</a>' +
				'</div>' +
			'</td>' +
		'</tr>' +
		'<tr><td background="/img/pt/dot_google.gif" style="padding:0px; height:1px;"></td></tr>' +
	'</table>';

	document.getElementById(googleAiduAdId).innerHTML = adString;*/

}