﻿// Default methods used for all markets:
//		Title - hyperlink
//		Description line 1
//		Description line 2 (if available)
//		Visible link - hyperlink

// Method that handles normal ads request (old ads)
function google_ad_request_done(google_ads) {
	// This function is mandatory and is used for displaying ads that are returned via the JavaScript-request
	var s = '';
	var i;

	// Check that ads for display are available.
	if (google_ads.length == 0) {
		return;
	}
	s += '<div class="panel textAlignLeft specialGoogleAds">';
	// Print "Ads By Google" -- include link to Google feedback page
	s += '<div class="adsByGoogle"><a href="' + google_info.feedback_url + '">' + AD_AdsByGoogle + '</a></div>';

	/*
	* If an Image-Ad is returned, it will be shown.
	* Otherwise create a string, that contains all ads, and
	* print this string using the "document.write()"-command.
	*/

	if (google_ads[0].type == "image") {
		s += '<a href="' + google_ads[0].url +
					'" target="_top" title="' + AD_GoToText + ' ' + google_ads[0].visible_url +
					'"><img src="' + google_ads[0].image_url +
					'"width="' + google_ads[0].image_width +
					'"height="' + google_ads[0].image_height + '"/></a>';
	} else {
		s += '<div class="textAds">';

		/*
		* Add every text-advertisment to the string.
		*/
		for (i = 0; i < google_ads.length; i++) {
			s += '<div class="googleAdLink" onmouseover="this.className=\'googleAdLinkHover\';" onmouseout="this.className=\'googleAdLink\';">' +
						'<a class="googleAdLink" target="_blank" href="' + google_ads[i].url +
						'" onmouseover="this.className=\'googleAdLinkHover\';window.status=\'' + AD_GoToText + ' ' + google_ads[i].visible_url + '\'" onmouseout="this.className=\'googleAdLink\';window.status=\'\';">' +
						'' + google_ads[i].line1 + '</a><br>' +
						'<span class="description">' + google_ads[i].line2 + (typeof (google_ads[i].line3) != 'undefined' ? ' ' + google_ads[i].line3 : '') + '</span><br>' +
						'<a class="url" target="_blank" href=' + google_ads[i].url + '>' + google_ads[i].visible_url + '</a></div>';
		}

		s += '</div>';
	}
	s += '</div>';

	document.write(s);
	return;
}

// Method that handles AFS ads requests (new ads)
function google_afs_request_done(google_ads) {
	// This function is mandatory and is used for displaying ads that are returned via the JavaScript-request
	var s = '';
	var i;

	// Check that ads for display are available.
	if (google_ads.length == 0) {
		return;
	}

	// Check extra texts
	if (typeof (AFS_AdsByGoogle) == 'undefined') AFS_AdsByGoogle = "Ads by Google";
	if (typeof (AFS_GoToText) == 'undefined') AFS_GoToText = "Go to";
	
	s += '<div class="panel textAlignLeft specialGoogleAds">';
	// Print "Ads By Google" -- include link to Google feedback page
	s += '<div class="adsByGoogle"><a href="http://services.google.com/feedback/online_hws_feedback">' + AFS_AdsByGoogle + '</a></div>';

	/*
	* If an Image-Ad is returned, it will be shown.
	* Otherwise create a string, that contains all ads, and
	* print this string using the "document.write()"-command.
	*/

	if (google_ads[0].type == "image") {
		s += '<a href="' + google_ads[0].url +
					'" target="_top" title="' + AFS_GoToText + ' ' + google_ads[0].visible_url +
					'"><img src="' + google_ads[0].image_url +
					'"width="' + google_ads[0].image_width +
					'"height="' + google_ads[0].image_height + '"/></a>';
	} else {
		s += '<div class="textAds">';

		/*
		* Add every text-advertisment to the string.
		*/
		for (i = 0; i < google_ads.length; i++) {
			s += '<div class="googleAdLink" onmouseover="this.className=\'googleAdLinkHover\';" onmouseout="this.className=\'googleAdLink\';">' +
						'<a class="googleAdLink" target="_blank" href="' + google_ads[i].url +
						'" onmouseover="this.className=\'googleAdLinkHover\';window.status=\'' + AFS_GoToText + ' ' + google_ads[i].visible_url + '\'" onmouseout="this.className=\'googleAdLink\';window.status=\'\';">' +
						'' + google_ads[i].line1 + '</a><br>' +
						'<span class="description">' + google_ads[i].line2 + (typeof (google_ads[i].line3) != 'undefined' ? ' ' + google_ads[i].line3 : '') + '</span><br/>' +
						'<a class="url" target="_blank" href=' + google_ads[i].url + '>' + google_ads[i].visible_url + '</a></div>';
		}

		s += '</div>';
	}
	s += '</div>';

	document.write(s);
	return;
}