//JavaScript Document
//Place functions within this document
//Call functions within the dom ready in the html page

/*
function getWindowSize()
{
if (window.innerWidth)
	theWidth=window.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth)
	theWidth=document.documentElement.clientWidth;
else if (document.body)
	theWidth=document.body.clientWidth;

if (window.innerHeight)
	theHeight=window.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight)
	theHeight=document.documentElement.clientHeight;
else if (document.body)
	theHeight=document.body.clientHeight;

//alert (theWidth+" "+theHeight );
//	logo= $('logo');
	distanza=(theWidth-1000)/2;
	if (distanza<0) distanza=0;
	$('logo').setStyles({
    //the pattern to follow is 'property': 'value',
    'left': distanza,
    'visibility': 'visible'
    });
 //   alert('pippo');

//	pageBox= document.getElementById('pagebox');
	distanza2=(theWidth-700)/2;
	if (distanza2<150) distanza2=150;
	$('pagebox').setStyles({
    //the pattern to follow is 'property': 'value',
    'left': distanza2,
    'visibility':'visible'
    });
	//pageBox.style.left=distanza2;
		
}
*/

var Size = function()
{
	var size = window.getSize();
	var theWidth=(size.x);
	//theHeight=(size.y);
/*	topx=(theHeight-800)/2;
		if (topx<0) topx=0;
	distanzax=(theWidth-1024)/2;
		if (distanzax<0) distanzax=0;
	$('pagina').setStyles({'left': distanzax,'top': topx});
*/
	var leftlogo = (theWidth-1000)/2;
	$('logo').setStyle('left',leftlogo);
	
}
window.addEvent('domready', Size);
window.addEvent('resize', Size);



var enterMain = function() {
	$('logo').fade('hide');
	$('logo').set('tween', {duration: 3000});
	//	var tweener = $('tweener');
	
    //$('tweener').setStyle('visibility','visible')
	//$('tweener').fade('in');

    $('tweener').set('tween', {duration: 5000})
	$('tweener').fade('out');
	menuApp.delay(2000)
	logo.delay(3000);
	boxes.delay(4000);
//    getWindowSize();
}
var enterNormal = function() {
	new XtLightbox('.xtlightbox-gallery a');
    boxes();
    //getWindowSize();

}

var logo = function() {
	$('logo').fade('in');
		
}
var menuApp = function() {
	var menu = $('menu');
	menu = new Fx.Tween(menu, {
		link: 'ignore',	
		transition: Fx.Transitions.Cubic.easeOut,
		duration:2000	
	});
	menu.start('top',0)

	var menubot = $('menubot');
	menubot = new Fx.Tween(menubot, {
		link: 'ignore',	
		transition: Fx.Transitions.Cubic.easeOut,
		duration:2000		
	});
	menubot.start('margin-top',0)
}


var boxes = function() {

    var pageBox = $('pagebox');
	pageBox = new Fx.Tween(pageBox,{
		delay:2000,
		link: 'cancel',	
		transition: Fx.Transitions.Cubic.easeInOut,
		duration:2000
		});
	pageBox.start('top',-550,80);


    $('case').addEvent('click',function()
	{
		$('case').set('href', '#');
       pageBox.start('top',-550);
		(function()
		{
		location.href="case.php";
		}).delay(1700);
	
	});

$('home').addEvent('click',function()
	{
		$('home').set('href', '#');
       pageBox.start('top',-550);
		(function()
		{
		location.href="home.php";
		}).delay(1700);
	
	});
$('costruzione').addEvent('click',function()
	{
		$('costruzione').set('href', '#');
       pageBox.start('top',-550);
		(function()
		{
		location.href="costruzione.php";
		}).delay(1700);

	});

$('photo').addEvent('click',function()
	{
		$('photo').set('href', '#');
       pageBox.start('top',-550);
//		leaveFunction('pagebox');
		(function()
		{
		location.href="photo.php";
		}).delay(1700);
	
	});
$('news').addEvent('click',function()
	{
		$('news').set('href', '#');
       pageBox.start('top',-550);
//		leaveFunction('pagebox');
		(function()
		{
		location.href="news.php";
		}).delay(1700);
	
	});
$('contatti').addEvent('click',function()
	{
		$('contatti').set('href', '#');
       pageBox.start('top',-550);
//		leaveFunction('pagebox');
		(function()
		{
		location.href="contatti.php";
		}).delay(1700);
	
	});
$('adv').addEvent('click',function()
	{
		$('adv').set('href', '#');
       pageBox.start('top',-550);
//		leaveFunction('pagebox');
		(function()
		{
		location.href="adv.php";
		}).delay(1700);
	
	});
$('link').addEvent('click',function()
	{
		$('link').set('href', '#');
       pageBox.start('top',-550);
//		leaveFunction('pagebox');
		(function()
		{
		location.href="link.php";
		}).delay(1700);
	
	});
$('deva').addEvent('mouseenter',function()
	{
	$('devaimg').set('src', 'immagini/d-evaWhite.jpg');
    });
$('deva').addEvent('mouseleave',function()
	{
	$('devaimg').set('src', 'immagini/d-eva.jpg');
    });


$('deva').addEvent('click',function()
	{
		$('deva').set('href', '#');
       pageBox.start('top',-550);
//		leaveFunction('pagebox');
		(function()
		{
		location.href="deva.php";
		}).delay(1700);
	
	});
//    alert('pippos');


}  


