function split_word(word, tonken_len) {
	if (typeof word == 'undefined') return "";
	var split_word = "";
	var buffer = "";
	for (j = 0; j < word.length; j++) {
		if (typeof word[j] != 'undefined') buffer = buffer + word[j];
		if (buffer.length >= tonken_len) {
			split_word = split_word + " " + buffer;
			buffer = "";
		}
	}
	if (buffer != "") split_word = split_word + " " + buffer;
	return split_word;
}

function split_words(orignal_line, maxlen) {
	if (typeof orignal_line == 'undefined') return "";
	var words = orignal_line.split(" ");
	var split_words_line = "";

	for (k = 0; k < words.length; k++) {
		word = words[k];
		if (word.length > maxlen) word = split_word(word, maxlen);
		split_words_line = split_words_line + " " + word;
	}
	return split_words_line;
}

function google_ad_request_done(google_ads) {
	var s = '';
	var i;

	if (google_ads.length == 0) {
		return;
	}

	s += '<div align="center" style="background-color: #f0f0f0;height:14px;vertical-align:middle;font-size:10px;font-family:Verdana,Arial,Helvetica,sans-serif;font-weight: normal; text-align:left;padding-left:5px;">' +
        '<a href="' + google_info.feedback_url + '" style="text-decoration:none;color: black;" target="_blank">Annunci Google</a></div>';

	s += '<div style="text-align: left; font-family: verdana,arial,sans-serif;">';

	if (google_ads[0].type == "image") {
		s += '<a href="' + google_ads[0].url +
                  '" target="_blank" title="go to ' + google_ads[0].visible_url +
                  '"><img style="border:none;" src="' + google_ads[0].image_url +
                  '"width="' + google_ads[0].image_width +
                  '"height="' + google_ads[0].image_height + '"/></a>';
	} else {
		for (i = 0; i < google_ads.length; ++i) {
			s += '<div style="border: 0px solid #aaaaaa; margin: 2px; padding: 2px; width: 168px; height: 70px; overflow: hidden;float:left;">';
			s += '<a style="cursor:pointer;cursor:hand;text-decoration:none; " href="' + google_ads[i].url +
             '" onmouseover="window.status=\'vai a ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'" target="_blank">' +
             '<span style="color:#0066CC;font-weight: bold;font-size:10px;text-decoration:underline">' + google_ads[i].line1 + '<br></span></a>' +
             '<span style="color:#000000;font-size:10px">' + split_words(google_ads[i].line2 + '. ' + google_ads[i].line3, 15) + '<br></span>' +
			 '<a style="cursor:pointer;cursor:hand;text-decoration:none; " href="' + google_ads[i].url +
             '" onmouseover="window.status=\'vai a ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'" target="_blank">' +
             '<span style="color:#818181;font-size:10px">' + google_ads[i].visible_url + '</span>' +
             '</a></div>';
		}

		if (google_ads[0].bidtype == "CPC") {
			if (typeof google_adnum != "undefined") {
				google_adnum += google_ads.length;
			}
		}
	}

	s += '</div>';

	document.write(s);
	return;
}

//google_ad_client = 'pub-2692991493106558'; 
google_ad_output = 'js';
google_max_num_ads = '4';
google_feedback = 'on';
google_encoding = 'utf8';
google_ad_type = 'text';
//google_language = 'it';
//google_adtest = 'on';

if (typeof google_adnum != "undefined") {
	google_skip = google_adnum;
}
