if (!Array.prototype.filter){Array.prototype.filter = function(fun /*, thisp*/){var len = this.length;if (typeof fun != "function"){throw new TypeError();}var res = new Array();var thisp = arguments[1]; for (var i = 0; i < len; i++){ if (i in this){var val = this[i];if (fun.call(thisp, val, i, this)){res.push(val);}}}return res;};}
BITracerBB=function(intTimeout,blnPmkInError,strPathCounter,strFormName){this.pmkForm=false;this.intTimeout=intTimeout;this.link=null;this.curTimeout=null;if((strPathCounter!='')&&(strPathCounter!=null)&&(strPathCounter!='undefined')){this.pathCounter=strPathCounter;}else{this.pathCounter='http://adimg.alice.it/tracks/bi/images/kpi.gif';};this.debugBI=this.getUrlParameter("debugBI");this.pathGo="http://go.alice.it";this.blnPmkInError=blnPmkInError;if((strFormName!='')&&(strFormName!=null)&&(strFormName!='undefined')){this.formName=strFormName;}else{this.formName='frmBILinkRedirect';}}
BITracerBB.prototype={callBIGif:function(objLink,blnGo,thePmk,theClkc,strFascia,newStrPathCounter,fncGoPage){try{this.pmkForm=false;if(this.curTimeout!=null){clearTimeout(this.curTimeout);}
this.objLink=objLink;this.link=objLink.href;var strUrlCounter="";if(((strFascia!=null)&&(strFascia!='undefined'))&&((thePmk!='')&&(thePmk!=null)&&(thePmk!='undefined'))){thePmk=thePmk+strFascia;}
if((fncGoPage!=null)&&(fncGoPage!='undefined')){this.fncGoPage=fncGoPage;}else{this.fncGoPage=null;}if(blnGo==false){var strPathCounter=this.pathCounter;if((newStrPathCounter!='')&&(newStrPathCounter!=null)&&(newStrPathCounter!='undefined')){strPathCounter=newStrPathCounter;}strUrlCounter=strPathCounter+'?pmk='+thePmk+'&rand='+Math.floor(1000000*Math.random())+'&link='+this.link;if(this.debugBI=="true"){alert(strUrlCounter);}var objRequest=this;
var returnsTimeout=function(){return objRequest.timeoutBI(thePmk);};var returns=function(){return objRequest.callBackBI();};var imgBi = document.createElement("IMG");imgBi.id="imgBi";imgBi.onload=returns;imgBi.src=strUrlCounter;document.body.appendChild(imgBi);this.curTimeout=setTimeout(returnsTimeout,this.intTimeout);}else if(blnGo==true){
strUrlCounter=this.pathGo+'/';if((theClkc!='')&&(theClkc!=null)&&(theClkc!='undefined')){strUrlCounter=strUrlCounter+theClkc;}strUrlCounter=strUrlCounter+'/';var strLink=this.link;if((thePmk!='')&&(thePmk!=null)&&(thePmk!='undefined')){var strPmk="pmk="+thePmk;if(this.link.indexOf("?")!=-1){strPmk="&"+strPmk;}else{strPmk="?"+strPmk;};strLink=this.link+strPmk;}strUrlCounter=strUrlCounter+strLink;if(this.debugBI=="true"){alert(strUrlCounter);}this.goUrl(strUrlCounter);}}catch(e){return true;}return false;},
callBackBI:function(){try{if(this.curTimeout!=null){clearTimeout(this.curTimeout);}if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}catch(e){if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}},timeoutBI:function(thePmk){try{if(this.curTimeout!=null){clearTimeout(this.curTimeout);}if(this.blnPmkInError){strPmk="pmk="+thePmk;if(this.link.indexOf("?")!=-1){strPmk="&"+strPmk;}else{strPmk="?"+strPmk;}if(this.fncGoPage!=null){this.fncGoPage();return false;};if(this.objLink.href.indexOf("#")==0){this.goUrl(this.link+strPmk);}else{document.location.href=this.objLink.href;}}
else{if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}}catch(e){if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}},getUrlParameter:function(param){var val="";var qs=window.location.search;var start=qs.indexOf(param);if(start!=-1){start+=param.length+1;var end=qs.indexOf("&",start);if(end==-1){end=qs.length}val=qs.substring(start,end);}return val;},
goUrl:function(urlLink){objRequest=false;page_request=false;if(this.objLink.target!=""){if(this.objLink.target.toLowerCase()=="_blank"){document.getElementById(this.formName).target="_blank";document.getElementById(this.formName).action=urlLink;document.getElementById(this.formName).submit();return false;};if(this.objLink.target.toLowerCase()=="_top"){document.getElementById(this.formName).target="_top";document.getElementById(this.formName).action=urlLink;document.getElementById(this.formName).submit();return false;};if(this.objLink.target.toLowerCase()=="_parent"){document.getElementById(this.formName).target="_parent";document.getElementById(this.formName).action=urlLink;document.getElementById(this.formName).submit();return false;}};document.getElementById(this.formName).target="";document.getElementById(this.formName).action=urlLink;document.getElementById(this.formName).submit();},
callBIForm:function(objLinkForm,blnGoForm,thePmkForm,theClkcForm,strFasciaForm,newStrPathCounterForm,fncGoPageForm){if (!this.pmkForm){objLinkForm.href=objLinkForm.action;return this.callBIGif(objLinkForm,blnGoForm,thePmkForm,theClkcForm,strFasciaForm,newStrPathCounterForm,function(){this.pmkForm=true;fncGoPageForm();});this.pmkForm=true;}else{return true;}},
track:function (trObjLink,trPmk,trFnc){return this.callBIGif(trObjLink,false,trPmk,'',null,null,trFnc);},
trackForm:function (trObjLink,trPmk,trFnc){return this.callBIForm(trObjLink,false,trPmk,'',null,null,trFnc);}
}

