﻿var AlertxmlReq ;
var Alertx;
function AlertEnableList(bool, ty){
bool==true?document.getElementById("alertFieldSet" + ty).style.display="block":document.getElementById("alertFieldSet" + ty).style.display="none";
d=document.getElementById("RegResponse" + ty );
d.style.display="none";

//bool==true?document.getElementById("desc" + ty).style.display="block":document.getElementById("desc" + ty).style.display="none";
}
function AlertProcedureSubmit(ty, lang){
d=document.getElementById("RegResponse" + ty );
d.style.display="none";
Alertx=AlertloadRequest(ty, lang);
return ty;
}
function AlertNewChannel(s,ty){
var checkb;
d=document.getElementById("RegResponse" + ty );
d.style.display="none";
checkb=document.getElementById(s);
var arr = document.getElementById("parameter" + ty).attributes["value"].value;
var a;
var exist;
exist=false;
if(document.getElementById("parameter" + ty).attributes["value"].value != undefined && document.getElementById("parameter" + ty).attributes["value"].value != " "){
                                                            a=arr.split(",");
                                                            for(i=0;i<a.length ;i++){if(s == a[i]){exist=true;}}
                                                            }
if(checkb.checked){
                if(!exist){
                
                            if(document.getElementById("parameter" + ty).attributes["value"].value ==" ")
                                {
                                document.getElementById("parameter" + ty).attributes["value"].value =s;
                                }else{
                                document.getElementById("parameter" + ty).attributes["value"].value  = document.getElementById("parameter" + ty).attributes["value"].value + "," + s ;
                                }
                           }
                   }else{    
                        document.getElementById("parameter" + ty).attributes["value"].value = " ";
                        for(i=0;i<a.length ;i++){if(s != a[i]){
                        if(document.getElementById("parameter" + ty).attributes["value"].value ==" ")
                                {
                                document.getElementById("parameter" + ty).attributes["value"].value =a[i];
                                }else{
                                document.getElementById("parameter" + ty).attributes["value"].value  = document.getElementById("parameter" + ty).attributes["value"].value + "," + a[i] ;
                                }
                        }
                        }
                   }
}
function AlertGetInput(){
SText= document.getElementById("keyword").value;
return SText;
}
function AlertClearInput(){
document.getElementById("list").style.display="none";
document.getElementById("keyword").value="";
document.getElementById("risultati").value="";
}
function AlertloadRequest(ty, lang){
d=document.getElementById("RegResponse" + ty );
d.style.display="none";
var i;
    i=ty.substring(0,1)=='M'?true:false;
    URL=  "/azienda/" + lang + "/investor_relations/AlertDispatcher.aspx";
    var t;
var checkb;
checkb=document.getElementById("registra_0" + ty );
if(checkb.checked){t="add";}
checkb=document.getElementById("registra_1" + ty );
if(checkb.checked){t="-";}
var de;

de=document.getElementById("vdm" + ty).value;
de=de.replace("+","pl");
	if(de==""){de=" ";}
    URL=URL + "?i=" + i + "&t=" + t + "&d=" + de 
    c=document.getElementById("parameter" + ty).attributes["value"].value;
    f=document.getElementById("alertFieldSet" + ty).attributes["value"].value;
    if(c!=""){URL=URL + "&c=" + c; }else{URL=URL + "&c=" + " ";}
    if(f!=""){URL=URL + "&f=" + f; }

try
  {
  // Firefox, Opera 8.0+, Safari
  AlertxmlReq=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    AlertxmlReq=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      AlertxmlReq=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  AlertxmlReq.onreadystatechange = function()
    {
        switch(AlertxmlReq.readyState)
        {
        case 0:
            break;
        case 1:
            break;
        case 2:
            break;
        case 3:
            break;
        case 4:
        
            AlertXMLVar=AlertHandler(AlertxmlReq.responseText);
          
            break;
        default:
            break;
        }
    }
    AlertxmlReq.open ('GET', URL, true);
    AlertxmlReq.send (null);
	return ty;
}
function AlertHandler(xml){  
var d;
d=document.getElementById("RegResponse" + Alertx );
d.style.display="block";
d.innerHTML=xml;
}

function AlertHideList(){

}
//+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.
// TOOLBOX ACTION                                        :
//+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.
var ActivePanelName="";
var millisecondi=1000;
function SetAltezzaPannello(PanelName,Altezza){
        var StilePannello= document.getElementById(PanelName).style;
        StilePannello.height=Altezza + "px";
    }
function NascondiPannello(Pannello){
        document.getElementById(Pannello).style.display="none";
}
function ShowToolboxPanel(PanelName){
        var AzioneEseguita=false;
        var StilePannello= document.getElementById(PanelName).style;
        var AltezzaPannello;
        var StilePannelloAttivo;
        var AltezzaPannelloAttivo;
        if(ActivePanelName!=""){    
                                    StilePannelloAttivo= document.getElementById(ActivePanelName).style;

                                }
        if(ActivePanelName!="" && ActivePanelName!=PanelName && AzioneEseguita!=true && StilePannelloAttivo.display=="block"){//Chiudere pannello attivo ed aprire pannello selezionato
                                StilePannelloAttivo.overflow="hidden";
                                AltezzaPannelloAttivo = eval(document.getElementById(ActivePanelName).clientHeight);
                                var ResetAltezza=0;
                                for(AltezzaDinamicaC=AltezzaPannelloAttivo;AltezzaDinamicaC >=1; AltezzaDinamicaC--){
                                    setTimeout("SetAltezzaPannello('" + ActivePanelName + "'," + AltezzaDinamicaC + ")",(millisecondi/AltezzaPannelloAttivo)*(AltezzaPannelloAttivo-AltezzaDinamicaC)) ;
                                    ResetAltezza++;
                                }
                                setTimeout("SetAltezzaPannello('" + ActivePanelName + "'," + ResetAltezza + ")", millisecondi) ;
                                setTimeout("NascondiPannello('" + ActivePanelName + "')", millisecondi) ;
                                StilePannelloAttivo.overflow="visible";
                                StilePannello.overflow="hidden";
                                StilePannello.display="block";
                                AltezzaPannello = eval(document.getElementById(PanelName).clientHeight);
                                SetAltezzaPannello(PanelName,0);
                                for(AltezzaDinamica=1;AltezzaDinamica<=AltezzaPannello;AltezzaDinamica++){
                                    setTimeout("SetAltezzaPannello('" + PanelName + "'," + AltezzaDinamica + ")", millisecondi + (millisecondi/AltezzaPannello)*AltezzaDinamica) ;
                                }
                                
                                StilePannello.overflow="visible";
                                AzioneEseguita=true;
                                }
       if(ActivePanelName!="" && ActivePanelName!=PanelName && AzioneEseguita!=true && StilePannelloAttivo.display=="none"){//aprire pannello selezionato
                                   StilePannello.display="block";
                                   StilePannello.overflow="hidden";
                                AltezzaPannello = eval(document.getElementById(PanelName).clientHeight);
                                SetAltezzaPannello(PanelName,0);
                                for(AltezzaDinamica=1;AltezzaDinamica<=AltezzaPannello;AltezzaDinamica++){
                                setTimeout("SetAltezzaPannello('" + PanelName + "'," + AltezzaDinamica + ")",(millisecondi/AltezzaPannello)*AltezzaDinamica) ;
                                }
                                StilePannello.overflow="visible";
                                AzioneEseguita=true;
                                }
        if(ActivePanelName=="" && AzioneEseguita!=true){//Aprire pannello selezionato
                                StilePannello.display="block";
                                StilePannello.overflow="hidden";
                                AltezzaPannello = eval(document.getElementById(PanelName).clientHeight);
                                SetAltezzaPannello(PanelName,0);
                                for(AltezzaDinamica=1;AltezzaDinamica<=AltezzaPannello;AltezzaDinamica++){
                                setTimeout("SetAltezzaPannello('" + PanelName + "'," + AltezzaDinamica + ")",(millisecondi/AltezzaPannello)*AltezzaDinamica) ;
                                }
                                StilePannello.overflow="visible";
                                AzioneEseguita=true;
                                }
        if(ActivePanelName!="" && ActivePanelName==PanelName && StilePannello.display=="block" && AzioneEseguita!=true){//Chiudere Pannello selezionato
                                StilePannello.overflow="hidden";
                                AltezzaPannello = eval(document.getElementById(PanelName).clientHeight);
                                var ResetAltezza=0;
                                for(AltezzaDinamica=AltezzaPannello;AltezzaDinamica >=1; AltezzaDinamica--){
                                    setTimeout("SetAltezzaPannello('" + PanelName + "'," + AltezzaDinamica + ")",(millisecondi/AltezzaPannello)*(AltezzaPannello-AltezzaDinamica)) ;
                                    ResetAltezza++;
                                }
                                setTimeout("SetAltezzaPannello('" + ActivePanelName + "'," + ResetAltezza + ")", millisecondi) ;
                                setTimeout("NascondiPannello('" + ActivePanelName + "')", millisecondi) ;
                               // StilePannello.overflow="visible";
                                AzioneEseguita=true;
                                }
                                
        if(ActivePanelName!="" && ActivePanelName==PanelName && StilePannello.display=="none" && AzioneEseguita!=true){//Aprire Pannello selezionato
                                StilePannello.display="block";
                                StilePannello.overflow="hidden";
                                AltezzaPannello = eval(document.getElementById(PanelName).clientHeight);
                                SetAltezzaPannello(PanelName,0);
                                for(AltezzaDinamica=1;AltezzaDinamica<=AltezzaPannello;AltezzaDinamica++){
                                setTimeout("SetAltezzaPannello('" + PanelName + "'," + AltezzaDinamica + ")",(millisecondi/AltezzaPannello)*AltezzaDinamica) ;
                                }
                                StilePannello.overflow="visible";
                                AzioneEseguita=true;
                                }
        ActivePanelName=PanelName;
   
}

function HideToolBoxPanel(PanelName){

var StilePannello= document.getElementById(PanelName).style;
StilePannello.display="block";
var AltezzaPannello = eval(document.getElementById(PanelName).clientHeight);

for(AltezzaDinamica=AltezzaPannello;AltezzaDinamica>=1;AltezzaDinamica--){
//rallentamento js
setTimeout("SetAltezzaPannello('" + PanelName + "'," + AltezzaDinamica + ")",(millisecondi/AltezzaPannello)*(AltezzaPannello-AltezzaDinamica)) ;
}
StilePannello.display="none";
StilePannello.height = AltezzaPannello;
}


