


var offset=2000;
var animateVel=10000;
var fadeVel='slow';
var lastKey="#do1";
var timer;

function preload() {
  if (!document.images) return;
  var wl = new Array();
  var arguments = preload.arguments;
  for (var i = 0; i < arguments.length; i++) {
    wl[i] = new Image();
    wl[i].src = arguments[i];
  }
}

// Alternare i DIV immagine per il fade in fade out
function img1() {
    clearTimeout(timer);
    preload("/images/sfondo-2.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do1").css("background-color","#FFFFFF");
    lastKey="#do1";


    $("img#bg").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg").css('z-index','-19999px');
    $("img#bg2").css('width','100%');
    $("img#bg2").css('z-index','-9999px');
    $("img#bg2").attr("src","/images/sfondo-1.jpg");
    $("img#bg2").fadeIn('fast');
    $("img#bg2").css('right','-'+offset+'px');
    $('img#bg2').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        //setTimeout(doIt, 1000);
        $('img#bg2').fadeTo('slow', '1.0');
        //
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img2()", animateVel);

};



function img2() {
    clearTimeout(timer);
    preload("/images/sfondo-3.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do2").css("background-color","#FFFFFF");
    lastKey="#do2";


    $("img#bg2").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg2").css('z-index','-19999px');
    $("img#bg").css('width','100%');
    $("img#bg").css('z-index','-9999px');

    $("img#bg").attr("src","/images/sfondo-2.jpg");
    $("img#bg").fadeIn('fast');
    $("img#bg").css('right','-'+offset+'px');
    $('img#bg').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        $('img#bg').fadeTo('slow', '1.0');
        //setTimeout(doIt2, animateVel);
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img3()", animateVel);
};

function img3() {
    clearTimeout(timer);
    preload("/images/sfondo-4.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do3").css("background-color","#FFFFFF");
    lastKey="#do3";


    $("img#bg").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg").css('z-index','-19999px');
    $("img#bg2").css('width','100%');
    $("img#bg2").css('z-index','-9999px');
    $("img#bg2").attr("src","/images/sfondo-3.jpg");
    $("img#bg2").fadeIn('fast');
    $("img#bg2").css('right','-'+offset+'px');
    $('img#bg2').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        //setTimeout(doIt, 1000);
        $('img#bg2').fadeTo('slow', '1.0');
        //setTimeout(doIt3, animateVel);
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img4()", animateVel);

};

function img4() {
    clearTimeout(timer);
    preload("/images/sfondo-5.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do4").css("background-color","#FFFFFF");
    lastKey="#do4";


    $("img#bg").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg").css('z-index','-19999px');
    $("img#bg2").css('width','100%');
    $("img#bg2").css('z-index','-9999px');
    $("img#bg2").attr("src","/images/sfondo-4.jpg");
    $("img#bg2").fadeIn('fast');
    $("img#bg2").css('right','-'+offset+'px');
    $('img#bg2').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        //setTimeout(doIt, 1000);
        $('img#bg2').fadeTo('slow', '1.0');
        //setTimeout(doIt3, animateVel);
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img5()", animateVel);

};

function img5() {
    clearTimeout(timer);
    preload("/images/sfondo-6.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do5").css("background-color","#FFFFFF");
    lastKey="#do5";


    $("img#bg").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg").css('z-index','-19999px');
    $("img#bg2").css('width','100%');
    $("img#bg2").css('z-index','-9999px');
    $("img#bg2").attr("src","/images/sfondo-5.jpg");
    $("img#bg2").fadeIn('fast');
    $("img#bg2").css('right','-'+offset+'px');
    $('img#bg2').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        //setTimeout(doIt, 1000);
        $('img#bg2').fadeTo('slow', '1.0');
        //setTimeout(doIt3, animateVel);
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img6()", animateVel);

};
function img6() {
    clearTimeout(timer);
    preload("/images/sfondo-7.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do6").css("background-color","#FFFFFF");
    lastKey="#do6";


    $("img#bg").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg").css('z-index','-19999px');
    $("img#bg2").css('width','100%');
    $("img#bg2").css('z-index','-9999px');
    $("img#bg2").attr("src","/images/sfondo-6.jpg");
    $("img#bg2").fadeIn('fast');
    $("img#bg2").css('right','-'+offset+'px');
    $('img#bg2').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        //setTimeout(doIt, 1000);
        $('img#bg2').fadeTo('slow', '1.0');
        //setTimeout(doIt3, animateVel);
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img7()", animateVel);

};
function img7() {
    clearTimeout(timer);
    preload("/images/sfondo-8.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do7").css("background-color","#FFFFFF");
    lastKey="#do7";


    $("img#bg").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg").css('z-index','-19999px');
    $("img#bg2").css('width','100%');
    $("img#bg2").css('z-index','-9999px');
    $("img#bg2").attr("src","/images/sfondo-7.jpg");
    $("img#bg2").fadeIn('fast');
    $("img#bg2").css('right','-'+offset+'px');
    $('img#bg2').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        //setTimeout(doIt, 1000);
        $('img#bg2').fadeTo('slow', '1.0');
        //setTimeout(doIt3, animateVel);
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img8()", animateVel);

};
function img8() {
    clearTimeout(timer);
    preload("/images/sfondo-1.jpg");
    $(lastKey).css("background-color","#81786c");
    $("#do8").css("background-color","#FFFFFF");
    lastKey="#do8";


    $("img#bg").fadeOut(fadeVel);
    //$("img#bg").css('right','-80px');
    $("img#bg").css('z-index','-19999px');
    $("img#bg2").css('width','100%');
    $("img#bg2").css('z-index','-9999px');
    $("img#bg2").attr("src","/images/sfondo-8.jpg");
    $("img#bg2").fadeIn('fast');
    $("img#bg2").css('right','-'+offset+'px');
    $('img#bg2').animate({
        opacity: 0.25,
        right: '+='+offset+'px'
      }, 100, function() {
        // Animation complete.
        //setTimeout(doIt, 1000);
        $('img#bg2').fadeTo('slow', '1.0');
        //setTimeout(doIt3, animateVel);
      });

    $("#title").css("color","#FFFFFF");
    $("#subtitle").css("color","#FFFFFF");
    $("img#tasto_scopri").attr("src","/images/scopri_bianco.jpg");
    $("body").css("background-color","#000000");
    $("#content").css('color','#FFFFFF');
    timer=setTimeout("img1()", animateVel);

};


