$(function() {
	var PaginaCorrente = location.href.substr(location.href.lastIndexOf("/")+1).split(/[?#]/)[0];
		$('#nav-sezioni li a').each(function(n){
			if($(this).attr('href') == PaginaCorrente)
				$(this).attr('class','selected');
			else
				$(this).removeAttr('selected');
		});

	/*
	$.ajax({	
		url : "textscroll.asp",
		success : function (data) {
			$(".scrollingtext").html(data);
			//$("ul#ticker01").liScroll({travelocity: 0.07});
			$(function() { //on DOM ready
				$("#scroller").simplyScroll({
				autoMode: 'loop',
				speed: 4
			});
	});
			
		}
	});
	*/
	
$(document).ready(function(){
//alert('test');
$("#scroller").simplyScroll({
				autoMode: 'loop',
				speed: 1,
				frameRate: 50
				});

});


	
	$('#btPrezziEsteri').click(
		function(e){
			var winWd = $(window).width() + $(window).scrollLeft();
			var winHt = $(window).height() + $(window).scrollTop();				
			
			
			$('<div id="box-dialog"></div><div id="closebox"><img src="images/ico-close.png"></div><div class="boxoverlayer"></div>').appendTo('body')
			$.ajax({
			  url: 'pagine/paesiesteri.html',
			  success: function(data) {
				$('#box-dialog').html(data);
			  }
			});
			var tpWd = $('#box-dialog').width();
			var tpHt = $('#box-dialog').height();



			var _left = 0;
			var _top = 0;
			_left = (winWd / 2) - (tpWd / 2) +"px";
			_top = (winHt / 2) - (tpHt / 2) +"px";
			
			_rightClose = (winWd / 2) - (tpWd / 2) - 20 +"px";
			_topClose = (winHt / 2) - (tpHt / 2) - 5 +"px";

			//alert(_top);

			$('#box-dialog')
				.css("top",_top)
				.css("left",_left);
			$('#closebox')
				.css({
					"top":_topClose,
					"right":_rightClose
					})
				.bind('click',function(){
					$('div').remove('#box-dialog');
					$('div').remove('.boxoverlayer');
					$('div').remove('#closebox');
				});
				
			$('.boxoverlayer')
				.css({
					"width":winWd,
					"height":winHt,
					"opacity":0.5
					})
				.bind('click',function(){
					$('div').remove('#box-dialog');
					$('div').remove('.boxoverlayer');
					$('div').remove('#closebox');
				});
			
			$('html,body').animate({scrollTop: $("#box-dialog").offset().top - 50 + "px"},'slow');
			
			
		}
	);
	
	$('#btICIM').click(
		function(e){
			var winWd = $(window).width() + $(window).scrollLeft();
			var winHt = $(window).height() + $(window).scrollTop();				
			
			
			$('<div id="box-dialog2"><img src="docs/certificato9001_2008.jpg" alt="" /></div><div id="closebox2"><img src="images/ico-close.png"></div><div class="boxoverlayer"></div>').appendTo('body')
			
			var tpWd = $('#box-dialog2').width();
			var tpHt = $('#box-dialog2').height();



			var _left = 0;
			var _top = 0;
			_left = (winWd / 2) - (tpWd / 2) +"px";
			_top = (winHt / 2) - (tpHt / 2) +"px";
			
			_rightClose = (winWd / 2) - (tpWd / 2) - 20 +"px";
			_topClose = (winHt / 2) - (tpHt / 2) - 5 +"px";

			//alert(_top);

			$('#box-dialog2')
				.css("top",_top)
				.css("left",_left);
			$('#closebox2')
				.css({
					"top":_topClose,
					"right":_rightClose
					})
				.bind('click',function(){
					$('div').remove('#box-dialog2');
					$('div').remove('.boxoverlayer');
					$('div').remove('#closebox2');
				});
				
			$('.boxoverlayer')
				.css({
					"width":winWd,
					"height":winHt,
					"opacity":0.5
					})
				.bind('click',function(){
					$('div').remove('#box-dialog2');
					$('div').remove('.boxoverlayer');
					$('div').remove('#closebox2');
				});
			
			$('html,body').animate({scrollTop: $("#box-dialog2").offset().top - 50 + "px"},'slow');
			
			
		}
	);
	
	
});
