var expSwitch = 0;

function closeMenu(obj){
    try {
        if(obj.target.id != "supportbox" && obj.target.id != "support"){
            $('supportbox').style.display = 'none';
        }
        if(obj.target.id != "acctbox" && obj.target.id != "acct"){
            $('acctbox').style.display = 'none';
        }
    } catch(e) {}
    return false;
}

function goToURL(url){
    location.href=url; return false;
}

function subMenuColor(evt){
    if(evt.type == "mouseover") evt.currentTarget.style.backgroundColor = '#eeeeee';
    if(evt.type == "mouseout") evt.currentTarget.style.backgroundColor = '#FFFFFF';
    return false;
}

function slide(elm, varY, transTime){
    var fps = 60;
    var delay = 1000/fps;
    var totalFrames = transTime/delay;
    var diff = parseInt(varY,10);
    var rate = (diff/totalFrames);
    
    var what = document.getElementById(elm);
    var start = parseInt(what.style.height.replace(/px/, ""),10);
    var stop = start + diff;
    var time = 0;
    
    for(var i = 0; i <= totalFrames; i++) {
        setTimeout('document.getElementById("'+what.id+'").style.height = "'+(start+(i*rate))+'px"',time += delay);
    }
    
    if(varY > 0){
        setTimeout('expSwitch = 1',time+delay);
    }
    else if(varY < 0){
        setTimeout('expSwitch = 0',time+delay);
    }
}

function expToggle(){
    durationTime = 0.72;
    framesSec = 60;
    if(expSwitch == 0){
        expSwitch = 2;
        slide('exp', 180, 720);
        new Effect.Opacity('dl', { fps: framesSec, duration: durationTime, transition: Effect.Transitions.linear, from: 1.0, to: 0.0,
            afterFinish: function(){
                $('dl').style.display = 'none';
                $('dl2').style.display = '';
            }
        });
        new Effect.Opacity('con_text', { fps: framesSec, duration: durationTime, transition: Effect.Transitions.linear, from: 1.0, to: 0.0,
            afterFinish: function(){
                $('con_text').style.display = 'none';
                $('vid').style.display = '';
            }
        });
    }
    else if(expSwitch == 1){
        expSwitch = 2;
        slide('exp', -180, 720);
        new Effect.Opacity('dl', { fps: framesSec, duration: durationTime, transition: Effect.Transitions.linear, from: 0.0, to: 1.0,
            beforeStart: function(){
                $('dl').style.display = '';
                $('dl2').style.display = 'none';
            }
        });
        new Effect.Opacity('con_text', { fps: framesSec, duration: durationTime, transition: Effect.Transitions.linear, from: 0.0, to: 1.0,
            beforeStart: function(){
                $('con_text').style.display = '';
                $('vid').style.display = 'none';
            }
        });
    }
}

function show_links(what,small,newwin){
    var newwin = (newwin == null) ? false : newwin;
    var link   = (newwin) ? ' target="_blank"' : '';
    var small  = (small == null) ? false : small;
    var append = (small) ? '_s.png' : '.png';
    var height = (small) ? '44' : '85';
    var spacer = (small) ? '9' : '14';
    var tab = (small) ? '45' : '70';
	var tab1 = (small) ? '45' : '60';
	
    var display = '<div style="height: '+height+'px; ">';
    display += '<a href="skype:seoroma.biz?call"><img style="display: inline;" src="immagini/skype'+append+'" alt="Chiamata Skype" onmouseover="document.getElementById(\'dl_display\').innerHTML = \'Skype\'; return false;" onmouseout="document.getElementById(\'dl_display\').innerHTML = \'&nbsp;\'; return false;"/></a>';
    display += '<div style="margin-left: '+spacer+'px; display: inline;"/>';
    display += '<a href="msnim:chat?contact=berno@seoroma.biz"><img style="display: inline;" src="immagini/messenger'+append+'" alt="Chat su Messenger" onmouseover="document.getElementById(\'dl_display\').innerHTML = \'Messenger\'; return false;" onmouseout="document.getElementById(\'dl_display\').innerHTML = \'&nbsp;\'; return false;"/></a>';
    display += '<div style="margin-left: '+spacer+'px; display: inline;"/>';
    display += '<a href="mailto:informazioni@seoroma.biz"><img style="display: inline;" src="immagini/email'+append+'" alt="Scrivi una Mail" onmouseover="document.getElementById(\'dl_display\').innerHTML = \'Email\'; return false;" onmouseout="document.getElementById(\'dl_display\').innerHTML = \'&nbsp;\'; return false;"/></a>';
	display += '<table><tr><td width="'+tab+'" align="center">';
	display += '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>';
	display += '<img src="http://mystatus.skype.com/smallicon/seoroma.biz" style="border: none;" alt="il mio stato skype" /></td><td width="'+tab1+'">&nbsp;</td>';
	display += '<td><img style="border-style: none;" src="http://messenger.services.live.com/users/ab183e742a9dd7cd@apps.messenger.live.com/presenceimage?mkt=it-IT" width="16" height="16" alt="il mio stato su Messenger" />';
    display += '</td></tr></table></div>';
	display += '</div>';
    what.innerHTML = display;
    return false;
}