Event.observe(window, 'load', initAll);

function initAll(){
    $('loadingD').show();
	Event.observe($('zacron'), 'click', showDataZ);
	Event.observe($('news'), 'click', showDataN);
	
	//new Insertion.After($('container'), "<img id=\"zacron\" class=\"area\" src=\"immagini/foglio2.png\"></img><div id='closeZ' class='chiudiArea'></div><div class='inArea'>La ZACRONWEB offre servizi di consulenza e realizzazione di applicazioni e sistemi Web, al fine di adattare al meglio le soluzioni tecnologiche disponibili alle esigenze del cliente</div>");

	$('areaN').innerHTML = "<div class='zacronTitolo' ></div><div class='newsTitolo'></div><div id='closeN' class='chiudiArea'></div><div class='inArea'><b>[27.05.08]</b> Dopo la segnalazione su <a href='http://www.sitocreativo.com/2008/05/16/zacronweb/'>SitoCreativo</a>, il nostro \"naturalistico sito\" riceve un nuovo riconoscimento da <a href='http://www.italiawebstar.com/'>Italia Web Star</a> che ci ha premiato con tre stelle nella categoria <a href='http://www.italiawebstar.com/interna.asp?c=WEB%20DESIGNER'>Web Designer</a></div>";
	$('areaZ').innerHTML = "<div class='zacronTitolo'></div><div id='closeZ' class='chiudiArea'></div><div class='inArea'><b>ZACRONweb</b> è un progetto di collaborazione tra Flavio Zaccaro e Francesco Ronzano.<br/>Per informazioni lasciaci un messaggio nella sezione <a href='contatti.htm'>Contatti</a> oppure invia una e-mail all'indirizzo <a href='mailto:info@zacronweb.com'>info@zacronweb.com</a>.</div>";
	Event.observe($('closeZ'), 'click', showDataZ);
	Event.observe($('closeN'), 'click', showDataN);
	
	$(nomeOriz).setStyle({bottom: '-483px' });

	$('newsT').setStyle({zIndex:1}); 
	$('areaN').setStyle({zIndex:1});		
	$('zacronT').setStyle({zIndex:1}); 
	$('areaZ').setStyle({zIndex:1});	

	preloadImages(immaginiA);
	window.setTimeout('checkLoadImg();', 1000);
}

function visualizzaPag(){
	$('loadingD').hide();
	// Effetti di visualizzazione immagini già in cache	
	$(nomeOriz).show();
	new Effect.Morph(nomeOriz,{
		style : 'bottom: 0px',
		duration : 2
	});
	preloadPageImages();
}

function showDataZ(){
	Event.stopObserving($('zacron'), 'click', showDataZ);
	Event.stopObserving($('news'), 'click', showDataN); 
		if($('newsT').getStyle('zIndex') == "10"){
			new Effect.Parallel([ 
				new Effect.Morph($('newsT'), {sync: true, style : 'bottom:-120px'}),
				new Effect.Morph($('areaN'), {sync: true, style : 'bottom:-120px'})],
				{ duration: 1.0}
			);
				
			window.setTimeout('preCompleteShow(\'zacronT\')', 1000);
			
		}
		else{
			
			completeShow('zacronT'); 
		} 
			
}

function showDataN(){
	Event.stopObserving($('zacron'), 'click', showDataZ);
	Event.stopObserving($('news'), 'click', showDataN);
		if($('zacronT').getStyle('zIndex') == "10"){
			new Effect.Parallel([ 
				new Effect.Morph($('zacronT'), {sync: true, style : 'bottom:-120px'}),
				new Effect.Morph($('areaZ'), {sync: true, style : 'bottom:-120px'})],
				{ duration: 1.0}
			);
						
			window.setTimeout('preCompleteShow(\'newsT\')', 1000);

			}
		else{
			
			completeShow('newsT');  
		} 


}

function prePos(nome){
	if(nome=='newsT'){
		$('newsT').show();
		$('areaN').show(); 
		$('newsT').setStyle({bottom: '-120px',zIndex:10 });
		$('areaN').setStyle({bottom: '-120px',zIndex:10 });
	}
	else{
		$('zacronT').show();
		$('areaZ').show();
		$('zacronT').setStyle({bottom: '-120px',zIndex:10 });
		$('areaZ').setStyle({bottom: '-120px',zIndex:10 });
	}
}

function postPos(nome){
	if(nome=='newsT'){
		$('newsT').setStyle({bottom: '0px',zIndex:1 });
		$('areaN').setStyle({bottom: '0px',zIndex:1 });

	}
	else{
		$('zacronT').setStyle({bottom: '0px',zIndex:1 });
		$('areaZ').setStyle({bottom: '0px',zIndex:1 });

	}
}

function preCompleteShow(nome){
	if(nome=='newsT'){
		postPos('zacronT');
		completeShow('newsT');
	}
	else{
		postPos('newsT');
		completeShow('zacronT');
	}	 	
}

function completeShow(nome){
	if(nome=='newsT')
		app='areaN';
	else
		app='areaZ';
		
		
	if($(nome).getStyle('zIndex') == "10"){
		new Effect.Parallel([ 
			new Effect.Morph(nome, {sync: true, style : 'bottom:-120px'}),
			new Effect.Morph(app, {sync: true, style : 'bottom:-120px'})],
			{ duration: 1.0}
		);
		if(nome=='newsT')
			window.setTimeout('postPos(\'newsT\')', 1500);
		else
			window.setTimeout('postPos(\'zacronT\')', 1500); 
	}
	else{
		prePos(nome);
		if(nome=='newsT'){ 
			new Effect.Parallel([ 
				new Effect.Morph($('newsT'), {sync: true, style : 'bottom:70px'}),
				new Effect.Morph($('areaN'), {sync: true, style : 'bottom:70px'})],
				{ duration: 1.0}
			);
		} 
		else{
				new Effect.Parallel([ 
				new Effect.Morph($('zacronT'), {sync: true, style : 'bottom:70px'}),
				new Effect.Morph($('areaZ'), {sync: true, style : 'bottom:70px'})],
				{ duration: 1.0}
			);
		}
	}
	window.setTimeout('completeShow1("' + nome + '")', 700);
	
}

function completeShow1(nome){
	Event.observe($('zacron'), 'click', showDataZ);
	Event.observe($('news'), 'click', showDataN);
}
