// aprire pop-up
function apriPop(url, name, w, h) {
	var l = Math.floor((screen.width-w)/3);
	var t = Math.floor((screen.height-h)/3);
	window.open(url,name,"width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}

// automazione per show/hide
function setSH() {

	var myElements = ".btSh";

	$(myElements).each(function(i) {

		$(this).click(function() {

			if($(this).next('div').css('display') == 'none')
				$(this).next('div').show('slow');
			else
				$(this).next('div').hide('slow');
		});

	});

}

// funzioni per il menù pricipale e tendina

function hideMenuSub() {
	var myElements = ".mnSub";

	$(myElements).each(function(i) {
		$(this).css('display','none');
	});
}

function setMenu() {

	hideMenuSub();

	var myElements = ".mnVoce";

	$(myElements).each(function(i) {

		$(this).hover(
			function() {
				$(this).find('div.mnSub').show('slow');
			},
			function() {
				$(this).find('div.mnSub').hide('slow');
			}
		);

	});

}

function animateIndex() {

	var tmp = 500;

	setTimeout ( function(){
		$('#scene1').show();
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#x512').fadeIn(1500);
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#x55').fadeIn(1500);
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#x35').fadeIn(1500);
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#scene1').fadeOut(1000);
	}, tmp) ;

	// -----------------------

	tmp += 1100;

	setTimeout ( function(){
		$('#scene2').show();
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#born').fadeIn(1500);
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#scene2').fadeOut(1500);
	}, tmp) ;


	// -----------------------

	tmp += 750;

	setTimeout ( function(){
		$('#scene3').show();
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#avventura').fadeIn(1500);
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#scene3').fadeOut(1500);
	}, tmp) ;

	// -----------------------

	tmp += 750;

	setTimeout ( function(){
		$('#scene4').show();
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#immersi').fadeIn(1500);
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#scene4').fadeOut(1500);
	}, tmp) ;

	// -----------------------

	tmp += 750;

	setTimeout ( function(){
		$('#scene5').show();
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#logo_home').fadeIn(1500);
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#scene5').fadeOut(1500);
	}, tmp) ;

	// -----------------------

	tmp += 750;

	setTimeout ( function(){
		$('#scene6').show();
	}, tmp) ;

	tmp += 750;

	setTimeout ( function(){
		$('#depliant').fadeIn(1500);
	}, tmp) ;

}

function animateColSx(pMov, pDelay) {

	setTimeout ( function(){

		$('#imgRiqMainSx').animate({
			marginLeft: '+='+pMov
		}, 7500, function() {
			pMov = pMov*-1;
			animateColSx(pMov, 3000);
			});
	}, pDelay);

}

$(document).ready(function() {

	setSH();

	if($.browser.msie) {
		if(jQuery.browser.version == '6.0') {
			$('#riqMainDx').css('width', '747px');
		}

		$('div.mnSub').css('top','18px');
		$('div.mnSub').css('left','0');
		$('div.mnSub').css('width','160px');
	}

	// Menù
	setMenu();

	// FancyBox
	$("a.gallery").fancybox();

	animateColSx(-180, 500);

});

