function
formatta_testo(w_text)
{
// vocals
w_text = w_text.replace(/…/g, "...");
w_text = w_text.replace(/à/g, "&agrave;");
		w_text = w_text.replace(/à/g,"&agrave;");
		w_text = w_text.replace(/è/g, "&egrave;");
		w_text = w_text.replace(/è/g,"&egrave;");
		w_text = w_text.replace(/ì/g, "&igrave;");
		w_text = w_text.replace(/ì/g,"&igrave;");
		w_text = w_text.replace(/ò/g, "&ograve;");
		w_text = w_text.replace(/ò/g,"&ograve;");
		w_text = w_text.replace(/ù/g, "&ugrave;");
		w_text = w_text.replace(/ù/g,"&ugrave;");

		w_text = w_text.replace(/€/g,"eeuro;");
		w_text = w_text.replace(/€/g,"eeuro;");

		w_text = w_text.replace(/£/g,"epound;");
		w_text = w_text.replace(/£/g,"epound;");

		return w_text;

}

function multa_fede(){
	iniData= new Date(2006,0,1); // data inizio sequenza mesi-1 es. set=8
	oggi= new Date();
	milDif=(oggi-iniData)
	giorni=parseInt(milDif/86400000);
	multa=Math.round(((giorni*350000)/1000000)*100)/100;
	anno=oggi.getFullYear().toString();
        anno=anno.substr(2,2);
        testo=oggi.getUTCDate()+'-'+(oggi.getUTCMonth()+1)+'-'+anno+'<br>totale: '+multa+' milioni &euro;';

if(document.getElementById('multa_fede'))
	document.getElementById('multa_fede').innerHTML = testo;
}

function scambia_multiple (f, g, v, i, tab, type) {
//   viscom = document.getElementById(f).style.display;
//   if(viscom == "none") 
     if(type == 0) 
      {
      document.getElementById(f).style.display = 'block';
      document.getElementById(g).style.display = 'block';
      document.getElementById(v).style.display = 'none';
      document.getElementById(i).style.display = 'none';
      document.getElementById(tab).className = 'form1_tab';
      }
   else
      {
      document.getElementById(v).style.display = 'block';
      document.getElementById(i).style.display = 'block';
      document.getElementById(f).style.display = 'none';
      document.getElementById(g).style.display = 'none';
      document.getElementById(tab).className = 'form2_tab';
      }
}

function scambia (f, g, v, i, type) {
//   viscom = document.getElementById(f).style.display;
//   if(viscom == "none") 
     if(type == 0) 
      {
      document.getElementById(f).style.display = 'block';
      document.getElementById(g).style.display = 'block';
      document.getElementById(v).style.display = 'none';
      document.getElementById(i).style.display = 'none';
      document.getElementById("the_tab").className = 'form1_tab';
      }
   else
      {
      document.getElementById(v).style.display = 'block';
      document.getElementById(i).style.display = 'block';
      document.getElementById(f).style.display = 'none';
      document.getElementById(g).style.display = 'none';
      document.getElementById("the_tab").className = 'form2_tab';
      }
}


//select all
function select_all()
{
var text_val=eval("document.modulo.textarea");
text_val.focus();
text_val.select();
}

/*------------------------------------------------------------------------------*/
/*------------ YOU tube functions for last video -------------------------------*/
/*------------------------------------------------------------------------------*/
function appendScriptTag(scriptSrc, scriptId, scriptCallback) 
	{
	// Remove any old existance of a script tag by the same name
	var oldScriptTag = document.getElementById(scriptId);
	if (oldScriptTag) 
		{
		oldScriptTag.parentNode.removeChild(oldScriptTag);
		}

	// Create new script tag
	var script = document.createElement('script');
	script.setAttribute('src', scriptSrc + '&alt=json-in-script&callback=' + scriptCallback);
	script.setAttribute('id', scriptId);
	script.setAttribute('type', 'text/javascript');
	document.getElementsByTagName('head')[0].appendChild(script);
	};

function listVideos () 
	{
	var queryUrl = 'http://gdata.youtube.com/feeds/api/users/staffgrillo/uploads?orderby=updated&vq=+-eng+-pdt&start-index=1&max-results=1';
	if (queryUrl ) 
		{
		appendScriptTag(queryUrl, 
                         'searchResultsVideoListScript', 
                         'listVideosCallback');
		}
	else 
		{
		alert('Unknown feed type specified');
		}
	};

function listVideosCallback(data) 
	{
	//Funzione modificata da Pier Antonio per la nuova versione del blog
	// Stores the json data returned for later lookup by entry index value
//	jsonFeed_ = data.feed;
	if(document.getElementById('searchResultsVideoList'))
		{
		var resultsTableContainer = document.getElementById('searchResultsVideoList');
		if(resultsTableContainer)
			{
			content = ''; 
			if(data.feed.entry)
				{
				for (var i = 0, entry; entry = data.feed.entry[i]; i++) 
					{
					content += '<h3>I video di beppegrillo.it</h3>' + 
					'<div id="anteprima"><div id="em">' + entry.media$group.media$title.$t.replace(' beppegrillo.it', '') + '</div><a href="http://www.youtube.com/staffgrillo#baseDiv" target="_blank">' +
					'<img src="http://www2.beppegrillo.it/php/overlay_script/video_sidebar_320.php?image=' + entry.media$group.media$thumbnail[3].url + '?time=' + '" alt="' + entry.media$group.media$title.$t.replace(' beppegrillo.it', '') + '"></a></div>';
					}
				}
			resultsTableContainer.innerHTML = content;
			}
		}
	};

