//	var mColore = new Array("blue", "green", "maroon", "orange");
//	var mEsadec = new Array("#70B8E1","#080","#75553A","#E08C1A")

$(document).ready(function(){
				var aLi = $("#tags>li");
				var iLi = aLi.length;
				$.each(aLi,function(i,o){
					//$(o).val(iLi-i);
					//$(o).val(Math.round(iLi*Math.sqrt(1-i/iLi)));
					$(o).val(Math.round(iLi*Math.pow(1-i/iLi,2))).attr("title",$(o).text());
				});
	
	//FACEBOX
	$('a[rel*=facebox]').facebox() 
	//$('#mappa').facebox() 

	//TOOLTIP SU LINGUA MANCANTE
	//$("#language").click( function() {$().message("Hello world!")} );
//	$('#language').qtip({
//	   content: 'Coming soon!',
//	   show: 'mouseover',
//	   hide: 'mouseout',
//		style: { 
//			  background: '#9BB70B',
//			  color: 'white',
//			  width: 100,
//			  textAlign: 'center',
//			  border: {
//				 color: '#9BB70B'
//			  },
//			  tip: 'topMiddle'
//		   },
//		   position: { adjust: { x: -105, y: 0 } }
//	})
	
	//ATTIVAZIONE MENU TESTATA ORIZZONTALE
	 
	 var sPath = window.location.pathname;
	 var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	

	 //ANIMAZIONE TAB
	$("div.tab_top").hover( function() {
		$(this).stop().animate({backgroundPosition: ('0 0')});
	}, function() {
         $(this).stop().animate({backgroundPosition: ('0 -10px')});
	});


	 //ANIMAZIONE TAB PAGINA CORRENTE	 
 	 $("div.tab_top").each ( function() {
// attivare dopo l'apertura della parte inglese
//		$(this).click(function(){
//			  window.location = $(this).children("a").attr("href");
//			}); 									  
	 if ($(this).children("a").attr("href") == sPage)
	   //$(this).css("background-image","url(img/tab_top_on.gif)");
	   {
       $(this)
	   .toggleClass("tab_top_on")
	   .unbind('mouseover')
	   .unbind('mouseout')
	   .hover( function() { /*per IE */
				$(this).stop().animate({backgroundPosition: ('0 0')});
			}, function() {
				 $(this).stop().animate({backgroundPosition: ('0 0')});
			});	 
	   }
	 });
	 
	 //ANIMAZIONE MENU
	$("div.menu_tab").hover( function() {
		$(this).stop().animate({backgroundPosition: '(0px 0px)'});
	}, function() {
         $(this).stop().animate({backgroundPosition: '(0px -20px)'});
	});
	
	 //OMBRA PULSANTI
 	$("div.menu_tab").prepend("<div style='position:absolute; top:-5px; left:-10px' class='ombra_menu'><img src='img/ombra_menu.gif'></div>");	
	
	//SFUMATURA BASSA DIV CENTRALE BIANCO
	$("div#centrale.bianco").prepend("<div style='position:absolute; bottom:-20px; left:0'><img src='img/centrale_bianco_bottom.gif' style='margin:0'></div>");	
		
	//ATTIVAZIONE MENU PAGINA CORRENTE
	 $("div.menu_tab").each ( function() {
		$(this).click(function(){
			  window.location = $(this).children("div").children("a").attr("href");
			}); 
	 if ($(this).children("div").children("a").attr("href") == sPage)
	   {
	   //$(this).css("background-image","url(img/tab_on.gif)");
	   $(this).toggleClass("menu_tab_on");
	   //$(this).hover( function() {}, function() {})
	   $(this).unbind('mouseout');
	   $(this).children('div.ombra_menu').hide();
	   }
	 });	
	
	//ATTIVAZIONE TAGCLOUD
	//$("#tags").tagcloud({height:80,type:"list",order:"rand",sizemin:12,sizemax:22,colormin:"e7f79c",colormax:"FFF"}).find("li").tsort({order:"rand"});

	//FLIP LOGO
	/*$("#logo_24_footer").click( function() {
			$(this)	.flip({ direction: 'tb', content:$("#logo_24_footer_flip"), bgColor: '#9BB70D', color: '#9BB70D', onEnd: function(){alert("Now I'm ready for another spin!")} });					 
	});*/
	
	//BACK HOME
	$('div#logo_top').click(function(){
	  window.location = "default.asp";
	}); 

	//BOTTOM NEWS SLIDER
		var newsoptions = {
		firstname: "mynews",
		secondname: "news_slider",
		thirdname:"news_display",
		fourthname:"news_button",
		//playingtitle:"Now Playing:",
		nexttitle:"Prossima:",
		prevtitle:"Precedente:",
		newsspeed:'15000',
		//effectspeed:'400',
		effectis:'0',
		mouseover:false,
		//newscountname:"test",
		disablenewscount:true,
		imagedir:'img/'
		}
		$.init_news(newsoptions);


	//TABBED LEFT MENU
  //Get all the LI from the #tabMenu UL
  $('#tabMenu > li').click(function(){
        
    //perform the actions when it's not selected
    if (!$(this).hasClass('selected')) {    

    //remove the selected class from all LI    
    $('#tabMenu > li').removeClass('selected');
    
    //After cleared all the LI, reassign the class to the selected tab
    $(this).addClass('selected');
    
    //Hide all the DIV in .boxBody
    $('.boxBody div').hide('1500');
    
    //Look for the right DIV index based on the Navigation UL index
    $('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').show('1500');
   }

  }).mouseover(function() {

    //Add and remove class, Personally I dont think this is the right way to do it, 
    //if you have better ideas to toggle it, please comment    
    $(this).addClass('mouseover');
    $(this).removeClass('mouseout'); 
	
    
  }).mouseout(function() { 
    
    //Add and remove class
    $(this).addClass('mouseout');
    $(this).removeClass('mouseover');    
    
  });

  
  //Mouseover with animate Effect for Category menu list  :)
  $('.boxBody #category li').mouseover(function() {
$("input[name='posiz']");
    //Change background color and animate the padding
    //$(this).css('background','#888');
    $(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});
	
  }).mouseout(function() {
    $("input[name='posiz']");
    //Change background color and animate the padding
    //$(this).css('background','');
    $(this).children().animate({paddingLeft:"0"}, {queue:false, duration:300});
  });  
  
  
   $('#posizioni tr:odd').addClass('odd');
  $('#posizioni tr:even').addClass('even');
//click su posizione  
	$("input[name='posiz']")
	.click(function() {
	$("td#posform").children("div").children("em").text($(this).val());
	$("input[name='posizione']").val($(this).val());
	});
	
//  //Click per i link del box
//  $('.boxBody li').click(function(){
//    window.location = $(this).find("a").attr("href");
//  }).mouseover(function() {
//    //$(this).css('background','#888');
//  }).mouseout(function() {
//    //$(this).css('background','');
//  });  	

  
});
