// JavaScript Document
$(document).ready(function(){
	//setFontSize();

	if($("#rotator").length){
		$("#rotator").fadeTransition({pauseTime: 7000, transitionTime: 2000, ignore: null, delayStart: 0, pauseNavigation: false});		
		$("#rotator").show();
	}
	
	if($("ul#ticker").length){
		$("ul#ticker").liScroll();
	}
	
	if($("#accordion").length){
		initMenu();
	}
	
	if($("#map").length){
		load();
	}
	
	$('.benvenuto').weatherfeed(['ITXX0251']);
	
	

	$(".opa-1").hover(function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-reparto-1.gif");
	}, function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-completa.gif");
	});

	$(".opa-2").hover(function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-reparto-2.gif");
	}, function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-completa.gif");
	});

	$(".opa-3").hover(function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-reparto-3.gif");
	}, function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-completa.gif");
	});
	
	$(".opa-4").hover(function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-reparto-4.gif");
	}, function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-completa.gif");
	});
	
	$(".opa-5").hover(function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-reparto-5.gif");
	}, function(){
		$("#map-aree").attr("src","images/mappa/strade-cartina-completa.gif");
	});
	
   $('area').each(function(){
      $(this).qtip({
		 position: {
			corner: {
			 target: 'topRight',
			 tooltip: 'bottomLeft'
			},
			 target: 'mouse'
		  },
         content: $(this).attr('alt'), 
         style: {name: 'blue', tip: true}
      });
   });
});

$(window).unload(function(){ 
	if($("#map").length){
		GUnload();
	}
});

var num=1;
function ScrollNews(content,direction){
	
	var totali=$(content +" [name^='item']").length;
	//alert(totali);
	//alert(num);
	if(direction=='+'){
		num++;
		if(num>totali) num=1;
	}else if(direction=='-'){
		num--;
		if(num<1) num=totali;
	}else{
		num=direction;
	}
	
	//alert(num);
	$(content +" .wrapper").scrollTo("[name='item"+num+"']", {duration:1000});
}

function initMenu() {
	$('#accordion ul').hide();
	$('#accordion ul.active').show();
	$('#accordion li a').click(function() {
		var checkElement = $(this).next();
		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;
		}
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#accordion ul:visible').slideUp('normal');
			checkElement.slideDown('normal');
			return false;
		}
	});
}
function apriViabilita(variab){
		window.open('http://geoweb.ar-tel.it/viabilita/viewer.htm' + ''+ variab +'','','width=790,height=545,menubar=no,scrollbars=no,resizable=no');
		//document.location.href="index.htm";
	}