var idSelectedBB="";var bbNotify="";
BottomBar = function()
{
    this.BI = new BITracerBB(500,true,null,"frmBILinkRedirectBottomBar");
    this.arrUrlDiv= new Array("","","","/common/iframe_mail/pf/iframe_mail_nolog.html","http://local.virgilio.it/html/common_local/iframe_local_2.html","/common/VIRGILIO/bottom_bar/iframe/iframe_notizie.html","","","","","","");
    this.arrBBDiv = new Array("cont_canali","cont_canali_pers","box_personal_chn_bar","box_mail_bar","box_local_bar","box_news_bar","box_nick","box_comm_nolog","box_comm_log_Nonick","box_gestione","box_msgbox","box_status");
    this.arrBBLnk = new Array("lnk_can","bxpersonal_chn","bxmail","bxlocal","bxnews","bxnick","bxcommnolog","bxcommlogNonick","bxgestione","bxmsgbox","bxstatus");
    this.arrPersCanDisabled = new Array("1","2","3","4","5","6","7","8","9","10","11");
    this.arrPersCanDefault = new Array("1","2","3","4","5","6","7","8","9","10","11");
    this.arrLclBB=new Array("Local");
    this.lclDomainBB="http://local.virgilio.it";
    this.dtBB=new Date();
    this.ckdtBB = new Date();
    this.ckdtBB.setTime(this.dtBB.getTime() + 3600000*24*3650);
    this.bbSetting = this.getCookieBB("vSettingChanBar").split("|");
    this.bbLogged = this.getCookieBB("PAAA_AUTHE");
    this.bbLoggedType="";
    this.timeoutLogged=null;
    if (this.bbLogged!=""){
        this.arrBBLnk[2]="bxmailLog";
        var tmpTypeLogged = this.getCookieBB("tinv");
        if ((tmpTypeLogged=="1")||(tmpTypeLogged=="6")){
                this.bbLoggedType="virgilio";
            }
        if (tmpTypeLogged=="5"){
            this.bbLoggedType="alice";
            }
    }
    this.bbSearchT="";
    this.paramHP="";
    if (window.location.host=="www.virgilio.it"){
        this.paramHP="?from=hpvirgilio&link=" + escape(top.window.location.href);
    }
    else {
        this.paramHP="?link=" + escape(top.window.location.href);
    }
    if ((window.location.host.toLowerCase().indexOf("community")!=-1)||(window.location.host.toLowerCase().indexOf("people")!=-1)){
      this.arrUrlDiv[5] = "http://community.virgilio.it/common/VIRGILIO/bottom_bar/iframe/iframe_notizie_utf8.html";
    }
    
    document.getElementById("ckUserCanPersAddName").onkeydown = this.captureEnter;
    document.getElementById("ckUserCanPersAddUrl").onkeydown = this.captureEnter;
}
BottomBar.prototype = {
btt_close : function  (ide,ade){
        var elm = document.getElementById(ide);
        var elmlnk = document.getElementById(ade);
        elm.style.display='none';
        elmlnk.className= '';
        return false;
    },
etichetta : function (eti,objDisplay) {
        if (objDisplay!=null){
            if(document.getElementById(objDisplay).style.display=="block")
                {return false;}
             }
        var etk = document.getElementById(eti);
        etk.style.display = 'block';
    },
etichetta_close : function  (etic) {
        var etkc = document.getElementById(etic);etkc.style.display = 'none';
    },
openbox : function (bxs,axs){
        if (ega != true){
            var bxt = document.getElementById(bxs);
            bxt.style.display = 'block';
            var axt = document.getElementById(axs);a
            xt.className = 'on';
            ega = true;
        }
        else
        {
            var bxt = document.getElementById(bxs);
            bxt.style.display = 'none';
            var axt = document.getElementById(axs);
            axt.className = '';
            ega = false;
        }
       return false;
    },
setCookieBB : function (name,value,expires,path,domain,secure){document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");},
getCookieBB : function (c_name){if(document.cookie.length>0){c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1){c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));}}return"";},
trim : function(stringa) {while (stringa.substring(0,1) == ' '){stringa = stringa.substring(1, stringa.length);}while (stringa.substring(stringa.length-1, stringa.length) == ' '){stringa = stringa.substring(0,stringa.length-1);}return stringa;},
loadLocalBB : function () {
        var lclCity = this.getCookieBB("vlocal_city");
        lclCity=lclCity.replace("city()_idcity()_provincia()_idprovincia()_hostcity()_regione()","");
        if (lclCity!=""){
            this.arrLclBB = lclCity.split("_");
            this.arrLclBB[0]=unescape(this.arrLclBB[0].replace("city(","").replace(")",""));
            this.arrLclBB[1]=this.arrLclBB[1].replace("idcity(","").replace(")","");
            this.arrLclBB[2]=this.arrLclBB[2].replace("provincia(","").replace(")","");
            this.arrLclBB[3]=this.arrLclBB[3].replace("idprovincia(","").replace(")","");
            if (lclCity.indexOf("hostcity")!=-1){
                    this.arrLclBB[4]=this.arrLclBB[4].replace("hostcity(","").replace(")","");
                    this.lclDomainBB="http://"+ this.arrLclBB[4] + ".virgilio.it";
                    this.arrLclBB[5]=this.arrLclBB[5].replace("regione(","").replace(")","");
                    this.arrLclBB[4]=this.arrLclBB[5];}else{this.arrLclBB[4]=this.arrLclBB[4].replace("regione(","").replace(")","");
                 //this.lclDomainBB="http://"+ this.arrLclBB[0].replace(/à/g,"a").replace(/è/g,"e").replace(/é/g,"e").replace(/ì/g,"i").replace(/ò/g,"o").replace(/ù/g,"u").replace(/ /g,"-").replace(/'/g,"") + ".virgilio.it";
                }
        }
},

