//TRASPARENZA PNGvar supersleight=false;//per tutti i browser che visualizzano di default le png//-----------------------------------------------------------------------------------------------------------//ROLLOVER IMGfunction MM_preloadImages() { //v3.0  	var d=document;  	if(d.images){ //controlla che il browser supporti		if(!d.MM_p) {			d.MM_p=new Array();		}		var i;		var j=d.MM_p.length;		var a=MM_preloadImages.arguments; 		for(i=0; i<a.length; i++){			if (a[i].indexOf("#")!=0){ 				d.MM_p[j]=new Image; 				d.MM_p[j++].src=a[i];			}		}	}}sfondo=1;function cambia_sfondo(){	if(sfondo==3){sfondo=1;}else{sfondo++;}	obj=document.getElementById("contenuto");	obj.style.backgroundImage="url(img/sfondo"+sfondo+".gif)";}/*ROLLOVER IMG*/function rollOver(obj, img) {//questa funzione mi serve per passare i parametri senza attivare la funzione	return function() { 		obj.src=img;		//if(supersleight && img.match(/\.png$/i) !== null){		if(supersleight && img.match(/\.png/i) !== null){			supersleight.aggiorna(obj);		}	}}function attiva_rollover(obj){	//l'immagine può essere png o no	//se l'immagine è png è già stata sostituita con shim, quindi percorso, nome, estensione sono diversi	filtro=obj.style.filter;	if(supersleight && filtro){//controllo se esiste filter		//ricavo da qui il nome originale della png		inizio="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='";		src=filtro.substr(inizio.length);		src=src.substr(0, src.indexOf("'"));	}else{		src=obj.getAttribute('src'); //no png o png non su IE	}	/*percorso_img=src.replace(/(.*\/?)[a-zA-Z0-9_-]+\.\w+$/, "$1");	nome_img=src.replace(/.*\/?([a-zA-Z0-9_-]+)\.(\w+)$/, "$1");*/	//nome_img=src.replace(/(.+)\.(\w+)$/, "$1");	nome_img=src.replace(/(.+)\.(\w+)\??[0-9]*$/, "$1");	//estensione_img=src.replace(/.*\/?[a-zA-Z0-9_-]+\.(\w+)$/, "$1");	estensione_img=src.replace(/.*\/?[a-zA-Z0-9_-]+\.(\w+)\??[0-9]*$/, "$1");	//estensione_img=src.replace(/.*\/?[a-zA-Z0-9_-]+\.(\w+\??[0-9]*)$/, "$1");	img_on=nome_img+"_on."+estensione_img;	img_off=nome_img+"."+estensione_img;	//preload, il percorso è relativo alla pagina html	MM_preloadImages(img_on);		//over e ricarico supersleight	Event.observe(obj, 'mouseover', rollOver(obj, img_on));		//out e ricarico supersleight	Event.observe(obj, 'mouseout', rollOver(obj, img_off));}//le immagini di rollover devono avere class img_rollover e lo stesso nome ma con l'aggiunta di _onfunction cerca_rollover(){	if($$('.img_rollover')){		$$('.img_rollover').each(function(obj){			attiva_rollover(obj);		});	}}//-----------------------------------------------------------------------------------------------------------//MENU A TENDINAmenu_aperto=false;function mostra_menu(e){	Event.stop(e);	if(menu_aperto){		new Effect.BlindUp('eventi_sub', {duration:0.5});	}else{		new Effect.BlindDown('eventi_sub', {duration:0.5});	}	menu_aperto=!menu_aperto;}//mostra_menu//-----------------------------------------------------------------------------------------------------------//DOWNLOADfunction login_download(e){	Event.stop(e);	new Ajax.Updater('centro_box_download', 'ricava_download.php',		{			method: 'post',			parameters: $H({'username': $F('username'), 'password': $F('password')}).toQueryString(),			onLoading: function(){				$('submit_download').disable();			},			onComplete: function(){				if($('a_logout')){					Event.observe($('a_logout'), 'click', logout_download);				}				if($('form_download')){//nel caso le password siano sbagliate					Event.observe($('form_download'), 'submit', login_download);				}			}		}	);}//login_downloadfunction logout_download(e){	Event.stop(e);	new Ajax.Updater('centro_box_download', 'ricava_download.php',		{			method: 'post',			parameters: $H({'logout': 'true'}).toQueryString(),			onComplete: function(){				if($('form_download')){					Event.observe($('form_download'), 'submit', login_download);				}			}				}	);}//login_download//-----------------------------------------------------------------------------------------------------------//CONTENUTO CENTROspostamento_centro=0;function centro_esci(obj){	testo=obj.down('p');	if(testo){testo.style.overflow='hidden';}	new Effect.Parallel(		 [ new Effect.Move(obj,{ x: -890, y:0}) ],		 {  			afterFinish: function(effect) { 				if(testo){testo.style.overflow='auto';}				obj.style.left="890px";;				obj.removeClassName('centro_box_in');				obj.addClassName('centro_box_out');			} 		 }	 );}//centro_escifunction centro_entra(obj_id){	new Effect.Parallel(		 [ new Effect.Move($(obj_id),{ x: -890, y:0}) ],		 {  			afterFinish: function(effect) { 				$(obj_id).removeClassName('centro_box_out');				$(obj_id).addClassName('centro_box_in');				spostamento_centro=0;			} 		 }	 );}//centro_escifunction sposta_centro(e){	Event.stop(e);	if(!spostamento_centro){		elt=Event.element(e);		if(elt.tagName!="A" && elt.tagName!="a" && elt.tagName!="area" && elt.tagName!="AREA"){			elt=elt.up('a');		}		classi=elt.readAttribute("class");		classi=classi.split(" ");		for(i=0; i<classi.length; i++){			if(classi[i].search(/^id_/)!=-1){				entra_id="centro_box_"+classi[i].replace("id_", "");			}		}		//console.log(entra_id);		if(!$(entra_id)){			//loading			$('centro_loading').show();			//creo quel div			new Insertion.Before($('centro_loading'), '<div id="'+entra_id+'" class="centro_box centro_box_out"></div>');			//lo riempo di contenuto			if(entra_id.search(/^centro_box_content_/)!=-1){				//contenuto				id=entra_id.replace("centro_box_content_", "");				url="ricava_contenuto.php";			}else if(entra_id.search(/^centro_box_news_/)!=-1){				//news				id=entra_id.replace("centro_box_news_", "");				url="ricava_news.php";			}else if(entra_id.search(/^centro_box_download/)!=-1){				//download				id=0;				url="ricava_download.php";			}			new Ajax.Updater(entra_id, url,				{					method: 'post',					parameters: $H({'id': id}).toQueryString(),					onComplete: function(){						if($$('.centro_box_in')[0].id!=entra_id){							spostamento_centro=entra_id;							centro_esci($$('.centro_box_in')[0]);							centro_entra(entra_id);							$('centro_loading').hide();							$$('.a_file').each(function(elt){								Event.observe(elt, 'click', mostra_file);							});							if($('form_download')){								Event.observe($('form_download'), 'submit', login_download);							}							if($('a_logout')){								Event.observe($('a_logout'), 'click', logout_download);							}						}					}				}			);		}else{			//il div esite già			if($$('.centro_box_in')[0].id!=entra_id){				spostamento_centro=entra_id;				centro_esci($$('.centro_box_in')[0]);				centro_entra(entra_id);			}		}	}}//sposta_centro//-----------------------------------------------------------------------------------------------------------//FILMATIfunction mostra_file(e){	Event.stop(e);	elt=Event.element(e);	if(elt.tagName!="A" && elt.tagName!="a"){		elt=elt.up('a');	}	classi=elt.readAttribute("class");	classi=classi.split(" ");	for(i=0; i<classi.length; i++){		if(classi[i].search(/^file_content_/)!=-1){			id=classi[i].replace("file_content_", "");			url="ricava_contenuto_file.php";		}		if(classi[i].search(/^file_news_/)!=-1){			id=classi[i].replace("file_news_", "");			url="ricava_news_file.php";		}	}	$('filmato').show();	$('filmato_contenuto').hide();	$('filmato_loading').show();	new Ajax.Updater('filmato_contenuto', url,		{			method: 'post',			parameters: $H({'id': id}).toQueryString(),			onComplete: function(){				$('filmato_loading').hide();				$('filmato_contenuto').show();			}		}	);}//mostra_filefunction chiudi_filmato(e){	Event.stop(e);	$('filmato').hide();}//chiudi_filmato//-----------------------------------------------------------------------------------------------------------//NEWSlunghezza_box_news=230;lunghezza_news=920;lunghezza_news_boxes=0;spostamento_news=0;function visibilita_frecce_news(){	left=Number(Element.getStyle('news_boxes', 'left').replace("px", ""));	//console.log('left '+left);	//console.log('lunghezza_news '+lunghezza_news);	//console.log('lunghezza_news_boxes '+lunghezza_news_boxes);	//avanti	if((lunghezza_news_boxes+left)>lunghezza_news){		$('freccia_news_avanti').show();	}else{		$('freccia_news_avanti').hide();	}	//indietro	if(left<0){		$('freccia_news_indietro').show();	}else{		$('freccia_news_indietro').hide();	}}//visibilita_frecce_newsfunction news_avanti(e){	Event.stop(e);	left=Number(Element.getStyle('news_boxes', 'left').replace("px", ""));	if(!spostamento_news){		spostamento_news=1;		//lo spostamento è relativo		new Effect.Parallel(			 [ new Effect.Move($('news_boxes'),{ x: -lunghezza_news, y:0}) ],			 {  				afterFinish: function(effect) { 					spostamento_news=0;					//verifico la visibilità delle frecce					visibilita_frecce_news();				} 			 }		 );	}}//news_avantifunction news_indietro(e){	Event.stop(e);	left=Number(Element.getStyle('news_boxes', 'left').replace("px", ""));	if(!spostamento_news){		spostamento_news=1;		//lo spostamento è relativo		new Effect.Parallel(			 [ new Effect.Move($('news_boxes'),{ x: lunghezza_news, y:0}) ],			 {  				afterFinish: function(effect) { 					spostamento_news=0;					//verifico la visibilità delle frecce					visibilita_frecce_news();				} 			 }		 );	}}//freccia_news_indietrofunction init_news(){	tot_news=$$('div.box_news').length;	lunghezza_news_boxes=tot_news*lunghezza_box_news;	Element.setStyle('news_boxes', {width: lunghezza_news_boxes+'px'});	visibilita_frecce_news();	$$('#freccia_news_avanti a').each(function(elt){		Event.observe(elt, 'click', news_avanti);	});	$$('#freccia_news_indietro a').each(function(elt){		Event.observe(elt, 'click', news_indietro);	});}//init_news//-----------------------------------------------------------------------------------------------------------