// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

// Banner in alto a sx
document.write('<div style="float: left; position: absolute; left: 0px; top: 0px; z-index: 1"> <a href="http://www2.beppegrillo.it/iniziative/free_tibet_eng.php" ><img src="http://www2.beppegrillo.it/iniziative/immagini/banner_TIBET_eng.png" border="0"></a> </div>');






function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
        (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    if (f.author != undefined)
       setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    if (f.email != undefined)
       setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    if (f.url != undefined)
       setCookie('mtcmthome1', f.url.value, now, '/', '', '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome1', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

var commenter_name;

function individualArchivesOnLoad(commenter_name) {

    hideDocumentElement('trackbacks-info');



    if (document.comments_form) {
        if (document.comments_form.email != undefined &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (document.comments_form.author != undefined &&
            (mtcmtauth = getCookie("mtcmtauth")))
            document.comments_form.author.value = mtcmtauth;
        if (document.comments_form.url != undefined && 
            (mtcmthome1 = getCookie("mtcmthome1")))
            document.comments_form.url.value = mtcmthome1;
        if (mtcmtauth || mtcmthome1) {
            document.comments_form.bakecookie.checked = true;
        } else {
            document.comments_form.bakecookie.checked = false;
        }
    }
}

function writeTypeKeyGreeting(commenter_name, entry_id) {

}



var __MTTBLINK__;
var __MTTBID__;
function obfuscator(coded, key, mode, path, hidden) {
	shift = coded.length;
	link = "";
	
	for(i=0;i<coded.length;i++) {
		if (key.indexOf(coded.charAt(i))==-1) {
			ltr = coded.charAt(i);link+=(ltr);
		} else {
			ltr = (key.indexOf(coded.charAt(i)) - shift + key.length) % key.length;
			link += (key.charAt(ltr));
		}
	}
	if(mode == 'hidden_input') {
		document.write('<input type="hidden" name="CCode" value="' + link + '" />');
	} else if(mode == '__MTTBLINK__') {
		__MTTBLINK__ = path + link;
		if(hidden) return;
		document.write(link);
	} else if(mode == '__MTTBID__') {
		__MTTBID__ = link;
		if(hidden) return;
		document.write(link);
	}
}

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>Just:<br><span class="timer"> '+giorni+' days<br> '+ore+' hours<br> '+minuti+' minutes<br> '+secondi+' seconds </span><br>to the pensions of the  parliamentarians</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;
setTimeout("countdown()",1000);
}

//cambia overlay
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);
}

// 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].innerHTML = "<div class='img_post'><span class='guarda_video'><img src='" + img_src + "' width='400' /></span><span class='guarda_video'>" + overlay + "</span></div>";

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

// 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);
