function setDateHome(id){
	var espDays = ['Domingo', 'Lunes', 'Martes', 'Mi\u00E9rcoles', 'Jueves', 'Viernes', 'S\u00E1bado'];
	var espMonth = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'];
	var refresh = 20; // numero di secondi per il refresh della data
	
	var today = new Date();
	$(id).update(espDays[today.getDay()] + ' <span>' + today.getDate() + ' de ' + espMonth[today.getMonth()] + ' de ' + today.getFullYear() + ' </span> | ' + today.getHours() + ':' + today.getMinutes() + ' h');
	
	new PeriodicalExecuter(function(){
		var today = new Date();
		$(id).update(espDays[today.getDay()] + ' <span>' + today.getDate() + ' de ' + espMonth[today.getMonth()] + ' de ' + today.getFullYear() + ' </span> | ' + today.getHours() + ':' + today.getMinutes() + ' h');
	}.bind(this), refresh)
}

function truncateTxt(charMax) {
	var objBlocks = $$('div.top_voted > h5');
	var spanTag;
	//var charMax = 50;
	var didascalia = '';
	
	if (charMax == undefined) charMax = 50;
	
	objBlocks.each(function (block){		
		/*if (block.hasClassName('logo')) charMax = 30;
		else charMax = 38;*/
	
		if (block.firstChild != null){
			didascalia = block.firstChild.nodeValue;
			
			if (didascalia.length > charMax)		
				block.update(didascalia.substr(0,didascalia.substr(0,charMax - 4).lastIndexOf(' ') ) + ' ...') ;
		}
	});
}


function checkPubli(){
	/* marzia 2008 02 14 - 
		raccolgo tutti i div che hanno classe che comincia con publi, verifico che non contengano l'immagine empty.gif che rappresenta la pubblicita' vuota. In caso affermativo nascondo il div padre.
	*/
	var elm;
	var emptyImgName = 'empty.gif'; // configurabile

	$A( $$('div[class*=publi] img') ).each(function(oneimg){
		//console.log("oneimg.src=" + oneimg.src + "; oneimg.src.indexOf(emptyImgName)=" + oneimg.src.indexOf(emptyImgName) + " oneimg.up(div)=" + oneimg.up('div'));
		if (oneimg.src.indexOf(emptyImgName) != -1)
			oneimg.up('div').hide();
	});
	
}

function initSlide(){
	var nextfototag = $('nextphoto');
	var prevfototag = $('prevphoto');
	if(imgGallery.length>0 && imgGallery.length != 1){
		prevfototag.className ="prevphoto left disabled";
		prevfototag.innerHTML = "&lt; anterior";
		nextfototag.innerHTML = "<a href=\"javascript:slide('right');\"> siguiente &gt;</a>";
		nextfototag.className = "nextphoto right";
	}
}

function slide(direction){
	/* 2008/03/03 - marzia
		Sostituiti tutti gli innerHtml con update dove possibile e reso lo script prototype oriented in modo da garantire la cross compatibilita' 
	*/
	
	var imgtag = $('imgGalleryId');
	var numfototag = $('numGalleryId');
	var prevfototag = $('prevphoto');
	var spanwidthtag = $('firmaSpanWidth');
	//console.log(imgGalleryPos);
	if (imgGallery.length > 0){
		/* marzia 2008/02/03
			se la lunghezza della gallery e' = 1 nascondo il box con il contatore di foto 
		*/
		if (imgGallery.length == 1) $$('.photocounter')[0].hide();
		
		if (direction =='left'){
			imgGalleryPos--;
			imgtag.width = widthGallery[imgGalleryPos];
			imgtag.src = imgGallery[imgGalleryPos];
			spanwidthtag.style.width = widthGallery[imgGalleryPos] + 'px';
			//numfototag.innerHTML = imgGalleryPos+1;
			numfototag.update((imgGalleryPos + 1) + " de " + imgGallery.length);

			if (urlGallery[imgGalleryPos]=='')
				//spanwidthtag.innerHTML = firmaGallery[imgGalleryPos];
				spanwidthtag.update(firmaGallery[imgGalleryPos]);
			else
				//spanwidthtag.innerHTML = "<a href=\"" + urlGallery[imgGalleryPos] + "\">" + firmaGallery[imgGalleryPos] + "</a>";
				spanwidthtag.update("<a href=\"" + urlGallery[imgGalleryPos] + "\">" + firmaGallery[imgGalleryPos] + "</a>");

			if (imgGalleryPos == 0){
				//prevfototag.innerHTML = "&lt; anterior";
				prevfototag.update("&lt; anterior");
				//prevfototag.className = "prevphoto left disabled";
				prevfototag.addClassName("prevphoto");
				prevfototag.addClassName("left");
				prevfototag.addClassName("disabled");
			}
		}	else {
			imgGalleryPos++;
			//console.log(imgGalleryPos);
			if (imgGalleryPos == imgGallery.length){
				imgGalleryPos = 0;
				/* commentato e sostutito con le funzioni prototype da marzia - 2008/03/03
				prevfototag.className ="prevphoto left disabled";
				prevfototag.innerHTML = "&lt; anterior";
				*/
				prevfototag.addClassName('prevphoto');
				prevfototag.addClassName('left');
				prevfototag.addClassName('disabled');
				prevfototag.update('&lt; anterior');
			}else if (imgGalleryPos == 1){
				/* commentato e sostutito con le funzioni prototype da marzia - 2008/03/03
				prevfototag.innerHTML = "<a href=\"javascript:slide('left');\">&lt; anterior</a> ";
				prevfototag.className = "prevphoto left";*/
				prevfototag.update("<a href=\"javascript:slide('left');\">&lt; anterior</a> ");
				prevfototag.addClassName("prevphoto");
				prevfototag.addClassName("left");
				prevfototag.removeClassName("disabled");
			}
			imgtag.width = widthGallery[imgGalleryPos];
			imgtag.src = imgGallery[imgGalleryPos];
			spanwidthtag.style.width = widthGallery[imgGalleryPos]+"px";
			//$('firmaSpanWidth').setStyle( {width: widthGallery[imgGalleryPos]+'px;'}); 
			
			numfototag.update('Foto' + (imgGalleryPos + 1) + " de " + imgGallery.length);
			//numfototag.innerHTML = imgGalleryPos+1;
			
			//console.log(numfototag.innerHTML );
			
			if (urlGallery[imgGalleryPos] ==''){
				//spanwidthtag.innerHTML = firmaGallery[imgGalleryPos]; 
				spanwidthtag.update(firmaGallery[imgGalleryPos]);
				if($('firmaSpanWidth').empty())
					$('firmaSpanWidth').style.height = '15px';
			}else{
				//spanwidthtag.innerHTML = "<a href=\""+ urlGallery[imgGalleryPos]+"\">"+firmaGallery[imgGalleryPos]+"</a>";
				spanwidthtag.update("<a href=\"" + urlGallery[imgGalleryPos] + "\">" + firmaGallery[imgGalleryPos] + "</a>");
			}
		}
	}
}