﻿{
//var ch="multi";
function switchMenu(){
    var qs=location.search.match(/\bc\= *([^\&]+)/);
       
    if(qs!=null)
    {
        if(mainToolbar.firstIndexOf(qs[1])!=-1) {
            channel=mainToolbar.firstIndexOf(qs[1]);
            channelId=qs[1];
        }
    }else{
        var qs=location.pathname.match(/(console.[^/]+)/);
        if(qs!=null){
            channel=consoleIdExt.MatchIndex(qs[1].replace("console_",""));
            channelId=qs[1].replace("console_","");
            
        }else{
            if(location.pathname.lastIndexOf("ps2-xbox-gcube-psx-n64-gameboy-dreamcast-saturn-neogeo")!=-1)
            {
                channel=8;
                channelId="ps2"
            }
        }
    }

    //if(channel<7){
    if((consoleNewGenId.lastIndexOf(channelId)!=-1||consoleNewGenIdExt.lastIndexOf(channelId)!=-1)&&channelId!="xbox"){
        $obj(mainToolbar[channel]).style.backgroundImage = "url('/img/main_toolbar/"+mainToolbar[channel]+".png')";
        $obj('navi_child_'+mainToolbar[channel]).className = "visible";
        $obj('toolbar_child').style.backgroundColor=childToolbarColor[channel];
    }else{
        //if(channel>=8&&channel<=16){
        if(consoleOldGenId.lastIndexOf(channelId)!=-1||consoleOldGenIdExt.lastIndexOf(channelId)!=-1){
            $obj('old_gen').style.backgroundImage = "url('/img/main_toolbar/old_gen.png')";
            $obj('navi_child_old_gen').className = "visible";
            $obj('toolbar_child').style.backgroundColor=childToolbarColor[0];
        }
        //if(channel==19){
        if(channelId=="my"){
            $obj('my').style.backgroundImage = "url('/img/main_toolbar/multi.png')";
            $obj('navi_child_my').className = "visible";
            $obj('toolbar_child').style.backgroundColor=childToolbarColor[0];
        }
    }
    $obj('toolbar_child').className = "visible";
    onLabel();
    WebtvCommunity();
}

function onLabel()
{
    //if(channel<7)
    if((consoleNewGenId.lastIndexOf(channelId)!=-1||consoleNewGenIdExt.lastIndexOf(channelId)!=-1)&&channelId!="xbox")
        $obj(mainToolbar[channel]).getElementsByTagName('a')[0].style.color=fontColor[channel];
    else{
        //if(channel>=8&&channel<=16)$obj('old_gen').getElementsByTagName('a')[0].style.color=fontColor[0];
        if(consoleOldGenId.lastIndexOf(channelId)!=-1||consoleOldGenIdExt.lastIndexOf(channelId)!=-1)$obj('old_gen').getElementsByTagName('a')[0].style.color=fontColor[0];
        //if(channel==19)$obj('play').getElementsByTagName('a')[0].style.color=fontColor[0];
        if(channelId=="playonline")$obj('play').getElementsByTagName('a')[0].style.color=fontColor[0];
    }
}

function offLabel()
{
	for (var i=0; i<=13;i++){
        if($obj(mainToolbar[i]).style.backgroundImage.indexOf('blank.gif')!=-1||$obj(mainToolbar[i]).style.backgroundImage=="")
        {
           $obj(mainToolbar[i]).getElementsByTagName('a')[0].style.color="#444";
        }
    }
}

function WebtvCommunity()
{
    /*if(consoleNewGenId.lastIndexOf(channelId)!=-1||consoleNewGenIdExt.lastIndexOf(channelId)!=-1)
        $obj("a_web_tv").href="/videorecensioni_videogiochi/index.aspx?c="+mainToolbar[channel];
    else
        $obj("a_web_tv").href="/videorecensioni_videogiochi/index.aspx?c=multi";
    */
    
    if(channel>0)
    {
        if (consoleNewGenId.lastIndexOf(channelId)!=-1||consoleNewGenIdExt.lastIndexOf(channelId)!=-1)
            $obj("a_community").href="http://www.gamesforum.it/board/forumdisplay.php?f="+urlForum[channel];
        else
            $obj("a_community").href="http://www.gamesforum.it/board/forumdisplay.php?f="+urlForum[7];  
    }
}
}