var myVtoggle1;
var myVtoggle2;
var myVtoggle3;
var myLayFooter;
var intervallFooter;
/*var myVtoggle4;*/
var myVcurrent = null;
var OBlk;
var LarghezzaScroll = 0;
	var CurPos=0;
	window.addEvent('domready', function() {			
	BtnMen = $$('.toggler')
		$each(BtnMen, function(a, b){
			Nom = a.id;
			Nom = Nom.replace('v_','');
			if ($(Nom) != null) {
				eval('myV' + Nom + '= new Fx.Slide(Nom);');
				eval('myV' + Nom + '.addEvent(\'complete\', function(){OBlk = false;ar = a.getElement(\'img\').src;if(a.getStyle(\'z-index\') > 10 ){ar = ar.replace(\'_b.png\', \'.png\');a.getElement(\'img\').src = ar.replace(\'.png\', \'_a.png\');  }else if (ar.indexOf(\'_a.png\') > 0){a.getElement(\'img\').src = ar.replace(\'_a.png\', \'.png\'); }});')

				eval('myV' + Nom + '.hide();');
				if(a.id != 'v_toggle4'){
				a.addEvent('click', function(e){
			
						if (myVcurrent != null && myVcurrent.id != a.id) {
						$('v_toggle1').setStyle('z-index',10);
						Hspan('myVtoggle1', '');
						i = $('v_toggle1').getElement('img').src;
						$('v_toggle1').getElement('img').src = i.replace('_a.png','.png'); 
						$('v_toggle2').setStyle('z-index',10);
						Hspan('myVtoggle2', '');
						i = $('v_toggle2').getElement('img').src;
						$('v_toggle2').getElement('img').src = i.replace('_a.png','.png'); 
						$('v_toggle3').setStyle('z-index',10);
						Hspan('myVtoggle3', '');
						i = $('v_toggle3').getElement('img').src;
						$('v_toggle3').getElement('img').src = i.replace('_a.png','.png');
					/*	$('v_toggle4').setStyle('z-index',10);
						Hspan('myVtoggle4', '');
						i = $('v_toggle4').getElement('img').src;
						$('v_toggle4').getElement('img').src = i.replace('_a.png','.png');*/
						myVcurrent.getElement('img').src = precImg;
						}
						if(myVcurrent == null || myVcurrent.id != a.id){
						a.setStyle('z-index',500);	
						precImg = a.getElement('img').src;
					/*	ar = a.getElement('img').src
						ar = ar.replace('_b.png', '.png');
						a.getElement('img').src = ar.replace('.png', '_a.png');	*/
						Aspan('myV' + a.id.replace('v_',''), '');
						myVcurrent = a;
						}
						else if(myVcurrent.id == a.id){
					
						Cspan('myV' + myVcurrent.id.replace('v_',''), '');	
						myVcurrent.getElement('img').src = precImg; 
						myVcurrent.setStyle('z-index',10);
						myVcurrent = null;
						}
		
					return false;
				})
				}
			}
			
			
			});
	
			BtnMen = $$('#toggle3 .sfondoRollLayMenu')
		$each(BtnMen, function(a, b){
			
			a.addEvent('mouseover', function(e){
				
				BtnMen5 = a.getElements('img');
				$each(BtnMen5, function(a, b){
					
					 if (a.src.indexOf('.png') > 0 && !a.hasClass('block') ) a.src = a.src.replace('.png', '_a.png');
				});			
				
				BtnMen5 = a.getElements('strong');
				$each(BtnMen5, function(a, b){
					if(!a.hasClass('block') ) a.setStyle('color','#E26608');
				});
				
			});
			a.addEvent('mouseout', function(e){
				BtnMen5 = a.getElements('img');
				$each(BtnMen5, function(a, b){
					 if (a.src.indexOf('.png') > 0 && !a.hasClass('block')  ) a.src = a.src.replace('_a.png', '.png');
				});			
				
				BtnMen5 = a.getElements('strong');
				$each(BtnMen5, function(a, b){
					if(!a.hasClass('block') ) a.setStyle('color','#669D00');
				});
				
			});
			
		});	
			
			
	BtnMens=$$('.ImgScrol');
	contar = 0;
	$$('body').adopt(new Element('div',{'id':'layFooter'}));
	$('layFooter').adopt(new Element('a',{'id':'linkIncasso','html':'ELETTRODOMESTICI<br>A INCASSO'}));
	$('layFooter').adopt(new Element('a',{'id':'linkLibera','html':'ELETTRODOMESTICI<br>A LIBERA<br>INSTALLAZIONE'}));
	
	$each(BtnMens, function(a, b){
		contar = contar +1;
		
		m = a.getStyle('width');
		m = m.replace('px','');
		m = parseInt(m);
		LarghezzaScroll = m + LarghezzaScroll +40;
		if (contar == 10) {
			$('Scrollatore').setStyle('margin-left', "-" + LarghezzaScroll + "px");
			CurPos=-1*LarghezzaScroll
		}		
	
		a.getParent('a').addEvent('click', function(e){
			/*alert()*/
			
			if (this.get('href') == null) {
				$('linkIncasso').set('href', '/elettrodomestici/funzioniIncasso.cfm?ParamFunzione=' + this.get('title'));
				$('linkLibera').set('href', '/elettrodomestici/funzioniLibera.cfm?ParamFunzione=' + this.get('title'));
				
				ele = e.target.getPosition();
				$('layFooter').setStyles({
					'top': (ele.y - 120),
					'left': (ele.x - 100),
					'display': 'block'
				})
				$('layFooter').addEvent('mouseout', function(e){myLayFooter = false;clearTimeout(intervallFooter);intervallFooter = setTimeout("chiudiLayFooter()",500);});
				$('layFooter').addEvent('mouseover', function(e){myLayFooter = true;clearTimeout(intervallFooter);});
				$('linkIncasso').addEvent('mouseover', function(e){myLayFooter = true;clearTimeout(intervallFooter);});
				$('linkLibera').addEvent('mouseover', function(e){myLayFooter = true;clearTimeout(intervallFooter);});
				myLayFooter = true;
				
			return false;
			}
			else {
				setTimeout("$('layFooter').setStyles({'display': 'none'})",300);
			}
			
			
		});
			a.getParent('a').addEvent('mouseout', function(e){myLayFooter = false;intervallFooter = setTimeout("chiudiLayFooter()",300);});
			a.getParent('a').addEvent('mouseover', function(e){clearTimeout(intervallFooter);});
	});

/*	$("Scrollatore").setStyle('width',LarghezzaScroll+"px");*/
	LarghezzaScroll=LarghezzaScroll-520;
	/*alert(LarghezzaScroll)*/
	
	
	BtnMen = $$('.roller')

$each(BtnMen, function(a, b){
	a.addEvent('mouseover', function(){
		if (a.src.indexOf('.jpg') > 0) a.src = a.src.replace('.jpg', '_a.jpg');		  	
		else if (a.src.indexOf('.gif') > 0) a.src = a.src.replace('.gif', '_a.gif');
		else if (a.src.indexOf('.png') > 0) a.src = a.src.replace('.png', '_a.png');
	});
	
	
	a.addEvent('mouseout', function(){
		if (a.src.indexOf('.jpg') > 0) a.src = a.src.replace('_a.jpg', '.jpg');
		else if (a.src.indexOf('.gif') > 0) a.src = a.src.replace('_a.gif', '.gif');
		else if (a.src.indexOf('.png') > 0) a.src = a.src.replace('_a.png', '.png');
	});
});
	
	
	
	


	$('forLayer').setStyle('display','block');
	
	if($chk($('video'))) SqueezeBox.assign($('video'),{onOpen:function(){},parse: 'rel'	});
	
	if($chk($('socialMod1'))) SqueezeBox.assign($('socialMod1'),{onOpen:function(){},parse: 'rel'	});
	if($chk($('socialMod2'))) SqueezeBox.assign($('socialMod2'),{onOpen:function(){},parse: 'rel'	});
	
	});	

