function getFile(fileName){
    oxmlhttp = null;
    try{
        oxmlhttp = new XMLHttpRequest();
        oxmlhttp.overrideMimeType("text/xml");
    }
    catch(e){
        try{
            oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){
            return null;
        }
    }
    if(!oxmlhttp) return null;
    try{
       oxmlhttp.open("GET",fileName,false);
       oxmlhttp.send(null);
    }
    catch(e){
       return null;
    }
    return oxmlhttp.responseText;
}
// fine funzione httpRequest

//var intro = ("<?php echo "$show_page";?>");

function show_page(){

	if (intro == 1){
	
			//inizio animazione
			//new Effect.Puff('fondo', {duration: 1.0});
			Sound.play($('sound_intro').value,{replace:true});
			
			new Effect.BlindDown('wrapper', { delay:1.5, duration:2.8, queue: 'front'});
			new Effect.Appear('header', {duration: 3.8});
			new Effect.Pulsate('header', { pulses: 2, duration: 3.0, queue: 'end' });
			
			new Effect.Parallel([
				
			  	new Effect.Appear('wrapper-menu', {sync: true}), 
			  	new Effect.Appear('wrapper-scatole', {sync: true})
			], { 
			  duration: 4.8,
			  delay: 6.5
			});
			
			new Effect.Parallel([
				new Effect.Morph('wrapper-scatole', {style: 'height:180px; width: 900px;', sync: true }),
				new Effect.Morph('mission', {style: 'height:180px; width: 300px;', sync: true }),
				new Effect.BlindDown('pmission', { sync: true}),
				new Effect.Morph('tecnologia', {style: 'height:180px; width: 300px;', sync: true }),
				new Effect.BlindDown('p-tecnologia', {sync: true}),
				new Effect.Morph('people', {style: 'height:180px; width: 300px;', sync: true }),
				new Effect.BlindDown('p-people',  {sync: true})
			  
			], { 
			  duration: 3.0,
			  delay: 5.3
			});
			
			
			new Effect.Parallel([
			
				new Effect.BlindUp('pmission', {sync: true}),
				new Effect.Fade('pmission', {sync: true}),
				new Effect.BlindUp('p-tecnologia', {sync: true}),
				new Effect.Fade('p-tecnologia', {sync: true}),
				new Effect.BlindUp('p-people', {sync: true }),
				new Effect.Fade('p-people', {sync: true })

			], { 
			  duration: 3.1,
			  delay: 8.0
			});
			
			
			
			
			new Effect.Parallel([
			
			
				new Effect.Morph('people', {style: 'height:50px; width: 300px;', sync: true}),
				new Effect.Morph('mission', {style: 'height:50px; width: 300px;', sync: true}),
				new Effect.Morph('tecnologia', {style: 'height:50px; width: 300px;', sync: true}),
			  	new Effect.Morph('wrapper-scatole', {style: 'height:50px; width: 900px;', sync: true })
			], { 
			  duration: 2.8,
			  delay: 9.0
			});
			
			new Effect.Parallel([
			
				new Effect.Appear('wrapper-video', { sync: true}),
				new Effect.Appear('wrapper-offices', { sync: true })
			], { 
			  duration: 4.0,
			  delay: 11.0
			});
			
			new Effect.Parallel([
			
				new Effect.Pulsate('wrapper-video', { sync: true })
			], { 
			  duration: 6.0,
			  delay: 11.0
			});
			
			new Effect.Parallel([
			
				new Effect.Pulsate('wrapper-offices', { sync: true })
			], { 
			  duration: 6.0,
			  delay: 16.0
			});
			
				setTimeout("acceso_spento()",21000);
		}
	else {
	//alert("hai già visto");
	 document.getElementById('wrapper').style.display = 'block';
	 document.getElementById('header').style.display = 'block';
	 document.getElementById('wrapper-menu').style.display = 'block';
	 document.getElementById('wrapper-scatole').style.display = 'block';
	 document.getElementById('wrapper-video').style.display = 'block';
	 document.getElementById('wrapper-offices').style.display = 'block';
	 acceso_spento();
	}

}





