	$(function() {
		var PaginaCorrente = location.href.substr(location.href.lastIndexOf("/")+1).split(/[?#]/)[0];
		if (PaginaCorrente || null) {
			var classeSezione = PaginaCorrente.substr(0,PaginaCorrente.lastIndexOf("."));
			$('#nav-section li a').each(function(n){
					
				if($(this).attr('href') == PaginaCorrente)
					$('div#mainnav').attr('class',classeSezione);
				else
					$('div#mainnav').removeAttr(classeSezione);
			});
		}
		$('#linkNewsletter').click(
			function(){
					$('.box-newsletter p').html('<form name="formNewsletter" id="formNewsletter" method="post" action="invioMail.asp"><input type="text" id="EmailNewsletter" name="Email" value="Inserisci la tua e-mail" style="width:107px;font-size:11px"><input type="hidden" value="si" name="newsletter"><input type="submit" class="marginT6" id="btNewsletter" name="Invia" value="invia"></form>')
					  }
		  );
		  
		$('#notelegali').click(
			function(e){
				var winWd = $(window).width() + $(window).scrollLeft();
				var winHt = $(window).height() + $(window).scrollTop();				
				
				
				$('<div id="boxnotelegali"></div><div id="closebox"><img src="image/ico-close.png"></div><div class="boxoverlayer"></div>').appendTo('body')
				$.ajax({
				  url: 'notelegali.asp',
				  success: function(data) {
					$('#boxnotelegali').html(data);
				  }
				});
				var tpWd = $('#boxnotelegali').width();
				var tpHt = $('#boxnotelegali').height();



				var _left = 0;
				var _top = 0;
				_left = (winWd / 2) - (tpWd / 2) +"px";
				_top = (winHt / 2) - (tpHt / 2) +"px";
				
				_rightClose = (winWd / 2) - (tpWd / 2) - 25 +"px";
				_topClose = (winHt / 2) - (tpHt / 2) -5 +"px";

				//alert(_top);
				
				$('#boxnotelegali')
					.css("top",_top)
					.css("left",_left);
				$('#closebox')
					.css({
						"top":_topClose,
						"right":_rightClose
						})
					.bind('click',function(){
						$('div').remove('#boxnotelegali');
						$('div').remove('.boxoverlayer');
						$('div').remove('#closebox');
					});
					
				$('.boxoverlayer')
					.css({
						"width":winWd,
						"height":winHt,
						"opacity":0.5
						})
					.bind('click',function(){
						$('div').remove('#boxnotelegali');
						$('div').remove('.boxoverlayer');
						$('div').remove('#closebox');
					});
			}
		);

	});