function chiudiLayFooter(){
		$('layFooter').setStyles({
					'display': 'none'
				})
				
}
	
	function scrollIcon(dir){
	$('layFooter').setStyle('display','none');	
	 $('Scrollatore').setStyle('margin-left', CurPos+"px" );
			CurPos = CurPos + dir;
		if (CurPos >= -0)	 CurPos = -2326;
		else if (CurPos <= -3260)   CurPos = -920;
		y = setTimeout("scrollIcon(" + dir + ")", "10");				
	}
	
	function stopScroll(){clearTimeout(y);}
		
	function Aspan(a,ot){
		if (OBlk != true) {
			OBlk = true;
			eval(a + '.slideIn();');
		}		
	}
	function Cspan(a,ot){
		OBlk = false;
		if(ot != '') {
			i = $(ot).getElement('img').src;
			$(ot).setStyle('z-index',10);
			$(ot).getElement('img').src = i.replace('_a.png','.png'); 
			myVcurrent = null;
		}
		eval( a + '.slideOut();');
		
	}
	
	function CspanBtn(a,ot){
		
		eval( a + '.slideOut();');
		
	}
	
	function Hspan(a,ot){
		eval( a + '.hide();');
	}
	function SearchWebSite(){	
	if ($('TextWebSite').value == "" || $('TextWebSite').value == "CERCA NEL SITO") {$('TextWebSite').value = "";$('TextWebSite').setStyle('background','#ffffff');$('TextWebSite').focus();}
	else if ($('TextWebSite').value != "" && $('TextWebSite').value.length < 3) alert("Il termine da ricercare deve essere di almeno 3 caratteri")
	else $('frmSearchWebSite').submit();
}	