loadBB : function (bbEmailNumMsg,bbEmailNumMsgAlice,bbEmailNumMsgVirgilio) {
        /*this.bbEmailNumMsg=bbEmailNumMsg;
        this.bbEmailNumMsgAlice=bbEmailNumMsgAlice;
        this.bbEmailNumMsgVirgilio=bbEmailNumMsgVirgilio;*/
        if(typeof bbEmailNumMsg == 'undefined'){this.bbEmailNumMsg="ON";}else{this.bbEmailNumMsg=bbEmailNumMsg;}
	if(typeof bbEmailNumMsgAlice == 'undefined'){this.bbEmailNumMsgAlice="OFF";}else{this.bbEmailNumMsgAlice=bbEmailNumMsgAlice;}
      	if(typeof bbEmailNumMsgVirgilio == 'undefined'){this.bbEmailNumMsgVirgilio="ON";}else{this.bbEmailNumMsgVirgilio=bbEmailNumMsgVirgilio;}
        this.loadLocalBB();
        this.loadPersChannel();
        if(this.arrLclBB[0]!="Local"){
            var strCityLocal=this.arrLclBB[0];
            if (strCityLocal.length>13)
                {
                    strCityLocal=strCityLocal.substr(0,10)+"...";
                }
            document.getElementById("alt_local").innerHTML="Virgilio " + strCityLocal;
            document.getElementById("alt_local").style.textTransform="capitalize";
      	    this.arrUrlDiv[4]="/common/VIRGILIO/bottom_bar/iframe/iframe_local_settato.html";
      	    document.getElementById("box_local_bar_iframe").style.height="100px";
        }
        this.minimizeBB(false);
        this.newsNotify(); 
        document.getElementById("bottom_bar").style.display="block";
        if (this.lclDomainBB!="http://local.virgilio.it"){
            document.getElementById("bxlocal").onclick=function(){return objBottomBar.BI.track(document.getElementById('bxlocal') ,'tb_local_gocity',function(){objBottomBar.etichetta_close('alt_local'); objBottomBar.openAllBB('box_local_bar','bxlocal');});};
        }
        this.emailStatus();
},
emailStatus:function(){
    if (this.bbLogged!=""){
            this.emailStatusLogged();
            var tmpTimeoutBottomBar =  this;
            this.timeoutLogged=setInterval(function(){
                                                if (tmpTimeoutBottomBar.getCookieBB("PAAA_AUTHE")==""){
                                                    tmpTimeoutBottomBar.emailStatusNoLogged();
                                                    clearInterval(tmpTimeoutBottomBar.timeoutLogged);
                                                    tmpTimeoutBottomBar.emailStatus();
                                                }
                                            },100);
        }
        else
        {
           var tmpTimeoutBottomBar =  this;
            this.timeoutLogged=setInterval(function(){
                                                if (tmpTimeoutBottomBar.getCookieBB("PAAA_AUTHE")!=""){
                                                    tmpTimeoutBottomBar.emailStatusLogged();
                                                    clearInterval(tmpTimeoutBottomBar.timeoutLogged);
                                                    tmpTimeoutBottomBar.emailStatus();
                                                }
                                            },300);       
        }

},
emailStatusLogged:function(){
            this.bbLogged = this.getCookieBB("PAAA_AUTHE");
            this.bbLoggedType="";
            if (this.bbLogged!=""){
                var tmpTypeLogged = this.getCookieBB("tinv");
                if ((tmpTypeLogged=="1")||(tmpTypeLogged=="6")){
                        this.bbLoggedType="virgilio";
                    }
                if (tmpTypeLogged=="5"){
                    this.bbLoggedType="alice";
                    }
            }
            this.emailNumberMsg();
            this.arrBBLnk[2]="bxmailLog";
            document.getElementById("bxmailLog").className=document.getElementById("bxmail").className;
            document.getElementById("bxmail").style.display="none";
            document.getElementById("bxmailLog").style.display="block";
            document.getElementById("box_mail_bar_iframe").style.height="64px";
},
emailNumberMsg:function(){
// TODO AV : var bbEmailNumMsg="ON";
      if(typeof this.bbEmailNumMsg == 'undefined'){this.bbEmailNumMsg="OFF";}
      if(typeof this.bbEmailNumMsgAlice == 'undefined'){this.bbEmailNumMsgAlice="ON";}
      if(typeof this.bbEmailNumMsgVirgilio == 'undefined'){this.bbEmailNumMsgVirgilio="ON";}
      
           if (this.bbLogged!=""){
                if (this.bbEmailNumMsg!="ON") {
                    document.getElementById("ntfciframe").style.display="none";
                    document.getElementById("bxmailLog").getElementsByTagName("SPAN")[0].style.marginTop="5px";
                }
                else {
                    if ((document.getElementById("minBB").style.display!="block")&&(document.getElementById("ntfciframe").src=="")){
                        if (this.bbLoggedType=="alice"){
                            if (this.bbEmailNumMsgAlice!="ON") {
                                document.getElementById("ntfciframe").style.display="none";
                                document.getElementById("bxmailLog").getElementsByTagName("SPAN")[0].style.marginTop="5px";
                            }else{
                                document.getElementById("ntfciframe").src="http://portale.rossoalice.alice.it/ps/PostLoginBarra.do";
                            }
                        }
                        if (this.bbLoggedType=="virgilio"){
                            if (this.bbEmailNumMsgVirgilio!="ON") {
                                document.getElementById("ntfciframe").style.display="none";
                                document.getElementById("bxmailLog").getElementsByTagName("SPAN")[0].style.marginTop="5px";
                            }else{
                                document.getElementById("ntfciframe").src="http://communicator.alice.it/asp/preview_spalla.asp?mini=ok";
                            }
                        }
                    }
                }
            }
},
emailStatusNoLogged:function(){
    if(top.document.location.hostname.indexOf("www.virgilio.it")!=-1)
    {
        top.document.location.reload();
    }
    document.getElementById("box_mail_bar_iframe").src = this.arrUrlDiv[3] + this.paramHP;
    this.arrBBLnk[2]="bxmail";
    document.getElementById("bxmailLog").style.display="none";
    document.getElementById("bxmail").className=document.getElementById("bxmailLog").className;
    document.getElementById("box_mail_bar_iframe").style.height="120px";
    document.getElementById("bxmail").style.display="block";
},
setBBLink : function (){
        var dt=new Date();
        dt.setDate(dt.getDate() + 1);
        var ckdt = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate());
        this.setCookieBB("bbVirgilio","prova",ckdt,"/","virgilio.it");
},
bbSearch : function (typeS){
            if(this.bbSearchT!=""){
                document.getElementById("lnSea"+this.bbSearchT).style.fontWeight="normal";
                document.getElementById("qs"+this.bbSearchT).style.display="none";
                document.getElementById("lnSea"+typeS).style.fontWeight="bold";
                document.getElementById("qs"+typeS).value=document.getElementById("qs"+this.bbSearchT).value;
             }
             document.getElementById("lnSea"+typeS).style.fontWeight="bold";
             document.getElementById("qs"+typeS).style.display="block";
             document.getElementById("qs"+typeS).focus();
             this.bbSearchT=typeS;return false;
},

