$(function(){InitSplash()})

function InitSplash(){
	$("#News div:last").attr("last", 1);
	News_SetCurrent($("#News div:first"));
	setInterval(function(){NewsNext()}, 3500)
};

function NewsNext(){
	if (window._lockSplashSlide == true) return;
	
	var curr = $("#News div[current=1]");
	if (curr.attr("last")==1)
		next = $("#News div:first");
	else
		next = $(curr).next();
	News_SetCurrent($(next));
}

function News_SetCurrent(curr){
	$("#News div[current=1]").attr("current", 0);
	curr.attr("current", 1);
	$("#cursore").clearQueue();
	$("#cursore").fadeTo(0, 1);
	$("#cursore").fadeOut(200, function () {
		$("#cursore").css("left", $(curr).css("left"));
		$("#cursore").fadeIn();
		$("#big img").attr('src', $(curr).find('img').attr('src').replace(/_over/, '').replace(/\.jpg/, '_big.jpg'));
		$("#big img").attr('alt', $(curr).find('img').attr('alt'));
		$("#big img").parent().attr('href', $(curr).find('img').parent().attr('href'));
		$("#big img").parent().attr('title', $(curr).find('img').parent().attr('title'));
		$("#testobig span.big").html($(curr).find('.titolo').html().replace(/class="titoloopportunita"/, 'class="big"'));
		$(".bigArrow").attr("href", $("#big img").parent().attr('href'));
		$(".tuttipost").attr("href", $("#big img").parent().attr('href'));
		
	});

	//curr.click();
}

function SplashCheckMouseOver (targetElem)
{
	window._lockSplashSlide = true;
	
	if ($(targetElem).attr('current') != 1)
		News_SetCurrent($(targetElem));
	
	$(targetElem).find('img').attr('src', $(targetElem).find('img').attr('src').replace(/_over/, '').replace(/\.jpg/, '_over.jpg'))
	$(targetElem).addClass('SplashMenuOver');
}

function SplashCheckMouseOut (targetElem)
{
	window._lockSplashSlide = false;
	
	$(targetElem).find('img').attr('src', $(targetElem).find('img').attr('src').replace(/_over/, ''))
	$(targetElem).removeClass('SplashMenuOver');
}