function VerStamp(IDPROD){
  Pagina_VerStamp = "prodotti_stamp.cfm?pid=" + IDPROD;
  window.open(Pagina_VerStamp,'STAMPA','width=700, height=500, menubar=yes, scrollbars=yes, left=2, top=2, target=_top');
}
var ttarif;
function apriTariffe(){
	clearTimeout(ttarif)
	$('sfondoTariffe').setStyle('display','block');	
}
function chiudiTariffe(){
	ttarif=setTimeout("$('sfondoTariffe').setStyle('display','none');	",300);
}

function rollTariffe(p){
	if(p){
	
		BtnMen=$('boxHomeCentro').getElements('.roller1');
			$each(BtnMen, function(a, b){
				if (a.src.indexOf('.jpg') > 0) a.src = a.src.replace('.jpg', '_a.jpg');		  	
				else if (a.src.indexOf('.gif') > 0) a.src = a.src.replace('.gif', '_a.gif');
				else if (a.src.indexOf('.png') > 0) a.src = a.src.replace('.png', '_a.png');
				});
			BtnMen=$('boxHomeCentro').getElements('a.tit');
			$each(BtnMen, function(a, b){
				a.addClass('overHome');
			});
		
		
	}
	else{
			BtnMen=$('boxHomeCentro').getElements('.roller1')
			$each(BtnMen, function(a, b){
			 	 if (a.src.indexOf('.jpg') > 0) a.src = a.src.replace('_a.jpg', '.jpg');
				else if (a.src.indexOf('.gif') > 0) a.src = a.src.replace('_a.gif', '.gif');
				else if (a.src.indexOf('.png') > 0) a.src = a.src.replace('_a.png', '.png');
				});
			BtnMen=$('boxHomeCentro').getElements('a.tit');
			$each(BtnMen, function(a, b){
				a.removeClass('overHome');
		});
	}
	
}