openAllBB : function (idDivBB,idLnkBB){
    document.getElementById("cont_canali_pers").style.display="none";document.getElementById("cont_servizi_pers").style.display="none";
    for(var k=0;k<this.arrBBDiv.length;k++){
    	if (document.getElementById(this.arrBBDiv[k])!=null){
		if (this.arrBBDiv[k]!=idDivBB){
		    document.getElementById(this.arrBBDiv[k]).style.display="none";
		}
		else{
			if(document.getElementById(this.arrBBDiv[k]).style.display!="block"){
			    document.getElementById(this.arrBBDiv[k]).style.display="block";
			    if(this.arrUrlDiv[k]!=""){
				if((document.getElementById(this.arrBBDiv[k]+"_iframe").src=="")||(document.getElementById(this.arrBBDiv[k]+"_iframe").src.replace("http://"+document.location.hostname,"")=='/common/VIRGILIO/bottom_bar/includes/loading.html')){
				    var paramHP="";
				    if (k==3){
					paramHP=this.paramHP;
				    }

				    document.getElementById(this.arrBBDiv[k]+"_iframe").src=this.arrUrlDiv[k]+paramHP;
				}
			    }
			}
			else{
			    document.getElementById(this.arrBBDiv[k]).style.display="none";
			}
		}
        }
    }
    for(var k=0;k<this.arrBBLnk .length;k++){
    	if (document.getElementById(this.arrBBLnk[k])!=null){
		if (this.arrBBLnk [k]!=idLnkBB){
		    if(document.getElementById(this.arrBBLnk[k]).className!="ntfc"){ 
			document.getElementById(this.arrBBLnk[k]).className="";
		     }
		}
		else{
		     if(document.getElementById(this.arrBBLnk [k]).className!="on"){
			document.getElementById(this.arrBBLnk [k]).className="on";
		     }
		     else{
		     document.getElementById(this.arrBBLnk [k]).className="";
		     }
		}
	}
		
    }
    return false;
},