function acceso_spento(){


//var on_off = getFile('acceso_spento.txt')
 if (on_off == '1'){
 		document.getElementById('news').style.display = 'block';
		pulse_news();
		//alert(on_off)
 		}
 else {
     document.getElementById('news').style.display = 'none'
 }
 
}

function pulse_news(){
new Effect.Pulsate('tbl-news', { pulses: 3, duration: 2.0 });
setTimeout("pulse_news()",6000);
}






function ViewOnScheda(contenuto, immagine_scheda){
		if (document.all||document.getElementById){
		cross_el2=document.getElementById? document.getElementById("scheda-filmati"):document.all.scheda-filmati
		cross_el1=document.getElementById? document.getElementById("locandina"):document.all.locandina
		
		 
		
		contenuto = getFile(contenuto)
		
		new Effect.SwitchOff('showrill', {duration: 0.4 });
		new Effect.Appear('scheda-filmati', {delay:1.0, duration:0.9});
		new Effect.Opacity('scheda-filmati', { delay:1.0, from: 0.0, to: 1.0, duration: 0.9 });
		new Effect.Opacity('wrapper-scatole', { delay:1.0, from: 1.0, to: 0.3, duration: 0.9 });
		new Effect.Opacity('horizontal', { from: 1.0, to: 0.1, duration: 0.9 });
		new Effect.Opacity('news', { from: 1.0, to: 0.0, duration: 0.9 });
		new Effect.Opacity('wrapper-offices', { from: 1.0, to: 0.0, duration: 0.9 });
		cross_el2.innerHTML= '<img src="img/space20.gif" width="20" height="20" alt="" />' + immagine_scheda + contenuto + '<a id="close" href="#scheda-filmati" onclick="ViewOffScheda()"><img src="img/transparent.gif" width="1" height="1" alt="" />X Close</a>'
		
		
		
		}
		else if (document.layers)
		{
		document.d1.document.d2.document.write(contenuto)
		document.d1.document.d2.document.write(immagine_scheda)
		document.d1.document.d2.document.close()
		}
		
	}


function ViewOffScheda(){
		
		var contenuto = " "
		var immagine_scheda = " "
		new Effect.Fade('scheda-filmati', {duration: 0.9 });
		new Effect.Appear('showrill', {delay:1.0, duration:0.9});
		new Effect.Opacity('horizontal', { from: 0.1, to: 1.0, duration: 0.0 });
		new Effect.Opacity('news', { from: 0.0, to: 1.0, duration: 0.0 });
		new Effect.Opacity('wrapper-offices', { from: 0.0, to: 1.0, duration: 0.0 });
		document.getElementById('horizontal').style.display='block';
		new Effect.Opacity('wrapper-scatole', { delay:1.0, from: 0.3, to: 1.0, duration: 0.9 });
		
}


var contatore = 0

