// JavaScript Document

//Setup the example once the animator div is present
//in the DOM.
function RegistraSwf()
{
    swfobject.registerObject("Animazione1");
    //swfobject.registerObject("Animazione6");
    swfobject.registerObject("mondosinistra");
    swfobject.registerObject("mondo_destra");
    swfobject.registerObject("news_sinistra");
    swfobject.registerObject("news_destra");
    swfobject.registerObject("promozione_sinistra");
    swfobject.registerObject("promozione_destra");
    swfobject.registerObject("infanzia_sinistra");
    swfobject.registerObject("infanzia_destra");
   swfobject.registerObject("toyscenter_sx");
   swfobject.registerObject("toyscenter_dx");
   swfobject.registerObject("trenino_id");

 
}
function FermaSwf(nome)
{
    //alert("ferma " + nome);
    var swf2 = swfobject.getObjectById(nome);
    swf2.anima_swf(2);
}
function AzionaSwf(nome)
{
    //alert("muovi " + nome);
    var swf2 = swfobject.getObjectById(nome);
    swf2.anima_swf(3);
}
function ControllaSwf()
{
      if(precedente_sezione==1)
	{
        FermaSwf('Animazione1');
    }
     if(precedente_sezione==2)
	{
        FermaSwf('toyscenter_sx');
        FermaSwf('toyscenter_dx');
    }
      if(precedente_sezione==3)
	{
        FermaSwf('mondosinistra');
        FermaSwf('mondo_destra');
    }
     if(precedente_sezione==4)
	{
        FermaSwf('news_sinistra');
        FermaSwf('news_destra');
    }
    if(precedente_sezione==5)
	{
        FermaSwf('promozione_sinistra');
        FermaSwf('promozione_destra');
    }
     if(precedente_sezione==6)
	{
		//FermaSwf('Animazione6');
	}
       if(precedente_sezione==7)
	{
		FermaSwf('infanzia_sinistra');
        FermaSwf('infanzia_destra');
	}
}
function SettaPresezione(pres)
{
	presezione=pres;
}

function ControllaPosizione()
{
  //  alert(precedente_sezione);
  //  alert(sezione_corrente);
   //   alert(presezione);
    if(sezione_corrente==1)
	{
        AzionaSwf('Animazione1');
		presezione='';
    }
    if(sezione_corrente==2)
	{
        AzionaSwf('toyscenter_sx');
        AzionaSwf('toyscenter_dx');
   
		if(presezione=='')
        {
           ChiSiamo();
        }
		else if(presezione=='chi siamo')
		{
			ChiSiamo();
		}
		else if(presezione=='scrivici')
		{
			Scrivici();
		}
		else if(presezione=='lavora')
		{
			LavoraConNoi();
		}
		else if(presezione=='punti vendita')
		{
			PuntiVendita();
		}
		
		
		presezione='';
    }

    if(sezione_corrente==3)
	{
       // AzionaSwf('Animazione1');
       AzionaSwf('mondosinistra');
       AzionaSwf('mondo_destra');
       if(presezione=='')
        {
           GiftCard();
        }
		else if(presezione=='ToysCard')
        {
            GifCard();
        }
        else if(presezione=='E_Commerce')
        {
            NegozioOnLine();
        }
		else if(presezione=='GiftCard')
        {
            GiftCard();
        }
		else if(presezione=='Eventi')
        {
            Eventi();
        }
        presezione='';
    }
     if(sezione_corrente==4)
	{
        AzionaSwf('news_sinistra');
        AzionaSwf('news_destra');
		if(presezione=='')
        {
           News();    
        }
		else if(presezione=='PrimaInfanzia')
        {
            News();
        }
		
		presezione='';
    }
 if(sezione_corrente==5)
	{
        AzionaSwf('promozione_sinistra');
        AzionaSwf('promozione_destra');
        if(presezione=='')
        {
           PromozioniInCorso();
        }
		else if(presezione=='SuperStar')
        {
            SuperStar();
        }
		else if(presezione=='FuoriTutto')
        {
            FuoriTutto();
        }
        else if(presezione=='PromozioniInCorso')
        {
            PromozioniInCorso();
        }
        presezione='';

    }


    if(sezione_corrente==6)
	{
		//AzionaSwf('Animazione6');
                ToysCard2();
	}
       if(sezione_corrente==7)
	{
		   AzionaSwf('infanzia_sinistra');
        AzionaSwf('infanzia_destra');
        
		if(presezione=='')
        {
           PrimaInfanzia();    
        }
		else if(presezione=='PrimaInfanzia')
        {
            PrimaInfanzia();
        }
		else if(presezione=='Partner')
        {
            Partner();
        }
		presezione='';
	}
	semaforo=true;
    document.htmlForm.sendField.value=1;
    sendToFlash();
}
function Muovi(valore,tempo)
{
	//alert(valore);
	var attributes =
	{
        points: { by: [valore, 0] }
             
       //scroll: { to: [0, 200] },
       // 1050
    };
   // FermaSwf('Animazione1');
   // FermaSwf('Animazione6');
    //animazione_area6

    var anim = new YAHOO.util.Motion('animator2', attributes ,tempo, YAHOO.util.Easing.easeOut);
    
    anim.onComplete.subscribe(function() {
		ControllaPosizione();
	});
     anim.onStart.subscribe(function() {
		ControllaSwf();
			});
	anim.animate();
}