selectPersCan : function (idCkSel){
    if (!document.getElementById("ckCan"+idCkSel).disabled){
        if (document.getElementById("ckCan"+idCkSel).checked){
            document.getElementById("ckCan"+idCkSel).checked=false;
        }
        else{
            document.getElementById("ckCan"+idCkSel).checked=true;
        }
        this.setCookieChan();
   }
},
selectPersCanUser : function (idCkSel){
        if (!document.getElementById("ckCanUser"+idCkSel).disabled){
            if (document.getElementById("ckCanUser"+idCkSel).checked){
                document.getElementById("ckCanUser"+idCkSel).checked=false;
            }
            else{
                document.getElementById("ckCanUser"+idCkSel).checked=true;
            }
            this.setCookieChanUser();
        }
},
loadPersChannel : function (){
    var arrChanLoad;var ckChan = this.getCookieBB("vChanBar"); 
    if (ckChan){
        arrChanLoad=ckChan.split("|");
    }
    else{
        arrChanLoad=this.arrPersCanDefault;
    }
    var arrChkLoad=document.getElementsByName("ckCan");
    
    for (var k=0; k<arrChkLoad.length;k++){
        arrChkLoad.checked=false;
    }
    
    for (var k=0; k<arrChanLoad.length;k++){
        if (document.getElementById("ckCan"+arrChanLoad[k])){
            document.getElementById("ckCan"+arrChanLoad[k]).checked=true;
        }
    }

    this.displayLinkChannelBB(arrChanLoad);
    this.loadPersChannelDisabled();
    this.displayLinkChannelBBUser();
},