function swapImage(id_immagine, id_div, p) {

var immagine = document.getElementById(id_immagine).src
var lungh = immagine.length
var indice = immagine.lastIndexOf("/")
//alert (contatore)
//alert (lungh)
//alert (indice)


var test_immagine = immagine.slice(indice,lungh)
//alert (test_immagine)
switch (test_immagine){
case '/freccette-giu-mission.gif':
	Sound.enable();
	Sound.play($('sound_demo_track_url').value,{replace:true});
	
	document.getElementById('IMG1-Mission').src = "img/freccette-su-mission.gif"
	document.getElementById('tecnologia-freccette').src = "img/freccette-su-mission.gif"
	document.getElementById('people-freccette').src = "img/freccette-su-mission.gif"
	new Effect.Opacity('wrapper-video', { from: 1.0, to: 0.5, duration: 0.5 });
	new Effect.DropOut('wrapper-video', { duration: 2.5 });
	new Effect.Opacity('news', { from: 1.0, to: 0.0, duration: 0.9 });
	new Effect.Opacity('wrapper-offices', { from: 1.0, to: 0.0, duration: 0.9 });
	//new Effect.BlindDown('wrapper-scatole', { scaleFrom: 100%, scaleTo: 150%});
	new Effect.Morph('wrapper-scatole', {style: 'height:180px; width: 900px;', duration: 1.5 });
	//alert(id_div);
	new Effect.Morph('mission', {style: 'height:180px; width: 300px;', duration: 1.5 });
	new Effect.BlindDown('pmission', { duration: 2.5 });
	new Effect.Morph('tecnologia', {style: 'height:180px; width: 300px;', duration: 1.5 });
	new Effect.BlindDown('p-tecnologia', { duration: 2.5 });
	new Effect.Morph('people', {style: 'height:180px; width: 300px;', duration: 1.5 });
	new Effect.BlindDown('p-people', { duration: 2.5 });
	//contatore = contatore+1
	return(false);
 case '/freccette-su-mission.gif':
 	
   	Sound.enable();
   	Sound.play('',{replace:true});
   	Sound.disable();
	document.getElementById('IMG1-Mission').src = "img/freccette-giu-mission.gif"
	document.getElementById('tecnologia-freccette').src = "img/freccette-giu-mission.gif"
	document.getElementById('people-freccette').src = "img/freccette-giu-mission.gif"
	new Effect.Morph('wrapper-scatole', {style: 'height:50px; width: 900px;', duration: 0.5 });
	new Effect.BlindUp('pmission', { duration: 1.0 });
	new Effect.Morph('mission', {style: 'height:50px; width: 300px;', duration: 1 });
	new Effect.BlindUp('p-tecnologia', { duration: 1.0 });
	new Effect.Morph('tecnologia', {style: 'height:50px; width: 300px;', duration: 1 });
	new Effect.BlindUp('p-people', { duration: 1.0 });
	new Effect.Morph('people', {style: 'height:50px; width: 300px;', duration: 1 });
	new Effect.Opacity('wrapper-video', { from: 0.4, to: 1.0, duration: 2.5 });
	new Effect.BlindDown('wrapper-video', { duration: 2.0 });
	new Effect.Opacity('news', { from: 0.0, to: 1.0, duration: 0.9 });
	new Effect.Opacity('wrapper-offices', { from: 0.0, to: 1.0, duration: 0.9 });
	
	return(false);
 }
}



function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function Appear(){
	 ('player-showrill');
}

function appare(id_titoli){
	new Effect.Opacity('header', { from: 1.0, to: 0.1, duration: 0.4 });
	new Effect.Opacity('wrapper-menu', { from: 1.0, to: 0.1, duration: 0.4 });
	new Effect.Opacity('showrill', { from: 1.0, to: 0.1, duration: 0.4 });
	new Effect.Opacity('works', { from: 1.0, to: 0.1, duration: 0.4 });
	new Effect.Opacity('wrapper-scatole', { from: 1.0, to: 0.1, duration: 0.4 });
	//new Effect.Fade('wrapper-parte-bassa', { duration: 0.4 });
	document.getElementById(id_titoli).style.display ='block'

}

function scompare(id_titoli){
	document.getElementById(id_titoli).style.display ='none'
	new Effect.Opacity('header', { from: 0.0, to: 1.0, duration: 0.5 });
	new Effect.Opacity('wrapper-menu', { from: 0.0, to: 1.0, duration: 0.5 });
	new Effect.Opacity('showrill', { from: 0.0, to: 1.0, duration: 0.5 });
	new Effect.Opacity('works', { from: 0.0, to: 1.0, duration: 0.5 });
	new Effect.Opacity('wrapper-scatole', { from: 0.0, to: 1.0, duration: 0.5 });
	//new Effect.Appear('wrapper-parte-bassa', { duration: 0.5 });
	
}

