﻿// JavaScript Document

var images = ['image-home1.jpg', 'image-home2.jpg', 'image-home3.jpg', 'image-home4.jpg', 'image-home5.jpg'];

$(document).ready(function(){
	$('<img src="immagini/' + images[Math.floor(Math.random() * images.length)] + '">').appendTo('div.layer-home-image');					   
})
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});


$(document).ready(function(){	
	$("#btn1[title]").tooltip({
		tipClass:"balloon1",
		offset:[0,-48],
		effect:"slide"
	});
	$("#btn2[title]").tooltip({
		tipClass:"balloon2",
		offset:[0,-114],
		effect:"slide"
	});
	$("#btn3[title]").tooltip({
		tipClass:"balloon3",
		offset:[0,-180],
		effect:"slide"
	});
	$("#btn4[title]").tooltip({
		tipClass:"balloon4",
		offset:[0,-248],
		effect:"slide"
	});
	//images gallery using fancybox
  $("a.gallery").fancybox({
		'titlePosition':'over'
	});
});	
