var confermaUscita = true; // impone l'avviso di mancato salvataggio in uscita dalle pagine

pwDiagnosticMode = false; // da abilitare solo per il debug

//**** FUNZIONI USATE PER MOSTRARE IL MESSAGGIO DI ELABORAZIONE IN CORSO
function showMsg(){
	document.getElementById("AjaxLoadingMessage").style["display"] = "inline";
}
function hideMsg(){
	document.getElementById("AjaxLoadingMessage").style["display"] = "none";
}
function pwBeforeCallback(){
	showMsg();
}
function pwAfterCallback(){
	hideMsg();
}
//****************************************************


//**** FUNZIONI USATE NELLE PAGINE: statopatrimoniale_attivo.aspx, statopatrimoniale_passivo.aspx,
//**** statopatrimoniale_abbreviato.aspx, contoeconomico.aspx, integrazione_indici.aspx, integrazione_rf_ord.aspx,
//**** integrazione_rf_abb.aspx;

// Funzione chiamata per eseguire un Custom CallBack
function doPulisciAnni(Anno, AnnoVis)
{	
	//Esegue solo su conferma
	if(confirm('ATTENZIONE: si desidera CANCELLARE TUTTI I VALORI nella colonna Anno ' + AnnoVis + '?'))	
	{
		pwBeginCallServerFunction("PulisciAnni", "PulisciAnniResult", null, false, Anno);
	}
	
}

//Funzione eseguita al ritorno dal Custom CallBack
function PulisciAnniResult(pwRsCallbackResponse)
{		
	//alert(pwRsCallbackResponse.data);	
}
//****************************************************


//**** FUNZIONI USATE NELLE PAGINE: rating_totale.aspx
function ButtonStampaRelazione()
{
    //prende tutti i check spuntati e li aggiunge all'elenco
    _elementi = document.getElementsByTagName('input');
    var esclusi = ' ';
    for(var i = 0; i < _elementi.length; i++) {

        if(_elementi[i].id.indexOf('lcbIndiciDettaglio_')>=0){
        //alert(_elementi[i].id + ' ' + _elementi[i].checked);
            if(!_elementi[i].checked){
               esclusi+= IndiciArray[_elementi[i].id.split('_')[1]] + ';';
            }
        }
    }
    //alert(esclusi);
    pwBeginCallServerFunction("btnStampaFascicolo", "btnStampaFascicoloResult", null, false, esclusi);
}

function btnStampaFascicoloResult(pwRsCallbackResponse)
{
    var dati = pwRsCallbackResponse.data;
    var aDati = dati.split(',');
    StampaGlobale(aDati[0],aDati[1]);
}
//****************************************************


//**** FUNZIONI USATE NELLE PAGINE: importa_bilancio_xbrl.aspx
// Funzione chiamata per eseguire un Custom CallBack
function doImportaXBRL() {
    document.getElementById('lblMess').innerHTML='';
    ShowWorking('<b>Importazione in corso, attendere prego...</b>', 'divLoadingImportazione');
    pwBeginCallServerFunction("ImportaXBRL", "doImportaXBRLResult", null, false, "dummy");
}

//Funzione eseguita al ritorno dal Custom CallBack
function doImportaXBRLResult(pwRsCallbackResponse) {
    HideWorking('', 'divLoadingImportazione');
    if (pwRsCallbackResponse.data != '') { alert(pwRsCallbackResponse.data.replace(/#/g,'\'')); } 
}


//****************************************************


//**** FUNZIONI USATE NELLE PAGINE: importa_bilancio_cerved.aspx
// Funzione chiamata per eseguire un Custom CallBack
function doControlloImportaCERVED() {
    pwBeginCallServerFunction("ControlloImportaCERVED", "doControlloImportaCERVEDResult", null, false, "dummy");
}

//Funzione eseguita al ritorno dal Custom CallBack
function doControlloImportaCERVEDResult(pwRsCallbackResponse) {
    if(pwRsCallbackResponse.data=="OK") {
        doImportaCERVED();
    }
    else {
        document.getElementById('txtDt_Chiu').focus();
    }
}



// Funzione chiamata per eseguire un Custom CallBack
function doImportaCERVED() {
    document.getElementById('lblMess').innerHTML='';
    ShowWorking('<b>Importazione in corso, attendere prego...</b>', 'divLoadingImportazione');
    pwBeginCallServerFunction("ImportaCERVED", "doImportaCERVEDResult", null, false, "dummy");
}

//Funzione eseguita al ritorno dal Custom CallBack
function doImportaCERVEDResult(pwRsCallbackResponse) {
    HideWorking('', 'divLoadingImportazione');
}


//****************************************************

function ShowWorking(messaggio, div) {
    document.getElementById(div).innerHTML = '&nbsp;&nbsp;<img src="' + ImgPath + 'loading16.gif" />&nbsp;' + messaggio;
}

function HideWorking(messaggio, div) {
    document.getElementById(div).innerHTML = messaggio;
}
