var arheadline_count;
var arheadline_interval;
var old_arheadline = 0;
var current_arheadline=0;
var arheadlines = new Array(); // an array of jQuery objects
npDivIndex =0;
function slideMeUp(what, bywhat){
		npDivIndex++;
		if(npDivIndex > 3){
			$nDiv = $("#"+bywhat+"1").html()
			npDivIndex = 1;
		}else{
			$nDiv = $("#"+bywhat+npDivIndex).html();
		}
		$("#"+what).html($nDiv);
		return false;
}

function slideMeDown(what, bywhat){
		npDivIndex--;
		if(npDivIndex <= 0){
			$pDiv = $("#"+bywhat+"3").html()
			npDivIndex = 3;
		}else{
			$pDiv = $("#"+bywhat+npDivIndex).html();
		}
		$("#"+what).html($pDiv);
		return false;
}

$(document).ready(function(){
	// amore
	$(".amore").bind('mouseover', function(){
	try{
		clearTimeout(showTime);
	}catch (e){
	}
		$("#menu").show();
	});

	$(".amore").bind('mouseout', function(){
		showTime = setTimeout('$("#menu").hide();',500);
	});

	$("#menu").bind('mouseover', function(){
		clearTimeout(showTime);
		$("#menu").fadeIn();
	});

	$("#menu").bind('mouseout', function(){
		showTime = setTimeout('$("#menu").hide();',500);
	});


	// control arheadlines


	arheadline_count = $("div.arheadline").size();

	for (var i = 0; i < arheadline_count; i++) {
	 arheadlines[i] = $("div.arheadline:eq("+i+")");
	}

	arheadlines[current_arheadline].css('top', '5px');

	arheadline_interval = setInterval(arheadline_rotate,6000);
	$('#arscrollup').hover(function() {
	 clearInterval(arheadline_interval);
	}, function() {
	 arheadline_interval = setInterval(arheadline_rotate,6000);
	 arheadline_rotate();
	});


	$("#aupNews").click(function() {
									 clearInterval(arheadline_interval);
									 aslideUpNews();
									 return false;
								 });
	$("#adownNews").click(function() {
									 clearInterval(arheadline_interval);
									 aslideDownNews();
									 return false;
								 });


}); // EO $()

function arheadline_rotate() {
  current_arheadline = (old_arheadline + 1) % arheadline_count;
  arheadlines[old_arheadline].animate({top: -33},"slow", function() {
    $(this).css('top', '170px');
    });
  arheadlines[current_arheadline].show().animate({top: 5},"slow");
  old_arheadline = current_arheadline;
}

function aslideUpNews(){
	arheadline_rotate();
}

function aslideDownNews(){
	if (old_arheadline == 0) {
		current_arheadline = arheadline_count - 1;
	} else {
		current_arheadline = (old_arheadline - 1) % arheadline_count;
	}
  arheadlines[old_arheadline].animate({top: 33},"slow", function() {
    $(this).css('top', '38px');
    });
  arheadlines[current_arheadline].css('top', '-33px');
  arheadlines[current_arheadline].show().animate({top: 5},"slow");
  old_arheadline = current_arheadline;
}