function popup(Site)
{
window.open(Site,'PopupName','toolbar=no,statusbar=no,location=no,scrollbars=yes,resizable=yes,width=280,height=220')
}


/* Nasconde in div */
function invisibile(div) {
var a = document.getElementById(div);        
a.style.display = 'none';
}

/*--------------------------------------------------------------------*/
/*----------------------------- AJAX ---------------------------------*/
/*--------------------------------------------------------------------*/
var myRequest = null;
var myDiv = null;
var myElement = null;

function 
CreateXmlHttpReq2(handler) 
	{
	var xmlhttp = null;
	try 
		{
		xmlhttp = new XMLHttpRequest();
		} 
	catch(e) 
		{
		try 
			{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch(e) 
			{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
	xmlhttp.onreadystatechange = handler;
	return xmlhttp;
	} // CreateXmlHttpReq2
function 
myHandler2(the_div) 
	{
    if(myRequest.readyState == 4 && myRequest.status == 200) 
		{
        e = document.getElementById(myDiv);
//alert(myRequest.responseText);
        e.innerHTML = myRequest.responseText;
		//alert(myReload);
		if (myReload)
			{
				document.location.reload(true);	
			}
		}
	}

function 
get_cont(url, the_div, doLocationReload) 
	{
//alert(url);
	myDiv = the_div;
	myReload = doLocationReload;
	myRequest = CreateXmlHttpReq2(myHandler2);
	myRequest.open("GET", url);
	myRequest.send(null);
	}

function creadata() {
function crea() 
{
  for (i = 0; i<crea.arguments.length; i++)
    this[i + 1] = crea.arguments[i];
}

var mesi = new crea('January','February','March',
    'April','May','June','July','August','September',
    'October','November','December');
var date = new Date();
var gg  = date.getDate();
var mese = date.getMonth()+1;
var yy = date.getYear();
var yyyy = (yy < 1000) ? yy + 1900 : yy;

document.write(mesi[mese] + " " + gg + ", " + yyyy);
}

function
countClick(company, company_url, from) 
        {
        var elImage = document.createElement('img');
        elImage.setAttribute('id', 'count_' + parseInt(Math.random()*99999999));
        elImage.setAttribute('alt', '');
        elImage.setAttribute('src', 'http://www.beppegrillo.it/en//count_click.php?company=' + company + '&company_url=' + company_url + '&from=' + from + '&cb=' + parseInt(Math.random()*99999999));
        elImage.style.display = 'none';
        document.body.appendChild(elImage);
        return true;
        } // countClick

/****
* Banner Ad Rotater v3.02
* Anarchos > anarchos3@hotmail.com
* http://anarchos.xs.mw/bannerad.phtml
**/

function Banner(refreshTime, width, height, altText, start, random){
	this.objName = "bannerAd" + (Banner.count++);
	eval(this.objName + "=this");
	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;
	if (!width) this.width = 776; else this.width = width;
	if (!height) this.height = 44; else this.height = height;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.ads = [];
	if (start) this.currentAd = start-1; else start = null;
	this.mySize = 0;

	this.Ad = function(src, href, target, mouseover) {
		var tempImage = new Image();
		tempImage.src = src;
		this.ads[this.mySize] = new Object();
		var ad = this.ads[this.mySize];
		ad.src = src;
		if (typeof(target) == "undefined" || target == null) ad.target = "_self"; else ad.target = target;
		ad.href = href;
		ad.mouseover = mouseover;
		this.mySize++;
	}

	this.link = function(){
		var	ad = this.ads[this.currentAd];
		if (ad.target == "_self"){
			location.href = ad.href;
		}
		else if (ad.target == "_blank" || ad.target == "_new"){
			open(ad.href,this.objName + "Win");
		}
		else top.frames[ad.target].location.href = ad.href;
	}

	this.showStatus = function(){
		var ad = this.ads[this.currentAd];
		if (ad.mouseover) status = ad.mouseover;
		else status = ad.href;
	}

	this.randomAd = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentAd);
		this.currentAd = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentAd == null) this.randomAd();
			if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1;
			tempCode = '<a href="javascript:'+this.objName+'.link();"';
			tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
			tempCode += ' onMouseOut="status=\'\';return true">';
			tempCode += '<img src="' + this.ads[this.currentAd].src + '" width="' + this.width;
			tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
			if (this.altText) tempCode += 'alt="'+this.altText + '" ';
			tempCode += 'border="0" /></a>';
			document.write(tempCode);
			this.nextAd();
		} else document.write("Error: two banners must be defined for the script to work.");
	}

	this.newAd = function(){
		if (!this.random){	
			this.currentAd++;
			if (this.currentAd >= this.mySize)
			   this.currentAd = 0;
		}
		else {
			this.randomAd();
		}
		this.nextAd();
	}

	this.nextAd = function(){
		document.images[this.objName+ 'Img'].src = this.ads[this.currentAd].src;
		setTimeout(this.objName+'.newAd()',this.refreshTime)
	}
}
Banner.count = 0;
