function toggle(target)
{
	obj=document.getElementById(target);
	obj.style.display=( (obj.style.display=='none') ? '' : 'none');
}
function hidediv(target)
{
    obj=document.getElementById(target);
	obj.style.display='none';
}
function showdiv(target)
{
	obj=document.getElementById(target);
	obj.style.display='';
}
function TracciaSpostamentoSito(nomesezione)
{
	pageTracker._trackPageview("/" + nomesezione);
	//alert(nomesezione);
}
function posLeft(eElement)
{
var nLeftPos = eElement.offsetLeft;
var eParElement = eElement.offsetParent;
while (eParElement != null)
{
nLeftPos += eParElement.offsetLeft;
eParElement = eParElement.offsetParent;
}
return nLeftPos;
}

function posTop(eElement)
{
var nTopPos = eElement.offsetTop;
var eParElement = eElement.offsetParent;
while (eParElement != null)
{
nTopPos += eParElement.offsetTop;
eParElement = eParElement.offsetParent;
}
return nTopPos;
}
function CreaSWF(id,titolo,nome_file,div,larghezza,altezza)
 {
       var flashvars = {
                  
            }
            var params = {
                    allowfullscreen:"true",
                    allowscriptaccess:"always",
					wmode: "transparent"
            }
            var attributes = {
                    id:id,
                    name:titolo
            }
            swfobject.embedSWF(nome_file, div, larghezza, altezza, "9.0.115", "Scripts//expressInstall.swf", flashvars, params, attributes);

 }
 function ResettaSottoMenu()
 {
     YAHOO.util.Dom.removeClass('m2_1', 'current'); // chi siamo
     YAHOO.util.Dom.removeClass('m2_2', 'current'); // Scrivici
     YAHOO.util.Dom.removeClass('m2_3', 'current'); // Lavora con noi
     YAHOO.util.Dom.removeClass('m2_4', 'current'); // Punti Vendita

     //YAHOO.util.Dom.removeClass('m3_1', 'current');// toys card
     YAHOO.util.Dom.removeClass('m3_2', 'current');// gift card
     YAHOO.util.Dom.removeClass('m3_3', 'current');// Eventi
     YAHOO.util.Dom.removeClass('m3_4', 'current');// Negozio on line

     //YAHOO.util.Dom.removeClass('m5_1', 'current');// superstar
     //YAHOO.util.Dom.removeClass('m5_2', 'current');// fuori tutto
    // YAHOO.util.Dom.removeClass('m5_3', 'current');
     //YAHOO.util.Dom.removeClass('m5_4', 'current');// promozioni in corso

     YAHOO.util.Dom.removeClass('m7_1', 'current');// prima infanzia
     YAHOO.util.Dom.removeClass('m7_2', 'current');// partner
 }
