
// invia link
function popup(ind)
{
 window.open(ind,'InviaLink','width=600,height=350,resizable=yes,scrollbars=no,menubar=no');
}

// vota cellulare
function vota(id)
{
 window.open('/vota_cellulare.php?id=' + id,'Voto','width=500,height=320,scrollbars=no,menubar=no,status=no');
 return false;
}

// AD BY GOOGLE
// This function displays the ad results.
// It must be defined above the script that calls show_ads.js
// to guarantee that it is defined when show_ads.js makes the call-back.
function google_ad_request_done(google_ads) {
    // Proceed only if we have ads to display!
    if (google_ads.length < 1 )
	return '<strong>ciao</strong>';

    var s = '';

    // Display ads here
 
    // Print "Ads By Google" -- include link to Google feedback page if available
    s += '<div style="text-align:left;">';
    
    if (google_info.feedback_url) {
	s += '<a href="' + google_info.feedback_url + '">Annunci Google</a>';
    } else {
	s += 'Annunci Google';
    }
        
    s += '</div>';

    // For an image ad, display the image; there will be only one .
    if (google_ads[0].type == 'image') {
	s += 
	    '<a href="' + google_ads[0].url + '" style="text-decoration: none">' +
	    '<img src="' + google_ads[0].image_url + 
	    '" height="' + google_ads[0].height + 
	    '" width="' + google_ads[0].width +
	    '" border="0"></a><br /><br />';
    } 
    // For text ads, display each ad in turn.
    // In this example, each ad goes in a new row in the table.
    else {
      if (google_ads.length == 1) {
	 s += 
	 '<a style="cursor:pointer;font-size:12pt" onclick="javascript:top.location.href=\'' + google_ads[0].url + '\';" onmouseover="this.style.textDecoration=\'underline\';window.status=\'apri ' + google_ads[0].visible_url + '\';" onmouseout="this.style.textDecoration=\'none\';window.status=\'\';">' +
	 '<strong>' + google_ads[0].line1 + '</strong><br />' +
		google_ads[0].line2 + '&nbsp;' + google_ads[0].line3 + '<br>' +
		'<span style="font-size:12px">' + google_ads[0].visible_url +
		'</span></a><br /><br />';
      } else if (google_ads.length >1) {  
	  s += '<table><tbody>';
	  for(i = 0; i < google_ads.length; ++i) {
	      s += 
		  '<tr>' +
		  '<td><a style="cursor:pointer" onclick="javascript:top.location.href=\'' + google_ads[i].url + '\';" onmouseover="this.style.textDecoration=\'underline\';window.status=\'apri ' + google_ads[i].visible_url + '\';" onmouseout="this.style.textDecoration=\'none\';window.status=\'\';">' +
         '<strong>' + google_ads[i].line1 + '</strong></a></td>' +
		  '<td>' +		  
		  google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '<br>' +
		  '<a style="cursor:pointer" onclick="javascript:top.location.href=\'' + google_ads[i].url + '\';" onmouseover="this.style.textDecoration=\'underline\';window.status=\'apri ' + google_ads[i].visible_url + '\';" onmouseout="this.style.textDecoration=\'none\';window.status=\'\';"><span style="font-size:10px">' + google_ads[i].visible_url +
		  '</span></a></td></tr>';
	  }
	  s += '</tbody></table>';
      }
    }


    // Finish up anything that needs finishing up
    
    document.write(s);
    return;
}


// email oclution: chiamare AEHit alla fine del file con mail da
// nascondere
function econvert(str)
{
    str = str.replace(/%7E/g,'~');
    str = str.replace(/%28/g,'(');
    str = str.replace(/%29/g,')');
    str = str.replace(/_dot_|_\._|\(\.\)/gi, '.');
    str = str.replace(/_at_|~at~/gi, '@');
    str = str.replace('sendmail:','mailto:');
    str = str.replace('sendto:','mailto:');
    str = str.replace('send:','mailto:');
    return str;
}

function AEHit()
{
    var spans = document.getElementById("aehsento");
    if (spans != null) {
	var encremail = spans.innerHTML;
	spans.innerHTML = econvert(encremail);
    }
}   
/* 
   modificare quella cazzo di AEHit() di modo che usi
   getElementByClass("aehsento",document,"span")
   e sostituisca tutte le occorrenze di span class="aehsento"
   inoltre, e piu' importante, modificare il codice html:
   span class="aehsento" e non id="aehsento"
*/

function getElementsByClass(searchClass,node,tag) {
/* codice recuperato da internet, sembra ok */
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}
