// JavaScript Document
/*
loaded=0;
showed=0;
function check() {
	loaded++
	$('#qui img').css({'opacity':'0'});
	if(loaded == $('#qui img').length) { 
		showfirst();
	}
}

function showfirst() {
	showed++;
//	if(showed == 1) {
		$('#loading').hide();
		$('#qui img').css({'z-index':'0','opacity':'0'});
		$('#qui img').first().css({'z-index':'1'});
		$('#qui img').first().animate({'opacity':'1'},1000);
		$('#titolo h4').html('<span>cattolicaturismo</span> - ' + $('#qui img').eq(0).attr('title'));
		$('#titolo').delay(500).animate({'top':'192px'});
		dorest();
//	}
}

function dorest() {
	$('span.slideshow').animate({'left':'100px', 'opacity':'0'});
	x=1;
	setInterval(function() {
		$('#qui img').css({'z-index':'0'});
		$('#qui img').eq(x).css({'z-index':'1'});
		$('#titolo h4').css({'opacity':'0'});
		$('#qui img').eq(x).animate({'opacity':'1'},1000);
		$('#titolo h4').delay(500).html('<span>cattolicaturismo</span> - ' + $('#qui img').eq(x).attr('title'));
		$('#titolo h4').animate({'opacity':'1'});
		$('#qui img').not('#qui img:eq('+x+')').animate({'opacity':'0'},1000);
		x++;
		if(x >= loaded) {x=0;}
	}, 10000);
}

$.ajax({
	type: "post",
	url: "http://www.cattolicaturismo.com/ajax/topslide.htm",
	success : function (response) {
		$('#qui').html(response);
	}
});*/



$(document).ready(function() {
	var rand = Math.floor(Math.random()*9)+1;
	$('#img-sx').css({'background':'url(../images/top_sx/cattolicaturismo_top_sin'+rand+'.jpg) top center no-repeat','opacity':'.2'});
	$('#img-sx').animate({'opacity':'1'},1000);
	
	var rand1 = Math.floor(Math.random()*16)+1;
	$('#qui img').css({'opacity':'0'});
	$('#qui img').attr('src', '../images/top_dx/cattolica_top_dx'+rand+'.jpg');
	$('#qui img').load(function () {
		$(this).animate({'opacity':'1'},1000)
	})
	
	$('.menu-top a').hover(function() {
		if ($(this).attr('class') != "current") {
			$(this).stop()
			$(this).animate({'line-height':'12px','color':'#f78103'}, 80);
		} else { 				$(this).stop(); $(this).animate({'color':'#c7d9de'}, 200) }
		}, function() {
		if ($(this).attr('class') != "current") {
			$(this).stop()
			$(this).animate({'line-height':'17px', 'color':'#2b7fb7'}, 250);	
		} else { 	$(this).stop(); $(this).animate({'color':'#a4bcc2'}, 300); }
	});
	$('.menu-top a.current').click(function(e){e.preventDefault();});
});
