function move()
{
	var obj = $get('Content');
	if (obj == null) { return; }

	var left = parseInt(obj.style['left']) + 4;

	obj.style['left'] = left + 'px';

	if (left < 238)
	{
		window.setTimeout('move()', 20);
	}
	else
	{
		window.setTimeout('fade()',  20);
	    window.setTimeout('Go(1)', 3000);
	}
}

function stay()
{
	var obj = $get('Content');
	if (obj == null) { return; }

	obj.style['left'] = '240px';
    obj.style['display'] = 'block';

	var obj = $get('Navigation');
	if (obj == null) { return; }

    obj.style['filter'] = 'alpha(opacity=100)';
    obj.style['opacity'] = 1;
    obj.style['display'] = 'block';
}

function fade()
{
	var obj = $get('Navigation');
	if (obj == null) { return; }

	if (obj.opacity == null) { obj.opacity = 0; }
	obj.opacity += 2;

    obj.style['filter'] = 'alpha(opacity=' + obj.opacity + ')';
    obj.style['opacity'] = obj.opacity / 100;
    obj.style['display'] = 'block';

	if (obj.opacity < 100)
	{
		window.setTimeout('fade()', 60);
	}
}

function Go(withClose)
{
	var ban = $get('banner');
	if (ban == null) { return; }

	for(i = 0; i < ban.childNodes.length; i++)
	{
	    if (!ban.childNodes[i].style) { continue; }
		ban.childNodes[i].style['display'] = 'none';
	}

	var play = $get('play');
	if (play == null) { return; }

	if (play.isOpen == null) { play.isOpen = false; }
	if (play.isOpen)
	{
		playClose();
	}
	else
	{
		playOpen(withClose);
	}
}

function playOpen(withClose)
{
	var ban = $get('banner');
	if (ban == null) { return; }

	var left = parseInt(ban.style['left']) - 4;
	var width = parseInt(ban.style['width']) + 4;

	ban.style['left'] = left + 'px';
	ban.style['width'] = width + 'px';
    ban.style['display'] = 'block';

	if (width < 235)
	{
	    window.setTimeout('playOpen(1)', 20);
	}
	else
	{
		var play = $get('play');
			play.isOpen = true;

        var playImage = $get('playImage');
			playImage.src = '../images/close.gif';

		for(i = 0; i < ban.childNodes.length; i++)
		{
	        if (!ban.childNodes[i].style) { continue; }
			ban.childNodes[i].style['display'] = 'block';
		}
		if (withClose == 1) { window.setTimeout('Go(0)', 10000); }
	}
}

function playClose()
{
	var ban = $get('banner');
	if (ban == null) { return; }

	var left = parseInt(ban.style['left']) + 4;
	var width = parseInt(ban.style['width']) - 4;

	ban.style['left'] = left + 'px';
	ban.style['width'] = width + 'px';
    ban.style['display'] = 'block';

	if (width > 3)
	{
		window.setTimeout('playClose()', 20);
	}
	else
	{
		ban.style['display'] = 'none';

		var play = $get('play');
			play.isOpen = false;

        var playImage = $get('playImage');
			playImage.src = '../images/open.gif';
	}
}




var currentMenu = null;
function menuEnter(objName)
{
	var menu = document.getElementById(objName);
	if (menu == null) { return; }

	if (currentMenu != null)
	{
        if (menu.id != currentMenu.id) { menuHide(); }
	}
	menu.style['display'] = 'block';
	currentMenu = menu;
}

function menuHide()
{
	if (currentMenu == null) { return; }
	currentMenu.style['display'] = 'none';
	currentMenu = null;
}

document.onclick = function(e)
{
    if (!e) { e = window.event; }
    var obj = e.target;
    if (obj == null) { obj = e.srcElement; }
    if (inElement(obj))
    {
        e.cancelBubble = true;
	    if (e.stopPropagation) e.stopPropagation();
	}
	else
	{
        menuHide();
    }
}

function inElement(obj)
{
    if (obj == null) { return false; }
    if (obj.className == 'menuItem') { return true; }
    if (obj.parentNode.className == 'menuItem') { return true; }
    if (obj.className == 'menu_chi1') { return true; }
    if (obj.className == 'menu_chi2') { return true; }
    if (obj.className == 'menu_chi3') { return true; }
    if (obj.className == 'menu_chi4') { return true; }
    if (obj.className == 'menu_off1') { return true; }
    if (obj.className == 'menu_off2') { return true; }
    if (obj.className == 'menu_cli1') { return true; }
    if (obj.className == 'menu_news1') { return true; }
    if (obj.className == 'menu_news2') { return true; }
    if (obj.className == 'menu_job1') { return true; }
    if (obj.className == 'menu_contatti1') { return true; }
    return false;
}

function setButton(obj, isOn)
{
	if (isOn)
	{
		obj.style['backgroundImage'] = 'url(../images/bottone_on.gif)';
	}
	else
	{
		obj.style['backgroundImage'] = 'url(../images/bottone_off.gif)';
	}
}

function showMenu(objName)
{
	var menu = document.getElementById(objName);
	if (menu)
	{
		menu.style.display = 'block';
		currentMenu = menu;
	}
}

function showHrefTop()
{
    if (document.getElementById('scroll') != null)
    {
        if (document.getElementById('scroll').offsetHeight < document.getElementById('scroll').scrollHeight)
        {
            document.getElementById('spanTop').style['visibility'] = 'visible';
        }
        else
        {
            document.getElementById('spanTop').style['visibility'] = 'hidden';
        }
    }
}