setCookieChan : function ()
{
    var objChSel = document.getElementsByName("ckCan");
    var strSelectCh="";var strSepCh="";
    for (var h=0;h<objChSel.length;h++){
        if (objChSel[h].checked) {
            strSelectCh = strSelectCh + strSepCh + objChSel[h].value;
        }
        strSepCh="|";
    }
    this.setCookieBB("vChanBar",strSelectCh,this.ckdtBB,"/","virgilio.it","");
    this.displayLinkChannelBB(strSelectCh.split("|"));
},

loadPersChannelDisabled : function (){
    for (var j=0; j<this.arrPersCanDisabled.length;j++){
        document.getElementById("ckCan"+this.arrPersCanDisabled[j]).disabled=true;
        document.getElementById("ckCan"+this.arrPersCanDisabled[j]).checked=true;
        document.getElementById("ckCan"+this.arrPersCanDisabled[j]).style.display="none"; 
        document.getElementById("lnCkCan"+this.arrPersCanDisabled[j]).style.display="none"; 
     }
},

isSelectedCh : function (element, index, array) {
    return (element==idSelectedBB);
},

displayUserAdd : function (){
    if (document.getElementById("box_personal_chn_bar").style.display=="block"){
        document.getElementById("box_personal_chn_bar").style.display="none";
    }
    else{
        document.getElementById("ckUserCanPersAddUrl").value="url";
        document.getElementById("ckUserCanPersAddUrl").style.color="#969696";
        document.getElementById("ckUserCanPersAddName").value="nome";
        document.getElementById("ckUserCanPersAddName").style.color="#969696";
        document.getElementById("box_personal_chn_bar").style.display="block";
     }
},

addPersChUser : function ()
{
    var strUrl=document.getElementById("ckUserCanPersAddUrl").value;
    var strName=document.getElementById("ckUserCanPersAddName").value;
    if ((strUrl!="url")&&(strName!="nome")&&(this.trim(strUrl)!="")&&(this.trim(strName)!="")) {
        var iInput=document.getElementsByName("ckCanPers").length;
        var strInsert = '<input type="checkbox" name="ckCanUser" id="ckCanUser'+iInput+'" value="'+escape(strUrl.replace("http://","")+'|'+strName)+'" onclick="objBottomBar.setCookieChanUser();" checked><a href="#" onclick="objBottomBar.selectPersCan(\''+iInput+'\');">'+strName+'</a>';
        document.getElementById("ckUserCanPers").innerHTML=document.getElementById("ckUserCanPers").innerHTML+strInsert;
        this.setCookieChanUser();
        this.enablePersCh();
    }
    else{
        alert("Attenzione! Inserire un nome ed un url validi.");
    }
},

setCookieChanUser: function ()
{
    var objChSel = document.getElementsByName("ckCanUser");
    var strSelectCh="";var strSepCh="";
    for (var h=0;h<objChSel.length;h++){
        if (objChSel[h].checked) {
            strSelectCh = strSelectCh + strSepCh + objChSel[h].value +  escape("|1");
        }
        else{
            strSelectCh = strSelectCh + strSepCh + objChSel[h].value + escape("|0");
        }
        strSepCh="|";
    }
    this.setCookieBB("vChanUserBar",strSelectCh,this.ckdtBB,"/","virgilio.it","");
    this.displayLinkChannelBBUser();
},

