﻿/* Inizializza lo slider */


$(function() {



document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
}
});





$(function() {
 		var url = window.location.pathname;
		 var site = url.split('/')[2];
		
		if (site=='Faq'){
		 	if (isObject(document.getElementsByClassName ('accordion')[0])) {
				document.getElementById('contentLine').style.height='1250px';
			}

		 
		 }

	

});



$(function() {


		
		
		if (isObject(document.getElementById('codiceCorretto'))){	

		/*document.getElementById('linkBotton').style.visibility = 'hidden';*/
		document.getElementById('CouponLinkAderisci').style.display = 'inline';
		document.getElementById('linkaderisci').style.display = 'inline';
		
		document.getElementById('coupon').style.visibility = 'hidden';	
			document.getElementById('coupon').style.height='1px';
		document.getElementById('coupon').style.width='1px';
		
		
	
		window.scrollTo(1,1);
		window.focus();

		
			


		}
		
		
		if (isObject(document.getElementById('codiceErrato'))){	

		/*document.getElementById('linkBotton').style.visibility = 'hidden';*/

		document.getElementById('coupon').style.visibility = 'visible';	
		document.getElementById('errorMessage').style.display = 'inline';	
			


		}
		
		if (isObject(document.getElementById('codiceUtilizzato'))){	

		/*document.getElementById('linkBotton').style.visibility = 'hidden';*/

		document.getElementById('coupon').style.visibility = 'visible';	
		document.getElementById('errorMessageUtilizzato').style.display = 'inline';	
				
		
		/* $('errorMessage').attr('Text' , 'La matricola è stata già utilizzata'); */
		
			


		}




});



$(function() {

    var bc = $('#BUTTON_BOX');
	//segue dichiarazione variabile contenente la f per lo scroll dell'IMAGE
	if (isObject(document.getElementById('SLOGAN_IMAGE'))){	
	
	
	    var $sloganImage = $('#SLOGAN_IMAGE').cycle({
	        fx: 'fade',
	        speed: 1500,
	        timeout: 500,
			easing: 'backinout'
			
			
	    });
		
	
		var bc = $('#BUTTON_BOX').cycle({
			pager:  '#BUTTON_BOX'
			
		});
		//inserisco un button per ogni figlio dei tag selezionato
		$sloganImage.children().each(function(i) {//value="'+(i+1)+'" 
			
	       $('<input type="button" value=" " class="btn"  onmouseover="this.className=\'btn btnHov\'" onmouseout="this.className=\'btn\'" />')
			.appendTo(bc).click(function() {
				$sloganImage.cycle(i);
				return false;
			});
	      });	      

	      
         	 document.getElementById('SLOGAN_IMAGE').style.visibility = "visible";
      }
   
});
	
	/* script slider header */

	
	$(function() {

    var bc = $('#slider');
	//segue dichiarazione variabile contenente la funzione per lo scroll dell'IMAGE
	if (isObject(document.getElementById('slider'))){	
	
	 $('#slider').nivoSlider();
       effect: 'Fade'
       


	    }   
});
	
	/* script sala Stampa Pop UP */

$(function() {


		 var url = window.location.pathname;
		 

			if ((url.split('/')[5]) != undefined) {		 	
				 var site = url.split('/')[5];

				site = site.substring (0,3);
				
				var sitelink = site + 'A';
				if (isObject(document.getElementById(site))){	
		
					document.getElementById(site).style.backgroundColor = "#CCCCCC";
				}
				if (isObject(document.getElementById(sitelink))){	
					document.getElementById(sitelink).style.color = "#005BAA";
				}
			}

		
		
			
	
		


});


 function isObject( cosa) {
 
 		if (!(cosa == null)) {
 			return( typeof cosa == 'object' );
 			}
 		else{
 			return false;
 			}
 }
 
 function chiudi(){}
 

$(function(){
	$(".menu-vertical li[class~='selected']").parents("li").each(function(index) { 
		$(this).children("a").attr("style", "color:#005baa !important");
	});		
});

$(function(){
	$(".menu-vertical li span.menu-item-text").each(function(index){ 
		if($(this).text().toUpperCase() == 'LUCE')
		{ 
			var height = $(this).parents("li:first").height();
			var top;
			switch(height)
			{
				case 30:
				top = '-25px';
				break;
				case 25:
				top = '-22px';
				break;
			}
			
			$(this).parents("a:first").append('<img src="/sitecollectionimages/luce20x20.png" style="position:relative; top:'+ top +'; left: 180px;"></img>');

		}
	});
	
	$(".menu-vertical li span.menu-item-text").each(function(index){ 
		if($(this).text().toUpperCase() == 'GAS')
		{ 
			var height = $(this).parents("li:first").height();
			var top;
			switch(height)
			{
				case 30:
				top = '-25px';
				break;
				case 25:
				top = '-22px';
				break;
			}

			$(this).parents("a:first").append('<img src="/sitecollectionimages/gas20x20.png" style="position:relative;top:'+ top +'; left: 180px;"></img>');

		}
	});
	
});

$(function(){
	$('li @[class="static selected"]').each(function(index)
		{
			 $(this).siblings('li').children('ul').hide();
			 $(this).parents('li').siblings('li').children('ul').hide();
			
		});
		/* document.getElementsByClassName('menu-vertical')[0].style.visibility ='visible'*/
		$('.menu-vertical').attr('style', 'visibility:visible');
 });
 
 
 


 


$(function() {


		 var url = window.location.pathname
		 var site = url.split('/')[2];
		
		
		
		
		if (url.split('/')[2]  != undefined) {
			  //	alert ('site: ' + site);
			 
			 site = site.toLowerCase();
		 }
		
			if (isObject(document.getElementById(site))){	

			document.getElementById(site).style.backgroundColor = "#fbaf32";
	
			}else{

			site = url.split('/')[1]
			site = site.toLowerCase();
		//	alert ('site' + site);
			if (isObject(document.getElementById(site))){	

			document.getElementById(site).style.backgroundColor = "#fbaf32";
			 var current  = document.getElementsByClassName('breadcrumbsCurrent');
			current = current[0];
			 if (current != null) {			 	

					for( var i=0; i<current.length; i++)
					{		
						
						current.style.display = 'inline';		
						current.style.visibility = 'visible';											
					}
			
				}
			}	
			
		}


});

 

function sendCodice() {
	
	var url = window.location.pathname;	 
		
	var codice = $(".codice").val() ;

	$(".sendCodice").val(codice);

	 var site = url.split('/')[1];

	/*if  (site.toUpperCase() == "RISPARMIOSUMISURA" ){
	var urllogin = "/pagine/convenzioneCasa.aspx?idO=8&Offerta=Risparmio%20su%20Misura&Fuel=3&codice=" + codice;
	alert (urllogin);
	}*/


	var urllogin = "/Convenzioni/pagine/convenzioneCasa.aspx?idO=8&Offerta=Risparmio%20su%20Misura&Fuel=3&codice=" + codice;
  	 window.location = urllogin ;
 //	alert ("urlogin: " + urllogin )
//	$('#convenzione').attr('action', urllogin );


//	$("#convenzione").submit();

}

