// Banner in alto a sx
// document.write('<div style="float: left; position: absolute; left: 0px; top: 0px; z-index: 1"> <a href="http://www.beppegrillo.it/tour.php" ><img alt="DVD Delirio Tour 2008-2009" src="http://www.beppegrillo.it/immagini/banner_delirio.gif" /></a> </div>');


// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

/*
function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle        
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
         }
      }
   }
window.attachEvent("onload", correctPNG);
*/


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';
      }
}


function countdown(){
	iniData= new Date(2008,9,28,0,0,0); // data inizio sequenza mesi-1 es. set=8
	oggi= new Date();
	//oggi.setHours(1,1,1,0) ;
	iniDataIt=iniData.getDate()+'-'+(iniData.getMonth()+1)+'-'+iniData.getFullYear()+' '+iniData.getHours()+':'+iniData.getMinutes()+':'+iniData.getSeconds();
	milDif=(iniData-oggi)
	giorni=parseInt(milDif/86400000);  
	milDif=milDif-(giorni*86400000); //millisecondi restanti talti i giorni
	ore=parseInt(milDif/3600000);
	milDif=milDif-(ore*3600000); //millisecondi restanti talti i giorni
	minuti=parseInt(milDif/60000);
	milDif=milDif-(minuti*60000); //millisecondi restanti talti i giorni
	secondi=parseInt(milDif/1000);
	milDif=milDif-(secondi*1000); //millisecondi restanti talti i giorni
	testo=' <div class="span3"><br><br>Mancano solo:<br><span class="timer"> '+giorni+' giorni<br> '+ore+' ore<br> '+minuti+' minuti<br> '+secondi+' secondi </span><br>alla pensione dei parlamentari</div>';
	testo2=' <div class="span4"><br>Mancano solo:<br><span class="timer2"> '+giorni+' giorni<br> '+ore+' ore<br> '+minuti+' minuti<br> '+secondi+' secondi </span><br>alla pensione dei parlamentari</div>';
	//alert(testo); //commentare
	//return testo
/*
	if (document.layers && document.layers.span1){
		document.layers.span1.document.write(testo);
		document.layers.span1.document.close();
                    	}else if (document.all && span1){
		span1.innerHTML=testo;                
	}
*/
if(document.getElementById('span1'))
      document.getElementById('span1').innerHTML = testo;

if(document.getElementById('span2'))
      document.getElementById('span2').innerHTML = testo2;

//setTimeout("countdown()",1000);

}




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


//cambia immagine per cliccare il video
function change_overlay()
{
url = document.location.href;
if (url.search('/eng/') != -1)
	{
	overlay = "<img src='http://www.beppegrillo.it/eng/immagini_blog/guarda_video.png'>";
	}
else if (url.search('/japanese/') != -1)
	{
	overlay = "<img src='http://www.beppegrillo.it/jap/immagini_blog/guarda_video.png'>";
	}
else if (url.search('/jap/') != -1)
	{
	overlay = "<img src='http://www.beppegrillo.it/jap/immagini_blog/guarda_video.png'>";
	}
else
	{
	overlay = "<img src='http://www.beppegrillo.it/immagini_blog/guarda_video.png'>";
	}
document.write(overlay);
}


/*------------------------------------------------------------------------------*/
/*------------ 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=published&vq=grillo+-pdt+-eng&start-index=1&max-results=1';
	if (queryUrl ) 
		{
		appendScriptTag(queryUrl, 
                         'searchResultsVideoListScript', 
                         'listVideosCallback');
		}
	else 
		{
		alert('Unknown feed type specified');
		}
	};

function listVideosCallback(data) 
	{
	// 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 += '<center><font size=2 color=#66667f><strong>' + entry.media$group.media$title.$t.replace(' beppegrillo.it', '') + '</strong></font></center><div style="width:181px; height:130px; position:relative; cursor:pointer; margin-bottom;5px">' + 
					'<span style="margin:0px ; position:absolute;">' + 
					'<a href="http://www.youtube.com/staffgrillo" target="_blank"><img src="http://www.beppegrillo.it/immagini/ultimovideo.jpg" /></a>' + 
					'</span>' + 
					'<span style="margin:3px 25px ; position:absolute;">' +
					'<a href="http://www.youtube.com/staffgrillo" target="_blank">' +
					'<img src="' + entry.media$group.media$thumbnail[0].url + '" target="_blank">' +
					'</span>' + 
					'<span style="position:absolute; z-index:50; margin-top:2px; margin-left:5px">' + 
					'<img src="http://www.beppegrillo.it/immagini/immagini/NUOVO_youtube.gif" width="58" height="58" >' + 
					'</span>' + 
					'</div>';
					}
				}
			resultsTableContainer.innerHTML = content;
			}
		}
	};
/*
// cambia immagine per cliccare il video
function 
cliccavideo()
	{
	var allPageTags=document.getElementsByTagName("a");
	for (i=0; i<allPageTags.length; i++) 
		{ 
		//Pick out the tags with our class name
		if(allPageTags[i].className && allPageTags[i].className=='link_youtube') 
			{
			movie = allPageTags[i].href;
			content = allPageTags[i].innerHTML;
			start = -1;
			end = -1;
			if((start = content.indexOf('alt="', 0)) != -1)
				{
				start += 5;
				end = content.indexOf('"', start);
				}
			else
			if((start = content.indexOf("alt='", 0)) != -1)
				{
				start += 5;
				end = content.indexOf("'", start);
				}
			else
			if((start = content.indexOf("alt=", 0)) != -1)
				{
				start += 4;
				end = content.indexOf(" ", start);
				}
			img_alt = start != -1 && end != -1 ? content.substring(start, end) : "";

			start = -1;
			end = -1;
			if((start = content.indexOf('src="', 0)) != -1)
				{
				start += 5;
				end = content.indexOf('"', start);
				}
			else
			if((start = content.indexOf("src='", 0)) != -1)
				{
				start += 5;
				end = content.indexOf("'", start);
				}
			else
			if((start = content.indexOf("src=", 0)) != -1)
				{
				start += 4;
				end = content.indexOf(" ", start);
				}
			img_src = start != -1 && end != -1 ? content.substring(start, end) : "";


	url = document.location.href;
	var overlay = "";	
	if (url.search('/eng/') != -1)
	
	{
	overlay = "<img alt=" + img_alt + " src='http://www.beppegrillo.it/eng/immagini_blog/guarda_video.png'>";
	}
	else if (url.search('/japanese/') != -1)
	{
	overlay = "<img alt=" + img_alt + " src='http://www.beppegrillo.it/jap/immagini_blog/guarda_video.png'>";
	}
	else if (url.search('/jap/') != -1)
	{
	overlay = "<img alt=" + img_alt + " src='http://www.beppegrillo.it/jap/immagini_blog/guarda_video.png'>";
	}
	else
	{
	overlay = "<img alt=" + img_alt + " src='http://www.beppegrillo.it/immagini_blog/guarda_video.png'>";
	}

			//Manipulate this in whatever way you want 
allPageTags[i].parentNode.innerHTML = "<table width=400 height=320 border=0 cellspacing=0 cellpadding=0><tr><td style='background-image: url(" + img_src + ");background-repeat: no-repeat'><a href=" + movie + " target='_blank'>" + overlay + "</a></td></tr></table>";
//allPageTags[i].href = "#";
//allPageTags[i].target = "_self";
	
		}
		}
	};*/
