$(document).ready(function(){
	
	var altezza = $(document).height();
	var larghezza = $(document).width();

	if ($(".blackBody").length>0) {
		$(".blackBody").hide();
		$(".blackBody").animate({opacity: 0}, 0);
		$(".blackBody").css("height",altezza+"px");
	}

	//$("#msg-offerta").hide();

	if ($("#TextScrollContainer").length>0) {
		var ciclo=0;
		var tickerEnd=$("#TextScrollContent").height()-262;
		//alert(tickerEnd);
		$("#TextScrollContainer").autoscroll({ 
		   direction: "down", 
		   step: 20, 
		   scroll: true,
		   onEvaluate: function () {
			   //alert(this.scrollTop);
			   var currTop=this.scrollTop;
			   if (currTop==tickerEnd) {
					ciclo=1;
					$("#TextScrollContainer").autoscroll("reverse");   
			   }
			   if (currTop==0 && ciclo==1) {
					$("#TextScrollContainer").autoscroll("reverse");   
			   }
		   }
		});
	}

	/*setTimeout(function() {
		$("#msg-offerta").show();
		var leftMsg=(larghezza-520)/2;
		$("#msg-offerta").css('left', leftMsg+'px');
		$(".blackBody").show().animate({opacity: .7}, 500, function() {
			$("#msg-offerta").animate({top: "50px"}, 500);															 
		});			
	}, 500);*/

	/*$('#bollo-offerta a').click(function(event) {
		$("#msg-offerta").show();
		var leftMsg=(larghezza-500)/2;
		$("#msg-offerta").css('left', leftMsg+'px');
		$(".blackBody").show().animate({opacity: 0.9}, 500, function() {
			//alert("eccomi");
			$("#msg-offerta").animate({top: "100px"}, 500);															 
		});
		event.preventDefault();
	});*/

	$('#msg-offerta a.closeLink').click(function(event) {
		$("#msg-offerta").animate({top: "-2000px"}, 500, function() {
			$(".blackBody").show().animate({opacity: 0}, 500, function() {
				$(".blackBody").hide();
				$("#msg-offerta").hide();
			});
		});															 
		event.preventDefault();
	});



});