function Check(id) {
         if(item_menu[id]==menu_corrente)
        {
            ok=false;
        }
        else
        {
            ok=true;
        }
        if(ok==true)
        {
        if(semaforo==true)
        {
            //Partenza_Toys_Center();
			
        if(player!=false)
        {
           StopPlayer();
        }
            
             semaforo=false;
             esistenza_pano=false;
			 TracciaSpostamentoSito(item_nome_sezione[id]);
             precedente_sezione=sezione_corrente;
			 sezione_corrente=item_menu[id];

            YAHOO.util.Dom.removeClass('uno', 'current');
            YAHOO.util.Dom.removeClass('due', 'current');
            YAHOO.util.Dom.removeClass('tre', 'current');
            YAHOO.util.Dom.removeClass('quattro', 'current');
            YAHOO.util.Dom.removeClass('cinque', 'current');
            YAHOO.util.Dom.removeClass('sei', 'current');
			YAHOO.util.Dom.removeClass('sette', 'current');
            YAHOO.util.Dom.addClass(id, 'current');
           
            hideDiv('sottomenu_uno');
           
            hideDiv('sottomenu_due');
            hideDiv('sottomenu_tre');
            hideDiv('sottomenu_quattro');
            hideDiv('sottomenu_cinque');
            hideDiv('sottomenu_sei');
			hideDiv('sottomenu_sette');



            showDiv(item_sottomenu[id]);
        
   intervallo=menu_corrente-item_menu[id];
   //alert(intervallo);
     
     contatore=intervallo;
     tempo=Math.abs(intervallo*fattore)
     Muovi(contatore*step,tempo);
   if(intervallo>0)
   {
	   document.htmlForm.sendField.value=3;
       sendToFlash();
   }
   else if(intervallo<0)
   {
		document.htmlForm.sendField.value=2;
       	sendToFlash();
   }
   else
   {
          
   }

            menu_corrente=item_menu[id];
        }
        //alert('found: ' + YAHOO.util.Dom.getElementsByClassName('glossymenu', 'ul').length + ' elements');
        }
    };


	function showHideDiv(nome)
    {
        var divstyle = new String();
        divstyle = document.getElementById(nome).style.visibility;
        if(divstyle.toLowerCase()=="visible" || divstyle == "")
        {
            document.getElementById(nome).style.visibility = "hidden";
        }
        else
        {
            document.getElementById(nome).style.visibility = "visible";
        }
    }
	function showDiv(nome)
    {
        var divstyle = new String();
        divstyle = document.getElementById(nome).style.visibility;
        document.getElementById(nome).style.visibility = "visible";
    }
    function hideDiv(nome)
    {
         document.getElementById(nome).style.visibility = "hidden";
    }
	function CaricaPagina(url,container)
{
	var args = {};

	var callback = {
			success : function(o) {
			
				document.getElementById(container).innerHTML = o.responseText;
				
				//YAHOO.example.panel.wait.hide();
			},
			failure : function(o) {
				document.getElementById(container).innerHTML = "" + url;
				
				//YAHOO.example.panel.wait.hide();
			}
		}
		//document.getElementById(container).innerHTML = "<div align=\"center\" ><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><img src=\"images/ajax-loader.gif\" border=\"0\" align=\"middle\" /></p></div>";
		YAHOO.util.Connect.asyncRequest('GET',url,callback);
	}
	function GetPagina(url,container)
	{
	var args = {};

	var callback = {
			success : function(o) 
			{
				document.getElementById(container).innerHTML = o.responseText;
	
				
				
			},
			failure : function(o) {
				document.getElementById(container).innerHTML = "CONNECTION FAILED!" + url;
				
				//YAHOO.example.panel.wait.hide();
			}
		}
		
		//document.getElementById(container).innerHTML = "<div align=\"center\" ><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><img src=\"images/ajax-loader.gif\" border=\"0\" align=\"middle\" /></p></div>";
		YAHOO.util.Connect.asyncRequest('GET',url,callback);
	}
    function GetDiv(url,container)
	{
       
	var args = {};

	var callback = {
			success : function(o)
			{
				document.getElementById(container).innerHTML = o.responseText;
        	},
			failure : function(o) {
				document.getElementById(container).innerHTML = "CONNECTION FAILED!" + url;

			}
		}

		YAHOO.util.Connect.asyncRequest('GET',url,callback);
	}
   
	function PostPagina(url,container)
	{
	var args = {};

	var callback = {
			success : function(o) 
			{
				document.getElementById(container).innerHTML = o.responseText;
				
			},
			failure : function(o) {
				document.getElementById(container).innerHTML = "CONNECTION FAILED!" + url;
				
				//YAHOO.example.panel.wait.hide();
			}
		}
		
		//document.getElementById(container).innerHTML = '<div align="center"><img src="images/ajax-loader.gif"></div>';
		YAHOO.util.Connect.asyncRequest('POST',url,callback);
	}

function CaricaPaginaMin(url,container)
{
	var args = {};

	var callback = {
			success : function(o) {

				document.getElementById(container).innerHTML = o.responseText;

				//YAHOO.example.panel.wait.hide();
			},
			failure : function(o) {
				document.getElementById(container).innerHTML = "" + url;

				//YAHOO.example.panel.wait.hide();
			}
		}
		YAHOO.util.Connect.asyncRequest('GET',url,callback);
	}
	
		reinitialiseScrollPane = function()
		{
           $(el).jScrollPane();
        }
		function CaricaTesto(indirizzo,pannello)
		{
			$(pannello).jScrollPane();
			$(pannello).load(indirizzo, '', reinitialiseScrollPane);

		}
		function StilaNews()
{
     $('#visualizzatore_news').jScrollPane();
}
function ben10()
{
    document.getElementById("ben10").onclick();
}

function centopunti()
{
    document.getElementById("hasbro").onclick();
}
function clementoni()
{
    document.getElementById("clementoni").onclick();
}
function sconto()
{
    document.getElementById("sconto").onclick();
}
function primo_volantino()
{
    document.getElementById("flipbook1").onclick();
}
function secondo_volantino()
{
    document.getElementById("flipbook2").onclick();
}
function terzo_volantino()
{
    document.getElementById("flipbook3").onclick();
}
function promozioni_in_corso()
{
    presezione='PromozioniInCorso';
    Check('cinque');
}
function e_commerce()
{
    presezione='E_Commerce';
    Check('tre');
}
function t_eventi()
{
    Check('tre');
    Eventi();
}
function t_novita()
{
     Check('quattro');
     News();
}
function t_prima_infanzia()
{
    Check('sette');
}
function t_fuori_tutto()
{
    Check('sette');
    FuoriTutto();
}
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

