$(document).ready(function(){	
																											
			//IMPAGINAZIONE HEADER CON IMMAGINE
		$('div.imgHeader').find('img').each(function(n){
			$(this).attr('height');
			var altezza = $(this).attr('height');			
			$(this).parent('.imgHeader').css({'height' : altezza });
	 //alert(altezza);
			});																									
																												
			$("div.boxUp").click(function () {																								
					
					var titolo = $(this).children('.tit');
					
					if(titolo.hasClass("off")) {	
							$(this).animate({bottom: "67"}, "slow");
							titolo.removeClass("off").addClass("on");
						}else{	
							titolo.removeClass("on").addClass("off");
							$(this).animate({bottom: "-2"}, "slow");
						}
});

// MENU istituzionale header																								
		closetimer = 0;
	if($("#nav")) {
		$("#nav b").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("clicked") != -1) {
				$(this).parent().next().slideUp(500);
				$(this).removeClass("clicked");
			}
			else {
				$("#nav b").removeClass();
				$(this).addClass("clicked");
				$("#nav ul:visible").slideUp(500);
				$(this).parent().next().slideDown(500);
			}
			return false;
		});
		$("#nav").mouseover(function() {
		clearTimeout(closetimer);
		});
		$("#nav").mouseout(function() {
			closetimer = window.setTimeout(function(){
			$("#nav ul:visible").slideUp(500);
			$("#nav b").removeClass("clicked");
			}, 4000);
		}); 
	}
	
// div scelta lingua
				$("#linkLang").click(function () {
    $("#overLang").slideToggle("slow");
				if($(this).hasClass("normal")) {		
					$(this).removeClass("normal").addClass("active");
				}else{
					$("#linkLang").removeClass("active").addClass("normal");
					}
			});
				
				$(".btInvia").click(function () {
				$("#selectLang").fadeIn("slow");
				$("#overLang").slideToggle("slow");
				$("#linkLang").removeClass("active").addClass("normal");
					});	

// TABS SCHEDA PRODOTTO E HP
// We can use this object to reference the panels container
	var panelContainer = $('div#panels');
	// Determine which tab should show first based on the URL hash
	var panelLocation = location.hash.slice(1);
	
	if(panelLocation){
		var panelNum = panelLocation;
	}
		else{
		var panelNum = '1';
	}
	// Hide all panels
	panelContainer.find('div.panel').hide();
	// Display the initial panel
	panelContainer.find('div.panel:nth-child(' + panelNum + ')').fadeIn('slow');
	//panelContainer.find('div.panel:last(' + panelNum + ')').fadeIn('slow');
	// Change the class of the current tab
 $('div#tabs').find('li:nth-child(' + panelNum + ')').removeClass().addClass('active');

 if (panelLocation=='11'){
	//alert(panelNum);
	$('#tab11').fadeIn('slow');
	$('.link a').addClass('active');
	}

	// What happens when a tab is clicked
	// -- Loop through each tab
	$('div#tabs').find('a').each(function(n){
		// For each tab, add a 'click' action
		$(this).click(function(){
			// Hide all panels
			panelContainer.find('div.panel').hide();
			// Find the required panel and display it
			panelContainer.find('div.panel:nth-child(' + (n+1) + ')').fadeIn('slow');
					$('#tabs ul li').removeClass('active');
					$(this).parent("li").addClass('active');
					$("#fancy_close, #fancy_loading, #fancy_left, #fancy_right, #fancy_overlay, #fancy_outer").fadeOut('slow');
					$('.link a').removeClass('active');
		});
		});

			// For each tab, add a 'click' action
		$('.link a').click(function (){
			// Hide all panels
			panelContainer.find('div.panel').hide();
			// Find the required panel and display it
			//panelContainer.find('div.panel:last()').fadeIn('slow');
			//panelContainer.find('div.panel:nth-child(' + (n+2) + ')').fadeIn('slow');
   $('#tab11').fadeIn('slow');
			//panelContainer.find('div#tab_tech()').fadeIn('slow');
					$('#tabs ul li').removeClass('active');
					$(this).addClass('active');
					$("#fancy_close, #fancy_loading, #fancy_left, #fancy_right, #fancy_overlay, #fancy_outer").fadeOut();
		});	
			
	});
		
//END READY FUNCTION		
	
		



				
		
		