displayLinkChannelBBUser : function (){
    var arrChanLoad=this.getCookieBB("vChanUserBar").split("|");
    document.getElementById("linkUserCanPers").innerHTML="";
    document.getElementById("ckUserCanPers").innerHTML="";
    var blnWriteElement=false;var blnWriteLinkElement=false;
    if (arrChanLoad){
        for (var s=0;s<arrChanLoad.length;s++)
        {
            var objLinkUser=unescape(arrChanLoad[s]).split("|");
            
            if((objLinkUser[1]!="undefined")&&(objLinkUser[1]!=undefined))
            {
                blnWriteElement=true;
                var strChecked="";
               
                var strExternalLink=objLinkUser[0] + "/";
                if (strExternalLink.indexOf("http")==-1){
                    strExternalLink='http://' + strExternalLink;
                }
                var strInsertCk ='<img name="" src="'+ strExternalLink + 'favicon.ico" style="background-color:#FFF;visibility:hidden;" width="16" height="16" alt="" class="icon" onload="this.style.visibility=\'visible\';"/>'+'<input type="checkbox" name="ckCanUser" id="ckCanUser'+s+'" value="'+escape(objLinkUser[0]+'|'+objLinkUser[1])+'"  checked style="display:none;"><a href="#" onclick="objBottomBar.delPersChUser(\''+s+'\');return false;" class="canc">Cancella</a>';
                strInsertCk += '<a href="'+ strExternalLink+'" id="lnCan'+s+'">'+objLinkUser[1]+'</a>';
                document.getElementById("ckUserCanPers").innerHTML=document.getElementById("ckUserCanPers").innerHTML+strInsertCk+'<div class="sep"></div>';    
            }
        }
        document.getElementById("ckUserCanPers").innerHTML= document.getElementById("ckUserCanPers").innerHTML;
        document.getElementById("linkUserCanPers").innerHTML= document.getElementById("linkUserCanPers").innerHTML;
        document.getElementById("linkUserCanPers").style.display="block";
        document.getElementById("ckUserCanPers").style.display="block";
    }
    if(!blnWriteElement)
    {
        document.getElementById("linkUserCanPers").style.display="none";
        document.getElementById("ckUserCanPers").style.display="none";
    }
    else if (!blnWriteLinkElement)
    {
        document.getElementById("linkUserCanPers").style.display="none";
    }
},


