// Beat Fly JavaScript core document
/*jquery setting*/
$(document).ready(function(){
						   
	//show-hide panel
	$('#panel').hide();
		
	$('a#panel-show').click(function() {
		$('#panel').fadeIn();
		return false;
	});
	  
	$('a#panel-hide').click(function() {
		$('#panel').fadeOut();
		return false;
	});
	
	//promozione animation
	$('#promozione img').hover(function() {
		$(this).stop().animate({
			opacity : 0.7
		}, 500);
		},
		function(){
		$(this).stop().animate({
			opacity : 1
		}, 500);
	});
	
	//overlay contenitore link
	$.ajaxSetup ({
		cache: false
	});
	var ajax_load = "<img src='../prevedi/js/splash_library/loader_grey.gif' alt='loading...' />";

		//load() functions link
		var loadUrllink = "include/link.asp";
		$("a#link").click(function(e){
			$("#contenitore").html(ajax_load).load(loadUrllink);
				$('#overlay').fadeIn();
		e.preventDefault();
		});
		
		//load() functions video home loadUrlvideohome
		var loadUrlvideohome = "include/video.html";
		$("a#videohome").click(function(e){
			$("#contenitore").html(ajax_load).load(loadUrlvideohome);
				$('#overlay').fadeIn();
		e.preventDefault();
		});
		
		//load() functions video loadUrlvideo
		var loadUrlvideo = "include/video.html";
		$("a#video").click(function(e){
			$("#contenitore").html(ajax_load).load(loadUrlvideo);
				$('#overlay').fadeIn();
		e.preventDefault();
		});
		
		//load() functions privacy loadUrlprivacy
		var loadUrlprivacy = "include/extra.html";
		$("a#privacy").click(function(e){
			$("#contenitore").html(ajax_load).load(loadUrlprivacy + " #privacy");
				$('#overlay').fadeIn();
		e.preventDefault();
		});
		
		//load() functions term loadUrlterm
		var loadUrlterm = "include/extra.html";
		$("a#term").click(function(e){
			$("#contenitore").html(ajax_load).load(loadUrlterm + " #term");
				$('#overlay').fadeIn();
		e.preventDefault();
		});
		
		//load() functions accessibilita loadUrlaccessibilita
		var loadUrlaccessibilita = "include/extra.html";
		$("a#accessibilita").click(function(e){
			$("#contenitore").html(ajax_load).load(loadUrlaccessibilita + " #accessibilita");
				$('#overlay').fadeIn();
		e.preventDefault();
		});
			
			//close
			$('a#chiudi').live("click",function(){
				$('#overlay').fadeOut();
			return false;
			});
			
	//RSS
	$('#subfooterprimo').rssfeed('http://www.ansa.it/web/notizie/rubriche/economia/economia_rss.xml', {
		limit:		5,
		titletag: 	'h5',
		content: 	false,
		showerror: 	true,
		errormsg: 	'Errore di caricamento'
	});
	$('#subfootersecondo').rssfeed('http://www.ilsole24ore.com/rss/finanza-e-mercati.xml', {
		limit:		5,
		titletag: 	'h5',
		content: 	false,
		showerror: 	true,
		errormsg: 	'Errore di caricamento'
	});
	
	//accordion
	$('.acc_container').hide();
		
	//accordion On Click
	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) {
			$('.acc_trigger').removeClass('active').next().slideUp();
			$(this).toggleClass('active').next().slideDown();
		}
		return false;
	});
		
});//end

//go up
$(function () {
	var scroll_timer;
	var displayed = false;
	var $message = $('#message a');
	var $window = $(window);
	var top = $(document.body).children(0).position().top;
	$window.scroll(function () {
		window.clearTimeout(scroll_timer);
		scroll_timer = window.setTimeout(function () {
			if($window.scrollTop() <= top)
			{
				displayed = false;
				$message.fadeOut(500);
			}
			else if(displayed == false)
			{
				displayed = true;
				$message.stop(true, true).show().click(function () { $message.fadeOut(500); });
			}
		}, 100);
	});
});
