var first=false;
var count=0;
var flash=false;

//----------------------RICONSOCE SE IL PLUGIN FLASH E' PRESENTE NEL BROWSER--------------------------------//

if(Browser.Plugins.Flash.version>=8) flash=true;

window.addEvent('domready', function() {
	//------------REPLACE DEL TESTO CON FLASH-----------------/
	if(flash==true){
		count=0;
		if($$('.replaceFlash')){
			$$('.replaceFlash').each(function(item){
				item.addClass('flash');
				var url="";
				if(item.getElement('a')) url=item.getElement('a');
				count++;
				var bgcolor="";
				var wMode="";
				if(item.getStyle('background-color')=='transparent'){
					var bgcolor='transparent';
					var wMode='transparent';
				}else{
					var bgcolor=item.getStyle('background-color');
					var wMode='window';
				}
				/*alert(item.getProperty('id')+' width: '+item.getStyle('width'));
				alert(item.getProperty('id')+' height: '+item.getStyle('height').toInt());*/
				var obj = new Swiff('../_res/swf/textreplace.swf', {
					id: 'myBeautifulMovie'+count,
					width: item.getStyle('width').toInt(),
					height: item.getStyle('height').toInt(),
					container: item,
					params: {
						codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
						quality: 'high',
						pluginspage: 'http://www.macromedia.com/go/getflashplayer',
						align: 'middle',
						play: 'true',
						loop: 'true',
						scale: 'noscale',
						wMode: wMode,
						devicefont: 'false',
						bgcolor: bgcolor,
						menu: 'false',
						allowFullScreen: 'false',
						allowScriptAccess:'sameDomain',
						salign: 'lt'
					},
					vars: {
						testo: item.get('text').trim(),
						dimensione: item.getStyle('font-size').toInt(),
						//carattere: 'Swis721 Cn BT',
						colore: item.getStyle('color').replace('#','0x'),
						coloreOver: '0x861517',
						url: url
					}
				});
			});
		}
	}
	//---------------------------------------------------------------------------------/
	if($('HideLeftSide')){
		var stato=0;
		var Spallafx = new Fx.Tween($('LeftSide'), {wait:false,fps:60,duration:750});
		var spostamento=$('LeftSide').getStyle('left');
		$('HideLeftSide').setProperty('title','Nascondi dettagli');
		if($('SubMenuGallery')) var mySlide = new Fx.Slide('SubMenuGallery').hide().toggle();
		$('HideLeftSide').addEvent('click', function(){
			if(stato==0){
				stato=1;
				if($('SubMenuGallery')){
					mySlide.slideOut().chain(function(){
						Spallafx.start('left', 910).chain(function(){
							$('HideLeftSide').setStyle('background-image','url(../_res/img/button_spalla_over.gif)');
							$('HideLeftSide').set('text','Mostra spalla');
							$('HideLeftSide').setProperty('title','Mostra dettagli');
						});
					});
				}else{
					Spallafx.start('left', 910).chain(function(){
						$('HideLeftSide').setStyle('background-image','url(../_res/img/button_spalla_over.gif)');
						$('HideLeftSide').set('text','Mostra spalla');
						$('HideLeftSide').setProperty('title','Mostra dettagli');
					});	
				}
			}else {
				stato=0;
				Spallafx.start('left', spostamento).chain(function(){
					$('HideLeftSide').setStyle('background-image','url(../_res/img/button_spalla.gif)');
					$('HideLeftSide').set('text','Nascondi spalla');
					$('HideLeftSide').setProperty('title','Nascondi dettagli');
					if($('SubMenuGallery')){mySlide.slideIn();}
				});
			}
		});
	}
	if($('Menu1'))$('Menu1').setStyle('visibility','visible');
});