displayLinkChannelBB : function (arrChanLoad){
    var objLnSel = document.getElementById("cont_canali_el").getElementsByTagName("A");
    for (var s=0;s<objLnSel.length;s++)
    {
        if(objLnSel[s].className!="min"){
          if(objLnSel[s].id!="lnCanPers"){
             idSelectedBB=objLnSel[s].id.replace("lnCan","");
             
             if (arrChanLoad.filter(this.isSelectedCh).length>0){
                objLnSel[s].style.display="block";
             }
             else{
                objLnSel[s].style.display="none";
             }    
          }
        }
    }
},
delPersChUser : function (idChUser)
{
    var d = document.getElementById("ckUserCanPers"); 
    var d_nested = document.getElementById("ckCanUser"+idChUser); 
    var d_remove = d.removeChild(d_nested);
    this.setCookieChanUser();
    this.enablePersCh();
    return false;
},
enablePersCh : function (){
    document.getElementById("ckUserCanPersAddName").value="nome";
    document.getElementById("ckUserCanPersAddUrl").value="url";
    document.getElementById("ckUserCanPersAddName").style.color="#9F9F9F";
    document.getElementById("ckUserCanPersAddUrl").style.color="#9F9F9F";
    var arrEnablePersCh=this.getCookieBB("vChanUserBar").split("|");
    if(arrEnablePersCh.length>=5){
        document.getElementById("ckUserCanPersAdd").style.display="none";
    }
    else{
        document.getElementById("ckUserCanPersAdd").style.display="block";
    }
},
searchBBFocus : function (){},
goSearchBB : function (e,idfrm,actFrm) {
    var fldFrm="ricerca";
    if(actFrm!=""){
        fldFrm=actFrm
    };
    var evt=(e)?e:(window.event)?window.event:null;
    if(evt){
        var key=(evt.charCode)?evt.charCode:((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
        if(key=="13") {
            document.getElementById("qsSearchBB").value=document.getElementById("qs"+this.bbSearchT).value;
            document.forms[idfrm].action="http://ricerca" + actFrm +".virgilio.it/" + fldFrm;document.forms[idfrm].submit();
        }
    }
},
minimizeBB : function(blnSaveSetting){

if(blnSaveSetting==false){
    if (this.bbSetting=="")
    {
        document.getElementById("minBB").style.display="none";
        document.getElementById("intBB").style.display="block";
    }else{
        if(this.bbSetting[0]=="true"){
            document.getElementById("minBB").style.display="none";
            document.getElementById("intBB").style.display="block";
        }else{
            document.getElementById("minBB").style.display="block";
            document.getElementById("intBB").style.display="none";
        }
    }    
}
else {
        if (this.bbSetting!="")
            {
                if(this.bbSetting[0]=="true"){
                    document.getElementById("minBB").style.display="block";
                    document.getElementById("intBB").style.display="none";
                    this.setCookieBB("vSettingChanBar","false",this.ckdtBB,"/","virgilio.it","");
                    this.bbSetting[0]="false";
                }else{
                    document.getElementById("minBB").style.display="none";
                    document.getElementById("intBB").style.display="block";
                    this.setCookieBB("vSettingChanBar","true",this.ckdtBB,"/","virgilio.it","");
                    this.bbSetting[0]="true";
                }
            }
        else{
                    document.getElementById("minBB").style.display="block";
                    document.getElementById("intBB").style.display="none";
                    this.setCookieBB("vSettingChanBar","false",this.ckdtBB,"/","virgilio.it","");
                    this.bbSetting[0]="false";
        }
        
    }
this.emailNumberMsg();
},
captureEnter:function(e) {
  e=e||window.event;
  if (e.keyCode == 13){
      objBottomBar.BI.track(document.getElementById("ckUserCanPersAddButton"),'tb_lnp_save',function(){objBottomBar.addPersChUser();});
    }
},
newsOpenAll:function(){
    this.etichetta_close('alt_news');
    this.newsNotifyOpen();
    
    if (document.getElementById("box_news_bar").style.display!="block"){
        var tmpOpen = this;
       
        this.BI.track(document.getElementById('bxnews') ,'tb_notify_open',function(){tmpOpen.openAllBB('box_news_bar','bxnews');});
    }
    else{
        this.openAllBB('box_news_bar','bxnews');
    }
    return false;
},
newsNotify:function(){
    var scriptId="scriptBBNotify";
    var script=document.getElementById(scriptId);
    var timestampBB=this.getCookieBB("timestampBB");
  var url="/common/VIRGILIO/bottom_bar/dati/bottombar_json.html?ts="+timestampBB;
  if(script)
  {
    script.resetLoading();
    script.parentNode.removeChild(script);
  }
  script=document.createElement('SCRIPT');
  script.id=scriptId;
  script.type = 'text/javascript';
  
  var intervalTimeout = 30000;
  script.timeoutID=setTimeout('document.getElementById("' + scriptId+ '").handleTimeout()',intervalTimeout);
  script.onload=function(){ document.getElementById("scriptBBNotify").dataReceived();};
  script.onreadystatechange= function () {if (this.readyState == 'loaded' || this.readyState == 'complete') {document.getElementById("scriptBBNotify").dataReceived();}}


  script.dataReceived=function(_resultStr){
    this.resetLoading();
    if (bbNotify!=""){document.getElementById("bxnews").className="ntfc";}
  };
  script.handleTimeout=function(){
      this.resetLoading();
  };
  script.onerror=function(){
    this.resetLoading();
    if(this.onerrorfunc!=null)
      this.onerrorfunc();
  };
  script.resetLoading=function(){
    clearTimeout(this.timeoutID);
    this.timeoutID=undefined;
  };
  
  script.src=url;
  document.getElementsByTagName('HEAD')[0].appendChild(script);

},
newsNotifyOpen:function(){
    this.arrUrlDiv[5] = this.arrUrlDiv[5] + "?" + escape(this.ckdtBB);
    if(document.getElementById("bxnews").className=="ntfc"){
        this.setCookieBB("timestampBB",bbNotify,this.ckdtBB,"/","virgilio.it","");
     }
}
}




